QString mapiTagString( int key ) { if ( MAPI_TagMap.count() == 0 ) { for ( int i=0; MAPI_TagStrings[ i ].str; i++ ) { MAPI_TagMap[ MAPI_TagStrings[ i ].tag ] = i18n( MAPI_TagStrings[ i ].str ); } } QMap<int,QString>::ConstIterator it = MAPI_TagMap.constFind( key ); if ( it == MAPI_TagMap.constEnd() ) { return QString().sprintf( "0x%04X", key ); } else { return QString().sprintf( "0x%04X ________: ", key ) + *it; } }
void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) { QHelpIndexModel *model = qobject_cast<QHelpIndexModel*>(indexWidget->model()); if (model) { QString keyword = model->data(index, Qt::DisplayRole).toString(); QMap<QString, QUrl> links = model->linksForKeyword(keyword); QUrl url; if (links.count() > 1) { TopicChooser tc(this, keyword, links); if (tc.exec() == QDialog::Accepted) url = tc.link(); } else if (links.count() == 1) { url = links.constBegin().value(); } else { return; } if (!HelpViewer::canOpenPage(url.path())) CentralWidget::instance()->setSource(url); else OpenPagesManager::instance().createPage(url); } }
void GroupchatTopicDlg::populateCountryAndScript() { QLocale::Language lang = static_cast<QLocale::Language>(m_addLangUi->cmbLang->currentData().toInt()); QMap<QString,QLocale::Script> scripts; QMap<QString,QLocale::Country> countries; m_addLangUi->cmbCountry->clear(); m_addLangUi->cmbScript->clear(); m_addLangUi->cmbCountry->addItem(tr("Any Country"), 0); m_addLangUi->cmbScript->addItem(tr("Any Script"), 0); if (lang) { for (auto const &loc : QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyCountry)) { if (loc != QLocale::c()) { scripts.insert(QLocale::scriptToString(loc.script()), loc.script()); countries.insert(QLocale::countryToString(loc.country()), loc.country()); } } m_addLangUi->cmbScript->setVisible(scripts.count() > 1); m_addLangUi->lblScript->setVisible(scripts.count() > 1); if (scripts.count() > 1) { for (auto it = scripts.constBegin(); it != scripts.constEnd(); ++it) { m_addLangUi->cmbScript->addItem(it.key(), it.value()); } } m_addLangUi->cmbCountry->setVisible(countries.count() > 1); m_addLangUi->lblCountry->setVisible(countries.count() > 1); if (countries.count() > 1) { for (auto it = countries.constBegin(); it != countries.constEnd(); ++it) { LanguageManager::LangId id; id.language = lang; id.country = it.value(); QString country = LanguageManager::countryName(id); m_addLangUi->cmbCountry->addItem(country, it.value()); } } } }
void FlyLinks::AssembleTreeWidget( const QMap<QString,QString>& objDataMap) { m_pObjPopup->setWindowFlags(Qt::Popup); m_pObjPopup->setFocusPolicy(Qt::NoFocus); m_pObjPopup->setMouseTracking(true); m_pObjPopup->viewport()->setMouseTracking(true); m_pObjPopup->viewport()->installEventFilter(this); m_pObjPopup->setColumnCount(1); m_pObjPopup->setUniformRowHeights(true); m_pObjPopup->setRootIsDecorated(false); m_pObjPopup->setEditTriggers(QTreeWidget::NoEditTriggers); m_pObjPopup->setSelectionBehavior(QTreeWidget::SelectRows); m_pObjPopup->setFrameStyle(QFrame::Box | QFrame::Plain); m_pObjPopup->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_pObjPopup->header()->hide(); m_pObjPopup->viewport()-> setProperty("cursor", QVariant(QCursor(Qt::PointingHandCursor))); m_pObjPopup->installEventFilter(this); PopulateTreeWidgetItems(objDataMap); //popup->setCurrentItem(popup->topLevelItem(0)); m_pObjPopup->resizeColumnToContents(0); m_pObjPopup->adjustSize(); m_pObjPopup->setUpdatesEnabled(true); int h = m_pObjPopup->sizeHintForRow(0) * (objDataMap.count()+1); //popup->resize(popup->width(), h); //popup->setMinimumHeight(h); m_pObjPopup->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_pObjPopup->setMaximumHeight(h); QList<QString> objKeyList = objDataMap.keys(); QListIterator<QString> objKeyIter(objKeyList); int iLenMax = 0,iLenCurrent = 0; while(objKeyIter.hasNext()) { iLenCurrent = objKeyIter.next().length(); if(iLenCurrent > iLenMax) { iLenMax = iLenCurrent; } } QFontMetrics objMetrics(m_pObjPopup->font()); m_pObjPopup->setMaximumWidth(objMetrics.maxWidth() * iLenMax); //adjust if necessary m_pObjPopup->resizeColumnToContents(0); m_pObjPopup->adjustSize(); m_pObjPopup->setUpdatesEnabled(true); }
void TransferFunctionEditor::mousePressEvent(QMouseEvent* e) { bool handled = false; lastMouseClick = e->pos(); if ((e->button() == Qt::LeftButton) && (e->modifiers() == Qt::NoButton)) { // Create context menu QMenu contextMenu(this); contextMenu.addAction(addPointAct); contextMenu.addSeparator(); QMap<QAction*, int> pointMap; for (int i = 0; i < controlPoints.size(); ++i) { Vector3 vec = controlPoints[i].point; QString text("Point: "); text += QString::number(vec.x); text += " "; text += QString::number(vec.y); QAction* action = contextMenu.addAction(text); action->setCheckable(true); if (i == selectedPoint) { action->setChecked(true); } pointMap[action] = i; } QAction* action = contextMenu.exec(e->globalPos()); if (pointMap.count(action) != 0) { selectedPoint = pointMap[action]; } handled = true; } else if (e->button() == Qt::RightButton) { actionsMenu->exec(e->globalPos()); handled = true; } if (!handled) { QGLViewer::mousePressEvent(e); } }
void QMakeSourceFileInfo::saveCache(const QString &cf) { #ifdef QMAKE_USE_CACHE if(cf.isEmpty()) return; QFile file(QMakeLocalFileName(cf).local()); if(file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); stream << qmake_version() << endl << endl; //version { //cache verification QMap<QString, QStringList> verify = getCacheVerification(); stream << verify.count() << endl; for(QMap<QString, QStringList>::iterator it = verify.begin(); it != verify.end(); ++it) { stream << it.key() << endl << it.value().join(";") << endl; } stream << endl; } if(files->nodes) { for(int file = 0; file < files->num_nodes; ++file) { for(SourceFiles::SourceFileNode *node = files->nodes[file]; node; node = node->next) { stream << node->file->file.local() << endl; //source stream << node->file->type << endl; //type //depends stream << ";"; if(node->file->deps) { for(int depend = 0; depend < node->file->deps->used_nodes; ++depend) { if(depend) stream << ";"; stream << node->file->deps->children[depend]->file.local(); } } stream << endl; stream << node->file->mocable << endl; //mocable stream << endl; //just for human readability } } } stream.flush(); file.close(); } #else Q_UNUSED(cf); #endif }
/** * @brief RsCollectionDialog::addAllChild: Add children to RsCollection * @param fileInfoParent: Parent's QFileInfo to scan * @param dirToAdd: QMap where directories are added * @param fileToHash: QStringList where files are added * @return false if too many items is selected and aborted */ bool RsCollectionDialog::addAllChild(QFileInfo &fileInfoParent , QMap<QString, QString > &dirToAdd , QStringList &fileToHash , int &count) { //Save count only first time to not scan all items on list .count() if (count == 0) count = (dirToAdd.count() + fileToHash.count()); QDir dirParent = fileInfoParent.absoluteFilePath(); dirParent.setFilter(QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot); QFileInfoList childrenList = dirParent.entryInfoList(); foreach (QFileInfo fileInfo, childrenList) { if (count == MAX_FILE_ADDED_BEFORE_ASK) { QMessageBox msgBox; msgBox.setText(tr("Warning, selection contains more than %1 items.").arg(MAX_FILE_ADDED_BEFORE_ASK)); msgBox.setInformativeText("Do you want to continue?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); int ret = msgBox.exec(); switch (ret) { case QMessageBox::Yes: break; case QMessageBox::No: return false; break; break; default: // should never be reached break; }//switch (ret) } if (fileInfo.isDir()) { dirToAdd.insert(fileInfo.absoluteFilePath(),fileInfo.absolutePath()); ++count; if (!addAllChild(fileInfo, dirToAdd, fileToHash, count)) return false; }//if (fileInfo.isDir()) if (fileInfo.isFile()){ fileToHash.append(fileInfo.absoluteFilePath()); ++count; if (dirToAdd.contains(fileInfo.absolutePath())) _listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),fileInfo.absolutePath()); else _listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),""); }//if (fileInfo.isFile()) }//foreach (QFileInfo fileInfo, dirParent.entryInfoList()) return true; }
void OptionsSimple::showHelp() { QList<CodecProblems::Problem> problemList; QMap<QString,QStringList> problems = config->pluginLoader()->encodeProblems(); for( int i=0; i<problems.count(); i++ ) { CodecProblems::Problem problem; problem.codecName = problems.keys().at(i); if( problem.codecName != "wav" ) { problem.solutions = problems.value(problem.codecName); problemList += problem; } } CodecProblems *problemsDialog = new CodecProblems( CodecProblems::Debug, problemList, this ); problemsDialog->exec(); }
void AdvancedDistance::UpdateAdvancedDistanceTable() { table_->horizontalHeader()->setClickable(false); table_->setSelectionMode(QAbstractItemView::SingleSelection); table_->verticalHeader()->setHidden(true); table_->horizontalHeader()->setStretchLastSection(true); table_->setColumnCount(2); SpinBoxDelegate *delegate = new SpinBoxDelegate; table_->setItemDelegateForColumn(1, delegate); QStringList headers; headers << STRING_ADVANCED_DISTANCE_DATE << STRING_ADVANCED_DISTANCE_MINEING_DAILY_ADVANCE_DISTANCE + "(m)"; table_->setHorizontalHeaderLabels(headers); QMap<QDate, float> map; if (handler_->GetDayAdvanceDistance(map)) { table_->setRowCount(map.count()); int cnt = 0; QMapIterator<QDate, float> i(map); while(i.hasNext()) { i.next(); QDate date = i.key(); float distance = i.value(); QTableWidgetItem* dateitem = new QTableWidgetItem; QString datestr = QString().sprintf("%d", date.month()) + STRING_ADVANCED_MONTH + QString().sprintf("%2d", date.day()) + STRING_ADVANCED_DAY; dateitem->setText(datestr); dateitem->setTextAlignment(Qt::AlignCenter); dateitem->setFlags(Qt::NoItemFlags); QTableWidgetItem* distanceitem = new QTableWidgetItem; distanceitem->setTextAlignment(Qt::AlignCenter); distanceitem->setData(0, QVariant::fromValue(distance)); table_->setItem(cnt, 0, dateitem); table_->setItem(cnt, 1, distanceitem); cnt++; } } }
void LoadGraphWindow::createGraphTable() { Manager::GraphManager* manager = Manager::GraphManager::getInstance(); Model::DB* db = manager->getDB(); bool error = false; qlonglong id; int graphsCount,row; QList<qlonglong> nodes; QList<qlonglong> edges; QList<qlonglong> layouts; QString name; QMap<qlonglong, Data::Graph*>::iterator iterGraph; QMap<qlonglong, Data::Graph*> graphs = Model::GraphDAO::getGraphs( db->tmpGetConn(), &error ); graphsCount = graphs.count(); numberOfGraphs->setText( tr( "%1 graph(s) found" ).arg( graphsCount ) ); graphsTable->setRowCount( graphsCount ); nodes = Model::NodeDAO::getListOfNodes( db->tmpGetConn(), &error ); edges = Model::EdgeDAO::getListOfEdges( db->tmpGetConn(), &error ); layouts = Model::GraphLayoutDAO::getListOfLayouts( db->tmpGetConn(), &error ); qDebug() << "[QOSG::LoadGraphWindow::createGraphTable] total number of nodes in DB: " << nodes.count(); qDebug() << "[QOSG::LoadGraphWindow::createGraphTable] total number of edges in DB: " << edges.count(); qDebug() << "[QOSG::LoadGraphWindow::createGraphTable] total number of layouts in DB: " << layouts.count(); for ( iterGraph = graphs.begin(), row=0; iterGraph != graphs.end(); ++iterGraph, row++ ) { id = iterGraph.key(); name = graphs.value( id )->getName(); QTableWidgetItem* itemID = new QTableWidgetItem( tr( "%1" ).arg( id ) ); QTableWidgetItem* itemName = new QTableWidgetItem( name ); QTableWidgetItem* itemNumberOfLayouts = new QTableWidgetItem( tr( "%1" ).arg( layouts.count( id ) ) ); QTableWidgetItem* itemNumberOfNodes = new QTableWidgetItem( tr( "%1" ).arg( nodes.count( id ) ) ); QTableWidgetItem* itemNumberOfEdges = new QTableWidgetItem( tr( "%1" ).arg( edges.count( id ) ) ); graphsTable->setItem( row, 0, itemID ); graphsTable->setItem( row, 1, itemName ); graphsTable->setItem( row, 2, itemNumberOfLayouts ); graphsTable->setItem( row, 3, itemNumberOfNodes ); graphsTable->setItem( row, 4, itemNumberOfEdges ); } if ( graphsTable->rowCount() > 0 ) { graphsTable->selectRow( 0 ); } }
void DirOpener::showHelp() { QList<CodecProblems::Problem> problemList; QMap<QString,QStringList> problems = ( mode == Convert ) ? config->pluginLoader()->decodeProblems() : config->pluginLoader()->replaygainProblems(); for( int i=0; i<problems.count(); i++ ) { CodecProblems::Problem problem; problem.codecName = problems.keys().at(i); if( problem.codecName != "wav" ) { problem.solutions = problems.value(problem.codecName); problemList += problem; } } CodecProblems *problemsDialog = new CodecProblems( CodecProblems::Debug, problemList, this ); problemsDialog->exec(); }
void TagDatabaseInMemoryTest::loadInvalidLines() { QTemporaryFile file; QVERIFY(file.open()); file.write("tag1,1\ntag3\n"); file.seek(0); TagDatabaseInMemory database("tests/resources/tag-types.txt", file.fileName()); QVERIFY(database.load()); QMap<QString, TagType> types = database.getTagTypes(QStringList() << "tag1" << "tag3"); QCOMPARE(types.count(), 1); QCOMPARE(types.contains("tag1"), true); QCOMPARE(types.contains("tag3"), false); QCOMPARE(types.value("tag1").name(), QString("artist")); QCOMPARE(database.count(), 1); }
void TagDatabaseInMemoryTest::loadValidData() { QTemporaryFile file; QVERIFY(file.open()); file.write("tag1,0\ntag2,1\ntag3,3\ntag4,4"); file.seek(0); TagDatabaseInMemory database("tests/resources/tag-types.txt", file.fileName()); QVERIFY(database.load()); QMap<QString, TagType> types = database.getTagTypes(QStringList() << "tag1" << "tag3"); QCOMPARE(types.count(), 2); QCOMPARE(types.contains("tag1"), true); QCOMPARE(types.contains("tag3"), true); QCOMPARE(types.value("tag1").name(), QString("general")); QCOMPARE(types.value("tag3").name(), QString("copyright")); QCOMPARE(database.count(), 4); }
/** Process each item to make a new RsCollection item */ void RsCollectionDialog::processItem(QMap<QString, QString> &dirToAdd , int &index , ColFileInfo &parent ) { ColFileInfo newChild; int count = dirToAdd.count(); if (index < count) { QString key=dirToAdd.keys().at(index); bool bad_chars_detected = false; QFileInfo fileInfo=key; QString cleanDirName = purifyFileName(fileInfo.fileName(),bad_chars_detected); newChild.name = cleanDirName; newChild.filename_has_wrong_characters = bad_chars_detected; newChild.size = fileInfo.isDir()? 0: fileInfo.size(); newChild.type = fileInfo.isDir()? DIR_TYPE_DIR: DIR_TYPE_FILE ; if (parent.name != "") { newChild.path = parent.path + "/" + parent.name; } else { newChild.path = parent.path; } dirToAdd[key] = newChild.path + "/" + newChild.name; //Move to next item ++index; if (index < count){ QString newKey = dirToAdd.keys().at(index); while ((dirToAdd.value(newKey) == key) && (index < count)) { processItem(dirToAdd, index, newChild); if (index < count)newKey = dirToAdd.keys().at(index); } } //Save parent when child are processed if (parent.name != "") { parent.children.push_back(newChild); parent.size += newChild.size; } else { _newColFileInfos.push_back(newChild); } }//(index < count) }
void BindEnum::setItems(const QMap<int, QString>& i) { Q_ASSERT(i.count() >= 1); mItems = i; mEditor->clear(); QMapIterator<int, QString> it(i); while( it.hasNext() ) { it.next(); Q_ASSERT( !it.value().isEmpty() ); mEditor->addItem( it.value(), it.key() ); } clear(); }
void KPasswordDialog::setKnownLogins(const QMap<QString, QString> &knownLogins) { const int nr = knownLogins.count(); if (nr == 0) { return; } if (nr == 1) { d->ui.userEdit->setText(knownLogins.begin().key()); setPassword(knownLogins.begin().value()); return; } Q_ASSERT(!d->ui.userEdit->isReadOnly()); if (!d->userEditCombo) { int row = -1; QFormLayout::ItemRole userEditRole = QFormLayout::FieldRole; d->ui.formLayout->getWidgetPosition(d->ui.userEdit, &row, &userEditRole); d->ui.formLayout->removeWidget(d->ui.userEdit); delete d->ui.userEdit; d->userEditCombo = new QComboBox(d->ui.credentialsGroup); d->userEditCombo->setEditable(true); d->ui.userEdit = d->userEditCombo->lineEdit(); d->ui.userNameLabel->setBuddy(d->userEditCombo); d->ui.formLayout->setWidget(row > -1 ? row : 0, userEditRole, d->userEditCombo); setTabOrder(d->ui.userEdit, d->ui.anonymousRadioButton); setTabOrder(d->ui.anonymousRadioButton, d->ui.domainEdit); setTabOrder(d->ui.domainEdit, d->ui.passEdit); setTabOrder(d->ui.passEdit, d->ui.keepCheckBox); connect(d->ui.userEdit, SIGNAL(returnPressed()), d->ui.passEdit, SLOT(setFocus())); } d->knownLogins = knownLogins; d->userEditCombo->addItems(knownLogins.keys()); d->userEditCombo->setFocus(); connect(d->userEditCombo, SIGNAL(activated(QString)), this, SLOT(activated(QString))); }
void FuzzyIndex::appendFields( const QString& table, const QMap< unsigned int, QString >& fields ) { try { qDebug() << "Appending to index:" << fields.count(); bool create = !IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() ); IndexWriter luceneWriter = IndexWriter( m_luceneDir, m_analyzer, create ); Document doc; QMapIterator< unsigned int, QString > it( fields ); while ( it.hasNext() ) { it.next(); unsigned int id = it.key(); QString name = it.value(); { Field* field = _CLNEW Field( table.toStdWString().c_str(), DatabaseImpl::sortname( name ).toStdWString().c_str(), Field::STORE_YES | Field::INDEX_UNTOKENIZED ); doc.add( *field ); } { Field* field = _CLNEW Field( _T( "id" ), QString::number( id ).toStdWString().c_str(), Field::STORE_YES | Field::INDEX_NO ); doc.add( *field ); } luceneWriter.addDocument( &doc ); doc.clear(); } luceneWriter.close(); } catch( CLuceneError& error ) { qDebug() << "Caught CLucene error:" << error.what(); Q_ASSERT( false ); } }
void ZFlyEmNeuronListModel::retrieveModel( const QModelIndexList &indexList, ZStackDoc *doc, bool forceUpdate) const { // doc->blockSignals(true); doc->beginObjectModifiedMode(ZStackDoc::OBJECT_MODIFIED_CACHE); QVector<const ZFlyEmNeuron*> neuronArray; QMap<std::string, QColor> colorMap; ZSwcColorScheme colorScheme; colorScheme.setColorScheme(ZColorScheme::UNIQUE_COLOR); foreach (QModelIndex index, indexList) { QVector<const ZFlyEmNeuron*> subArray = getNeuronArray(index); foreach (const ZFlyEmNeuron *neuron, subArray) { neuronArray.append(neuron); if (colorMap.count(neuron->getType()) == 0) { colorMap[neuron->getType()] = colorScheme.getColor(colorMap.size()); } }
// XMLTV stuff bool FillData::GrabDataFromFile(int id, QString &filename) { QList<ChanInfo> chanlist; QMap<QString, QList<ProgInfo> > proglist; if (!xmltv_parser.parseFile(filename, &chanlist, &proglist)) return false; chan_data.handleChannels(id, &chanlist); icon_data.UpdateSourceIcons(id); if (proglist.count() == 0) { LOG(VB_GENERAL, LOG_INFO, "No programs found in data."); endofdata = true; } else { prog_data.HandlePrograms(id, proglist); } return true; }
// XMLTV stuff bool FillData::GrabDataFromFile(int id, QString &filename) { ChannelInfoList chanlist; QMap<QString, QList<ProgInfo> > proglist; m_xmltv_parser.lateInit(); if (!m_xmltv_parser.parseFile(filename, &chanlist, &proglist)) return false; m_chan_data.handleChannels(id, &chanlist); if (proglist.count() == 0) { LOG(VB_GENERAL, LOG_INFO, "No programs found in data."); m_endofdata = true; } else { m_prog_data.HandlePrograms(id, proglist); } return true; }
// adds a random direction and moves on (if possible) void AbstractGrid::addRandomCable(QList<uint>& list) { int cell = list.first(); // find all the cells surrounding list.first() // (0 when cells don't exist) int ucell = uCell(cell); // up int rcell = rCell(cell); // right int dcell = dCell(cell); // down int lcell = lCell(cell); // left QMap<Directions, int> freeCells; // of those cells map the ones that are free if (ucell != NO_CELL && m_cells[ucell]->cables() == None) { freeCells[Up] = ucell; } if (rcell != NO_CELL && m_cells[rcell]->cables() == None) { freeCells[Right] = rcell; } if (dcell != NO_CELL && m_cells[dcell]->cables() == None) { freeCells[Down] = dcell; } if (lcell != NO_CELL && m_cells[lcell]->cables() == None) { freeCells[Left] = lcell; } if (freeCells.isEmpty()) return; // no free cells left QMap<Directions, int>::ConstIterator it = freeCells.constBegin(); // move the iterator to a random direction connecting to a free cell for (int i = qrand() % freeCells.count(); i > 0; --i) ++it; // add the cable in the direction of cell Directions newCables = Directions(m_cells[cell]->cables() | it.key()); m_cells[cell]->setCables(newCables); // add a cable in the opposite direction, on the free cell m_cells[it.value()]->setCables(invertDirection(it.key())); // append the cell that was free to the list list.append(it.value()); }
void restore_port_attributes(int port, bool clear) { if (!open_xv_ports.count(port)) return; if (!open_xv_ports[port].attribs.size()) return; MythXDisplay *disp = open_xv_ports[port].disp; MythXLocker lock(disp); QMap<QString,int>::iterator it; for (it = open_xv_ports[port].attribs.begin(); it != open_xv_ports[port].attribs.end(); ++it) { QByteArray ascii_name = it.key().toAscii(); const char *cname = ascii_name.constData(); xv_set_attrib(disp, port, cname, it.value()); } if (clear) open_xv_ports[port].attribs.clear(); }
void Music::onPull() { QVector<Resources::Music> files = selected(); if (files.isEmpty()) return; QFileDialog dialog(this, translate("title_browse"), Helpers::Settings::previousDirectory()); dialog.setAcceptMode(QFileDialog::AcceptOpen); dialog.setFileMode(QFileDialog::Directory); if (dialog.exec() != QFileDialog::Accepted) return; QStringList folders = dialog.selectedFiles(); if (folders.count() != 1) return; QDir directory(folders.first()); Helpers::Settings::previousDirectory(directory.absolutePath()); QMap<QString, bool> paths; foreach(const Resources::Music &file, files) paths[file.path] = false; Pull *pull = new Pull(device, paths, directory); connections.append(connect(pull, SIGNAL(finished(QVariant)), this, SLOT(onPullFinished(QVariant)), Qt::QueuedConnection)); Tasks::instance()->add(translate("task_pull").arg(QString::number(paths.count())), pull); }
bool Machine::addRotors(QMap<int, QPointer<Rotor> > rotorArray) { bool result = true; this->rotorArray.clear(); this->rotorArray = rotorArray; rotorArray.count(); QMapIterator<int, QPointer<Rotor> > i(rotorArray); while (i.hasNext()) { i.next(); if (! addRotor(i.key(), i.value())) { this->rotorArray.clear(); result = false; return result; } } return result; }
void KSharedPtrTest::testOrdering() { Base* obj = new Base; KSharedPtr<Base> ptrBase(obj); Base* obj2 = new Base; KSharedPtr<Base> ptrBase2(obj2); QVERIFY( obj != obj2 ); QVERIFY( ptrBase != ptrBase2 ); QVERIFY( ptrBase < ptrBase2 || ptrBase2 < ptrBase ); QMap<KSharedPtr<Base>, int> map; map.insert( ptrBase, 1 ); QVERIFY( map.contains( ptrBase ) ); QVERIFY( !map.contains( ptrBase2 ) ); QCOMPARE( map.value( ptrBase, 0 ), 1 ); map.insert( ptrBase2, 2 ); QVERIFY( map.contains( ptrBase2 ) ); QCOMPARE( map.value( ptrBase2, 0 ), 2 ); QCOMPARE( map.count(), 2 ); }
void KPasswordDialog::setKnownLogins( const QMap<QString, QString>& knownLogins ) { const int nr = knownLogins.count(); if ( nr == 0 ) { return; } if ( nr == 1 ) { d->ui.userEdit->setText( knownLogins.begin().key() ); setPassword( knownLogins.begin().value() ); return; } Q_ASSERT( !d->ui.userEdit->isReadOnly() ); if ( !d->userEditCombo ) { d->ui.formLayout->removeWidget(d->ui.userEdit); delete d->ui.userEdit; d->userEditCombo = new QComboBox(this); d->userEditCombo->setEditable(true); d->ui.userEdit = d->userEditCombo->lineEdit(); // QSize s = d->userEditCombo->sizeHint(); // d->ui.userEditCombo->setFixedHeight( s.height() ); // d->ui.userEditCombo->setMinimumWidth( s.width() ); d->ui.userNameLabel->setBuddy( d->userEditCombo ); d->ui.formLayout->setWidget( d->commentRow, QFormLayout::FieldRole, d->userEditCombo ); setTabOrder( d->ui.userEdit, d->ui.anonymousCheckBox ); setTabOrder( d->ui.anonymousCheckBox, d->ui.domainEdit ); setTabOrder( d->ui.domainEdit, d->ui.passEdit ); setTabOrder( d->ui.passEdit, d->ui.keepCheckBox ); connect( d->ui.userEdit, SIGNAL(returnPressed()), d->ui.passEdit, SLOT(setFocus()) ); } d->knownLogins = knownLogins; d->userEditCombo->addItems( knownLogins.keys() ); d->userEditCombo->setFocus(); connect( d->userEditCombo, SIGNAL(activated(QString)), this, SLOT(activated(QString)) ); }
/* very specialized method to extract data from a specific XLS sheet online at * http://www.nordpoolspot.com/PageFiles/9383/Elspot%20Prices_2013_Daily_NOK.xls */ QMap<QDateTime, double> Util::parseXLS_daily(const QString& content) { static QString day_start = "<td style=\"text-align:left;\">"; static QString endTd = "</td>"; static QString price_html_start = "<td style=\"text-align:right;\">"; static QString price_html_preliminary = "<td style=\"color:purple;text-align:right;\">"; QMap<QDateTime, double> priceMap; // The last few days in the document will be marked with a purple tag if its been weekend. Thus the extra work. // We're basically extracting the dato and the first price instance per line. Current version works great, but // could of course break anytime during the future if the format changes in the file. QStringList lines = content.split('\n'); for(QString line : lines) { if(line.contains(day_start)) { int indexDateStart = line.indexOf(day_start) + day_start.length(); int indexDateEnd = line.indexOf(endTd, indexDateStart); QString datestring = line.mid(indexDateStart, indexDateEnd-indexDateStart); QDateTime date = QDateTime::fromString(datestring, Constants::DateTimeFormat); int indexPriceStart = 0; if(line.contains(price_html_preliminary)) indexPriceStart = line.indexOf(price_html_preliminary, indexDateEnd) + price_html_preliminary.length(); else indexPriceStart = line.indexOf(price_html_start, indexDateEnd) + price_html_start.length(); int indexPriceEnd = line.indexOf(endTd, indexPriceStart); QString pricestring = line.mid(indexPriceStart, indexPriceEnd-indexPriceStart).replace(',', '.'); double price = pricestring.toDouble(); priceMap.insert(date, price); } } if(priceMap.count() <= 0) Logger::get().append("ParseXLSDaily: Expected more than 0 items in the pricelist.", true); return priceMap; }
void SpikePage::setGroups(const QMap<int, QList<int> >& groups,const QMap<int, QMap<QString,QString> >& information){ //Clean the groupTable, just in case, before creating empty rows. groupTable->clearContents(); groupTable->setRowCount(groups.count()); QMap<int,QList<int> >::const_iterator iterator; //The iterator gives the keys sorted. for(iterator = groups.begin(); iterator != groups.end(); ++iterator){ QList<int> channelIds = iterator.value(); QList<int>::iterator channelIterator; //create the string containing the channel ids QString group; for(channelIterator = channelIds.begin(); channelIterator != channelIds.end(); ++channelIterator){ group.append(QString::number(*channelIterator)); group.append(" "); } groupTable->setItem(iterator.key() - 1,0,new QTableWidgetItem(group)); QMap<QString,QString> groupInformation = information[iterator.key()]; QMap<QString,QString>::Iterator iterator2; //The positions of the information in the table are hard coded (for the moment :0) ) for(iterator2 = groupInformation.begin(); iterator2 != groupInformation.end(); ++iterator2){ if(iterator2.key() == NB_SAMPLES){ groupTable->setItem(iterator.key() - 1,1,new QTableWidgetItem(iterator2.value())); } else if(iterator2.key() == PEAK_SAMPLE_INDEX){ groupTable->setItem(iterator.key() - 1,2,new QTableWidgetItem(iterator2.value())); } else if(iterator2.key() == NB_FEATURES){ groupTable->setItem(iterator.key() - 1,3,new QTableWidgetItem(iterator2.value())); } } //groupTable->adjustRow(iterator.key() - 1); }//end of groups loop }
void EmoticonSelector::prepareList(void) { // kdDebug(14000) << k_funcinfo << "called." << endl; int row = 0; int col = 0; QMap<QString, QStringList> list = Kopete::Emoticons::self()->emoticonAndPicList(); int emoticonsPerRow = static_cast<int>(sqrt(list.count())); //kdDebug(14000) << "emoticonsPerRow=" << emoticonsPerRow << endl; if ( lay ) { QObjectList *objList = queryList( "EmoticonLabel" ); //kdDebug(14000) << k_funcinfo << "There are " << objList->count() << " EmoticonLabels to delete." << endl; objList->setAutoDelete(true); objList->clear(); delete objList; delete lay; } lay = new QGridLayout(this, 0, 0, 4, 4, "emoticonLayout"); movieList.clear(); for (QMap<QString, QStringList>::const_iterator it = list.constBegin(); it != list.constEnd(); ++it ) { QWidget *w = new EmoticonLabel(it.data().first(), it.key(), this); movieList.push_back( ((QLabel*)w)->movie() ); connect(w, SIGNAL(clicked(const QString&)), this, SLOT(emoticonClicked(const QString&))); // kdDebug(14000) << "adding Emoticon to row=" << row << ", col=" << col << "." << endl; lay->addWidget(w, row, col); if ( col == emoticonsPerRow ) { col = 0; row++; } else col++; } resize(minimumSizeHint()); }
bool KAccelActions::init( KConfigBase& config, const QString& sGroup ) { kdDebug(125) << "KAccelActions::init( " << sGroup << " )" << endl; QMap<QString, QString> mapEntry = config.entryMap( sGroup ); resize( mapEntry.count() ); QMap<QString, QString>::Iterator it( mapEntry.begin() ); for( uint i = 0; it != mapEntry.end(); ++it, i++ ) { QString sShortcuts = *it; KShortcut cuts; kdDebug(125) << it.key() << " = " << sShortcuts << endl; if( !sShortcuts.isEmpty() && sShortcuts != "none" ) cuts.init( sShortcuts ); m_prgActions[i] = new KAccelAction( it.key(), it.key(), it.key(), cuts, cuts, 0, 0, // pObjSlot, psMethodSlot, true, false ); // bConfigurable, bEnabled } return true; }