TuiNodeColor.cpp   TuiNodeColor.cpp 
skipping to change at line 16 skipping to change at line 16
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelTranslator.hpp"
#include "TuiNodeColor.hpp" #include "TuiNodeColor.hpp"
#include <QKeyEvent> #include <QKeyEvent>
TuiNodeColor::TuiNodeColor(const QString& text, QObject* receiver, const ch ar* method, Vec3f defValue, TuiNode* parent, TuiNode* prev) TuiNodeColor::TuiNodeColor(const QString& text, QObject* receiver, const ch ar* method, Vec3f defValue, TuiNode* parent, TuiNode* prev)
: TuiNodeEditable(text, parent, prev), value(defValue), editingPart( 0) : TuiNodeEditable(text, parent, prev), value(defValue), editingPart( 0)
{ {
this->connect(this, SIGNAL(setValue(Vec3f)), receiver, method); this->connect(this, SIGNAL(setValue(Vec3f)), receiver, method);
} }
TuiNodeResponse TuiNodeColor::handleEditingKey(int key) TuiNodeResponse TuiNodeColor::handleEditingKey(int key)
skipping to change at line 91 skipping to change at line 92
response.accepted = true; response.accepted = true;
response.newNode = this; response.newNode = this;
emit(setValue(value)); emit(setValue(value));
return response; return response;
} }
return response; return response;
} }
QString TuiNodeColor::getDisplayText() QString TuiNodeColor::getDisplayText()
{ {
QString red = QString("%1").arg(value[0], 2, 'f', 2);
QString green = QString("%1").arg(value[1], 2, 'f', 2);
QString blue = QString("%1").arg(value[2], 2, 'f', 2);
const char* formatString;
if (!editing) if (!editing)
{ {
return displayText + QString(": RGB %1,%2,%3").arg(value[0] , 2, 'f', 2).arg(value[1], 2, 'f', 2).arg(value[2], 2, 'f', 2); formatString = ": RGB %1,%2,%3";
} }
else else
{ {
if (editingPart==0) switch (editingPart)
return displayText + QString(": RGB >%1<,%2,%3").ar {
g(value[0], 2, 'f', 2).arg(value[1], 2, 'f', 2).arg(value[2], 2, 'f', 2); case 0:
else if (editingPart==1) formatString = ": RGB >%1<,%2,%3";
return displayText + QString(": RGB %1,>%2<,%3").ar break;
g(value[0], 2, 'f', 2).arg(value[1], 2, 'f', 2).arg(value[2], 2, 'f', 2); case 1:
else if (editingPart==2) formatString = ": RGB %1,>%2<,%3";
return displayText + QString(": RGB %1,%2,>%3<").ar break;
g(value[0], 2, 'f', 2).arg(value[1], 2, 'f', 2).arg(value[2], 2, 'f', 2); case 2:
else formatString = ": RGB %1,%2,>%3<";
return QString("error, unknown color part \"%1\"").a break;
rg(editingPart); default:
return QString(q_("error, unknown color part \"%1\""
)).arg(editingPart);
}
} }
QString stringValue = QString(formatString).arg(red, green, blue);
return prefixText + q_(displayText) + stringValue;
} }
void TuiNodeColor::incPart(int part, bool add) void TuiNodeColor::incPart(int part, bool add)
{ {
float diff = 0.01; float diff = 0.01;
if (add) if (add)
{ {
if (value[part]+diff > 1.0) if (value[part]+diff > 1.0)
value[part] = 1.0; value[part] = 1.0;
 End of changes. 6 change blocks. 
14 lines changed or deleted 24 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/