void NodeModel::fromVariantMap(const QVariantMap& map){ QVariantList pos = map["Position"].toList(); QVariantMap netDeviceMap = map["NetDevice"].toMap(); QVariantMap noiseSourceMap = map["NoiseSource"].toMap(); //Migration for older versions of the dgm files. if(netDeviceMap.isEmpty()){ QVariantList netDevicesList = map["NetDevices"].toList(); if(!netDevicesList.isEmpty()){ netDeviceMap = netDevicesList.at(0).toMap(); } } if(noiseSourceMap.isEmpty()){ QVariantList noiseSourcesList = map["NoiseSources"].toList(); if(!noiseSourcesList.isEmpty()){ noiseSourceMap = noiseSourcesList.at(0).toMap(); } } name = map["Name"].toString(); position = QPointF(pos.at(0).toDouble(), pos.at(1).toDouble()); if (!netDeviceMap.isEmpty()){ netDevice = new NetDeviceModel(netDeviceMap); } if(!noiseSourceMap.isEmpty()){ noiseSource = new NoiseSourceModel(noiseSourceMap); } this->hasOutlet = map["HasOutlet"].toBool(); this->outletImpedance.setValue(map["OutletImpedance"].toString()); }
bool ChangeLog::checkChanges(const QString &previousVersion, const QString ¤tVersion) { QVersionNumber previous = QVersionNumber::fromString(previousVersion); QVersionNumber current = QVersionNumber::fromString(currentVersion); if (current <= previous) { qCInfo(CHANGELOG_CATEGORY) << "Current version isn't newer, than previous" << previousVersion << currentVersion; return false; } QFileSelector fileSelector; fileSelector.setExtraSelectors(QStringList() << QLocale::system().uiLanguages().constFirst().split('-').constFirst()); const QString path = fileSelector.select(":/changelogs/changelog.json"); QFile file(path); if (!file.open(QIODevice::ReadOnly)) { qCCritical(CHANGELOG_CATEGORY) << "Fail to open changelog file" << path << file.errorString(); return false; } QByteArray data = file.readAll(); QJsonParseError parseError; QJsonDocument document = QJsonDocument::fromJson(data, &parseError); if (parseError.error != QJsonParseError::NoError) { qCritical(CHANGELOG_CATEGORY) << "Fail to parse changelog data JSON:" << data << "error at offset" << parseError.offset << parseError.errorString() << parseError.error; return false; } QVariantList content = document.array().toVariantList(); while (!content.isEmpty()) { if (QVersionNumber::fromString(content.constFirst().toMap().value("version").toString()) > current) { content.takeFirst(); } else { break; } } QVariantList result; while (!content.isEmpty()) { if (QVersionNumber::fromString(content.constFirst().toMap().value("version").toString()) > previous) { result.append(content.takeFirst()); } else { break; } } if (result.isEmpty()) { qCWarning(CHANGELOG_CATEGORY) << "Empty changelog" << previousVersion << currentVersion; return false; } emit changesAvailable(result); return true; }
int RepDataModel::childCount(const QVariantList &indexPath) { #ifdef USE_FULL_FETCH return indexPath.isEmpty() ? vcardList_.size() : 0; #endif #ifdef USE_SPARSE_FETCH return indexPath.isEmpty() ? dataList_.size() : 0; #endif }
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()
void ItemScanner::fillCommonContainer(qlonglong imageid, ImageCommonContainer* const container) { QVariantList imagesFields; QVariantList imageInformationFields; { CoreDbAccess access; imagesFields = access.db()->getImagesFields(imageid, DatabaseFields::Name | DatabaseFields::Category | DatabaseFields::ModificationDate | DatabaseFields::FileSize); imageInformationFields = access.db()->getItemInformation(imageid, DatabaseFields::Rating | DatabaseFields::CreationDate | DatabaseFields::DigitizationDate | DatabaseFields::Orientation | DatabaseFields::Width | DatabaseFields::Height | DatabaseFields::Format | DatabaseFields::ColorDepth | DatabaseFields::ColorModel); } if (!imagesFields.isEmpty()) { container->fileName = imagesFields.at(0).toString(); container->fileModificationDate = imagesFields.at(2).toDateTime(); container->fileSize = imagesFields.at(3).toLongLong(); } if (!imageInformationFields.isEmpty()) { container->rating = imageInformationFields.at(0).toInt(); container->creationDate = imageInformationFields.at(1).toDateTime(); container->digitizationDate = imageInformationFields.at(2).toDateTime(); container->orientation = DMetadata::valueToString(imageInformationFields.at(3), MetadataInfo::Orientation); container->width = imageInformationFields.at(4).toInt(); container->height = imageInformationFields.at(5).toInt(); container->format = formatToString(imageInformationFields.at(6).toString()); container->colorDepth = imageInformationFields.at(7).toInt(); container->colorModel = (imagesFields.at(1).toInt() == DatabaseItem::Video) ? DMetadata::videoColorModelToString((DMetadata::VIDEOCOLORMODEL)imageInformationFields.at(8).toInt()) : DImg::colorModelToString((DImg::COLORMODEL)imageInformationFields.at(8).toInt()); } }
static void bindParameters(const QVariantList& bindValues, QSqlQuery *sqlQuery) { if (!bindValues.isEmpty()) { for (int i = bindValues.length() - 1; i >= 0; --i) { sqlQuery->bindValue(i, bindValues.at(i)); } } }
void WampRouterRegistration::handleRemote(qulonglong requestId, WampRouterSession* /*caller*/, QVariantList params) { QVariantList invArr{(int)WampMsgCode::INVOCATION, requestId, registrationId(), QVariantMap()}; if(!params.isEmpty()) invArr.append(QVariant(params)); //if(arr.count()>5) invArr.append(arr[5]); _session->sendWampMessage(invArr); }
//![11] void FtpDownloader::processItem(const QVariantList &indexPath) { if (!m_selectionPossible) return; m_currentIndexPath = indexPath; enableDownloadButton(); if (!indexPath.isEmpty()) { // If the user has selected an valid item in the directory listing ListView, check whether it's a directory const FtpItem item = m_model.data(indexPath).value<FtpItem>(); if (item.isDirectory) { // In this case clear the content of the model ... m_model.clear(); // ... assemble the path for the selected subdirectory ... m_currentPath += '/'; m_currentPath += item.fileName; // ... and trigger a listing for this subdirectory m_ftp->cd(item.fileName); m_ftp->list(); // Update the status property m_parentDirectoryAvailable = true; emit parentDirectoryAvailableChanged(); return; } } }
void RipperCC::parseRipperDb() { _timer->start(); QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); // Occurs error if(reply->error() != QNetworkReply::NoError) { qDebug() << "RippperCC Plugin:" << reply->errorString(); reply->close(); return; } // No errors QByteArray ba = reply->readAll(); QVariantMap ripperMap = QJsonWrapper::parseJson(ba).toMap(); if (!ripperMap.contains(QLatin1String("rippers"))) return; QVariantList ripperList = ripperMap.value(QLatin1String("rippers")).toList(); if (ripperList.isEmpty()) return; _rippers.clear(); foreach (const QVariant &item, ripperList) { Ripper ripper; ripper.jid = item.toMap().value(QLatin1String("jabber")).toString(); ripper.url = item.toMap().value(QLatin1String("link")).toString(); _rippers << ripper; }
//If the data store changes this method updates the SceneCover with the latest push message void CoverManager::pushListUpdated() { QSettings settings; QVariantList pushList = settings.value("pushList").toList(); if (!pushList.isEmpty()) { //Read in the last message from the list QVariant lastReceivedPushMessageVariant = pushList.last(); QString lastReceivedPushMessage; QStringList messageParts; lastReceivedPushMessage = lastReceivedPushMessageVariant.toString(); qDebug() << "Last push received: " << lastReceivedPushMessage; messageParts = lastReceivedPushMessage.split('|'); if (messageParts.size() != 5) { qDebug() << "Invalid list length. Expected 5, received: " << messageParts.size(); } else { m_pushMessageCover->setProperty("priority", messageParts[0].toInt()); m_pushMessageCover->setProperty("title", messageParts[1]); m_pushMessageCover->setProperty("body", messageParts[2]); setDescription(messageParts[4]); } return; } else { //If the list is empty let's display some data to let the user know m_pushMessageCover->setProperty("priority", 13013); m_pushMessageCover->setProperty("title", ""); m_pushMessageCover->setProperty("body", ""); setDescription("-"); } }
ListView *QuotesApp::setUpQuotesList() { ListView *listView = 0; // Load the quotes table from the database. QVariantList sqlData = mQuotesDbHelper->loadDataBase("quotes.db", "quotes"); if (!sqlData.isEmpty()) { // A GroupDataModel is used for creating a sorted list. mDataModel = new GroupDataModel(QStringList() << "lastname" << "firstname"); mDataModel->setParent(this); mDataModel->setGrouping(ItemGrouping::ByFirstChar); mDataModel->insert(sqlData); // The list view is set up in QML, here we retrieve it to connect it to // a data model. listView = mNav->findChild<ListView*>("quotesList"); listView->setDataModel(mDataModel); // By connecting to the selectionChanged signal we can find out when selection has // changed and update the content pane information based on the selected item. QObject::connect(listView, SIGNAL(selectionChanged(const QVariantList, bool)), this, SLOT(onListSelectionChanged(const QVariantList, bool))); // Connect to the models item added and updated signals, since we want to // select the item in the list if it has been manipulated. QObject::connect(mDataModel, SIGNAL(itemAdded(QVariantList)), this, SLOT(onModelUpdate(QVariantList))); QObject::connect(mDataModel, SIGNAL(itemUpdated(QVariantList)), this, SLOT(onModelUpdate(QVariantList))); }
/* ========================================================================== */ QVariant LispPlugin::read_from(QVariantList& tokenz) { if (tokenz.isEmpty()) throw runtime_error("unexpected EOF while reading"); QByteArray token = tokenz.takeFirst().toByteArray(); if (token == "(") { //auto L = QVariant(QVariant::List); QVariantList L; while (tokenz[0] != ")") L.append(read_from(tokenz)); tokenz.takeFirst(); // pop off ) return L; } else if (token == ")") { throw std::runtime_error("enexcepted )"); } else { bool successCast; auto i = token.toInt(&successCast); if (successCast) return i; auto d = token.toDouble(&successCast); if (successCast) return d; return QString(token); } }
bool App::deleteObject(const QString &customerID) { bool deleted = false; bool saved = false; if (!validateID(customerID)) return false; // Create a person object with the required id. // The name can be left out because find() will use the == operator // defined in the Person class. See Person.cpp Person *person = new Person(customerID, QString(), QString()); const QVariantList deleteIndexPath = m_dataModel->find(person); if (deleteIndexPath.isEmpty()) { alert(tr("Object ID not found.")); } else { deleted = m_dataModel->removeAt(deleteIndexPath); } if (deleted) { saved = m_storage->save(m_lastCustomerID, m_dataModel); } return (deleted && saved); }
void QmlProfilerEventsModelProxy::notesChanged(int typeIndex) { const QmlProfilerNotesModel *notesModel = d->modelManager->notesModel(); if (typeIndex == -1) { d->notes.clear(); for (int noteId = 0; noteId < notesModel->count(); ++noteId) { int noteType = notesModel->typeId(noteId); if (noteType != -1) { QString ¬e = d->notes[noteType]; if (note.isEmpty()) { note = notesModel->text(noteId); } else { note.append(QStringLiteral("\n")).append(notesModel->text(noteId)); } } } } else { d->notes.remove(typeIndex); QVariantList changedNotes = notesModel->byTypeId(typeIndex); if (!changedNotes.isEmpty()) { QStringList newNotes; for (QVariantList::ConstIterator it = changedNotes.begin(); it != changedNotes.end(); ++it) { newNotes << notesModel->text(it->toInt()); } d->notes[typeIndex] = newNotes.join(QStringLiteral("\n")); } } emit notesAvailable(typeIndex); }
//! [4] // Change the first and last name of the person with the given id. bool App::updateObject(const QString &id, const QString &firstName, const QString &lastName) { bool updated = false; bool saved = false; if (!validateID(id)) return false; Person *person = new Person(id, firstName, lastName); // Find person in the datamodel. // Only the id is used by find(). This is because Person // defines equality (==) as having the same id. (See the definition of "==" // in the person class.) const QVariantList updateIndexPath = m_dataModel->find(person); // update the item if found if (updateIndexPath.isEmpty()) { alert(tr("Object ID not found.")); updated = false; } else { updated = m_dataModel->updateItem(updateIndexPath, person); } // Save the datamodel if we updated something. if (updated) { saved = m_storage->save(m_lastCustomerID, m_dataModel); } return (updated && saved); }
void QgsFilterAlgorithmConfigurationWidget::setConfiguration( const QVariantMap &configuration ) { mOutputExpressionWidget->setRowCount( 0 ); int currentRow = 0; const QVariantList outputs = configuration.value( "outputs" ).toList(); for ( const QVariant &outputvar : outputs ) { const QVariantMap output = outputvar.toMap(); mOutputExpressionWidget->insertRow( currentRow ); mOutputExpressionWidget->setItem( currentRow, 0, new QTableWidgetItem( output.value( "name" ).toString() ) ); QgsExpressionLineEdit *expressionBuilder = new QgsExpressionLineEdit(); expressionBuilder->registerExpressionContextGenerator( this ); expressionBuilder->setExpression( output.value( "expression" ).toString() ); mOutputExpressionWidget->setCellWidget( currentRow, 1, expressionBuilder ); QCheckBox *isModelOutput = new QCheckBox(); isModelOutput->setChecked( output.value( "isModelOutput" ).toBool() ); mOutputExpressionWidget->setCellWidget( currentRow, 2, isModelOutput ); currentRow++; } if ( outputs.isEmpty() ) addOutput(); }
void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signalIndex, const QVariantList &arguments) { if (!webChannel || webChannel->d_func()->transports.isEmpty()) { if (signalIndex == s_destroyedSignalIndex) objectDestroyed(object); return; } if (!signalToPropertyMap.value(object).contains(signalIndex)) { QJsonObject message; const QString &objectName = registeredObjectIds.value(object); Q_ASSERT(!objectName.isEmpty()); message[KEY_OBJECT] = objectName; message[KEY_SIGNAL] = signalIndex; if (!arguments.isEmpty()) { message[KEY_ARGS] = wrapList(arguments); } message[KEY_TYPE] = TypeSignal; broadcastMessage(message); if (signalIndex == s_destroyedSignalIndex) { objectDestroyed(object); } } else { pendingPropertyUpdates[object][signalIndex] = arguments; if (clientIsIdle && !blockUpdates && !timer.isActive()) { timer.start(PROPERTY_UPDATE_INTERVAL, this); } } }
/* 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; }
void populateRows(int start, int end) { if(start > ROWS_TO_REFRESH) return; if(!prepare()) return; if (end > ROWS_TO_REFRESH) end = ROWS_TO_REFRESH; QVariantList transactions; while(start <= end) { if(visibleTransactions.first() == "*"||visibleTransactions.contains(ttm->index(start, TransactionTableModel::Type).data().toString())) transactions.append(addTransaction(start)); start++; } if(!transactions.isEmpty()) emitTransactions(transactions); running = false; }
void MainScreen::sendMessage(Peer* peer, const QString& message) { QByteArray bytes = message.toUtf8(); if (peer->type() == TGL_BROADCAST_CHAT) { BroadcastChat* chat = (BroadcastChat*)peer; GroupDataModel* members = (GroupDataModel*)chat->members(); tgl_peer_id_t* peers = new tgl_peer_id_t[members->size()]; int idx = 0; for (QVariantList indexPath = members->first(); !indexPath.isEmpty(); indexPath = members->after(indexPath)) { User* user = (User*)members->data(indexPath).value<QObject*>(); peers[idx].type = user->type(); peers[idx].id = user->id(); idx++; } tgl_do_send_broadcast(gTLS, members->size(), peers, bytes.data(), bytes.length(), Storage::_broadcastSended, chat); delete[] peers; } else tgl_do_send_message(gTLS, {peer->type(), peer->id()}, (const char*)bytes.data(), bytes.length(), 0, 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()); } } }
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; }
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; }
void XmlPListSerializer::RenderList(const QString &sName, const QVariantList &list) { bool array = true; if (!list.isEmpty()) { QVariant::Type t = list[0].type(); QListIterator<QVariant> it(list); while (it.hasNext()) { if (it.next().type() != t) { array = false; break; } } } QString sItemName = GetItemName(sName); m_pXmlWriter->writeTextElement("key", sName); m_pXmlWriter->writeStartElement(array ? "array" : "dict"); QListIterator<QVariant> it(list); while (it.hasNext()) RenderValue(sItemName, it.next(), !array); m_pXmlWriter->writeEndElement(); }
int Twitter::childCount(const QVariantList& indexPath) { //we're working with the first item. if (indexPath.isEmpty()) { return _tweetList.size(); } return 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 ); }
QVariant CTransaction::toJsonVariant(QVariantList data) { if(data.isEmpty()) return ""; QJsonDocument jsonDocument = QJsonDocument::fromVariant(data); QByteArray byte_array = jsonDocument.toJson(QJsonDocument::Compact); QVariant json_var(byte_array); return json_var; }
/** * Replace named placeholder query with positional placeholder query to get rid of problems with QT code. * This fixes: * 1. When a query has no parameters but bindValues *is* supplied. * 2. When a query uses the same named parameter more than once in query string. * * Fix should be applied in QT code in QSqlRecordPrivate. */ void SqlQueryUtils::prepareQuery(const QString &query, const QVariantMap &bindValues, QSqlQuery *sqlQuery) { QString positionalQuery(query); QVariantList positionalBindValues = createPositionalQueryAndList(positionalQuery, bindValues); if (sqlQuery->prepare(positionalQuery)) { if (!positionalBindValues.isEmpty()) { bindParameters(positionalBindValues, sqlQuery); } } }
QVariantList AppEntry::actions() const { QVariantList actionList; actionList << Kicker::jumpListActions(m_service); if (!actionList.isEmpty()) { actionList << Kicker::createSeparatorActionItem(); } QObject *appletInterface = m_owner->rootModel()->property("appletInterface").value<QObject *>(); const bool systemImmutable = appletInterface->property("immutability").toInt() == Plasma::Types::SystemImmutable; const QVariantList &addLauncherActions = Kicker::createAddLauncherActionList(appletInterface, m_service); if (!systemImmutable && !addLauncherActions.isEmpty()) { actionList << addLauncherActions << Kicker::createSeparatorActionItem(); } const QVariantList &recentDocuments = Kicker::recentDocumentActions(m_service); if (!recentDocuments.isEmpty()) { actionList << recentDocuments << Kicker::createSeparatorActionItem(); } // Don't allow adding launchers, editing, hiding, or uninstalling applications // when system is immutable. if (systemImmutable) { return actionList; } if (m_menuEntryEditor->canEdit(m_service->entryPath())) { actionList << Kicker::createSeparatorActionItem(); QVariantMap editAction = Kicker::createActionItem(i18n("Edit Application..."), "editApplication"); editAction["icon"] = "kmenuedit"; // TODO: Using the KMenuEdit icon might be misleading. actionList << editAction; } #ifdef HAVE_APPSTREAMQT if (m_service->isApplication()) { actionList << appstreamActions(m_service); } #endif QQmlPropertyMap *appletConfig = qobject_cast<QQmlPropertyMap *>(appletInterface->property("configuration").value<QObject *>()); if (appletConfig && appletConfig->contains("hiddenApplications") && qobject_cast<AppsModel *>(m_owner)) { const QStringList &hiddenApps = appletConfig->value("hiddenApplications").toStringList(); if (!hiddenApps.contains(m_service->menuId())) { actionList << Kicker::createActionItem(i18n("Hide Application"), "hideApplication"); } } return actionList; }
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; }