Example #1
0
void TestParser::parseUrl(){
  //"http:\/\/www.last.fm\/venue\/8926427"
  QByteArray json = "[\"http:\\/\\/www.last.fm\\/venue\\/8926427\"]";
  QVariantList list;
  list.append (QVariant(QLatin1String("http://www.last.fm/venue/8926427")));
  QVariant expected (list);

  Parser parser;
  bool ok;
  QVariant result = parser.parse (json, &ok);
  QVERIFY (ok);
  QCOMPARE(result, expected);
}
Example #2
0
 void TestParser::parseSimpleArray() {
  QByteArray json = "[\"foo\",\"bar\"]";
  QVariantList list;
  list.append (QLatin1String("foo"));
  list.append (QLatin1String("bar"));
  QVariant expected (list);

  Parser parser;
  bool ok;
  QVariant result = parser.parse (json, &ok);
  QVERIFY (ok);
  QCOMPARE(result, expected);
}
Example #3
0
QList<QVariantList> XlsxReader::read(const QString &xlsxFilePath)
{
    QList<QVariantList> data;
    QXlsx::Document doc(xlsxFilePath);
    QXlsx::CellRange range = doc.dimension();

    for(int row = range.firstRow(); row <= range.lastRow(); ++row)
    {
        QVariantList rowData;
        for(int col = range.firstColumn(); col <= range.lastColumn(); ++col)
        {
            QXlsx::Cell *cell = doc.cellAt(row, col);

            if(cell)
                rowData.append(cell->value());
            else
                rowData.append(QVariant());
        }
        data.append(rowData);
    }
    return data;
}
Example #4
0
void App::sendCommandToHeadless(const CommandMessage &command, const User &user)
{
	QVariantList invokeData;
	invokeData.append(QVariant(command.toMap()));

	if (!user.isEmpty()){
		invokeData.append(QVariant(user.toMap()));
	}

	QByteArray buffer;
	m_jsonDA->saveToBuffer(invokeData, &buffer);

    InvokeRequest request;
    request.setTarget(INVOKE_TARGET_KEY_PUSH);
    request.setAction(BB_PUSH_COLLECTOR_COMMAND_ACTION);
    request.setMimeType("text/plain");
    request.setData(buffer);
    m_invokeTargetReply = m_invokeManager->invoke(request);

    // Connect to the reply finished signal.
    checkConnectResult(QObject::connect(m_invokeTargetReply, SIGNAL(finished()), this, SLOT(onInvokeResult())));
}
void QuotesApp::deleteRecord()
{
    QVariantList indexPath = mListView->selected();

    if (!indexPath.isEmpty()) {
        QVariantMap map = mDataModel->data(indexPath).toMap();

        // Delete the item from the database based on unique ID. If successful, remove it
        // from the data model (which will remove the data from the list).
        if (mQuotesDbHelper->deleteById(map["id"])) {

            // Delete is the only operation where the logics for updating which item
            // is selected is handled in code.
            // Before the item is removed, we store how many items there are in the
            // category that the item is removed from, we need this to select a new item.
            QVariantList categoryIndexPath;
            categoryIndexPath.append(indexPath.first());
            int childrenInCategory = mDataModel->childCount(categoryIndexPath);

            mDataModel->remove(map);

            // After removing the selected item, we want another quote to be shown.
            // So we select the next quote relative to the removed one in the list.
            if (childrenInCategory > 1) {
                // If the Category still has items, select within the category.
                int itemInCategory = indexPath.last().toInt();

                if (itemInCategory < childrenInCategory - 1) {
                    mListView->select(indexPath);
                } else {
                    // The last item in the category was removed, select the previous item relative to the removed item.
                    indexPath.replace(1, QVariant(itemInCategory - 1));
                    mListView->select(indexPath);
                }
            } else {
                // If no items left in the category, move to the next category. 
                // If there are no more categories below(next), select the previous category.
                // If no items left at all, navigate to the list.
                QVariantList lastIndexPath = mDataModel->last();

                if (!lastIndexPath.isEmpty()) {
                    if (indexPath.first().toInt() <= lastIndexPath.first().toInt()) {
                        mListView->select(indexPath);
                    } else {
                        mListView->select(mDataModel->last());
                    }
                }
            } // else statment
        } //if statement
    } // top if statement
} // deleteRecord()
Example #6
0
void ItemTagsScriptable::untag()
{
    const auto args = currentArguments();
    auto tagName = args.value(0).toString();

    if ( args.size() <= 1 ) {
        const auto dataValueList = call("selectedItemsData").toList();

        if ( tagName.isEmpty() ) {
            QStringList allTags;
            for (const auto &itemDataValue : dataValueList) {
                const auto itemData = itemDataValue.toMap();
                allTags.append( ::tags(itemData) );
            }

            tagName = askRemoveTagName(allTags);
            if ( allTags.isEmpty() )
                return;
        }

        QVariantList dataList;
        dataList.reserve( dataValueList.size() );
        for (const auto &itemDataValue : dataValueList) {
            auto itemData = itemDataValue.toMap();
            auto itemTags = ::tags(itemData);
            if ( removeTag(tagName, &itemTags) )
                itemData.insert( mimeTags, itemTags.join(",") );
            dataList.append(itemData);
        }

        call( "setSelectedItemsData", QVariantList() << QVariant(dataList) );
    } else {
        const auto rows = this->rows(args, 1);

        if ( tagName.isEmpty() ) {
            QStringList allTags;
            for (int row : rows)
                allTags.append( this->tags(row) );

            tagName = askRemoveTagName(allTags);
            if ( allTags.isEmpty() )
                return;
        }

        for (int row : rows) {
            auto itemTags = tags(row);
            if ( removeTag(tagName, &itemTags) )
                setTags(row, itemTags);
        }
    }
}
Example #7
0
QVariant valueToVariant(const Calligra::Sheets::Value& value, Sheet* sheet)
{
    //Should we use following value-format enums here?
    //fmt_None, fmt_Boolean, fmt_Number, fmt_Percent, fmt_Money, fmt_DateTime, fmt_Date, fmt_Time, fmt_String
    switch (value.type()) {
    case Calligra::Sheets::Value::Empty:
        return QVariant();
    case Calligra::Sheets::Value::Boolean:
        return QVariant(value.asBoolean());
    case Calligra::Sheets::Value::Integer:
        return static_cast<qint64>(value.asInteger());
    case Calligra::Sheets::Value::Float:
        return (double) numToDouble(value.asFloat());
    case Calligra::Sheets::Value::Complex:
        return sheet->map()->converter()->asString(value).asString();
    case Calligra::Sheets::Value::String:
        return value.asString();
    case Calligra::Sheets::Value::Array: {
        QVariantList colarray;
        for (uint j = 0; j < value.rows(); j++) {
            QVariantList rowarray;
            for (uint i = 0; i < value.columns(); i++) {
                Calligra::Sheets::Value v = value.element(i, j);
                rowarray.append(valueToVariant(v, sheet));
            }
            colarray.append(rowarray);
        }
        return colarray;
    }
    break;
    case Calligra::Sheets::Value::CellRange:
        //FIXME: not yet used
        return QVariant();
    case Calligra::Sheets::Value::Error:
        return QVariant();
    }
    return QVariant();
}
Example #8
0
QByteArray LoadTagsResponseJSON::getJson() const
{
    QJson::Serializer serializer;
    serializer.setDoublePrecision(DOUBLE_PRECISION_RESPONSE);
    QVariantMap obj, rss, jchannel;

    QVariantList jchannels;

    QVariantList jtags;
    QVariantMap channel;

    obj["errno"]= m_errno;

    if (m_errno == SUCCESS){
	    for(int j=0; j<m_tags.size(); j++)
	    {
		Tag tag = m_tags.at(j);
		QVariantMap jtag;
		jtag["title"] = tag.getLabel();
		jtag["link"] = tag.getUrl();
		jtag["description"] = tag.getDescription();
		jtag["latitude"] = tag.getLatitude();
		jtag["altitude"] = tag.getAltitude();
		jtag["longitude"] = tag.getLongitude();
		jtag["user"] = tag.getUser().getLogin();
		jtag["pubDate"] = tag.getTime().toString("dd MM yyyy HH:mm:ss.zzz");
		jtags.append(jtag);
	    }
	    channel["items"] = jtags;
	//    channel["name"] = m_channels.at(i).getName();
	    jchannels.append(channel);

	    jchannel["items"] = jchannels;
	    rss["channels"] = jchannel;
	    obj["rss"] = rss;
    }
    return serializer.serialize(obj);
}
Example #9
0
QByteArray LoadTagsResponseJSON::getJson() const
{
  QJson::Serializer serializer;
  QVariantMap obj, rss, jchannel;

  QList<QSharedPointer<Channel> > hashKeys = m_hashMap.uniqueKeys();
  QVariantList jchannels;

  for(int i=0; i<hashKeys.size(); i++)
  {
    QList<QSharedPointer<DataMark> > tags = m_hashMap.values(hashKeys.at(i));
    QVariantList jtags;
    QVariantMap channel;

    for(int j=0; j<tags.size(); j++)
    {
      QSharedPointer<DataMark> tag = tags.at(j);
      QVariantMap jtag;
      jtag["title"] = tag->getLabel();
      jtag["link"] = tag->getUrl();
      jtag["description"] = tag->getDescription();
      jtag["latitude"] = tag->getLatitude();
      jtag["altitude"] = tag->getAltitude();
      jtag["longitude"] = tag->getLongitude();
      jtag["user"] = tag->getUser()->getLogin();
      jtag["pubDate"] = tag->getTime().toString("dd MM yyyy HH:mm:ss.zzz");
      jtags.append(jtag);
    }
    channel["items"] = jtags;
    channel["name"] = hashKeys.at(i)->getName();
    jchannels.append(channel);
  }
  jchannel["items"] = jchannels;
  rss["channels"] = jchannel;
  obj["rss"] = rss;
  obj["errno"]= m_errno;
  return serializer.serialize(obj);
}
Example #10
0
void tst_QPoint::test()
{
    Point point;

    {
        QCOMPARE(point.pointSize(),1.0);
        QCOMPARE(point.vertices().toList().count(),0);
    }

    {
        QSignalSpy spyPointSize(&point,SIGNAL(pointSizeChanged()));
        point.setPointSize(5.0);
        QCOMPARE(spyPointSize.size(), 1);
        QCOMPARE(point.pointSize(),5.0);
        point.setPointSize(5.0);
        QCOMPARE(spyPointSize.size(), 1);
    }

    {
        QSignalSpy spyVertices(&point,SIGNAL(verticesChanged()));
        QVariantList vertices;
        vertices.append(QVariant(1.0f));
        vertices.append(QVariant(2.0f));
        vertices.append(QVariant(3.0f));
        point.setVertices(vertices);
        QCOMPARE(spyVertices.size(), 1);

        QVariantList readVertices = point.vertices().toList();
        QCOMPARE(readVertices.count(),3);
        QCOMPARE(readVertices.at(0).toReal(),1.0);
        QCOMPARE(readVertices.at(1).toReal(),2.0);
        QCOMPARE(readVertices.at(2).toReal(),3.0);

        point.setVertices(vertices);
        QCOMPARE(spyVertices.size(), 2);
    }

}
Example #11
0
void CMuleKad::OnRequestRecived(const QString& Command, const QVariant& Parameters, QVariant& Result)
{
	QVariantMap Request = Parameters.toMap();

	QVariantMap Response;

	if(Command == "GetLog")
	{
		QList<CLog::SLine> Log = GetLog();

		int Index = -1;
		if(uint64 uLast = Request["LastID"].toULongLong())
		{
			for(int i=0;i < Log.count(); i++)
			{
				if(uLast == Log.at(i).uID)
				{
					Index = i;
					break;
				}
			}
		}

		QVariantList Entries;
		for(int i=Index+1;i < Log.count(); i++)
		{
			QVariantMap LogEntry;
			LogEntry["ID"] = Log.at(i).uID;
			LogEntry["Flag"] = Log.at(i).uFlag;
			LogEntry["Stamp"] = (quint64)Log.at(i).uStamp;
			LogEntry["Line"] = Log.at(i).Line;
			Entries.append(LogEntry);
		}
		Response["Lines"] = Entries;
	}
	else if(Command == "Shutdown")
	{
		QTimer::singleShot(100,this,SLOT(Shutdown()));
	}
	else if(Command == "GetSettings")
	{
		if(Request.contains("Options"))
		{
			QVariantMap Options;
			foreach(const QString& Key, Request["Options"].toStringList())
				Options[Key] = m_Settings->value(Key);
			Response["Options"] = Options;
		}
		else
		{
Example #12
0
void ScProcess::updateTextMirrorForDocument ( Document * doc, int position, int charsRemoved, int charsAdded )
{
    QVariantList argList;
    
    argList.append(QVariant(doc->id()));
    argList.append(QVariant(position));
    argList.append(QVariant(charsRemoved));
    
    QTextCursor cursor = QTextCursor(doc->textDocument());
    cursor.setPosition(position, QTextCursor::MoveAnchor);
    cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, charsAdded);
    
    argList.append(QVariant(cursor.selection().toPlainText()));
    
    try {
        QDataStream stream(mIpcSocket);
        stream.setVersion(QDataStream::Qt_4_6);
        stream << QString("updateDocText");
        stream << argList;
    } catch (std::exception const & e) {
        scPost(QString("Exception during ScIDE_Send: %1\n").arg(e.what()));
    }
}
Example #13
0
IResponse *GroupsService::getUsersGroups( IRequest *req)
{
    QVariantList groups;
    QSqlQuery query;

    if(m_proxyConnection->session()->value("logged") !=""){

        int page;
        if(!(page= req->parameterValue("page").toInt())){
            QVariantMap error;
            error.insert("page_number","error");
            return req->response(QVariant(error), IResponse::BAD_REQUEST);
        }

        query.prepare("SELECT * FROM groups "
                      "INNER JOIN group_users ON groups.id = group_users.group_id "
                      "WHERE group_users.status = 1 AND group_users.user_id = :user_id "
                      "ORDER BY groups.name ASC LIMIT :limit OFFSET :offset ");
        query.bindValue(":user_id", m_proxyConnection->session()->value("logged").toString());
        query.bindValue(":limit",PER_PAGE);
        query.bindValue(":offset", (page-1)* PER_PAGE);

        if(!query.exec())
            return req->response(IResponse::INTERNAL_SERVER_ERROR);

        while(query.next()){
           QString user_id = m_proxyConnection->session()->value("logged").toString();

           QVariantMap group;
           QString group_id = query.value(query.record().indexOf("id")).toString();
           group.insert("id",query.value(query.record().indexOf("id")));
           group.insert("name",query.value(query.record().indexOf("name")));
           group.insert("description",query.value(query.record().indexOf("description")));
           group.insert("date_created", query.value(query.record().indexOf("date_created")));

           if(isAdmin(user_id.toUInt(),group_id.toUInt()))
               group.insert("admin","1");
           else
               group.insert("admin","0");

          group.insert("member","1");

           groups.append(group);
        }

        return req->response(QVariant(groups),IResponse::OK);
    }
    return req->response(IResponse::UNAUTHORIZED);

}
Example #14
0
QVariantList parseRetrievedAudioList(const QByteArray &result, const QString& userId)
{
	std::cout << QString(result).toStdString() << std::endl;

	QVariantList list;
	QScriptEngine engine;
	QScriptValue response = engine.evaluate("(" + QString(result) + ")").property(RESPONSE);
	QScriptValueIterator it(response);

	while (it.hasNext()) {
		it.next();

		// Parse aid & oid
		QString aid = it.value().property(AID).toString();
		QString oid = it.value().property(OWNER_ID).toString();

		// Parse artist
		QByteArray rawText = it.value().property(ARTIST).toVariant().toByteArray();
		QString artist = QString::fromUtf8(rawText, rawText.size());

		rawText.clear();

		// Parse title
		rawText = it.value().property(TITLE).toVariant().toByteArray();
		QString title = QString::fromUtf8(rawText, rawText.size());

		// Parse duration
		QString duration = it.value().property(DURATION).toString();

		// Parse url
		QString url = it.value().property(TRACK_URL).toString();

		if (!aid.isEmpty() && !oid.isEmpty() && !artist.isEmpty() && !title.isEmpty() && !url.isEmpty())
		{
			QVariantMap track;

			track.insert(AID, aid);
			track.insert(OWNER_ID, oid);
			track.insert(OWNED, userId.toInt() == oid.toInt());
			track.insert(ARTIST, artist);
			track.insert(TITLE,title);
			track.insert(DURATION,duration);
			track.insert(TRACK_URL,url);

			list.append(track);
		}
	}

	return list;
}
Example #15
0
void MusicVideos::refresh()
{
    QVariantMap params;
    QVariantList properties;
    properties.append("fanart");
    properties.append("playcount");
    properties.append("year");
    properties.append("resume");
    params.insert("properties", properties);


    if (m_recentlyAdded) {
        KodiConnection::sendCommand("VideoLibrary.GetMusicVideos", params, this, "listReceived");
    } else {
        QVariantMap sort;
        sort.insert("method", "label");
        sort.insert("order", "ascending");
        sort.insert("ignorearticle", ignoreArticle());
        params.insert("sort", sort);

        KodiConnection::sendCommand("VideoLibrary.GetRecentlyAddedMusicVideos", params, this, "listReceived");
    }
}
Example #16
0
QString HubConnection::onSending()
{
    QVariantList lst;
    QVariantMap map;
    for(int i = 0; i < _hubs.count(); i++)
    {
        map.insert("Name", _hubs.keys().at(i));
        lst.append(map);
    }
    

    QString json = QextJson::stringify(QVariant::fromValue(lst));
    return json;
}
Example #17
0
QVariantMap ObjectGroup::toJsonObject(bool internal)
{
    QVariantMap object = Object::toJsonObject(internal);
    QVariantList objects;

    for(int i=0; i < mObjects.size(); i++) {
        objects.append(mObjects[i]->toJsonObject(internal));
    }

    if (! objects.isEmpty())
        object.insert("objects", objects);

    return object;
}
Example #18
0
QVariantList EventQuery::createDecorationData(const QStringList & item) const
{
    Q_UNUSED(item);

    QVariantList decorationList;
    decorationList.reserve(Max_columns-1);

    for(int i = 0; i < Max_columns; i++) {
        //TODO: find out if event is also available in akonadi
        decorationList.append(QVariant());
    }

    return decorationList;
}
bool EncryptedStoredMessageModule::Private::processJsonCheck(TcpSocketHandler &socket, const TcpProtocol::RequestHeader &header, const QVariant &data)
{
	auto serverBase = _pOwner->getServerBase();
	auto receiverFingerprint = socket._key.fingerprint().toLatin1();

	auto messages = serverBase->getMessageDatabase()->getUnreadMessages(receiverFingerprint);
	QVariantList msglist;
	foreach (auto message, messages) {
		QVariantMap msg;
		msg["id"] = message->getId();
		msg["sender_fingerprint"] = message->getSenderFingerprint();
		msg["data"] = message->getMessage();
		msglist.append(msg);
	}
Example #20
0
bool SharedCookieJarQt::setCookiesFromUrl(const QList<QNetworkCookie>& cookieList, const QUrl& url)
{
    if (!QNetworkCookieJar::setCookiesFromUrl(cookieList, url))
        return false;

    if (!m_database.isOpen())
        return false;

    QSqlQuery sqlQuery(m_database);
    sqlQuery.prepare(QLatin1String("INSERT OR REPLACE INTO cookies (cookieId, cookie) VALUES (:cookieIdvalue, :cookievalue)"));
    QVariantList cookiesIds;
    QVariantList cookiesValues;
    foreach (const QNetworkCookie &cookie, cookiesForUrl(url)) {
        if (cookie.isSessionCookie())
            continue;
        cookiesIds.append(cookie.domain().append(QLatin1String(cookie.name())));
        cookiesValues.append(cookie.toRawForm());
    }
    sqlQuery.bindValue(QLatin1String(":cookieIdvalue"), cookiesIds);
    sqlQuery.bindValue(QLatin1String(":cookievalue"), cookiesValues);
    sqlQuery.execBatch();
    return true;
}
QVariant QDeclarativeContactDetails::updateValue(const QString &, const QVariant &input)
{
    if (input.userType() == QMetaType::QObjectStar) {
        QDeclarativeContactDetail *detail =
                        qobject_cast<QDeclarativeContactDetail *>(input.value<QObject *>());
        if (detail) {
            QVariantList varList;
            varList.append(input);
            return varList;
        }
    }

    return input;
}
QVariant gvariantToQVariant(GVariant *value)
{
	GVariantClass c = g_variant_classify(value);
	if(c == G_VARIANT_CLASS_BOOLEAN)
		return QVariant((bool) g_variant_get_boolean(value));

	else if(c == G_VARIANT_CLASS_BYTE)
		return QVariant((char) g_variant_get_byte(value));

	else if(c == G_VARIANT_CLASS_INT16)
		return QVariant((int) g_variant_get_int16(value));

	else if(c == G_VARIANT_CLASS_UINT16)
		return QVariant((unsigned int) g_variant_get_uint16(value));

	else if(c == G_VARIANT_CLASS_INT32)
		return QVariant((int) g_variant_get_int32(value));

	else if(c ==  G_VARIANT_CLASS_UINT32)
		return QVariant((unsigned int) g_variant_get_uint32(value));

	else if(c == G_VARIANT_CLASS_INT64)
		return QVariant((long long) g_variant_get_int64(value));

	else if(c == G_VARIANT_CLASS_UINT64)
		return QVariant((unsigned long long) g_variant_get_uint64(value));

	else if(c == G_VARIANT_CLASS_DOUBLE)
		return QVariant(g_variant_get_double(value));

	else if(c == G_VARIANT_CLASS_STRING)
		return QVariant(g_variant_get_string(value, NULL));

	else if(c == G_VARIANT_CLASS_ARRAY)
	{
		gsize dictsize = g_variant_n_children(value);
		QVariantList list;
		for (int i=0;i<dictsize;i++)
		{
			GVariant *childvariant = g_variant_get_child_value(value,i);
			GVariant *innervariant = g_variant_get_variant(childvariant);
			list.append(gvariantToQVariant(innervariant));
		}
		return list;
	}

	else
		return QVariant::Invalid;

}
    void btWorldFactory::createSphere(QVariantList &shapesList, btScalar radius, btVector3 pos, btVector3 euler, double density) {

        QVariantMap sphereMap;
        sphereMap.insert("type","sphere");
        sphereMap.insert("radius",(double)radius);
        sphereMap.insert("posX",(double)pos.x());
        sphereMap.insert("posY",(double)pos.y());
        sphereMap.insert("posZ",(double)pos.z());
        sphereMap.insert("eulerX",(double)euler.x());
        sphereMap.insert("eulerY",(double)euler.y());
        sphereMap.insert("eulerZ",(double)euler.z());
        sphereMap.insert("density",(double)density);
        shapesList.append(sphereMap);
    }
Example #24
0
QVariantList PopulatorDialog::textValues(Populator::PopColumn c)
{
	QVariantList ret;
	for (int i = 0; i < spinBox->value(); ++i)
	{
		QStringList l;
		for (int j = 0; j < c.size; ++j)
			l.append(QChar((qrand() % 58) + 65));
		ret.append(l.join("")
				.replace(QRegExp("(\\[|\\'|\\\\|\\]|\\^|\\_|\\`)"), " ")
				.simplified());
	}
	return ret;
}
Example #25
0
void DroidStoreAPI::parseResultsJSON(QString jsonString, QString categoryOnly)
{
	JsonDataAccess jda;
	QVariant jsonDATA 	= jda.loadFromBuffer(jsonString);
	_results 			= jsonDATA.toMap().value("results").toList();

	QVariantList newResults = _results;

	if(categoryOnly != "all")
	{
		newResults.clear();

		foreach (QVariant app , _results)
		{
			if(categoryOnly == "game")
			{
				if(app.toMap().value("cat_int").toInt() >= 25) // if it's an game type
				{
					newResults.append(app);
				}
			}
			else if(categoryOnly == "app")
			{
				if(app.toMap().value("cat_int").toInt() <= 26) // if it's a app type
				{
					newResults.append(app);
				}
			}
			else
			{
				if(app.toMap().value("cat_int").toInt() == categoryOnly.toInt()) // if it's a specific type
				{
					newResults.append(app);
				}
			}
		}
	}
Example #26
0
bool DC1394Slider::init(cameraFeature_id_t feature, char* label, DC1394Thread *controlThread)
{
    m_Feature=feature;
    this->controlThread = controlThread;

    connect(controlThread,SIGNAL(sliderHasFeatureDone(QObject*,bool)),
           this,SLOT(onHasFeatureDone(QObject*,bool)),Qt::QueuedConnection);

    connect(controlThread,SIGNAL(sliderRefreshDone(QObject*,bool,bool,bool,bool,bool,bool,double)),
            this,SLOT(onRefreshDone(QObject*,bool,bool,bool,bool,bool,bool,double)),Qt::QueuedConnection);

    connect(controlThread,SIGNAL(sliderSetFeatureDC1394Done(QObject*,double)),
            this,SLOT(onSliderSetFeatureDone(QObject*,double)),Qt::QueuedConnection);

    connect(controlThread,SIGNAL(sliderRadioAutoDone(QObject*,bool,bool)),
            this,SLOT(onRadioAutoDone(QObject*,bool,bool)),Qt::QueuedConnection);

    connect(controlThread,SIGNAL(sliderPowerDone(QObject*,bool,bool,bool,bool)),
            this,SLOT(onPowerDone(QObject*,bool,bool,bool,bool)),Qt::QueuedConnection);

    connect(controlThread,SIGNAL(sliderOnePushDone(QObject*,double)),
            this,SLOT(onOnePushDone(QObject*,double)),Qt::QueuedConnection);

    type = SLIDER;
    m_Name=label;

    ui->label->setTitle(m_Name);

    connectWidgets();

    QVariantList list;
    list.append(qVariantFromValue((void*)this));
    list.append(QVariant((int)m_Feature));
    controlThread->doTask(_sliderHasFeature,list);

    return true;
}
Example #27
0
bool FBXMLHandler::endElement( const QString & /*namespaceURI*/,
                               const QString & /*localName*/,
                               const QString & /*qName*/ )
{
    flushCharacters();

    QVariant c = iStack [iStack.count() - 1] ;
    QString name = topName();

    iStack.removeLast();
    iNameStack.removeLast();

    if (!iStack.count())
    {
        iRootObject = c;
        iRootName = name;
    }
    else
    {
        QVariant tC = iStack[iStack.count() - 1] ;
        if (tC.isNull())
        {
            tC = QVariantHash();
            iStack.replace(iStack.count() - 1, tC);
        }

        if (tC.type() == QVariant::List)
        {
            QVariantList list = tC.toList();
            list.append( c.toHash() );

            iStack.replace( iStack.count() - 1 , list);

        }
        else if (tC.type() == QVariant::Hash)
        {
            QVariantHash hash = tC.toHash();
            if (c.isNull())
            {
                c  = QString("");
            }
            hash.insert( name, c );

            iStack.replace( iStack.count() - 1 , hash);
        }
    }

    return true;
}
 void TestJSonDriver::parseSimpleArray() {
  QString json = "[\"foo\",\"bar\"]";
  QVariantList list;
  list.append (QVariant(QString("foo")));
  list.append (QVariant(QString("bar")));
  QVariant expected (list);

  JSonDriver driver;
  bool status;
  QVariant result = driver.parse (json, &status);
  qDebug() << "expected: " << expected;
  qDebug() << "result: " << result;
  QVERIFY (!status);
  QCOMPARE(result, expected);
}
Example #29
0
QVariantList FileSystem::entryList(const QString &path, const QString &filter)
{
    QDir dir(path);
    QStringList nameFilters;
    nameFilters.append(QString("*%1*").arg(filter));
    dir.setNameFilters(nameFilters);
    dir.setFilter(QDir::AllEntries|QDir::NoDot);
    QFileInfoList infos = dir.entryInfoList();
    QVariantList data;
    foreach(const QFileInfo& info, infos) {
        const QVariantMap& entry = toMap(info);
        data.append(entry);
    }
    return data;
}
void PerformanceCounterSelection::Save()
{
  QString filename = RDDialog::getSaveFileName(this, tr("Save File"), QDir::homePath(),
                                               tr("Performance Counter Settings (*.json)"));

  if(filename.isEmpty())
    return;

  QVariantList counterIds;
  for(const GPUCounter v : m_SelectedCounters.keys())
  {
    const Uuid uuid = m_CounterToUuid[v];
    QVariantList e;

    for(const uint32_t b : uuid.words)
    {
      e.append(b);
    }

    counterIds.append(QVariant(e));
  }

  QVariantMap doc;
  doc[lit("counters")] = counterIds;

  QFile f(filename);
  if(f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
  {
    SaveToJSON(doc, f, JSON_ID, JSON_VER);
  }
  else
  {
    RDDialog::critical(this, tr("Error saving config"),
                       tr("Couldn't open path %1 for write.").arg(filename));
  }
}