void TestControllerTest::testResults()
{
    ITestSuite* suite = new FakeTestSuite(TestSuiteName, m_project);
    m_testController->addTestSuite(suite);

    QSignalSpy spy(m_testController, SIGNAL(testRunFinished(KDevelop::ITestSuite*,KDevelop::TestResult)));
    QVERIFY(spy.isValid());

    QList<TestResult::TestCaseResult> results;
    results << TestResult::Passed << TestResult::Failed << TestResult::Error << TestResult::Skipped << TestResult::NotRun;

    foreach (TestResult::TestCaseResult result, results)
    {
        emitTestResult(suite, result);
        QCOMPARE(spy.size(), 1);

        QVariantList arguments = spy.takeFirst();
        QCOMPARE(arguments.size(), 2);

        QVERIFY(arguments.first().canConvert<ITestSuite*>());
        QCOMPARE(arguments.first().value<ITestSuite*>(), suite);

        QVERIFY(arguments.at(1).canConvert<TestResult>());
        QCOMPARE(arguments.at(1).value<TestResult>().suiteResult, result);

        foreach (const QString& testCase, suite->cases())
        {
            QCOMPARE(arguments.at(1).value<TestResult>().testCaseResults[testCase], result);
        }
    }
Exemplo n.º 2
0
QVariant QVariantTree::internalDelTreeValue(const QVariant& root,
                                    const QVariantList& address,
                                    bool* isValid) const
{
    QVariant result = root;
    bool trueValid = true;

    if (address.isEmpty())
        result.clear(); // if no address -> invalid
    else if (address.count() == 1) {
        QVariantTreeElementContainer* containerType = containerOf(result.type());
        if (containerType == NULL)
            trueValid = false;
        else
            result = containerType->delItem(result, address.first());
    }
    else {
        QVariantTreeElementContainer* containerType = containerOf(result.type());
        if (containerType && containerType->keys(result).contains(address.first())) {
            result = containerType->item(result, address.first());
            result = internalDelTreeValue(result, address.mid(1));
            result = containerType->setItem(root, address.first(), result);
        }
        else
            trueValid = false;
    }

    if (isValid)
        *isValid = trueValid;

    return result;
}
Exemplo n.º 3
0
QVariant QVariantTree::internalSetTreeValue(const QVariant& root,
                                    const QVariantList& address,
                                    const QVariant& value,
                                    bool* isValid) const
{
    QVariant result = root;
    bool trueValid = true;

    if (address.isEmpty())
        result = value;
    else {
        QVariantTreeElementContainer* containerType = containerOf(result.type());
        if (containerType && containerType->keys(result).contains(address.first())) {
            result = containerType->item(result, address.first());
            result = internalSetTreeValue(result, address.mid(1), value);
            result = containerType->setItem(root, address.first(), result);
        }
        else
            trueValid = false;
    }

    if (isValid)
        *isValid = trueValid;

    return result;
}
Exemplo n.º 4
0
ReadOnlyArchiveInterface::ReadOnlyArchiveInterface(QObject *parent, const QVariantList & args)
        : QObject(parent)
        , m_waitForFinishedSignal(false)
        , m_isHeaderEncryptionEnabled(false)
        , m_isCorrupt(false)
{
    qCDebug(ARK) << "Created read-only interface for" << args.first().toString();
    m_filename = args.first().toString();
}
Exemplo n.º 5
0
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()
Exemplo n.º 6
0
/* Special version of the state() call which does not call event loop.
 * Needed in order to fix NB#175098 where Qt4.7 webkit crashes because event
 * loop is run when webkit does not expect it. This function is called from
 * bearer management API syncStateWithInterface() in QNetworkSession
 * constructor.
 */
uint IcdPrivate::state(QList<IcdStateResult>& state_results)
{
    QVariant reply;
    QVariantList vl;
    uint signals_left, total_signals;
    IcdStateResult result;
    time_t started;
    int timeout_secs = timeout / 1000;

    PDEBUG("%s\n", "state_results");

    clearState();
    reply = mDBus->call(ICD_DBUS_API_STATE_REQ);
    if (reply.type() != QVariant::List)
        return 0;
    vl = reply.toList();
    if (vl.isEmpty())
        return 0;
    reply = vl.first();
    signals_left = total_signals = reply.toUInt();
    if (!signals_left)
        return 0;

    started = time(0);
    state_results.clear();
    mError.clear();
    while (signals_left) {
        mInterface.clear();
	while ((time(0)<=(started+timeout_secs)) && mInterface.isEmpty()) {
	    mDBus->synchronousDispatch(1000);
        QCoreApplication::sendPostedEvents(icd, QEvent::MetaCall);
	}

        if (time(0)>(started+timeout_secs)) {
	    total_signals = 0;
	    break;
	}

	if (mSignal != ICD_DBUS_API_STATE_SIG) {
	    continue;
	}

	if (mError.isEmpty()) {
	    if (!mArgs.isEmpty()) {
	        if (mArgs.size()==2)
	            get_state_all_result2(mArgs, result);
		else
	            get_state_all_result(mArgs, result);
		state_results << result;
	    }
	    signals_left--;
	} else {
	    qWarning() << "Error:" << mError;
	    break;
	}
    }

    PDEBUG("total_signals=%d\n", total_signals);
    return total_signals;
}
Exemplo n.º 7
0
void ResourcesModelPrivate::_q_onRequestFinished() {
    if (!request) {
        return;
    }

    Q_Q(ResourcesModel);

    if (request->status() == ResourcesRequest::Ready) {
        const QVariantMap result = request->result().toMap();
    
        if (!result.isEmpty()) {
            next = result.value("next").toString();
            previous = result.value("previous").toString();
        
            const QVariantList list = result.value("items").toList();
        
            if (!list.isEmpty()) {
                if (roles.isEmpty()) {
                    setRoleNames(list.first().toMap());
                }
                
                q->beginInsertRows(QModelIndex(), items.size(), items.size() + list.size() - 1);
                
                foreach (const QVariant &item, list) {
                    items << item.toMap();
                }
                
                q->endInsertRows();
                emit q->countChanged(q->rowCount());
            }
        }
    }
Exemplo n.º 8
0
static void get_addrinfo_all_result(QList<QVariant>& args,
				    IcdAddressInfoResult& ret)
{
    int i=0;

    if (args.isEmpty())
      return;

    ret.params.service_type = args[i++].toString();
    ret.params.service_attrs = args[i++].toUInt();
    ret.params.service_id = args[i++].toString();
    ret.params.network_type = args[i++].toString();
    ret.params.network_attrs = args[i++].toUInt();
    ret.params.network_id = args[i++].toByteArray();

    QVariantList vl = args[i].toList();
    QVariant reply = vl.first();
    QList<QVariant> lst = reply.toList();
    for (int k=0; k<lst.size()/6; k=k+6) {
        IcdIPInformation ip_info;
	ip_info.address = lst[k].toString();
	ip_info.netmask = lst[k++].toString();
	ip_info.default_gateway = lst[k++].toString();
	ip_info.dns1 = lst[k++].toString();
	ip_info.dns2 = lst[k++].toString();
	ip_info.dns3 = lst[k++].toString();

	ret.ip_info << ip_info;
    }
}
Exemplo n.º 9
0
void OSCRemote::readOscMsg(QString addr, QVariantList args)
{
    qWarning()<<"OSC|"<<addr<<args;
    if(!addr.startsWith(_oscAddress))
        return;
    qWarning()<<"1";
    if(args.size()!=2)
        return;
        qWarning()<<"2";
    bool ok = true;
    float intensity = (float)(args.at(1).toInt(&ok))/255.0f;
    if(!ok)
        return;
        qWarning()<<"3";
    
    QString led = args.first().toString();
    if(led == "LED1")
        ledChanged(1, intensity);
    else if(led == "LED2")
        ledChanged(2, intensity);
    else if(led == "LED3")
        ledChanged(3, intensity);
    else if(led == "LED"){
        ledChanged(1, intensity);
        ledChanged(2, intensity);
        ledChanged(3, intensity);
    }
    
}
Exemplo n.º 10
0
void TestLogging::systemLogs()
{
    // check the active system log at boot
    QVariantMap params;
    params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceSystem));
    params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeActiveChange));

    // there should be 2 logs, one for shutdown, one for startup (from server restart)
    QVariant response = injectAndWait("Logging.GetLogEntries", params);
    verifyLoggingError(response);
    QVariantList logEntries = response.toMap().value("params").toMap().value("logEntries").toList();
    QVERIFY(logEntries.count() == 2);

    QVariantMap logEntryShutdown = logEntries.first().toMap();

    QCOMPARE(logEntryShutdown.value("active").toBool(), false);
    QCOMPARE(logEntryShutdown.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeActiveChange));
    QCOMPARE(logEntryShutdown.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceSystem));
    QCOMPARE(logEntryShutdown.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo));

    QVariantMap logEntryStartup = logEntries.last().toMap();

    QCOMPARE(logEntryStartup.value("active").toBool(), true);
    QCOMPARE(logEntryStartup.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeActiveChange));
    QCOMPARE(logEntryStartup.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceSystem));
    QCOMPARE(logEntryStartup.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo));
}
Exemplo n.º 11
0
void
RoviPlugin::albumLookupFinished()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
    Q_ASSERT( reply );

    if ( reply->error() != QNetworkReply::NoError )
        return;

    Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();

    QJson::Parser p;
    bool ok;
    QVariantMap response = p.parse( reply, &ok ).toMap();

    if ( !ok || response.isEmpty() || !response.contains( "searchResponse" ) )
    {
        tLog() << "Error parsing JSON from Rovi!" << p.errorString() << response;
        emit info( requestData, QVariant() );
        return;
    }

    QVariantList resultList = response[ "searchResponse" ].toMap().value( "results" ).toList();
    if ( resultList.size() == 0 )
    {
        emit info( requestData, QVariant() );
        return;
    }

    QVariantMap results = resultList.first().toMap();
    QVariantList tracks = results[ "album" ].toMap()[ "tracks" ].toList();

    if ( tracks.isEmpty() )
    {
        tLog() << "Error parsing JSON from Rovi!" << p.errorString() << response;
        emit info( requestData, QVariant() );
    }


    QStringList trackNameList;
    foreach ( const QVariant& track, tracks )
    {
        const QVariantMap trackData = track.toMap();
        if ( trackData.contains( "title" ) )
            trackNameList << trackData[ "title" ].toString();
    }

    QVariantMap returnedData;
    returnedData["tracks"] = trackNameList;

    emit info( requestData, returnedData );

    Tomahawk::InfoSystem::InfoStringHash criteria;
    criteria["artist"] = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>()["artist"];
    criteria["album"] = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>()["album"];

    emit updateCache( criteria, 0, requestData.type, returnedData );
}
int OpsSqlDataSource::lastOutboundId()
{
    int op_id = -1;
    QVariant result = _sda->execute("select max(out_op_id) from outbound_ops_queue");
    QVariantList list = result.value<QVariantList>();
    QVariant row = list.first();
    op_id = row.toMap().value("max(out_op_id)").toInt();
    return op_id;
}
Exemplo n.º 13
0
uint IcdPrivate::state(QString& service_type, uint service_attrs,
		       QString& service_id, QString& network_type,
		       uint network_attrs, QByteArray& network_id,
		       IcdStateResult& state_result)
{
    QTimer timer;
    QVariant reply;
    uint total_signals;
    QVariantList vl;

    clearState();

    reply = mDBus->call(ICD_DBUS_API_STATE_REQ,
			service_type, service_attrs, service_id,
			network_type, network_attrs, network_id);
    if (reply.type() != QVariant::List)
        return 0;
    vl = reply.toList();
    if (vl.isEmpty())
        return 0;
    reply = vl.first();
    total_signals = reply.toUInt();
    if (!total_signals)
        return 0;

    timer.setSingleShot(true);
    timer.start(timeout);

    mInterface.clear();
    while (timer.isActive() && mInterface.isEmpty()) {
        QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);

	if (mSignal != ICD_DBUS_API_STATE_SIG) {
            mInterface.clear();
	    continue;
	}
    }

    timer.stop();

    if (mError.isEmpty()) {
        if (!mArgs.isEmpty()) {
	    if (mArgs.size()>2)
	        get_state_all_result(mArgs, state_result);
	    else {
	        // We are not connected as we did not get the status we asked
	        return 0;
	    }
	}
    } else {
        qWarning() << "Error:" << mError;
    }

    // The returned value should be one because we asked for one state
    return total_signals;
}
bool DeclarativeDBusAdaptor::handleMessage(const QDBusMessage &message, const QDBusConnection &connection)
{
    QVariant variants[10];
    QGenericArgument arguments[10];

    const QMetaObject * const meta = metaObject();
    const QVariantList dbusArguments = message.arguments();

    QString member = message.member();
    QString interface = message.interface();

    // Don't try to handle introspect call. It will be handled
    // internally for QDBusVirtualObject derived classes.
    if (interface == QLatin1String("org.freedesktop.DBus.Introspectable")) {
        return false;
    } else if (interface == QLatin1String("org.freedesktop.DBus.Properties")) {
        if (member == QLatin1String("Get")) {
            interface = dbusArguments.value(0).toString();
            member = dbusArguments.value(1).toString();

            const QMetaObject * const meta = metaObject();
            if (!member.isEmpty() && member.at(0).isUpper())
                member = "rc" + member;

            for (int propertyIndex = meta->propertyOffset();
                    propertyIndex < meta->propertyCount();
                    ++propertyIndex) {
                QMetaProperty property = meta->property(propertyIndex);

                if (QLatin1String(property.name()) != member)
                    continue;

                QVariant value = property.read(this);
                if (value.userType() == qMetaTypeId<QJSValue>())
                    value = value.value<QJSValue>().toVariant();

                if (value.userType() == QVariant::List) {
                    QVariantList variantList = value.toList();
                    if (variantList.count() > 0) {

                        QDBusArgument list;
                        list.beginArray(variantList.first().userType());
                        foreach (const QVariant &listValue, variantList) {
                            list << listValue;
                        }
                        list.endArray();
                        value = QVariant::fromValue(list);
                    }
                }

                QDBusMessage reply = message.createReply(QVariantList() << value);
                connection.call(reply, QDBus::NoBlock);

                return true;
            }
Exemplo n.º 15
0
uint IcdPrivate::statistics(QList<IcdStatisticsResult>& stats_results)
{
    QTimer timer;
    QVariant reply;
    QVariantList vl;
    uint signals_left, total_signals;
    IcdStatisticsResult result;

    clearState();
    reply = mDBus->call(ICD_DBUS_API_STATISTICS_REQ);
    if (reply.type() != QVariant::List)
        return 0;
    vl = reply.toList();
    if (vl.isEmpty())
        return 0;
    reply = vl.first();
    if (reply.type() != QVariant::UInt)
        return 0;
    signals_left = total_signals = reply.toUInt();

    if (!signals_left)
        return 0;

    timer.setSingleShot(true);
    timer.start(timeout);
    stats_results.clear();
    while (signals_left) {
	mInterface.clear();
	while (timer.isActive() && mInterface.isEmpty()) {
	    QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
	}

	if (!timer.isActive()) {
	    total_signals = 0;
	    break;
	}

	if (mSignal != ICD_DBUS_API_STATISTICS_SIG) {
	    continue;
	}

	if (mError.isEmpty()) {
  	    get_statistics_all_result(mArgs, result);
	    stats_results << result;
	    signals_left--;
	} else {
	    qWarning() << "Error:" << mError;
	    break;
	}
    }
    timer.stop();

    return total_signals;
}
Exemplo n.º 16
0
void ActionManager::acceptAction()
{
    ActionType action = m_deferredAction.first;
    if (action == None)
        return;

    QVariantList data = m_deferredAction.second;

    switch(action)
    {
        case DeleteFunctions:
        {
            m_functionManager->deleteFunctions(data);
        }
        break;
        case DeleteShowItems:
        {
            m_showManager->deleteShowItems(data);
        }
        break;
        case DeleteVCPage:
        {
            m_virtualConsole->deletePage(data.first().toInt());
        }
        break;
        case DeleteVCWidgets:
        {
            m_virtualConsole->deleteVCWidgets(data);
        }
        break;
        case VCPagePINRequest:
        {
            m_virtualConsole->setSelectedPage(data.first().toInt());
        }
        break;
        default: break;
    }

    // invalidate the action just processed
    m_deferredAction = QPair<ActionType, QVariantList> (None, QVariantList());
}
Exemplo n.º 17
0
Arquivo: uloz.cpp Projeto: marxoft/qdl
void Uloz::onCaptchaSubmitted() {
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(this->sender());

    if (!reply) {
        emit error(NetworkError);
        return;
    }

    QUrl redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();

    if (redirect.isValid()) {
        emit downloadRequestReady(QNetworkRequest(redirect));
    }
    else {
        QString response(reply->readAll());
        QVariantMap result = Json::parse(response).toMap();

        if (!result.isEmpty()) {
            redirect = result.value("url").toUrl();

            if (redirect.isValid()) {
                emit downloadRequestReady(QNetworkRequest(redirect));
            }
            else {
                QVariantList errors = result.value("errors").toList();

                if (!errors.isEmpty()) {
                    QString errorString = errors.first().toString();

                    if ((errorString.startsWith("Error rewriting")) || (errorString.startsWith("Text je op"))) {
                        m_captchaKey = QString::number(QDateTime::currentMSecsSinceEpoch());
                        emit error(CaptchaError);
                    }
                    else {
                        emit error(UnknownError);
                    }
                }
                else {
                    emit error(UnknownError);
                }
            }
        }
        else if ((response.contains("Error rewriting")) || (response.contains("Text je ops"))) {
            m_captchaKey = QString::number(QDateTime::currentMSecsSinceEpoch());
            emit error(CaptchaError);
        }
        else {
            emit error(UnknownError);
        }
    }

    reply->deleteLater();
}
Exemplo n.º 18
0
void VimeoPlugin::onStreamsRequestFinished() {
    if (m_streamsRequest->status() == QVimeo::StreamsRequest::Ready) {
        const QVariantList streams = m_streamsRequest->result().toList();
        
        if (streams.isEmpty()) {
            emit error(tr("No streams found"));
            return;
        }

        if (m_settings.value("useDefaultVideoFormat", true).toBool()) {
            const QString format = m_settings.value("videoFormat", "1080p").toString();

            for (int i = 0; i < VIDEO_FORMATS.indexOf(format); i++) {
                for (int j = 0; j < streams.size(); j++) {
                    const QVariantMap stream = streams.at(j).toMap();

                    if (stream.value("id") == format) {
                        emit downloadRequest(QNetworkRequest(stream.value("url").toString()));
                        return;
                    }
                }
            }

            emit error(tr("No stream found for the chosen video format"));
        }
        else {
            QVariantList settingsList;
            QVariantList options;
            QVariantMap list;
            list["type"] = "list";
            list["label"] = tr("Video format");
            list["key"] = "videoFormat";
            list["value"] = streams.first().toMap().value("url");
            
            for (int i = 0; i < streams.size(); i++) {
                const QVariantMap stream = streams.at(i).toMap();
                QVariantMap option;
                option["label"] = QString("%1P").arg(stream.value("height").toString());
                option["value"] = stream.value("url");
                options << option;
            }

            list["options"] = options;
            settingsList << list;
            emit settingsRequest(tr("Choose video format"), settingsList, "submitFormat");
        }
    }
    else if (m_streamsRequest->status() == QVimeo::StreamsRequest::Failed) {
        emit error(m_streamsRequest->errorString());
    }   
}
Exemplo n.º 19
0
uint IcdPrivate::addrinfo(QString& service_type, uint service_attrs,
			  QString& service_id, QString& network_type,
			  uint network_attrs, QByteArray& network_id,
			  IcdAddressInfoResult& addr_result)
{
    QTimer timer;
    QVariant reply;
    uint total_signals;
    QVariantList vl;

    clearState();

    reply = mDBus->call(ICD_DBUS_API_ADDRINFO_REQ,
			service_type, service_attrs, service_id,
			network_type, network_attrs, network_id);
    if (reply.type() != QVariant::List)
        return 0;
    vl = reply.toList();
    if (vl.isEmpty())
        return 0;
    reply = vl.first();
    total_signals = reply.toUInt();

    if (!total_signals)
        return 0;

    timer.setSingleShot(true);
    timer.start(timeout);

    mInterface.clear();
    while (timer.isActive() && mInterface.isEmpty()) {
        QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);

	if (mSignal != ICD_DBUS_API_ADDRINFO_SIG) {
            mInterface.clear();
	    continue;
	}
    }

    timer.stop();

    if (mError.isEmpty()) {
        get_addrinfo_all_result(mArgs, addr_result);
    } else {
        qWarning() << "Error:" << mError;
    }

    // The returned value should be one because we asked for one addrinfo
    return total_signals;
}
Exemplo n.º 20
0
void VkontakteAuth::dataReady()
{
  OAUTH_PREPARE_REPLY
  OAUTH_BAD_STATUS

  QVariantMap data = JSON::parse(raw).toMap();
  if (data.contains(LS("error")))
    return setError("data_error: " + data.value(LS("error")).toMap().value(LS("error_msg")).toByteArray());

  QVariantList list = data.value(LS("response")).toList();
  if (list.isEmpty())
    return setError("invalid_data");

  QVariantMap response = list.first().toMap();
  QByteArray uid = response.value(LS("uid")).toByteArray();
  if (uid.isEmpty())
    return setError("invalid_uid");

  User user;
  user.name = response.value(LS("first_name")).toString() + LC(' ') + response.value(LS("last_name")).toString();
  if (user.name == LS(" "))
    user.name = QString();

  QString screen_name = response.value(LS("screen_name")).toString();
  if (screen_name.isEmpty())
    user.link = LS("http://vk.com/id") + uid;
  else
    user.link = LS("http://vk.com/") + screen_name;

  QStringList birthday = response.value(LS("bdate")).toString().split(LC('.'));
  if (birthday.size() == 3) {
    user.birthday = birthday.at(2) + LC('-');
    if (birthday.at(1).size() == 1)
      user.birthday += LC('0');

    user.birthday += birthday.at(1) + LC('-');

    if (birthday.at(0).size() == 1)
      user.birthday += LC('0');

    user.birthday += birthday.at(0);
  }

  QByteArray id = SimpleID::encode(SimpleID::make("vkontakte:" + uid, SimpleID::UserId));
  AuthCore::state()->add(new AuthStateData(m_state, "vkontakte", id, response, user));

  log(NodeLog::InfoLevel, "Data is successfully received, id:" + id + ", uid:" + uid);
  deleteLater();
}
Exemplo n.º 21
0
void VCCueList::addFunctions(QVariantList idsList, int insertIndex)
{
    if (idsList.isEmpty())
        return;

    if (isEditing())
    {
        Chaser *ch = chaser();
        if (ch == NULL)
            return;

        if (insertIndex == -1)
            insertIndex = ch->stepsCount();

        for (QVariant vID : idsList) // C++11
        {
            quint32 fid = vID.toUInt();
            ChaserStep step(fid);
            if (ch->durationMode() == Chaser::PerStep)
            {
                Function *func = m_doc->function(fid);
                if (func == NULL)
                    continue;

                step.duration = func->totalDuration();
                if (step.duration == 0)
                    step.duration = 1000;
                step.hold = step.duration;
            }
            Tardis::instance()->enqueueAction(Tardis::ChaserAddStep, ch->id(), QVariant(), insertIndex);
            ch->addStep(step, insertIndex++);
        }

        ChaserEditor::updateStepsList(m_doc, chaser(), m_stepsList);
        emit stepsListChanged();
    }
    else
    {
        Function *f = m_doc->function(idsList.first().toUInt());
        if (f == NULL || f->type() != Function::ChaserType)
            return;

        setChaserID(f->id());
    }
}
Exemplo n.º 22
0
void QQuickAndroid9PatchDivs::fill(const QVariantList &divs, qreal size)
{
    if (!data.isEmpty())
        return;

    inverted = divs.isEmpty() || divs.first().toInt() != 0;
    // Reserve an extra item in case we need to add the image width/height
    if (inverted) {
        data.reserve(divs.size() + 2);
        data.append(0);
    } else {
        data.reserve(divs.size() + 1);
    }

    foreach (const QVariant &div, divs)
        data.append(div.toReal());

    data.append(size);
}
Exemplo n.º 23
0
void FunctionManager::renameFunctions(QVariantList IDList, QString newName, bool numbering, int startNumber, int digits)
{
    if (IDList.isEmpty())
        return;

    if (IDList.count() == 1)
    {
        // single Function rename
        Function *f = m_doc->function(IDList.first().toUInt());
        if (f != NULL)
        {
            Tardis::instance()->enqueueAction(FunctionSetName, f->id(), f->name(), newName.simplified());
            f->setName(newName.simplified());
        }
    }
    else
    {
        int currNumber = startNumber;

        for(QVariant id : IDList) // C++11
        {
            Function *f = m_doc->function(id.toUInt());
            if (f == NULL)
                continue;

            if (numbering)
            {
                QString fName = QString("%1 %2").arg(newName.simplified()).arg(currNumber, digits, 10, QChar('0'));
                Tardis::instance()->enqueueAction(FunctionSetName, f->id(), f->name(), fName);
                f->setName(fName);
                currNumber++;
            }
            else
            {
                Tardis::instance()->enqueueAction(FunctionSetName, f->id(), f->name(), newName.simplified());
                f->setName(newName.simplified());
            }
        }
    }

    updateFunctionsTree();
}
Exemplo n.º 24
0
QString HtmlUtils::fromHtmlList_helper(const QVariant &item, const QString &indent, const HtmlUtils::FromHtmlListOptions &options)
{
	QString ret;
	Q_UNUSED(options)
	if(item.type() == QVariant::List) {
		QVariantList lst = item.toList();
		QF_ASSERT(!lst.isEmpty(), "Bad item list!", return ret);
		QString element_name = lst.first().toString();
		//qfInfo() << element_name << item;
		QF_ASSERT(!element_name.isEmpty(), "Bad element name!", return ret);
		QString attrs_str;
		int ix = 1;
		QVariant attrs = lst.value(ix);
		if(attrs.type() == QVariant::Map) {
			QVariantMap m = attrs.toMap();
			QMapIterator<QString, QVariant> it(m);
			while(it.hasNext()) {
				it.next();
				attrs_str += ' ' + it.key() + '=' + '"' + it.value().toString() + '"';
			}
			ix++;
		}
		bool has_children = (ix < lst.count());
		ret += '\n' + indent;
		if(has_children) {
			ret += '<' + element_name + attrs_str + '>';
			QString indent2 = indent + '\t';
			bool has_child_elemet = false;
			for (; ix < lst.count(); ++ix) {
				QVariant v = lst[ix];
				if(!v.toList().isEmpty())
					has_child_elemet = true;
				ret += fromHtmlList_helper(v, indent2, options);
			}
			if(has_child_elemet)
				ret += '\n' + indent;
			ret += "</" + element_name + '>';
		}
		else {
			ret += '<' + element_name + attrs_str + "/>";
		}
	}
Exemplo n.º 25
0
void CityModel::onSetFavoriteCity(QString city)
{
    if (updateFavoriteCity(city, true)) {

        // After setting a new city as favorite we load the corresponding item data
        // and add it to the model, this will automatically make it appear in the list.
        QString query = "select * from cities WHERE name='" + city + "'";
        DataAccessReply reply = mSqlConnector->executeAndWait(query, INITIAL_LOAD_ID);

        if (reply.hasError()) {
            qWarning() << "onLoadAsyncResultData: " << reply.id() << ", SQL error: " << reply;
        } else {
            QVariantList cityData = reply.result().value<QVariantList>();

            // Check if the city is already in the list, if its not we add it to the model, first is 
            // used since in our city data there is only one instance of each city.
            QVariantMap addedItem = cityData.first().toMap();
            if (find(addedItem).isEmpty()) {
                insert(addedItem);
            }
        }
    }
}
Exemplo n.º 26
0
void SpotifyImages::FetchInfo(int id, const Song& metadata) {
  if (metadata.artist().isEmpty()) {
    emit Finished(id);
    return;
  }

  // Fetch artist id.
  QUrl search_url(kSpotifySearchUrl);
  search_url.addQueryItem("q", metadata.artist());
  search_url.addQueryItem("type", "artist");
  search_url.addQueryItem("limit", "1");

  qLog(Debug) << "Fetching artist:" << search_url;

  QNetworkRequest request(search_url);
  QNetworkReply* reply = network_->get(request);
  NewClosure(reply, SIGNAL(finished()), [this, id, reply]() {
    reply->deleteLater();
    QJson::Parser parser;
    QVariantMap result = parser.parse(reply).toMap();
    QVariantMap artists = result["artists"].toMap();
    if (artists.isEmpty()) {
      emit Finished(id);
      return;
    }
    QVariantList items = artists["items"].toList();
    if (items.isEmpty()) {
      emit Finished(id);
      return;
    }
    QVariantMap artist = items.first().toMap();
    QString spotify_uri = artist["uri"].toString();

    FetchImagesForArtist(id, ExtractSpotifyId(spotify_uri));
  });
}
Exemplo n.º 27
0
void ApiYandexSearch::getSuggestionsFinished(QNetworkReply *reply)
{
    QByteArray content = reply->readAll();

    if (m_suggestionsParameters.v == "4") {
        QJsonParseError parseError;

        QVariant json = QJsonDocument::fromJson(content, &parseError).toVariant();
        if (Q_UNLIKELY(parseError.error)) {
            qWarning() << "ApiYandexSearch::getSuggestionsFinished():"
                       << tr("Can't parse JSON data:") << content
                       << tr(". Parser returned an error:") << parseError.errorString();
            qWarning() << "Request:" << m_currentSuggestionsRequest;
            m_currentSuggestionsRequest.clear();
            return;
        }
        QVariantList jsonList = json.toList();

        if (jsonList.size() == 0) {
                return;
        }

        QVariantList suggestions = jsonList.at(1).toList();

        QList<Consts::Shared::Suggestion> suggestionsToReturn;
        forc11 (QVariant var, suggestions) {
            Consts::Shared::Suggestion suggestion;

            // Query
            if (var.type() == QVariant::String) {
                suggestion.text = var.toString();
                suggestion.kind = Consts::Shared::Suggestion::Kind::Query;
            }
            else if (var.type() == QVariant::List) {
                QVariantList list = var.toList();

                QString kind = list.first().toString();

                // Fact
                if (kind == "fact") {
                    suggestion.text = list.at(1).toString();
                    suggestion.kind = Consts::Shared::Suggestion::Kind::Fact;
                    suggestion.others.fact = list.at(2).toString();
                }

                // Navigation
                else if (kind == "nav") {
                    suggestion.text = list.at(3).toString();
                    suggestion.kind = Consts::Shared::Suggestion::Kind::Navigation;
                    const QString nameOfGoToSite = QString::fromUtf8("перейти на сайт");
                    if (list.at(2).toString() != nameOfGoToSite)
                        suggestion.others.linkTitle = list.at(2).toString();
                }
                else {
                    continue;
                }
            }
            else {
                continue;
            }

            suggestionsToReturn.append(suggestion);
        }
Exemplo n.º 28
0
TorrentSession::TorrentSession():
p_( new Private ) {
	QVariantList range = Settings::instance().get( "listen" ).toList();
	this->p_->session.listen_on( std::make_pair( range.first().toInt(), range.last().toInt() ) );
	this->p_->timer.start();
}
Exemplo n.º 29
0
Client::DataList Client::getData(const string& query) {
    QJsonDocument root;

    QString temp = QString::fromStdString(query);
    QByteArray bytearray = query.c_str();
    QString query_string = QString::fromUtf8(bytearray.data(), bytearray.size());

    qDebug() << "query_string: " << query_string;

    QString uri = getQueryString(query_string);
    qDebug() << "uri: "  << uri;
    get(uri, root);

    DataList result;

    QVariantMap variant = root.toVariant().toMap();

    // Iterate through the weather data
    for (const QVariant &i : variant["businesses"].toList()) {
        QVariantMap item = i.toMap();

        QString name = removeTestInfo(item["name"].toString());
        qDebug() << "name: " << name;

        QString business_url = item["business_url"].toString();
        qDebug() << "business_url: " << business_url;

        QString s_photo_url = item["s_photo_url"].toString();
        qDebug() << "s_photo_url: " << s_photo_url;

        QString photo_url = item["photo_url"].toString();
        qDebug() << "photo_url: " << photo_url;

        QString rating_s_img_url = item["rating_s_img_url"].toString();
        qDebug() << "rating_s_img_url: " << rating_s_img_url;

        QString address = item["address"].toString();
        qDebug() << "address: " << address;

        QString telephone = item["telephone"].toString();
        qDebug() << "telephone: " << telephone;

        QVariantList deals = item["deals"].toList();

        QString summary;
        if ( deals.count() > 0 ) {
            QVariantMap temp = deals.first().toMap();
            summary = temp["description"].toString();
        }

        qDebug() << "summary: " << summary;

        // Add a result to the weather list
        result.emplace_back(
            Data { name.toStdString(), business_url.toStdString(), s_photo_url.toStdString(),
                   photo_url.toStdString(), rating_s_img_url.toStdString(),
                   address.toStdString(), telephone.toStdString(), summary.toStdString() });
    }

    return result;
}
Exemplo n.º 30
0
ReadWriteArchiveInterface::ReadWriteArchiveInterface(QObject *parent, const QVariantList & args)
        : ReadOnlyArchiveInterface(parent, args)
{
    qCDebug(ARK) << "Created read-write interface for" << args.first().toString();
}