本文整理汇总了C++中QStringList::filter方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::filter方法的具体用法?C++ QStringList::filter怎么用?C++ QStringList::filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: opposite_color
QString opposite_color(QStringList list, int *error)
{
if(list.filter("blue").count() == 0)
{
return "blue";
}
else if(list.filter("red").count() == 0)
{
return "red";
}
else if(list.filter("green").count() == 0)
{
return "green";
}
else if(list.filter("white").count() == 0)
{
return "white";
}
else if(list.filter("orange").count() == 0)
{
return "orange";
}
else
{
//Incorrect color selection
*error = 11;
return "error";
}
}
示例2: traffic
QStringList CSite::traffic(quint16 &busy) const {
QStringList zeeiList = m_zeei.split("\n");
QStringList btsList = zeeiList.filter("BTS-");
busy = 0;
QStringList btss;
for (int i = 0; i < btsList.count(); i++) {
QStringList btsLine = btsList[i].split(" ");
btsLine.removeAll("");
QString state = btsLine[btsLine.indexOf(btsLine.filter("BTS-").first()) + 2];
if (state.contains("BL-")) {
btss << state;
continue;
}
QString fr = btsLine.takeLast();
QString hr = btsLine.takeLast();
quint8 btsBusy = fr.toUShort() + hr.toUShort();
if (!btsBusy)
btss << "EMPTY";
else if (i < m_caps.count() && btsBusy > m_caps[i] - BUSY_LIMIT)
btss << "FULL";
else
btss << QString::number(btsBusy);
busy += btsBusy;
}
return btss;
}
示例3: SaveSettings
//================
// PUBLIC SLOTS
//================
void page_fluxbox_settings::SaveSettings(){
QStringList FB;
if(ui->radio_simple->isChecked()){
FB = readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-init");
// - window placement
int index = FB.indexOf( FB.filter("session.screen0.windowPlacement:").join("") );
QString line = "session.screen0.windowPlacement:\t"+ui->combo_session_wloc->itemData( ui->combo_session_wloc->currentIndex() ).toString();
if(index < 0){ FB << line; } //add line to the end of the file
else{ FB[index] = line; } //replace the current setting with the new one
// - window focus
index = FB.indexOf( FB.filter("session.screen0.focusModel:").join("") );
line = "session.screen0.focusModel:\t"+ui->combo_session_wfocus->itemData( ui->combo_session_wfocus->currentIndex() ).toString();
if(index < 0){ FB << line; } //add line to the end of the file
else{ FB[index] = line; } //replace the current setting with the new one
// - window theme
index = FB.indexOf( FB.filter("session.styleFile:").join("") );
line = "session.styleFile:\t"+ui->combo_session_wtheme->itemData( ui->combo_session_wtheme->currentIndex() ).toString();
if(index < 0){ FB << line; } //add line to the end of the file
else{ FB[index] = line; } //replace the current setting with the new one
// - workspace number
index = FB.indexOf( FB.filter("session.screen0.workspaces:").join("") );
line = "session.screen0.workspaces:\t"+QString::number(ui->spin_session_wkspaces->value());
if(index < 0){ FB << line; } //add line to the end of the file
else{ FB[index] = line; } //replace the current setting with the new one
}else{
//advanced editor
FB = ui->text_file->toPlainText().split("\n");
}
//Save the fluxbox settings
bool ok = overwriteFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-init", FB);
if(!ok){ qDebug() << "Warning: Could not save fluxbox-init"; }
emit HasPendingChanges(false);
}
示例4: availableODBCDrivers
/**
* get MSSQL ODBC drivers name and version, every item such as:
* -------------------------------------------------------------
* 10.00/SQL Server Native Client 10.0
* 09.00/SQL Native Client
* 03.50/SQL Server
* -------------------------------------------------------------
* @author XChinux<[email protected]>
* @final 2013-04-18
* @return QStringList desc sorted ver/drivername lists
*/
QStringList TcMSSQL::availableODBCDrivers()
{
QStringList slDrivers;
#ifdef Q_OS_WIN
QSettings sts("HKEY_LOCAL_MACHINE\\SOFTWARE\\ODBC\\ODBCINST.INI"
"\\ODBC Drivers", QSettings::NativeFormat);
QStringList slKeys = sts.allKeys();
QStringList slKeys2;
slKeys2 << slKeys.filter("SQL Server") << slKeys.filter("Native Client");
slKeys2.removeDuplicates();
QStringListIterator it(slKeys2);
while (it.hasNext())
{
QString strV = it.next();
if (sts.value(strV).toString() == "Installed")
{
QSettings sts2("HKEY_LOCAL_MACHINE\\SOFTWARE\\ODBC\\ODBCINST.INI\\"
+ strV, QSettings::NativeFormat);
strV.prepend(sts2.value("DriverODBCVer").toString() + "/");
slDrivers << strV;
}
}
qSort(slDrivers.begin(), slDrivers.end(), qGreater<QString>());
#endif
return slDrivers;
}
示例5: detectDriver
gpu::driver gpu::detectDriver() {
QStringList out = globalStuff::grabSystemInfo("lsmod");
if (!out.filter("radeon").isEmpty())
return XORG;
if (!out.filter("fglrx").isEmpty())
return FGLRX;
return DRIVER_UNKNOWN;
}
示例6: disktypeInfo
QStringList Backend::disktypeInfo(QString node){
//Run disktype on the device and return any info
QStringList info = runShellCommand("disktype /dev/"+node);
//In case there are multiple partitions on the device, remove all the invalid ones (EFI boot partitions for instance)
QStringList parts = info.join("\n").split("\nPartition ");
//qDebug() << "DiskType Partitions:" << node << parts;
if(parts.filter("Volume name ").length()>0){
parts = parts.filter("Volume name ");
if(parts.length()>1 && parts.filter("file system").isEmpty()){ parts = parts.filter("file system"); }
}
for(int i=0; i<parts.length(); i++){
if(parts[i].contains("Partition GUID ") ){ parts.removeAt(i); i--; } //EFI boot partition
}
if(!parts.isEmpty()){
info = parts[0].split("\n"); //only use the first partition with both a label and a file system
}
//qDebug() << " - Filtered:" << info;
//qDebug() << "Disktype Detection:" << node;
QStringList dsDetection = DEVDB::disktypeDetectionStrings();
QString bytes, fs, type, label;
bool blankDisk=false;
for(int i=0; i<info.length(); i++){
//qDebug() << "Line:" << info[i];
if(info[i].isEmpty() || info[i].startsWith("---")){ continue; } //skip this line
else if( info[i].startsWith("Character device,") && !info[i].contains("unknown size") ){
//Get the size if possible
QString tmp = info[i].section("(",1,1).section(")",0,0);
if(tmp.contains("bytes")){ bytes = tmp.section(" ",0,0,QString::SectionSkipEmpty); }
//qDebug() << " - bytes:" << bytes;
}else if( info[i].contains("Blank disk/medium") ){
blankDisk = true;
//qDebug() << " - Blank disk";
}else if( info[i].contains("file system") ){
if(fs.isEmpty() || !fs.contains("(hints")){
QString tmp = info[i].section("file system",0,0);
for(int j=0; j<dsDetection.length(); j++){
if(tmp.contains(dsDetection[j].section("::::",0,0))){ fs = dsDetection[j].section("::::",1,1); break; }
}
}
//qDebug() << " - File System:" << fs;
}else if( info[i].contains("Volume name") ){
label = info[i].section("\"",1,1).section("\"",0,0).simplified(); //name is within quotes
//qDebug() << " - Label:" << label;
}
//stop if all info found (size is always the first to be found in info)
if(!fs.isEmpty() && !label.isEmpty()){ break; }
}
if( (blankDisk || (bytes.toInt()<2049) ) && (node.startsWith("cd") || node.startsWith("acd")) && label.isEmpty() && fs.isEmpty() ){ type = "CD-BLANK"; }
if( (node.startsWith("cd")||node.startsWith("acd")) && (bytes.isEmpty()) ){ type = "CD-NONE"; }
//Format the outputs
//qDebug() << "Results:" << fs << label << type;
return (QStringList() << fs << label << type);
}
示例7: updateSyntaxElementLabel
void PreferencesDialog::updateSyntaxElementLabel(QLabel* Label, const QStringList& Decorations,
const QString& ColorName)
{
QStringList Font = Decorations.filter(QRegExp("bold|italic"));
QStringList TextDecoration = Decorations.filter(QRegExp("underline|strike-through"));
QString Stylesheet = QString("QLabel {font: %1;text-decoration: %2;color: %3}")
.arg(Font.isEmpty() ? "none" : Font.join(" "))
.arg(TextDecoration.isEmpty() ? "none" : TextDecoration.join(" ").replace("strike-through","line-through"))
.arg(ColorName);
Label->setStyleSheet(Stylesheet);
Label->setProperty("ColorName",ColorName);
}
示例8: reloadConfiguration
void Firefox::reloadConfiguration()
{
KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), QLatin1String("General") );
if (QSqlDatabase::isDriverAvailable("QSQLITE")) {
KConfigGroup grp = config;
/* This allows the user to specify a profile database */
m_dbFile = grp.readEntry<QString>("dbfile", "");
if (m_dbFile.isEmpty() || QFile::exists(m_dbFile)) {
//Try to get the right database file, the default profile is used
KConfig firefoxProfile(QDir::homePath() + "/.mozilla/firefox/profiles.ini",
KConfig::SimpleConfig);
QStringList profilesList = firefoxProfile.groupList();
profilesList = profilesList.filter(QRegExp("^Profile\\d+$"));
int size = profilesList.size();
QString profilePath;
if (size == 1) {
// There is only 1 profile so we select it
KConfigGroup fGrp = firefoxProfile.group(profilesList.first());
profilePath = fGrp.readEntry("Path", "");
} else {
// There are multiple profiles, find the default one
foreach(const QString & profileName, profilesList) {
KConfigGroup fGrp = firefoxProfile.group(profileName);
if (fGrp.readEntry<int>("Default", 0)) {
profilePath = fGrp.readEntry("Path", "");
break;
}
}
}
示例9: findFunction
ScriptFunction ScriptParser::findFunction(QString functionName, int nbArgs, bool &ok)
{
QStringList functionNames = _functions.keys();
functionNames = functionNames.filter(functionName,Qt::CaseInsensitive);
if(functionNames.isEmpty())
{
ok = false;
return ScriptFunction(QString(),QStringList());
}
else
{
ScriptFunction function = _functions.value(functionNames.first());
if(nbArgs==function.args.size())
{
ok = true;
return function;
}
else
{
ok = false;
return ScriptFunction(QString(),QStringList());
}
}
}
示例10: dataDirFileList
QStringList DiskUtil::dataDirFileList(const QString &subdirectory) {
QDir dir(DiskUtil::dataDir() + subdirectory);
QStringList entries = dir.entryList(QDir::Files);
return entries.filter(QRegExp("^[^.].*$")); // extra filter to remove files starting
// with a dot on Windows
}
示例11: setEditable
void QtVCardPhotoAndNameFields::setEditable(bool editable) {
this->editable = editable;
ui->avatarWidget->setEditable(editable);
ui->lineEditFN->setVisible(editable);
ui->labelFN->setVisible(!editable);
ui->lineEditNICKNAME->setVisible(editable);
ui->labelNICKNAME->setVisible(!editable);
// prefix given middle last suffix
ui->lineEditPREFIX->setVisible(editable);
ui->lineEditGIVEN->setVisible(editable);
ui->lineEditMIDDLE->setVisible(editable);
ui->lineEditFAMILY->setVisible(editable);
ui->lineEditSUFFIX->setVisible(editable);
ui->labelFULLNAME->setVisible(!editable);
QStringList fullname;
fullname << ui->lineEditPREFIX->text() << ui->lineEditGIVEN->text() << ui->lineEditMIDDLE->text();
fullname << ui->lineEditFAMILY->text() << ui->lineEditSUFFIX->text();
for (QStringList::iterator i = fullname.begin(); i != fullname.end(); i++) {
*i = i->trimmed();
}
ui->labelFULLNAME->setText((fullname.filter(QRegExp(".+"))).join(" "));
}
示例12: operator
CommandResult_t operator() (const UrlComposite& rx) const
{
QStringList urls;
try
{
urls = boost::apply_visitor (RxableRangesVisitor { AzothProxy_, Entry_ }, rx.Range_);
}
catch (const StringCommandResult& res)
{
return res;
}
if (rx.Pat_)
urls = urls.filter (QRegExp { QString::fromStdString (*rx.Pat_) });
for (const auto& url : urls)
{
if (url.isEmpty ())
continue;
const auto& entity = Util::MakeEntity (QUrl::fromEncoded (url.toUtf8 ()),
{},
Params_ | FromUserInitiated);
IEM_->HandleEntity (entity);
}
return true;
}
示例13: statFile
/**
* @fn childrenPids
*/
QList<Q_PID> QueuedProcess::childrenPids() const
{
QStringList allDirectories
= QDir("/proc").entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
QStringList directories = allDirectories.filter(QRegExp("(\\d+)"));
QList<Q_PID> pids
= std::accumulate(directories.cbegin(), directories.cend(), QList<Q_PID>(),
[this](QList<Q_PID> &list, const QString &dir) {
QFile statFile(QString("/proc/%1/stat").arg(dir));
if (!statFile.open(QIODevice::ReadOnly | QIODevice::Text))
return list;
QString output = statFile.readAll();
output.remove(QRegExp("\\d+ \\(.*\\) . "));
Q_PID ppid = output.split(' ').first().toLongLong();
if (ppid == pid())
list.append(dir.toLongLong());
statFile.close();
return list;
});
return pids;
}
示例14: on_filterText_textChanged
void MainWindow::on_filterText_textChanged(const QString & text)
{
QMapIterator<QString, QStringList> it(m_extMap);
//
// Build extension tree (eventually apply a filter)
//
while (it.hasNext()) {
it.next();
QString key = it.key();
QStringList valueList = it.value();
if (text!="") {
valueList = valueList.filter(text, Qt::CaseInsensitive);
}
if (!valueList.empty()) {
QTreeWidgetItem * corpItem = new QTreeWidgetItem(m_ui->extensionsTree);
corpItem->setText(0, key + " ("+QString::number(valueList.count())+")");
QStringListIterator it(valueList);
while (it.hasNext()) {
QTreeWidgetItem * child = new QTreeWidgetItem(corpItem);
child->setText(0, it.next());
}
}
}
if(text!="") {
m_ui->extensionsTree->expandAll();
}
}
示例15: read_mtab
void RootMount::read_mtab()
{
p->hash.clear();
QProcess process;
process.start( "mount" );
process.waitForFinished();
QStringList output = QString(process.readAll()).split("\n");
QRegExp reg;
reg.setPattern( "^(/.*)\\son\\s(/.*)\\stype\\siso\\S*\\s\\(ro\\)" );
output = output.filter( reg );
for( int i=0 ; i<output.count() ; i++ )
{
QString str = output.at(i);
int pos;
pos = reg.indexIn( str );
if( pos == -1 )
continue;
p->hash.insert( reg.cap(1) , reg.cap(2) );
}
}