void djvFileInfoUtil::recent( const QString & fileName, QStringList & list, int max) { const int index = list.indexOf(fileName); if (-1 == index) { // Insert new item at front of list. list.push_front(fileName); while (list.count() > max) { list.pop_back(); } } else { // Move existing item to front of list. list.removeAt(list.indexOf(fileName)); list.push_front(fileName); } }
void CAbstractUpdateController::launchUpdate() { QString proc; QStringList args; QString DLType; updateShellCommand(proc, args); //if jail is present if (mJailPrefix.length()) { args.push_front(proc); args.push_front(mJailPrefix); proc = "chroot"; } mUpdProc.start(proc,args); if (!mUpdProc.waitForStarted()) { reportError(tr("Can not execute update shell command")); return; } DLType = dlType(); if (DLType.length()) mUpdProc.setDLType(DLType); if (currentState() != eUPDATING) setCurrentState(eUPDATING); }
void CompleterLineEdit::filterText(const QString & txt) { QStringList sl; if ( txt.isEmpty() ) { for (PluginsNamesMap::iterator it = _imp->names.begin(); it != _imp->names.end(); ++it) { sl.push_front(it->second.second); } } else { QString pattern; for (int i = 0; i < txt.size(); ++i) { pattern.push_back( QLatin1Char('*') ); pattern.push_back(txt[i]); } pattern.push_back( QLatin1Char('*') ); QRegExp expr(pattern, Qt::CaseInsensitive, QRegExp::WildcardUnix); #ifdef NODE_TAB_DIALOG_USE_MATCHED_LENGTH std::map<int, QStringList> matchOrdered; for (PluginsNamesMap::iterator it = _imp->names.begin(); it != _imp->names.end(); ++it) { if ( expr.exactMatch(it->second.first) ) { QStringList& matchedForLength = matchOrdered[expr.matchedLength()]; matchedForLength.push_front(it->second.second); } } for (std::map<int, QStringList>::iterator it = matchOrdered.begin(); it != matchOrdered.end(); ++it) { sl.append(it->second); } #else for (PluginsNamesMap::iterator it = _imp->names.begin(); it != _imp->names.end(); ++it) { if ( it->second.first.contains(expr) ) { sl.push_front(it->second.second); } } #endif } _imp->model->setStringList(sl); _imp->listView->setModel(_imp->model); int rowCount = _imp->model->rowCount(); if (rowCount == 0) { return; } QPoint p = mapToGlobal( QPoint( 0, height() ) ); //QDesktopWidget* desktop = QApplication::desktop(); //QRect screen = desktop->screenGeometry(); //double maxHeight = ( screen.height() - p.y() ) * 0.8; //QFontMetrics fm = _imp->listView->fontMetrics(); //maxHeight = std::min( maxHeight, ( rowCount * fm.height() * 1.2 + fm.height() ) ); // Position the text edit // _imp->listView->setFixedSize(width(),maxHeight); _imp->listView->move(p); _imp->listView->show(); } // CompleterLineEdit::filterText
QStringList MythGenericTree::getRouteByString() { QStringList routeByString; routeByString.push_front(getString()); MythGenericTree *parent = this; while( (parent = parent->getParent()) ) { routeByString.push_front(parent->getString()); } return routeByString; }
void CompleterLineEdit::filterText(const QString & txt) { QStringList sl; if ( txt.isEmpty() ) { for (PluginsNamesMap::iterator it = _imp->names.begin(); it != _imp->names.end(); ++it) { sl.push_front(it->second.comboLabel); } } else { QString pattern; for (int i = 0; i < txt.size(); ++i) { pattern.push_back( QLatin1Char('*') ); pattern.push_back(txt[i]); } pattern.push_back( QLatin1Char('*') ); QRegExp expr(pattern, Qt::CaseInsensitive, QRegExp::WildcardUnix); #ifdef NODE_TAB_DIALOG_USE_MATCHED_LENGTH std::map<int, QStringList> matchOrdered; for (PluginsNamesMap::iterator it = _imp->names.begin(); it != _imp->names.end(); ++it) { if ( expr.exactMatch(it->second.lineEditLabel) ) { QStringList& matchedForLength = matchOrdered[expr.matchedLength()]; matchedForLength.push_front(it->second.comboLabel); } } for (std::map<int, QStringList>::iterator it = matchOrdered.begin(); it != matchOrdered.end(); ++it) { sl.append(it->second); } #else for (PluginsNamesMap::iterator it = _imp->names.begin(); it != _imp->names.end(); ++it) { if ( it->second.lineEditLabel.contains(expr) ) { sl.push_front(it->second.comboLabel); } } #endif } _imp->model->setStringList(sl); _imp->listView->setModel(_imp->model); int rowCount = _imp->model->rowCount(); if (rowCount == 0) { return; } QPoint p = mapToGlobal( QPoint( 0, height() ) ); _imp->listView->move(p); _imp->listView->show(); } // CompleterLineEdit::filterText
bool nameSpecSearch(QString phrase) { QFile dataFile(fileName); bool isAvailable = false; if((!dataFile.open(QFile::ReadOnly))){ throw "Could not open file " + fileName; } QTextStream in(&dataFile); QStringList withinName; while(!in.atEnd()){ QString line = in.readLine(); //read one line at a time if(line.contains(phrase) >= 0){ isAvailable = true; QStringList temp = line.split('|'); QStringList temp2; for(int i = temp.size()-1; i>=0;i--){ temp2.push_back(temp[i]); } line = temp2.join("|"); withinName.push_front(line); isAvailable = true; } } withinName.sort(); if(isAvailable){ qDebug() << "Name" << "\t\t" << "Birthday"; qDebug() << "====" << "\t\t" << "========"; } for (QStringList::iterator it = withinName.begin();it != withinName.end(); ++it){ QString current = *it; QStringList lineItems = current.split('|'); qDebug() << lineItems[0] << "\t" << lineItems[1]; } return isAvailable; }
void TagGuesser::guessTags(MPDSong &song) { QString pattern = Config::instance()->guessPattern(); // Check that we have a pattern at all if (pattern.isEmpty()) return; // Cant guess from URL's if (song.url().contains("://")) return; // Return if we already have everything we can guess if (!(song.title().isEmpty() || song.album().isEmpty() || song.artist().isEmpty() || song.track().isEmpty())) return; DEBUG4("Guessing.."); // Tokens to expand. %a=album, %b=band, %n=tracknr, %t=title, %i=ignore QStringList matchers = pattern.split(QRegExp("%[abnti]"), QString::SkipEmptyParts); QStringList markers = pattern.split('%', QString::SkipEmptyParts); // Check that we actually have any matchers, if not, return filename as title, the rest empty. DEBUG4("Matchers size: %d %d", matchers.size(), markers.size()); if (matchers.isEmpty() || markers.isEmpty()) { DEBUG4("No matchers or no markers"); if (song.title().isEmpty()) song.setTitle(song.url()); return; } // Remove bogus markers DEBUG4("Removing bogus markers"); markers = markers.filter(QRegExp("^[abnti]")); // Remove trailing garbage on markers DEBUG4("Removing trailing garbage on markers"); markers = markers.replaceInStrings(QRegExp("^([abnti]).*"), "%\\1"); DEBUG4("Adding greedy front matcher"); // If pattern does not have leading characters, add a greedy matcher at front so we get the whole start if (pattern.contains(QRegExp("^%[abnti]"))) matchers.push_front("^"); // If pattern contains trailing characters, add a dummy marker at the end. DEBUG4("Finding last matcher"); QString lastMarker = markers.last(); DEBUG4("Finding end of last marker"); int endOfLastMatcher = pattern.lastIndexOf(lastMarker) + lastMarker.size(); DEBUG4("Adding dummy end marker"); if (endOfLastMatcher < pattern.size()) markers += "trailingcharacters"; foreach (QString p, markers) { DEBUG4("marker : %s", qPrintable(p)); }
QStringList Vizkit3DConfig::getVisualizationFrames() const { QStringList frames = getWidget()->getVisualizationFrames(); if (!frames.isEmpty()) frames.push_front(getWidget()->getVisualizationFrame()); return frames; }
void GeneralForm::reloadSmiles() { QList<QStringList> emoticons = SmileyPack::getInstance().getEmoticons(); if (emoticons.isEmpty()) { // sometimes there are no emoticons available, don't crash in this case qDebug() << "reloadSmilies: No emoticons found"; return; } QStringList smiles; for (int i = 0; i < emoticons.size(); i++) smiles.push_front(emoticons.at(i).first()); const QSize size(18,18); bodyUI->smile1->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[0]).pixmap(size)); bodyUI->smile2->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[1]).pixmap(size)); bodyUI->smile3->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[2]).pixmap(size)); bodyUI->smile4->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[3]).pixmap(size)); bodyUI->smile5->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[4]).pixmap(size)); bodyUI->smile1->setToolTip(smiles[0]); bodyUI->smile2->setToolTip(smiles[1]); bodyUI->smile3->setToolTip(smiles[2]); bodyUI->smile4->setToolTip(smiles[3]); bodyUI->smile5->setToolTip(smiles[4]); //set maximum size of emoji QDesktopWidget desktop; int maxSize = qMin(desktop.geometry().height()/8, desktop.geometry().width()/8); // 8 is the count of row and column in emoji's in widget bodyUI->emoticonSize->setMaximum(SmileyPack::getInstance().getAsIcon(smiles[0]).actualSize(QSize(maxSize,maxSize)).width()); }
void GeneralForm::reloadSmiles() { QList<QStringList> emoticons = SmileyPack::getInstance().getEmoticons(); if (emoticons.isEmpty()) { // sometimes there are no emoticons available, don't crash in this case qDebug() << "reloadSmilies: No emoticons found"; return; } QStringList smiles; for (int i = 0; i < emoticons.size(); i++) smiles.push_front(emoticons.at(i).first()); const QSize size(18,18); bodyUI->smile1->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[0]).pixmap(size)); bodyUI->smile2->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[1]).pixmap(size)); bodyUI->smile3->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[2]).pixmap(size)); bodyUI->smile4->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[3]).pixmap(size)); bodyUI->smile5->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[4]).pixmap(size)); bodyUI->smile1->setToolTip(smiles[0]); bodyUI->smile2->setToolTip(smiles[1]); bodyUI->smile3->setToolTip(smiles[2]); bodyUI->smile4->setToolTip(smiles[3]); bodyUI->smile5->setToolTip(smiles[4]); }
void Notifier::onCopyPathDocument() { QModelIndex const& selectedInd = _observer->selectedIndex(); if (!selectedInd.isValid()) return; BsonTreeItem const *documentItem = QtUtils::item<BsonTreeItem*>(selectedInd); if (!documentItem) return; if (!(detail::isSimpleType(documentItem) || detail::isDocumentType(documentItem) || !detail::isDocumentRoot(documentItem))) return; QStringList namesList; BsonTreeItem const *documentItemHelper = documentItem; while (!detail::isDocumentRoot(documentItemHelper)) { if (!detail::isArrayChild(documentItemHelper)) { namesList.push_front(QString::fromStdString(documentItemHelper->fieldName())); } documentItemHelper = dynamic_cast<BsonTreeItem*>(documentItemHelper->parent()); } QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(namesList.join(".")); }
/** * @brief Reload smileys and size information. */ void UserInterfaceForm::reloadSmileys() { QList<QStringList> emoticons = SmileyPack::getInstance().getEmoticons(); // sometimes there are no emoticons available, don't crash in this case if (emoticons.isEmpty()) { qDebug() << "reloadSmilies: No emoticons found"; return; } QStringList smileys; for (int i = 0; i < emoticons.size(); ++i) smileys.push_front(emoticons.at(i).first()); const QSize size(18, 18); for (int i = 0; i < smileLabels.size(); ++i) { QIcon icon = SmileyPack::getInstance().getAsIcon(smileys[i]); smileLabels[i]->setPixmap(icon.pixmap(size)); smileLabels[i]->setToolTip(smileys[i]); } // set maximum size of emoji QDesktopWidget desktop; // 8 is the count of row and column in emoji's in widget const int sideSize = 8; int maxSide = qMin(desktop.geometry().height() / sideSize, desktop.geometry().width() / sideSize); QSize maxSize(maxSide, maxSide); QIcon icon = SmileyPack::getInstance().getAsIcon(smileys[0]); QSize actualSize = icon.actualSize(maxSize); bodyUI->emoticonSize->setMaximum(actualSize.width()); }
bool KJavaAppletServer::callMember(QStringList & args, QStringList & ret_args) { JSStackFrame frame( d->jsstack, ret_args ); args.push_front( QString::number(frame.ticket) ); process->send( KJAS_CALL_MEMBER, args ); waitForReturnData( &frame ); return frame.ready; }
QStringList fs::list(const QString &path){ QDirIterator dirIt(path,QDirIterator::Subdirectories); QStringList list; while (dirIt.hasNext()) { dirIt.next(); list.push_front(dirIt.filePath()); } return list; }
QString OSConfigurator_linux24::printUpdateAddressCommand( Interface *intf, QStringList &update_addresses, QStringList &ignore_addresses) { QStringList out; update_addresses.push_front(intf->getName().c_str()); out.push_back("update_addresses_of_interface"); out.push_back("\"" + update_addresses.join(" ") + "\""); out.push_back("\"" + ignore_addresses.join(" ") + "\""); return out.join(" "); }
bool KJavaAppletServer::putMember( QStringList & args ) { QStringList ret_args; JSStackFrame frame( d->jsstack, ret_args ); args.push_front( QString::number(frame.ticket) ); process->send( KJAS_PUT_MEMBER, args ); waitForReturnData( &frame ); return frame.ready && ret_args.count() > 0 && ret_args[0].toInt(); }
void MainWindow::openRecent() { QAction* action = qobject_cast<QAction*>(sender()); QString file = action->data().toString(); QSettings settings; QStringList current = settings.value(RECENTS).toStringList(); current.push_front(file); current.removeDuplicates(); settings.setValue(RECENTS, current); if(action) openFile(file); }
void VLCRecorder::findVLCApplication(QStringList suggestedVLCLocations) { suggestedVLCLocations.push_front(this->getVLCDefaultLocation()); foreach(QString path, suggestedVLCLocations) { if(this->isValidVLC(path)) { this->setVLCPath(path); return; } } }
QString IpCalculator::toString(quint32 address) { QStringList parts; for (int i = 0; i < 4; i++) { quint32 value = 0x000000FF & address; parts.push_front(QString::number(value)); address >>= 8; } return parts.join(QString(".")); }
void CAbstractUpdateController::launchCheck() { QString proc; QStringList args; checkShellCommand(proc, args); //if jail is present if (mJailPrefix.length()) { args.push_front(proc); args.push_front(mJailPrefix); proc = "chroot"; } mUpdProc.start(proc,args); if (!mUpdProc.waitForStarted()) { reportError(tr("Can not execute update shell command")); return; } setCurrentState(eCHECKING); }
void MainWindow::open(QString fileName = QString("")) { QStringList fileNames; if (fileName.isEmpty()) { fileNames = QFileDialog::getOpenFileNames(this, "Select one or more files to open", (openFiles.size() > 0 && !getCurFileObj()->path.isEmpty()) ? getCurFileObj()->path : lastDir); } else { fileNames.push_front(fileName); } while (fileNames.count()) { if (!fileNames.back().isEmpty()) { bool alreadyOpen = false; QList<QsciteEditor *> openTabs = openFiles.keys(); QList<QsciteEditor *>::iterator tab; for (tab = openTabs.begin(); tab != openTabs.end(); ++tab) { if (fileNames.front() == openFiles[*tab].fullName) { alreadyOpen = true; if (fileNames.count() == 1) { changeTabs(*tab); } qDebug() << "file is already open"; } } if (alreadyOpen) { fileNames.pop_front(); continue; } if ((!tabWidget->count()) || (!getCurFileObj()->baseName.isEmpty()) || getCurDoc()->isModified()) { createDocument(); } loadFile(fileNames.front()); setCurrentTabTitle(); addRecentFile(fileNames.front()); } fileNames.pop_front(); } if (!openFiles.empty()) { getCurDoc()->setFocus(); lastDir = getCurFileObj()->path; } }
void mos_add_recent_file(const QString& filepath) { QSettings s; QStringList recent = s.value("recent_files").toStringList(); recent.removeAll(filepath); recent.push_front(filepath); while(recent.size() > int(max_recent_files)) { recent.pop_back(); } s.setValue("recent_files", recent); }
/** Take the given scope and key and convert them to a string list of key tokens that will be used to navigate through a Property hierarchy E.g., scope "someplugin" and key "/foo/bar/baz" will become a string list of { "properties", "someplugin", "foo", "bar", "baz" }. "properties" is always first because that's the permanent ``root'' Property node. */ static QStringList makeKeyTokens_( QString const &scope, QString const &key ) { // XXX - debugger probes //const char * scope_str = scope.toLocal8Bit().data(); //const char * key_str = key.toLocal8Bit().data(); QStringList keyTokens = QStringList( scope ); keyTokens += key.split( '/', QString::SkipEmptyParts ); // be sure to include the canonical root node keyTokens.push_front( "properties" ); return keyTokens; } // makeKeyTokens_
void MainWindow::updatePath() { QTreeWidgetItem *item = tree->currentItem(); if (!item) return; QStringList list; while (item) { list.push_front(item->text(0)); item = item->parent(); } QString path; while (!list.isEmpty()) path += "/" + list.takeFirst(); this->path->setText(path); }
void Controls::addRecentFiles(const QString &fileName) { QMenu *rf = m_ui->menuRecent_Models; QStringList files; { QSettings settings; settings.beginGroup("General"); int numFiles = settings.beginReadArray("RecentFiles"); for (int i = 0; i < numFiles; ++i) { settings.setArrayIndex(i); QByteArray coded = settings.value("file").toByteArray(); files.append(QUrl::fromPercentEncoding(coded)); } } files.removeAll(fileName); files.push_front(fileName); if (files.size() > 10) files.pop_back(); QAction *act; while (rf->actions().count() > 0) { act = rf->actions().at(0); rf->removeAction(act); delete act; } for (int i = 0; i < files.count(); ++i) { act = new QAction(files.at(i), this); connect(act, SIGNAL(triggered()), this, SLOT(load())); rf->addAction(act); } { QSettings settings; settings.beginGroup("General"); settings.beginWriteArray("RecentFiles", files.count()); for (int i = 0; i < files.count(); ++i) { settings.setArrayIndex(i); QByteArray coded = QUrl::toPercentEncoding(files.at(i)); settings.setValue("file", coded); } settings.endArray(); settings.endGroup(); settings.sync(); } }
void PlaylistManager::onCustomResort(QStringList uuids) { Q_D(PlaylistManager); Q_ASSERT(uuids.length() == d->playlists.size() - 1); uuids.push_front(playlist(SearchMusicListID)->id()); d->sortUUIDs.clear(); for (auto sortID = 0; sortID < uuids.length(); ++sortID) { d->sortUUIDs << uuids.value(sortID); } QSqlDatabase::database().transaction(); saveSortOrder(); QSqlDatabase::database().commit(); }
void RecentFiles::existentialCheck() { QStringList deletions; foreach (QString filename, m_recentFileNames) { if (!QFile::exists(filename)) { deletions.push_front(filename); } } foreach (QString filename, deletions) { m_recentFileNames.removeAll(filename); }
void MainWindow::setSettings(QString fileName) { //Save a list the five last documents opened on this computer QStringList recentFiles = QStringList(); if(settings.contains("recentFiles")) { recentFiles = settings.value("recentFiles").toStringList(); if(recentFiles.length() == 5) { recentFiles.pop_back(); } } recentFiles.push_front(fileName); settings.setValue("recentFiles", recentFiles); }
QStringList PropertyModel::propertyPathFromIndex(const QModelIndex& index) const { QStringList path; if (index.isValid()) { PropertyItem* item = static_cast<PropertyItem*>(index.internalPointer()); if (!item->isSeparator()) { do { path.push_front(item->propertyName()); item = item->parent(); } while (item != this->rootItem && item != 0); } } return path; }
void Settings::setMostRecentFile(const QString &filePath) { QStringList currentList; currentList = getRecentFileList(); foreach(const QString &item, currentList) { if (item==filePath) { currentList.removeOne(item); break; } } currentList.push_front(filePath); settings.setValue("File/Recents", currentList); }