Example #1
0
    const bool ParserNode::getValueAsBoolean(std::string key)
    {
        std::string value = getDataValue(key);
        std::transform(value.begin(), value.end(), value.begin(), ::tolower);

        return (value == "1" || value == "true");
    }
Example #2
0
 const double ParserNode::getValueAsDouble(std::string key)
 {
     std::string value = getDataValue(key);
     if (value == "")
         return 0.0;
     else
         return std::stod(value);
 }
Example #3
0
 const float ParserNode::getValueAsFloat(std::string key)
 {
     std::string value = getDataValue(key);
     if (value == "")
         return 0.0f;
     else
         return std::stof(value);
 }
Example #4
0
 const int32_t ParserNode::getValueAsInteger32(std::string key)
 {
     std::string value = getDataValue(key);
     if (value == "")
         return 0;
     else
         return std::stoi(value);
 }
Example #5
0
bool editorModel::setData(const QModelIndex &index,const QVariant &value,int role)
{
    if (role == Qt::EditRole)
    {
        //if (!dataList[index.row()].fields[index.column()].ignore)
        if (!isDataIgnored(index.row(),index.column()))
        {
            //if (dataList[index.row()].fields[index.column()].value != value.toString())
            if (getDataValue(index.row(),index.column()) != value.toString())
            {
                //dataList[index.row()].fields[index.column()].value = value.toString();
                //dataList[index.row()].fields[index.column()].modified = true;
                //dataList[index.row()].modified = true;
                setData2(index.row(),index.column(),value.toString());
                emit dataChanged(index,index);
            }
        }
    }

    return false;
}
Example #6
0
QVariant editorModel::data(const QModelIndex &index, int role) const
{
    if ((role == Qt::DisplayRole) || (role == Qt::EditRole))
    {
        return getDataValue(index.row(),index.column()); //dataList[index.row()].fields[index.column()].value;
    }
    if (role == Qt::BackgroundRole)
    {

        //if (!dataList[index.row()].fields[index.column()].modified)
        if (!isDataModified(index.row(),index.column()))
        {
            QBrush Background(QColor(255,255,255));
            Background.setStyle(Qt::SolidPattern);
            return Background;
        }
        else
        {
            QBrush Background(QColor(255,0,0));
            Background.setStyle(Qt::SolidPattern);
            return Background;
        }

    }
    if (role == Qt::ForegroundRole)
    {

        //if (dataList[index.row()].fields[index.column()].ignore)
        if (isDataIgnored(index.row(),index.column()))
        {
            QBrush FontColor(QColor(191,184,181));
            return FontColor;
        }

    }
    return QVariant();
}
Example #7
0
void FixedAspectLabel::mouseMoveEvent(QMouseEvent *event) {
    if(event->buttons() != Qt::NoButton) {
        event->setAccepted(false);
        return;
    }
    if (!_statusBar || scaledPixmap.isNull()) return;
    int xp=event->pos().x() - x;
    int yp=event->pos().y() - y;
    if (xp >= 0 && yp >=0 &&
            xp < scaledPixmap.width() &&
            yp < scaledPixmap.height()) {
        QToolTip::hideText();
        yp = scaledPixmap.height() - yp - 1;
        xp = (xp * originalPixmap.width())/scaledPixmap.width();
        yp = (yp * originalPixmap.height())/scaledPixmap.height();
        QString status;
        if(dbuffer) {
            double d = getDataValue(xp,yp);
            status = "%4[ %1, %2 ] = %3";
            status = status.arg(xp).arg(yp).arg(d).arg(varname);
        }
        else {
            status = "%3[ %1 , %2 ]";
            status = status.arg(xp).arg(yp).arg(varname);
        }
        _statusBar->showMessage(status);
    }
    else {
        QKeySequence ctrl(Qt::ControlModifier);
        QToolTip::showText(event->globalPos(),
                           tr("<p>Press \"f\" to enable fit-to-window mode.  ")+
                           tr("Use the mouse wheel while holding ") +
                           ctrl.toString(QKeySequence::NativeText) +
                           tr(" to zoom in and out.</p>"));
    }
}
Example #8
0
 const std::string ParserNode::getValueAsString(std::string key)
 {
     return getDataValue(key);
 }
Example #9
0
/**
	Formatowanie wyjsciowej prognozy pogody
**/
bool WeatherParser::getData(const QString &page, const PlainConfigFile *wConfig, Forecast &forecast) const
{
	kdebugf();

	bool cs = wConfig->readBoolEntry("Default","CaseSensitive");

	int num_layouts = wConfig->readNumEntry("Default","Layouts");
	WDataValue dValue;

	QString actualName;
	QVector<WDataValue> valsList;
	QStringList nextDaysNamesList;
	QVector<WDataValue> nextDaysValsList;

	bool result;
	int cursor = 0;
	for (int i = 0; i < num_layouts; i++)
	{
		QString layoutSection = QString("Layout%1").arg(i + 1);
		QString layoutName = wConfig->readEntry(layoutSection,"Name");
		int num_repeats = wConfig->readNumEntry(layoutSection,"Repeats");
		int num_values = wConfig->readNumEntry(layoutSection,"Values");

		for (int j = 0; j < num_repeats; j++)
		{
			for (int k = 0; k<num_values; k++)
			{
				QString valSection = QString("Layout%1Value%2").arg(i + 1).arg(k + 1);

				dValue.Name = wConfig->readEntry(valSection,"Name");
				dValue.Start = wConfig->readEntry(valSection,"Start");
				dValue.End = wConfig->readEntry(valSection,"End");
				dValue.Content = "";

				result = getDataValue(page, dValue,cursor, wConfig, cs);

				if (dValue.Content.isEmpty())
					continue;
				else if (dValue.Name == "Phantom")
					continue;

				if (layoutName == "Name")
					forecast.LocationName = dValue.Content;
				else if (layoutName == "Actual")
				{
					if (dValue.Name == "Name")
						actualName = dValue.Content;
					else
						valsList.push_back(dValue);
				}
				else if (layoutName == "DaysNames")
				{
					if (dValue.Name == "Actual")
						actualName = dValue.Content;
					else if (dValue.Name == "NextDays")
						nextDaysNamesList.push_back(dValue.Content);
				}
				else if (layoutName == "NextDays" && dValue.Name == "Name")
					nextDaysNamesList.push_back(dValue.Content);
				else
					nextDaysValsList.push_back(dValue);
			}
		}
	}

	QString Data("");

	ForecastDay fDay;

	fDay["Name"] = actualName;
	for (QVector<WDataValue>::iterator it = valsList.begin(); it != valsList.end(); it++)
	{
		if ((*it).Name == "Icon")
			fDay["Icon"] = WeatherGlobal::getIconPath(wConfig->readEntry("Icons", (*it).Content));
		else
			fDay[(*it).Name] = (*it).Content;
	}

	forecast.Days.push_back(fDay);
	fDay.clear();

	int num_vals = nextDaysValsList.count();
	int num_names = nextDaysNamesList.count();

	if (!num_names)
		return false;

	int T = num_vals / num_names;

	if (!T)
		return false;

	Data = "";
	num_vals = T * num_names; /* Dorr: fix for index out of bounds when parsing data from
					Onet (num vals 31, num names 5, crash at i = 30 ->
					nextDaysNamesList[5] which is having 5 elements) */
	for (int i = 0; i < num_vals; i++)
	{
		WDataValue& val = nextDaysValsList[i];

		if (i % T == 0)
			fDay["Name"] = nextDaysNamesList[i / T];

		if (val.Name == "Icon")
			fDay["Icon"] = WeatherGlobal::getIconPath(wConfig->readEntry("Icons",val.Content));
		else
			fDay[val.Name] = val.Content;

		if (i % T == T - 1)
		{
			forecast.Days.push_back(fDay);
			fDay.clear();

			Data = "";
		}
	}

	kdebugf2();
	return true;
}