Beispiel #1
0
void KateFindInFilesOptions::save(KConfigGroup& config)
{
  if (this != &self()) {
    self().save(config);
    return;
  }

  // first remove duplicates, as setDuplicatesEnabled does not work for QComboBox with Model
  // further, limit count of entries to 15. then save
  QStringList stringList = m_searchItems.stringList();
  stringList.removeDuplicates();
  if (stringList.count() > 15)
    stringList.erase(stringList.begin() + 15, stringList.end());
  config.writeEntry("LastSearchItems", stringList);
  
  stringList = m_searchPaths.stringList();
  stringList.removeDuplicates();
  if (stringList.count() > 15)
    stringList.erase(stringList.begin() + 15, stringList.end());
  config.writeEntry("LastSearchPaths", stringList);

  stringList = m_searchFilters.stringList();
  stringList.removeDuplicates();
  if (stringList.count() > 15)
    stringList.erase(stringList.begin() + 15, stringList.end());
  config.writeEntry("LastSearchFiles", stringList);


  config.writeEntry("Recursive", m_recursive);
  config.writeEntry("CaseSensitive", m_casesensitive);
  config.writeEntry("RegExp", m_regexp);
  config.writeEntry("FollowDirectorySymlinks", m_followDirectorySymlinks);
  config.writeEntry("IncludeHiddenFiles", m_includeHiddenFiles);
}
Beispiel #2
0
QByteArray combinePath(const char *infile, const char *outfile)
{
    QFileInfo inFileInfo(QDir::current(), QFile::decodeName(infile));
    QFileInfo outFileInfo(QDir::current(), QFile::decodeName(outfile));
    int numCommonComponents = 0;

    QStringList inSplitted = inFileInfo.dir().canonicalPath().split(QLatin1Char('/'));
    QStringList outSplitted = outFileInfo.dir().canonicalPath().split(QLatin1Char('/'));

    while (!inSplitted.isEmpty() && !outSplitted.isEmpty() &&
            inSplitted.first() == outSplitted.first()) {
        inSplitted.erase(inSplitted.begin());
        outSplitted.erase(outSplitted.begin());
        numCommonComponents++;
    }

    if (numCommonComponents < 2) {
        /*
          The paths don't have the same drive, or they don't have the
          same root directory. Use an absolute path.
        */
        return QFile::encodeName(inFileInfo.absoluteFilePath());
    } else {
        /*
          The paths have something in common. Use a path relative to
          the output file.
        */
        while (!outSplitted.isEmpty()) {
            outSplitted.erase(outSplitted.begin());
            inSplitted.prepend(QLatin1String(".."));
        }
        inSplitted.append(inFileInfo.fileName());
        return QFile::encodeName(inSplitted.join(QLatin1String("/")));
    }
}
Beispiel #3
0
QString PrePost::expandAliases(const QString& from, const QString& msg) {
    int pos = msg.indexOf(' ');
    QString word = (pos != -1)?msg.left(pos):msg;
    QStringList args;
    if(pos != -1)
        args = msg.right(msg.length() - pos - 1).split(' ',QString::SkipEmptyParts);
    QStringList largs;
    for(AliasMap::Iterator it = alias[from].begin(); it != alias[from].end(); ++it) {
        if(it.key() == word) {
            QString tmp = *it;
            QString res;
            int i = 0;
            while((i = tmp.indexOf('$')) != -1) {
                res += tmp.left(i);
                tmp.remove(0,i);
                if(tmp.startsWith("$$")) {
                    res += "$";
                    tmp.remove(0,2);
                } else if (tmp.startsWith("$*")) {
                    res += args.join(" ");
                    tmp.remove(0,2);
                } else if (tmp.startsWith("$n")) {
                    res += "\n";
                    tmp.remove(0,2);
                } else if (tmp.startsWith("$+")) {
                    if(args.begin() != args.end()) {
                        largs << *(args.begin());
                        args.erase(args.begin());
                    }
                    tmp.remove(0,2);
                } else if (tmp.startsWith("$-")) {
                    if(largs.begin() != largs.end()) {
                        QStringList::Iterator p = --largs.end();
                        args.prepend(*p);
                        largs.erase(p);
                    }
                    tmp.remove(0,2);
                } else {
                    QRegExp re("^\\$(\\d).*");
                    if(re.exactMatch(tmp)) {
                        int number = re.cap(1).toInt();
                        res += args[number-1];
                        tmp.remove(0,2);
                    } else {
                        QString error("Wrong argument : \"" + tmp.left(2) + "\"");
                        manager()->connectionPlugin()->serverSend(from,error);
                        return "";
                    }
                }
            }
            res += tmp;
            return res;
        }
    }

    return msg;
}
Beispiel #4
0
void Connector::setConnected(bool state)
{
  QStringList args;
  QString cmd;

  if(conn_connected!=state) {
    if(!conn_is_stopping) {
      if(state) {
	if(conn_script_up_process==NULL) {
	  if(!conn_script_up.isEmpty()) {
	    args=conn_script_up.split(" ");
	    cmd=args[0];
	    args.erase(args.begin());
	    conn_script_up_process=new QProcess(this);
	    connect(conn_script_up_process,
		    SIGNAL(error(QProcess::ProcessError)),
		    this,SLOT(scriptErrorData(QProcess::ProcessError)));
	    connect(conn_script_up_process,
		    SIGNAL(finished(int,QProcess::ExitStatus)),
		    this,SLOT(scriptUpFinishedData(int,QProcess::ExitStatus)));
	    conn_script_up_process->start(cmd,args);
	  }
	}
	else {
	  if(global_log_verbose) {
	    Log(LOG_WARNING,"curl(1) script-up command overrun, cmd: \""+
		args.join(" ")+"\"");
	  }
	  else {
	    Log(LOG_WARNING,"curl(1) command overrun");
	  }
	}
      }
      else {
	if(conn_script_down_process==NULL) {
Beispiel #5
0
void Msg::clearmsgCmd(const QString& from, const QStringList& list) {
	if(list[0] == "") { // no arg
	    QFile f(manager()->dataDir() + "/msg/" + from);
	    f.remove();
	    QString txt("You clear your messages");
        manager()->connectionPlugin()->serverSend(from,txt);
	}
	else {
	    if (list[0].toInt() < 1) {
            manager()->connectionPlugin()->serverSend(from, "Parameter(s) must be greater than 0!");
            return;
	    }

	    int start = list[0].toInt() - 1;
	    int stop = (list[1] == "")?(start+1):(list[1].toInt());

	    QFile f(manager()->dataDir() + "/msg/" + from);
	    if (!f.open(QIODevice::ReadOnly)) {
            octInfo("Could not read message file\n");
            return;
	    }

	    QTextStream stream(&f);
	    QString line;
	    QStringList l;
	    while((line = stream.readLine()) != QString::null) l << line;
	    f.close();

	    if (start >= l.count()) {
            manager()->connectionPlugin()->serverSend(from, "Too large(s) parameter(s)!");
            return;
	    }
	    if (stop > l.count())
            stop = l.count();

	    l.erase(l.begin() + start, l.begin() + stop);

	    if (l.count()) {
            if (!f.open(QIODevice::WriteOnly)) {
                octInfo("Could not write message file.\n");
                return;
            }

            QTextStream stream2(&f);
            for(QStringList::Iterator it = l.begin(); it != l.end(); ++it)
                stream2 << (*it + "\n");
            f.close();
	    } else
            f.remove();

	    QString txt("You clear message");

	    if (start + 1  == stop)
            txt += " " + QString::number(stop);
	    else
            txt += "s " + QString::number(start+1) + " to " + QString::number(stop);

        manager()->connectionPlugin()->serverSend(from,txt);
	}
}
void QrcEditor::resolveLocationIssues(QStringList &files)
{
    const QDir dir = QFileInfo(m_treeview->fileName()).absoluteDir();
    const QString dotdotSlash = QLatin1String("../");
    int i = 0;
    const int count = files.count();
    const int initialCount = files.count();

    // Find first troublesome file
    for (; i < count; i++) {
        QString const &file = files.at(i);
        const QString relativePath = dir.relativeFilePath(file);
        if (relativePath.startsWith(dotdotSlash))
            break;
    }

    // All paths fine -> no interaction needed
    if (i == count) {
        return;
    }

    // Interact with user from now on
    ResolveLocationContext context;
    bool abort = false;
    for (QStringList::iterator it = files.begin(); it != files.end(); ) {
        // Path fine -> skip file
        QString const &file = *it;
        QString const relativePath = dir.relativeFilePath(file);
        if (!relativePath.startsWith(dotdotSlash)) {
            continue;
        }
        // Path troublesome and aborted -> remove file
        bool ok = false;
        if (!abort) {
            // Path troublesome -> query user "Do you want copy/abort/skip".
            QAbstractButton *clickedButton = context.execLocationMessageBox(this, file, initialCount > 1);
            if (clickedButton == context.copyButton) {
                const QFileInfo fi(file);
                QFileInfo suggestion;
                QDir tmpTarget(dir.path() + QString(QDir::separator()) + QString("Resources"));;
                if (tmpTarget.exists())
                    suggestion.setFile(tmpTarget, fi.fileName());
                else
                    suggestion.setFile(dir, fi.fileName());
                // Prompt for copy location, copy and replace name.
                const QString copyName = context.execCopyFileDialog(this, dir, suggestion.absoluteFilePath());
                ok = !copyName.isEmpty() && copyFile(file, copyName, this);
                if (ok)
                    *it = copyName;
            } else if (clickedButton == context.abortButton) {
                abort = true;
            }
        } // !abort
        if (ok) { // Remove files where user canceled or failures occurred.
            ++it;
        } else {
            it = files.erase(it);
        }
    } // for files
}
Beispiel #7
0
void ThemesDlg::saveUserAddedThemes()
{
    KStandardDirs ksd;
    QStringList t = themes();
    QStringList dirs = ksd.findDirs("data", QString(kapp->objectName()) + "/themes");
    QStringList::Iterator it = t.begin();
    bool remove;

    while (it != t.end()) {
        remove = false;
        QStringList::Iterator jtend(dirs.end());
        for (QStringList::Iterator jt = dirs.begin(); jt != jtend; ++jt) {
            if (QString(QFileInfo(*it).dir().path() + '/') == *jt) {
                remove = true;
                break;
            }
        }
        if (remove)
            it = t.erase(it);
        else
            ++it;
    }
    SuperKarambaSettings::setUserAddedThemes(t);
    SuperKarambaSettings::self()->writeConfig();
}
// Main Command processing function
void cCommands::process( cUOSocket *socket, const QString &command )
{
	if( !socket->player() )
		return;

	P_PLAYER pChar = socket->player();
	QStringList pArgs = QStringList::split( " ", command, true );

	// No Command? No Processing
	if( pArgs.isEmpty() )
		return;

	QString pCommand = pArgs[0].upper(); // First element should be the command

	// Remove it from the argument list
	pArgs.erase( pArgs.begin() );

	// Check if the priviledges are ok
	if( !pChar->account()->authorized("command", pCommand.latin1() ))
	{
		socket->sysMessage( tr( "Access to command '%1' was denied" ).arg( pCommand.lower() ) );
		socket->log( QString("Access to command '%1' was denied\n").arg(pCommand.lower()) );
		return;
	}

	// Dispatch the command
	if ( dispatch( socket, pCommand, pArgs ) )
		socket->log( QString( "Used command '%1'.\n" ).arg( command ) );
}
QStringList QMacSettingsPrivate::children(const QString &prefix, ChildSpec spec) const
{
    QStringList result;
    int startPos = prefix.size();

    for (int i = 0; i < numDomains; ++i) {
        for (int j = 0; j < numHostNames; ++j) {
            QCFType<CFArrayRef> cfarray = CFPreferencesCopyKeyList(domains[i].applicationOrSuiteId,
                                                                   domains[i].userName,
                                                                   hostNames[j]);
            if (cfarray) {
                CFIndex size = CFArrayGetCount(cfarray);
                for (CFIndex k = 0; k < size; ++k) {
                    QString currentKey =
                            qtKey(static_cast<CFStringRef>(CFArrayGetValueAtIndex(cfarray, k)));
                    if (currentKey.startsWith(prefix))
                        processChild(currentKey.midRef(startPos), spec, result);
                }
            }
        }

        if (!fallbacks)
            break;
    }
    std::sort(result.begin(), result.end());
    result.erase(std::unique(result.begin(), result.end()),
                 result.end());
    return result;
}
Beispiel #10
0
/*!
    Returns the list of classes of this element.
*/
QStringList QWebElement::classes() const
{
    if (!hasAttribute(QLatin1String("class")))
        return QStringList();

    QStringList classes =  attribute(QLatin1String("class")).simplified().split(QLatin1Char(' '), QString::SkipEmptyParts);
#if QT_VERSION >= 0x040500
    classes.removeDuplicates();
#else
    int n = classes.size();
    int j = 0;
    QSet<QString> seen;
    seen.reserve(n);
    for (int i = 0; i < n; ++i) {
        const QString& s = classes.at(i);
        if (seen.contains(s))
            continue;
        seen.insert(s);
        if (j != i)
            classes[j] = s;
        ++j;
    }
    if (n != j)
        classes.erase(classes.begin() + j, classes.end());
#endif
    return classes;
}
QString DiffEditorController::prepareBranchesForCommit(const QString &output)
{
    // TODO: More git-specific code...
    QString moreBranches;
    QString branches;
    QStringList res;
    foreach (const QString &branch, output.split(QLatin1Char('\n'))) {
        const QString b = branch.mid(2).trimmed();
        if (!b.isEmpty())
            res << b;
    }
    const int branchCount = res.count();
    // If there are more than 20 branches, list first 10 followed by a hint
    if (branchCount > 20) {
        const int leave = 10;
        //: Displayed after the untranslated message "Branches: branch1, branch2 'and %n more'"
        //  in git show.
        moreBranches = QLatin1Char(' ') + tr("and %n more", 0, branchCount - leave);
        res.erase(res.begin() + leave, res.end());
    }
    branches = QLatin1String("Branches: ");
    if (res.isEmpty())
        branches += tr("<None>");
    else
        branches += res.join(QLatin1String(", ")) + moreBranches;

    return branches;
}
void NimCompilerBuildStep::updateArguments()
{
    auto bc = qobject_cast<NimBuildConfiguration *>(buildConfiguration());
    QTC_ASSERT(bc, return);

    QStringList arguments;
    arguments << QStringLiteral("c");

    switch (m_defaultOptions) {
    case Release:
        arguments << QStringLiteral("-d:release");
        break;
    case Debug:
        arguments << QStringLiteral("--debugInfo")
                  << QStringLiteral("--lineDir:on");
        break;
    default:
        break;
    }

    arguments << QStringLiteral("--out:%1").arg(m_outFilePath.toString());
    arguments << QStringLiteral("--nimCache:%1").arg(bc->cacheDirectory().toString());

    arguments << m_userCompilerOptions;
    arguments << m_targetNimFile.toString();

    // Remove empty args
    auto predicate = [](const QString &str) { return str.isEmpty(); };
    auto it = std::remove_if(arguments.begin(), arguments.end(), predicate);
    arguments.erase(it, arguments.end());

    processParameters()->setArguments(arguments.join(QChar::Space));
}
QtUiApplication::QtUiApplication(int &argc, char **argv)
#ifdef HAVE_KDE4
    : KApplication(),  // KApplication is deprecated in KF5
#else
    : QApplication(argc, argv),
#endif
    Quassel(),
    _aboutToQuit(false)
{
#ifdef HAVE_KDE4
    Q_UNUSED(argc); Q_UNUSED(argv);

    // Setup KDE's data dirs
    // Because we can't use KDE stuff in (the class) Quassel directly, we need to do this here...
    QStringList dataDirs = KGlobal::dirs()->findDirs("data", "");

    // Just in case, also check our install prefix
    dataDirs << QCoreApplication::applicationDirPath() + "/../share/apps/";

    // Normalize and append our application name
    for (int i = 0; i < dataDirs.count(); i++)
        dataDirs[i] = QDir::cleanPath(dataDirs.at(i)) + "/quassel/";

    // Add resource path and just in case.
    // Workdir should have precedence
    dataDirs.prepend(QCoreApplication::applicationDirPath() + "/data/");
    dataDirs.append(":/data/");

    // Append trailing '/' and check for existence
    auto iter = dataDirs.begin();
    while (iter != dataDirs.end()) {
        if (!iter->endsWith(QDir::separator()) && !iter->endsWith('/'))
            iter->append(QDir::separator());
        if (!QFile::exists(*iter))
            iter = dataDirs.erase(iter);
        else
            ++iter;
    }

    dataDirs.removeDuplicates();
    setDataDirPaths(dataDirs);

#else /* HAVE_KDE4 */

    setDataDirPaths(findDataDirPaths());

#endif /* HAVE_KDE4 */

#if defined(HAVE_KDE4) || defined(Q_OS_MAC)
    disableCrashhandler();
#endif /* HAVE_KDE4 || Q_OS_MAC */
    setRunMode(Quassel::ClientOnly);

#if QT_VERSION < 0x050000
    qInstallMsgHandler(Client::logMessage);
#else
    qInstallMessageHandler(Client::logMessage);
#endif
}
Beispiel #14
0
bool
DropJob::validateLocalFiles(const QString &paths, const QString &suffix)
{
    QStringList filePaths = paths.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
    for ( QStringList::iterator it = filePaths.begin(); it != filePaths.end(); ++it )
        if ( !validateLocalFile( *it, suffix ) )
            filePaths.erase( it );
    return !filePaths.isEmpty();
}
Beispiel #15
0
    : QApplication(argc, argv)
#endif
{
#ifdef HAVE_KDE4
    Q_UNUSED(argc); Q_UNUSED(argv);

    // Setup KDE's data dirs
    // Because we can't use KDE stuff in (the class) Quassel directly, we need to do this here...
    QStringList dataDirs = KGlobal::dirs()->findDirs("data", "");

    // Just in case, also check our install prefix
    dataDirs << QCoreApplication::applicationDirPath() + "/../share/apps/";

    // Normalize and append our application name
    for (int i = 0; i < dataDirs.count(); i++)
        dataDirs[i] = QDir::cleanPath(dataDirs.at(i)) + "/quassel/";

    // Add resource path and just in case.
    // Workdir should have precedence
    dataDirs.prepend(QCoreApplication::applicationDirPath() + "/data/");
    dataDirs.append(":/data/");

    // Append trailing '/' and check for existence
    auto iter = dataDirs.begin();
    while (iter != dataDirs.end()) {
        if (!iter->endsWith(QDir::separator()) && !iter->endsWith('/'))
            iter->append(QDir::separator());
        if (!QFile::exists(*iter))
            iter = dataDirs.erase(iter);
        else
            ++iter;
    }

    dataDirs.removeDuplicates();
    Quassel::setDataDirPaths(dataDirs);

#else /* HAVE_KDE4 */

    Quassel::setDataDirPaths(Quassel::findDataDirPaths());

#endif /* HAVE_KDE4 */

#if defined(HAVE_KDE4) || defined(Q_OS_MAC)
    Quassel::disableCrashHandler();
#endif /* HAVE_KDE4 || Q_OS_MAC */

    Quassel::setRunMode(Quassel::ClientOnly);

#if QT_VERSION >= 0x050000
    connect(this, &QGuiApplication::commitDataRequest, this, &QtUiApplication::commitData, Qt::DirectConnection);
    connect(this, &QGuiApplication::saveStateRequest, this, &QtUiApplication::saveState, Qt::DirectConnection);
#endif

#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
    QGuiApplication::setFallbackSessionManagementEnabled(false);
#endif
}
void DolphinRemoteEncoding::slotDefault()
{
    // We have no choice but delete all higher domain level
    // settings here since it affects what will be matched.
    KConfig config(("kio_" + m_currentURL.scheme() + "rc").toLatin1());

    QStringList partList = m_currentURL.host().split('.', QString::SkipEmptyParts);
    if (!partList.isEmpty()) {
        partList.erase(partList.begin());

        QStringList domains;
        // Remove the exact name match...
        domains << m_currentURL.host();

        while (!partList.isEmpty()) {
            if (partList.count() == 2) {
                if (partList[0].length() <= 2 && partList[1].length() == 2) {
                    break;
                }
            }

            if (partList.count() == 1) {
                break;
            }

            domains << partList.join(".");
            partList.erase(partList.begin());
        }

        for (QStringList::const_iterator it = domains.constBegin(); it != domains.constEnd();++it) {
            qCDebug(DolphinDebug) << "Domain to remove: " << *it;
            if (config.hasGroup(*it)) {
                config.deleteGroup(*it);
            } else if (config.group("").hasKey(*it)) {
                config.group("").deleteEntry(*it); //don't know what group name is supposed to be XXX
            }
        }
    }
    config.sync();

    // Update the io-slaves.
    updateView();
}
Beispiel #17
0
QString Mailbox::path() const
{
    QStringList list = _name.split(delimiter);
    list.erase( list.end() );
    QString str = list.join(delimiter);
    if ( !str.isEmpty() )
        str += delimiter;

    return str;
}
Beispiel #18
0
QStringList
ProjectPackager::getAudioFiles()
{
    QStringList list;

    // get the Composition from the document, so we can iterate through it
    Composition *comp = &m_doc->getComposition();

    // We don't particularly care about tracks here, so just iterate through the
    // entire Composition to find the audio segments and get the associated
    // file IDs from which to obtain a list of actual files.  This could
    // conceivably pick up audio segments that are residing on MIDI tracks and
    // wouldn't otherwise be functional, but the important thing is to never
    // miss a single file that has any chance of being worth preserving.
    for (Composition::iterator i = comp->begin(); i != comp->end(); ++i) {
        if ((*i)->getType() == Segment::Audio) {

            AudioFileManager *manager = &m_doc->getAudioFileManager();

            unsigned int id = (*i)->getAudioFileId();

            AudioFile *file = manager->getAudioFile(id);

            // some polite sanity checking to avoid possible crashes
            if (!file) continue;

            list << file->getFilename();
        }
    }

    // QStringList::removeDuplicates() would have been easy, but it's only in Qt
    // 4.5.0 and up.  So here's the algorithm from Qt 4.5.0, courtesy of (and
    // originally Copyright 2009) Nokia

    QStringList *that = &list;

    int n = that->size();
    int j = 0;
    QSet<QString> seen;
    seen.reserve(n);
    for (int i = 0; i < n; ++i) {
        const QString &s = that->at(i);
        if (seen.contains(s))
            continue;
        seen.insert(s);
        if (j != i)
            (*that)[j] = s;
        ++j;
    }
    if (n != j)
        that->erase(that->begin() + j, that->end());
//    return n - j;

    return list;
}
static QString takeProgIdArgument(QStringList &args)
{
    // if the arguments contain an option in the form "ProgId=...", find it and consume it
    QStringList::iterator it = std::find_if (args.begin(), args.end(), StartsWithProgId());
    if (it == args.end())
        return QString();

    const QString progId = it->mid(QString::fromLatin1("ProgId=").size());
    args.erase(it);
    return progId;
}
Beispiel #20
0
void DebuggerConsoleView::trimList(QStringList& l, int max_size)
{
    int length = l.count();
    if (length > max_size)
    {
        for(int to_delete = length - max_size; to_delete; --to_delete)
        {
            l.erase(l.begin());
        }
    }
}
Beispiel #21
0
QString GwtCallback::getFixedWidthFontList()
{
   QFontDatabase db;
   QStringList families = db.families();

   QStringList::iterator it = std::remove_if(
            families.begin(), families.end(), isProportionalFont);
   families.erase(it, families.end());

   return families.join(QString::fromUtf8("\n"));
}
Beispiel #22
0
void GDBOutputWidget::trimList(QStringList& l, int max_size)
{
    int length = l.count();
    if (length > max_size)
    {
        for(int to_delete = length - max_size; to_delete; --to_delete)
        {
            l.erase(l.begin());
        }
    }
}
Beispiel #23
0
int startProcess(const QString &cmd)
{
   QStringList args = cmd.split(" ", QString::SkipEmptyParts);
   if( args.count() <= 0 )
      return 0;
   QString app = args[0];
   args.erase(args.begin());
   qint64 pid = 0;
   qDebug() << "Starting app" << app << "with params" << args.join("\" \"");
   QProcess::startDetached(app, args, QString(), &pid);
   qDebug() << "pid: " << pid;
   return pid;
}
void OpenDialog::accept()
{
   int maxNofRecentFiles = 10;
   fixCurrentText( m_pLineA );

   QString s = m_pLineA->currentText();
   s = QUrl::fromLocalFile(s).toLocalFile();
   QStringList* sl = &m_pOptions->m_recentAFiles;
   // If an item exist, remove it from the list and reinsert it at the beginning.
   sl->removeAll(s);
   if ( !s.isEmpty() ) sl->prepend( s );
   if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() );

   fixCurrentText( m_pLineB );
   s = m_pLineB->currentText();
   s = QUrl::fromLocalFile(s).toLocalFile();
   sl = &m_pOptions->m_recentBFiles;
   sl->removeAll(s);
   if ( !s.isEmpty() ) sl->prepend( s );
   if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() );

   fixCurrentText( m_pLineC );
   s = m_pLineC->currentText();
   s = QUrl::fromLocalFile(s).toLocalFile();
   sl = &m_pOptions->m_recentCFiles;
   sl->removeAll(s);
   if ( !s.isEmpty() ) sl->prepend( s );
   if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() );

   fixCurrentText( m_pLineOut );
   s = m_pLineOut->currentText();
   s = QUrl::fromLocalFile(s).toLocalFile();
   sl = &m_pOptions->m_recentOutputFiles;
   sl->removeAll(s);
   if ( !s.isEmpty() ) sl->prepend( s );
   if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() );

   QDialog::accept();
}
Beispiel #25
0
WeatherGlobal::WeatherGlobal()
{
	QStringList serverList = QStringList::split(";", config_file.readEntry("Weather", "Servers"));
	QStringList serversUsing = QStringList::split(";", config_file.readEntry("Weather", "ServersUsing"));

	QDir dir(dataPath(WeatherConfigPath), "*.ini");
	dir.setFilter(QDir::Files);

	QStringList iniFiles;
	for (unsigned int i = 0; i < dir.count(); ++i)
		iniFiles.append(dir[i]);

	// Remove non-existent files from the server list
	//
	for (unsigned int i = 0; i < serverList.count(); ++i)
	{
		QStringList::iterator file = iniFiles.find(serverList[i]);
		if (file == iniFiles.end())
		{
			serverList.removeAt(i);
			serversUsing.removeAt(i);
		}
		else
			iniFiles.erase(file);
	}

	// Add new files to the server list
	//
	serverList += iniFiles;
	for (unsigned int i = 0; i < iniFiles.count(); ++i)
		serversUsing.append("1");

	// Load server configs and initialize server list
	//
	for (unsigned int i = 0; i < serverList.count(); ++i)
	{
		PlainConfigFile wConfig(getConfigPath(serverList[i]));
		servers_.append(Server(wConfig.readEntry("Header","Name"), serverList[i], serversUsing[i] == "1"));
	}

	// Load recent locations search list
	//
	for (unsigned int i = 0; i < RECENT_LOCATIONS_COUNT; i++)
	{
		QString city = config_file.readEntry("Weather", QString("Location%1").arg(i + 1));
		if (!city.isEmpty() && !recentLocations_.contains(city))
			recentLocations_.push_back(city);
	}

}
Beispiel #26
0
Handle(Standard_Type) Subassembly::lookupType ( QStringList& path_components ) const
{
  // The front path component is the name of a figure with ".type" appended
  // to it.
  int dot_pos = path_components.front().lastIndexOf( '.' );
  QString name = path_components.front().left( dot_pos );
  QString type = path_components.front().right( path_components.front().length()
						- dot_pos - 1 );

  if ( subassembly_->name() == name && subassembly_->type() == type ) {
    path_components.erase( path_components.begin() );
    return subassembly_->lookupType( path_components );
  }

  return Handle(Standard_Type)();
}
QStringList MainWindow::getPrompt()
{
    QStringList returnPrompts;
    QStringList copiedPrompts;
    for (QString c : prompts)
    {
        copiedPrompts.push_back(c);
    }
    for (int i = 0; i < 3; ++i)
    {
        int pindex = rand() % copiedPrompts.size();
        returnPrompts.append(copiedPrompts.at(pindex));
        copiedPrompts.erase(copiedPrompts.begin() + pindex);
    }
    return returnPrompts;
}
void commandSet( cUOSocket *socket, const QString &command, QStringList &args ) throw()
{
	Q_UNUSED(command);
	if( args.size() < 1 )
	{
		socket->sysMessage( "Usage: set <key> <value>" );
		return;
	}	

    QString key = args[0];
	args.erase( args.begin() );
    QString value = args.join( " " );

	socket->sysMessage( tr( "Please select a target to 'set %1 %2' " ).arg( key ).arg( value ) );
	socket->attachTarget( new cSetTarget( key, value ) );
}
Beispiel #29
0
void VideoScannerThread::SetDirs(QStringList dirs)
{
    QString master = gCoreContext->GetMasterHostName().toLower();
    QStringList searchhosts, mdirs;
    m_offlineSGHosts.clear();

    QStringList::iterator iter = dirs.begin(), iter2;
    while ( iter != dirs.end() )
    {
        if (iter->startsWith("myth://"))
        {
            QUrl sgurl = *iter;
            QString host = sgurl.host().toLower();
            QString path = sgurl.path();

            if (!m_liveSGHosts.contains(host))
            {
                // mark host as offline to warn user
                if (!m_offlineSGHosts.contains(host))
                    m_offlineSGHosts.append(host);
                // erase from directory list to skip scanning
                iter = dirs.erase(iter);
                continue;
            }
            else if ((host == master) &&  (!mdirs.contains(path)))
                // collect paths defined on master backend so other
                // online backends can be set to fall through to them
                mdirs.append(path);
            else if (!searchhosts.contains(host))
                // mark host as having directories defined so it
                // does not fall through to those on the master
                searchhosts.append(host);
        }

        ++iter;
    }

    for (iter = m_liveSGHosts.begin(); iter != m_liveSGHosts.end(); ++iter)
        if ((!searchhosts.contains(*iter)) && (master != *iter))
            for (iter2 = mdirs.begin(); iter2 != mdirs.end(); ++iter2)
                // backend is online, but has no directories listed
                // fall back to those on the master backend
                dirs.append(gCoreContext->GenMythURL(*iter,
                                            0, *iter2, "Videos"));

    m_directories = dirs;
}
Beispiel #30
0
void KrView::initProperties()
{
    _properties = createViewProperties();

    KConfigGroup grpSvr(_config, "Look&Feel");
    KConfigGroup grpInstance(_config, _instance.name());

    _properties->displayIcons = grpInstance.readEntry("With Icons", _WithIcons);
    _properties->numericPermissions = grpSvr.readEntry("Numeric permissions", _NumericPermissions);

    int sortOptions = _properties->sortOptions;
    if (grpSvr.readEntry("Show Directories First", true))
        sortOptions |= KrViewProperties::DirsFirst;
    if(grpSvr.readEntry("Always sort dirs by name", false))
        sortOptions |=  KrViewProperties::AlwaysSortDirsByName;
    if (!grpSvr.readEntry("Case Sensative Sort", _CaseSensativeSort))
        sortOptions |= KrViewProperties::IgnoreCase;
    if (grpSvr.readEntry("Locale Aware Sort", true))
        sortOptions |= KrViewProperties::LocaleAwareSort;
    _properties->sortOptions = static_cast<KrViewProperties::SortOptions>(sortOptions);

    _properties->sortMethod = static_cast<KrViewProperties::SortMethod>(
                                  grpSvr.readEntry("Sort method", (int) _DefaultSortMethod));
    _properties->humanReadableSize = grpSvr.readEntry("Human Readable Size", _HumanReadableSize);

    _properties->localeAwareCompareIsCaseSensitive = QString("a").localeAwareCompare("B") > 0;     // see KDE bug #40131
    QStringList defaultAtomicExtensions;
    defaultAtomicExtensions += ".tar.gz";
    defaultAtomicExtensions += ".tar.bz2";
    defaultAtomicExtensions += ".tar.lzma";
    defaultAtomicExtensions += ".tar.xz";
    defaultAtomicExtensions += ".moc.cpp";
    QStringList atomicExtensions = grpSvr.readEntry("Atomic Extensions", defaultAtomicExtensions);
    for (QStringList::iterator i = atomicExtensions.begin(); i != atomicExtensions.end();) {
        QString & ext = *i;
        ext = ext.trimmed();
        if (!ext.length()) {
            i = atomicExtensions.erase(i);
            continue;
        }
        if (!ext.startsWith('.'))
            ext.insert(0, '.');
        ++i;
    }
    _properties->atomicExtensions = atomicExtensions;
}