void JsUtil::toString(QVariant object,QString &output) { if (object.type() == QVariant::Map) { QMapIterator<QString,QVariant> iter(object.value<QVariantMap>()); QString sep = ""; if (iter.hasNext()) { output += "{"; do { iter.next(); output += sep; output += iter.key(); output += ":"; toString(iter.value(),output); sep = ","; } while (iter.hasNext()); output += "}"; } } else if (object.type() == QVariant::List) { QListIterator<QVariant> iter (object.value<QVariantList>()); QString sep = ""; if (iter.hasNext()) { output += "["; do { output += sep; toString(iter.next(),output); sep = ","; } while (iter.hasNext()); output += "]"; } } else if (object.type() == QVariant::String) { output += "\"" + object.toString() + "\""; } else if (object.type() == QVariant::Bool || object.type() == QVariant::Int || object.type() == QVariant::Double || object.type() == QVariant::LongLong) { output += object.toString(); } }
void SubassemblyView::updateConstraintName ( const QString& /*name*/ ) { // The budget approach is just to recompute all of the list view strings. // Not sure what being more selective would avail us. //ListViewItem* list_item = list_view_item_->firstChild(); //TODO ListViewItem* list_item = static_cast<ListViewItem*>(list_view_item_->child(0)); QListIterator< std::shared_ptr<AssemblyConstraint>> constraint = subassembly_->constraints(). constraints(); while ( constraint.hasNext() ) { QString text; if ( constraint.peekNext()->type() == lC::STR::MATE_OFFSET || constraint.peekNext()->type() == lC::STR::ALIGN_OFFSET ) text = tr( "Offset %1: " ). arg( UnitsBasis::instance()->format( constraint.peekNext()->offset(),false)); if ( constraint.peekNext()->reference1().empty() ) { text += lC::formatName( model()->idPath( constraint.peekNext()->reference0())); } else { text += tr( "%1 to %2" ). arg( lC::formatName( model()->idPath( constraint.peekNext()->reference0()))). arg( lC::formatName( model()->idPath( constraint.peekNext()->reference1()))); } list_item->setData( text, lC::DETAIL ); //TODO //list_item = list_item->nextSibling(); } }
void UpdatingModel::setUrl(const QUrl& _url) { qDebug() << "model set_url " << "old " << url << "new " << _url; if (_url != url) { url = _url; qDebug() << "cleared model"; clear(); if (settings->contains(url.toString())) lastModified = settings->value(url.toString()).toDateTime(); // attempt to fill from cache if (url2listCache->contains(url)) { qDebug() << "pulling from cache " << url; QList<QString> *itemList = url2listCache->value(url); QListIterator<QString> i (*itemList); while (i.hasNext()) { appendRow(new QStandardItem(i.next())); } sort(0); } else { // fire the timer now timer->start(50); } } }
bool Dispatcher::play(QStringList::Iterator it) { if (it == m_history.end()) { return false; } bool playing = false; QUrl url(*it); QListIterator<MediaHandler*> mhit = m_loader->mediaHandlersIterator(); while (mhit.hasNext()) { MediaHandler* handler = mhit.next(); if (handler->handles(url)) { stop(); connect(handler, SIGNAL(playbackFinished()), m_timer, SLOT(stop())); connect(handler, SIGNAL(playbackFinished()), this, SLOT(next())); m_currentHandler = handler; m_currentHandler->setMedia(url); togglePlayback(); playing = true; break; } } if (playing) { m_currentHistoryPosition = it; } else { m_history.erase(it); m_currentHistoryPosition = m_history.begin(); } return playing; }
void SubassemblyView::addDependency ( const QVector<uint>& surface_id ) { // Basically, the idea here is to connect to each component of the // references path whose name change could affect the display. So, // exhustively examine each element of the path and see what it // means to us. Note, since part faces are not real ModelItems, we // skip the last element of the id_path. QVector<uint> id_path; id_path.reserve( surface_id.size()-1 ); for ( int i = 0; i < surface_id.size()-1; ++i ) { id_path.push_back( surface_id[i] ); ModelItem* item = model()->lookup( id_path ); // The first order check is that we don't already depend on this item. bool found = false; QListIterator<std::shared_ptr<ModelItem>> it (dependencies_); while(it.hasNext()) { if(it.next().get() == item) { found = true; break; } } if ( found ) { continue; } // If it's a model, part or assembly, then it can be renamed by the user. else if ( dynamic_cast<Model*>( item ) != 0 || dynamic_cast<Assembly*>( item ) != 0 || dynamic_cast<Part*>( item ) != 0 ) { dependencies_.append( std::shared_ptr<ModelItem>(item) ); connect( item, SIGNAL( nameChanged(const QString&) ), SLOT( updateConstraintName( const QString&) ) ); } } }
//--------------------------------------------------------------------------- // getWordItems // //! Construct a list of word items to be inserted into a word list, based on //! the results of a list of searches. // //! @param searchSpecs the list of search specifications //! @return a list of word items //--------------------------------------------------------------------------- QList<WordTableModel::WordItem> WordVariationDialog::getWordItems(const QList<SearchSpec>& searchSpecs) const { QList<WordTableModel::WordItem> wordItems; QMap<QString, QString> wordMap; QListIterator<SearchSpec> lit (searchSpecs); while (lit.hasNext()) { QStringList wordList = wordEngine->search(lexicon, lit.next(), false); QStringListIterator wit (wordList); while (wit.hasNext()) { QString str = wit.next(); wordMap.insert(str.toUpper(), str); } } QMapIterator<QString, QString> mit (wordMap); while (mit.hasNext()) { mit.next(); QString value = mit.value(); QList<QChar> wildcardChars; for (int i = 0; i < value.length(); ++i) { QChar c = value[i]; if (c.isLower()) wildcardChars.append(c); } QString wildcard; if (!wildcardChars.isEmpty()) { qSort(wildcardChars.begin(), wildcardChars.end(), Auxil::localeAwareLessThanQChar); foreach (const QChar& c, wildcardChars) wildcard.append(c.toUpper()); } wordItems.append(WordTableModel::WordItem( mit.key(), WordTableModel::WordNormal, wildcard)); }
void ExportGesamt::reload() { QListIterator<AActivity*> iter = manager->getActivities(); int i = 0; while(iter.hasNext()) { AActivity *a = iter.next(); if (actToList.contains(a)) { QString farbe = MainWindow::getFarbe(a); actToList.value(a)->setBackgroundColor(QColor(farbe)); actToList.value(a)->setToolTip(a->getAnlass()); i++; continue; } QString farbe = MainWindow::getFarbe(a); QListWidgetItem *item = new QListWidgetItem(a->getListString()); item->setBackgroundColor(QColor(farbe)); item->setToolTip(a->getAnlass()); ui->listAnzeige->insertItem(i, item); liste.insert(i, a); actToList.insert(a, item); listToAct.insert(item, a); i++; } show(); }
void outputStringList(QIODevice& output, const QStringList& sl){ QListIterator<QString> itr (sl); while (itr.hasNext()) { output.write(QString(itr.next()).toUtf8()); } }
void FavouriteManagerPrivate::save() { QDomDocument document; QDomElement rootElement = document.createElement("favourites"); QListIterator<QPair<QString, Station> > iterator = QListIterator<QPair<QString, Station> >(data); while (iterator.hasNext()) { QPair<QString, Station> entry = iterator.next(); QDomElement element = XmlConversionHelper::toXml(entry.second, &document); element.setAttribute(BACKEND_ATTRIBUTE, entry.first); rootElement.appendChild(element); } document.appendChild(rootElement); QDir favouriteDir = QDir(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); if (!favouriteDir.exists()) { QDir::root().mkpath(favouriteDir.absolutePath()); } QFile file (favouriteDir.absoluteFilePath(fileName)); if (!file.open(QIODevice::WriteOnly)) { return; } QTextStream stream(&file); document.save(stream, 2); file.close(); }
MyFileSystemNodeItem::MyFileSystemNodeItem (const QFileInfo & info, QObject * parent) : QObject (parent) , m_size (info.size ()) , m_info (info) { MyFileSystemNodeItem::s_instances.insert (m_info.filePath (), this); if (m_info.isDir ()) { const QFileInfoList list (QDir (m_info.filePath ()).entryInfoList (filter, sort)); #ifdef USE_ITERATOR QListIterator<QFileInfo> it (list); while (it.hasNext ()) { m_size += (new MyFileSystemNodeItem (it.next (), this))->getSize (); } #else # ifdef USE_FOREACH foreach (QFileInfo entry, list) { m_size += (new MyFileSystemNodeItem (entry, this))->getSize (); } # else const int nb = list.count (); for (int idx = 0; idx < nb; idx++) { m_size += (new MyFileSystemNodeItem (list.at (idx), this))->getSize (); } # endif #endif } }
void KdeObservatory::updateViews() { m_viewTransitionTimer->stop(); foreach(QGraphicsWidget *widget, m_views) widget->hide(); m_views.clear(); QListIterator< QPair<QString, bool> > i (m_activeViews); while (i.hasNext()) { const QPair<QString, bool> &pair = i.next(); const QString &view = pair.first; if (pair.second && m_viewProviders.value(view)) m_views.append(m_viewProviders[view]->views()); } if (m_views.count() > 0) { if (m_views.count() != m_lastViewCount) m_currentView = m_views.count()-1; moveViewRight(); if (m_enableAutoViewChange && m_views.count() > 1) m_viewTransitionTimer->start(); } }
void MainWindow::joystickTrayShow() { QMenu *tempmenu = (QMenu*) sender(); QList<QAction*> menuactions = tempmenu->actions(); QListIterator<QAction*> listiter (menuactions); while (listiter.hasNext()) { QAction *action = listiter.next(); action->setChecked(false); QHash<QString, QVariant> tempmap = action->data().toHash(); QHashIterator<QString, QVariant> iter(tempmap); while (iter.hasNext()) { iter.next(); int joyindex = iter.key().toInt(); int configindex = iter.value().toInt(); JoyTabWidget *widget = (JoyTabWidget*)ui->tabWidget->widget(joyindex); if (configindex == widget->getCurrentConfigIndex()) { action->setChecked(true); } } } }
void DialogTwaLine::setStart(QPointF start) { this->start=start; if(line!=NULL) { delete line; line=NULL; } QListIterator<POI*> i (list); while(i.hasNext()) { POI * poi=i.next(); list.removeOne(poi); if(poi->isPartOfTwa()) { parent->slot_delPOI_list(poi); delete poi; } } this->line=new vlmLine(parent->getProj(),parent->getScene(),Z_VALUE_ROUTE); line->setLinePen(pen); this->tabWidget->setCurrentIndex(0); this->doubleSpinBox->setFocus(); this->doubleSpinBox->selectAll(); this->move(position); traceIt(); }
void processFilters(QImage *& image, QListIterator<Filter *> i) { while (i.hasNext()) { Filter * f = i.next(); uint w = image->width(); uint h = image->height(); if (f->getArea().isNull()) { f->setArea(QRect(QPoint(0, 0), QSize(w, h))); } if (! f->isApplicable(w, h)) { QRect area = f->getArea(); fatal(QObject::tr("Too small image (%1x%2), pointed filter" " with pointed area (%3x%4+%5+%6) not applicable") .arg(w).arg(h).arg(area.x()).arg(area.y()) .arg(area.width()).arg(area.height())); } QImage * newImage = f->filter(*image); delete image; image = newImage; } }
//========================================= // clientInit //----------------------------------------- void ServerHandler::clientInit (void) { QListIterator<ServerFolder*> it (mFolderList); while (it.hasNext()) { ServerFolder* thisFolder = it.next(); thisFolder -> updateFolder(); } mServer -> writeClient ("INIT_DONE"); }
/*public*/ SignalMast* SmlBeanTableDataModel::getDestMastFromRow(int row) const{ // if object has been deleted, it's not here; ignore it QHash<SignalMastLogic*, SignalMast*>* b = act->signalMastLogicList->at(row); QListIterator<SignalMastLogic*> en = b->keys(); while (en.hasNext()) { return b->value(en.next()); } return NULL; }
void ItemContainerPrivate::cleanList (QStringList & list, QList<QSharedPointer<Item> > & find) { QListIterator <QSharedPointer<Item> > iter (find); while (iter.hasNext()) { list.removeAll (iter.next()->constructInfo()); } }
/*public*/ SignalMastLogic* SmlBeanTableDataModel::getLogicFromRow(int row) const { QHash<SignalMastLogic*, SignalMast*>* b = act->signalMastLogicList->at(row); QListIterator<SignalMastLogic*> en = b->keys(); while (en.hasNext()) { return en.next(); } return NULL; }
//Will need to redo this so that we work out the row number from looking in the signalmastlogiclist. //@Override /*public*/ void SmlBeanTableDataModel::propertyChange(PropertyChangeEvent* e) { if (act->suppressUpdate) { return; } // updateNameList(); if ( e->getPropertyName() == ("length") || e->getPropertyName() == ("updatedDestination") || e->getPropertyName() == ("updatedSource")) { updateNameList(); //log.debug("Table changed length to "+signalMastLogicList.size()); fireTableDataChanged(); } //else if (e.getSource() instanceof SignalMastLogic) { else if(qobject_cast<SignalMastLogic*>( e->getSource())!= NULL) { SignalMastLogic* logic = (SignalMastLogic*) e->getSource(); if (matchPropertyName(e)) { for (int i = 0; i < act->signalMastLogicList->size(); i++) { QHash<SignalMastLogic*, SignalMast*>* b = act->signalMastLogicList->at(i); QListIterator<SignalMastLogic*> en = b->keys(); while (en.hasNext()) { SignalMastLogic* sm = en.next(); if (sm == logic) { fireTableRowsUpdated(i, i); } } } } } //else if (e.getSource() instanceof jmri.SignalMast) { else if(qobject_cast<SignalMast*>(e->getSource())!= NULL) { SignalMast* sigMast = (SignalMast*) e->getSource(); for (int i = 0; i < act->signalMastLogicList->size(); i++) { QHash<SignalMastLogic*, SignalMast*>* b = act->signalMastLogicList->at(i); QListIterator<SignalMastLogic*> en = b->keys(); while (en.hasNext()) { SignalMastLogic* sm = en.next(); //SignalMast dest = b.get(sm); if (sm->getSourceMast() == sigMast) { fireTableRowsUpdated(i, i); } } } } }
ThreadListModel::ThreadListModel (const QList<Message *> &data, QObject * parent) : QAbstractListModel (parent), m_data (data) { QListIterator<Message *> it (m_data); while (it.hasNext ()) { rowAdded (it.next ()); } }
//========================================= // slotNotify //----------------------------------------- void ServerHandler::slotNotify (QString* mailbox,QPoint* count) { QListIterator<ServerFolder*> it (mFolderList); while (it.hasNext()) { ServerFolder* thisFolder = it.next(); if (thisFolder->getFolder() == *mailbox) { thisFolder->setStatus (count); thisFolder->updateFolder(); break; } } }
KbAnim::KbAnim(QObject *parent, const KeyMap& map, const QUuid id, CkbSettings& settings) : QObject(parent), _script(0), _map(map), repeatTime(0), kpRepeatTime(0), stopTime(0), kpStopTime(0), repeatMsec(0), kpRepeatMsec(0), _guid(id), _needsSave(false) { SGroup group(settings, _guid.toString().toUpper()); _keys = settings.value("Keys").toStringList(); // Convert key list from storage names if needed if(!settings.value("UseRealNames").toBool()){ QMutableListIterator<QString> i(_keys); while(i.hasNext()){ i.next(); QString& key = i.value(); key = _map.fromStorage(key); } } _name = settings.value("Name").toString().trimmed(); _opacity = settings.value("Opacity").toString().toDouble(); if(_opacity < 0.) _opacity = 0.; else if(_opacity > 1.) _opacity = 1.; bool modeOk = false; _mode = (Mode)metaObject()->enumerator(metaObject()->indexOfEnumerator("Mode")).keysToValue(settings.value("BlendMode").toString().toLatin1(), &modeOk); if(!modeOk) _mode = Normal; _scriptName = settings.value("ScriptName").toString().trimmed(); _scriptGuid = settings.value("ScriptGuid").toString(); { SGroup group(settings, "Parameters"); foreach(const QString& param, settings.childKeys()) _parameters[param.toLower()] = settings.value(param); } if(!_scriptGuid.isNull()){ _script = AnimScript::copy(this, _scriptGuid); if(_script){ // Remove nonexistant parameters foreach(const QString& name, _parameters.keys()){ AnimScript::Param param = _script->param(name); if(param.type == AnimScript::Param::INVALID || param.type == AnimScript::Param::LABEL) _parameters.remove(name); } // Add defaults for unset parameters QListIterator<AnimScript::Param> i = _script->paramIterator(); while(i.hasNext()){ AnimScript::Param param = i.next(); if(!_parameters.contains(param.name) && param.type != AnimScript::Param::LABEL) _parameters[param.name] = param.defaultValue; } _scriptName = _script->name(); reInit(); } }
bool createConnection(QSqlDatabase &db) { QString s = QDesktopServices::storageLocation(QDesktopServices::DataLocation); QDir d(s); d.mkpath(s); db.setDatabaseName(s + QDir::separator() + "qrdc.db"); if (!db.open()) { QMessageBox::critical(0, QObject::tr("Opening database error"), QObject::tr("Unable to establish a database connection.")); return false; } else { if (db.tables().isEmpty()) { bool ok = false; QStringList list; QFile file(":sql/sql/data.sql"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::critical(0, QObject::tr("Error"), QObject::tr("fail to open data.sql to read")); return false; } else { list = QString(file.readAll()).split("\n"); file.close(); } if (!list.isEmpty()) { QSqlQuery q; QListIterator<QString> itr (list); while (itr.hasNext()) { QString s = itr.next(); if (!s.isEmpty()) { if (!q.exec(s)) { QMessageBox::critical(0, QObject::tr("Creating database error"), QObject::tr("Unable to execute query: %1").arg(s)); return false; } else ok = true; } } if (ok) QMessageBox::information(0, QObject::tr("Creating database"), QObject::tr("Database created OK")); } else { QMessageBox::critical(0, QObject::tr("Creating database error"), QObject::tr("Unable to read sql.")); return false; } } } return true; }
void polarList::stats(void) { qWarning() << "Nb polar: " << polars.count(); QListIterator<Polar*> i (polars); int k=0; while(i.hasNext()) { Polar * item = i.next(); qWarning() << k << ": " << item->getName() << "(nb used=" << item->nbUsed << ")"; k++; } }
//--------------------------------------------------------------------------- // asString // //! Return a string representing the search spec. // //! @return the string representation //--------------------------------------------------------------------------- QString SearchSpec::asString() const { QString str; QListIterator<SearchCondition> it (conditions); while (it.hasNext()) { if (!str.isEmpty()) str += (conjunction ? QString(" AND ") : QString(" OR ")); str += it.next().asString(); } return str; }
CDspLockedPointer<CDispUser> CDspDispConfigGuard::getDispUserByName( const QString& userName ) { CDspLockedPointer<CDispUsersPreferences> pUsersPrefs = getDispUserPreferences(); QListIterator< CDispUser* > it ( pUsersPrefs->m_lstDispUsers ); while( it.hasNext() ) { CDispUser* pUser = it.next(); if( pUser->getUserName() == userName ) return CDspLockedPointer<CDispUser>( &m_dispMutex, pUser ); } return CDspLockedPointer<CDispUser>( &m_dispMutex, 0 ); }
ServiceOption * AddValueSettings::serviceOption (const QString & id) const { ServiceOption * ret = 0; QListIterator<ServiceOption *> iter (d_ptr->m_serviceOptions); while (iter.hasNext() == true) { ServiceOption * option = iter.next (); if (option->id() == id) { ret = option; break; } } return ret; }
void Dispatcher::reinitDisplay(const QString& label) { QItemSelectionModel* oldSelectionModel = m_selectionModel; m_selectionModel = new QItemSelectionModel(m_currentModel); m_selectionModel->setCurrentIndex(m_currentModel->index(0, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current); QListIterator<Display*> it = m_loader->displaysIterator(); while (it.hasNext()) { Display* display = it.next(); display->setModel(m_currentModel, label); display->setSelectionModel(m_selectionModel); } delete oldSelectionModel; }
void MenuManager::dumpMenuStrings() { QMapIterator<QString, QList<QString> > i(menuStrings); while (i.hasNext()) { i.next(); qDebug() << "Menu name:"<<i.key();// << ": " << i.value() << endl; QListIterator<QString> li (i.value()); while (li.hasNext()) { qDebug() << "Menu entry:"<<li.next(); } } }
//==================================== // init //------------------------------------ void Notify::init ( bool clean ) { sigprocmask(SIG_BLOCK, &block_set,0); QList<char*> mFolderNames = mParse -> folderList(); if (clean) { printf ("________cleaning: pollable event occured\n"); cleanActiveFolderNotification(); } QList<char*> subdir; subdir.append ((char*)"/new"); subdir.append ((char*)"/cur"); QListIterator<char*> it ( mFolderNames ); int FDcount = 0; while (it.hasNext()) { QPoint* dirCount = 0; char* value = it.next(); for (int i=0;i<subdir.count();i++) { if (i == 0) { dirCount = new QPoint; } int count = getFiles ( myFolder + QString(value+QString(subdir.at(i))+"/*") ); if (i == 0) { dirCount->setX (count); } if (i == 1) { dirCount->setY (count); } activateFolderNotification ( value,subdir.at(i) ); if (i == 1) { int start = FDcount; int ended = FDcount + 4; for (int n=start;n<ended;n++) { mNotifyCount.insert ( mFDs[n], dirCount ); } FDcount = ended; NotifyCount* initial = new NotifyCount ( value,*dirCount ); mInitialFolderList.append (initial); } } } sigprocmask(SIG_UNBLOCK, &block_set,0); }