Esempio n. 1
0
NewKeyCommand::NewKeyCommand(TreeViewModel *model, int index, DataContainer *data, bool isBelow, QUndoCommand* parent)
	: QUndoCommand(parent)
	, m_parentNode(model->model().at(index))
	, m_newNode(NULL)
	, m_value(data->newValue())
	, m_metaData(data->newMetadata())
{
	TreeViewModel* parentModel = m_parentNode->getChildren();
	kdb::Key newKey = parentModel->createNewKey(m_parentNode->getPath() + "/" + data->newName(), m_value, m_metaData);

	QStringList newNameSplit = parentModel->getSplittedKeyname(newKey);
	kdb::Key parentKey = m_parentNode->getKey();

	if(!parentKey)
		parentKey = kdb::Key(m_parentNode->getPath().toStdString(), KEY_END);

	QStringList parentNameSplit = parentModel->getSplittedKeyname(parentKey);

	//check if the new key is directly below the parent
	QSet<QString> diff = newNameSplit.toSet().subtract(parentNameSplit.toSet());

	if(diff.count() > 1 || isBelow)
		setText("newBranch");
	else
		setText("newKey");

	m_name = cutListAtIndex(newNameSplit, parentNameSplit.count()).first();

	parentModel->sink(m_parentNode, newNameSplit, newKey.dup());

	m_newNode = m_parentNode->getChildByName(m_name);
	parentModel->removeRow(m_parentNode->getChildIndexByName(m_name));
}
Esempio n. 2
0
void QDeclarativeContactFetchHint::setDetailDefinitionsHint(const QStringList& definitionNames)
{
    if (definitionNames.toSet() != m_fetchHint.detailDefinitionsHint().toSet()) {
        m_fetchHint.setDetailDefinitionsHint(definitionNames);
        emit fetchHintChanged();
    }
}
Esempio n. 3
0
void QDeclarativeContactFetchHint::setRelationshipTypesHint(const QStringList& relationshipTypes)
{
    if (relationshipTypes.toSet() != m_fetchHint.relationshipTypesHint().toSet()) {
        m_fetchHint.setRelationshipTypesHint(relationshipTypes);
        emit fetchHintChanged();
    }
}
Esempio n. 4
0
LanguageListModel::LanguageListModel(ModelType type, QObject* parent)
 : QStringListModel(parent)
 , m_sortModel(new QSortFilterProxyModel(this))
#ifndef NOKDE
 , m_systemLangList(new KConfig(QLatin1String("locale/kf5_all_languages"), KConfig::NoGlobals, QStandardPaths::GenericDataLocation))
#endif
{
#ifndef NOKDE
    setStringList(m_systemLangList->groupList());
#else
    QStringList ll;
    QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
    foreach(const QLocale& l, allLocales)
        ll.append(l.name());
    ll=ll.toSet().toList();
    setStringList(ll);
#endif

    if (type==WithEmptyLang) insertRows(rowCount(), 1);
#if 0 //KDE5PORT
    KIconLoader::global()->addExtraDesktopThemes();
#endif
    //qWarning()<<KIconLoader::global()->hasContext(KIconLoader::International);
    //qDebug()<<KIconLoader::global()->queryIconsByContext(KIconLoader::NoGroup,KIconLoader::International);
    m_sortModel->setSourceModel(this);
    m_sortModel->sort(0);
}
Esempio n. 5
0
const QStringList LoadSavePlugin::getExtensionsForColors(const int id)
{
	QList<FileFormat>::const_iterator it(findFormat(id));
	QList<FileFormat>::const_iterator itEnd(formats.constEnd());
	QStringList filterList;
	// We know the list is sorted by id, then priority, so we can just take the
	// highest priority entry for each ID, and we can start with the first entry
	// in the list.
	//First, check if we even have any plugins to load with
	if (it != itEnd)
	{
		if ((it->load) && (it->colorReading))
			filterList.append(it->fileExtensions);
		unsigned int lastID = it->formatId;
		++it;
		for ( ; it != itEnd ; ++it)
		{
			// Find the next load/save (as appropriate) plugin for the next format type
			if (((it->load) && (it->colorReading)) && (it->formatId > lastID))
			{
				// And add it to the filter list, since we know it's 
				// the highest priority because of the sort order.
				filterList.append(it->fileExtensions);
				lastID = it->formatId;
			}
		}
	}
	else
		qDebug("%s", tr("No File Loader Plugins Found").toLocal8Bit().data());
	// Avoid duplicate entries in the list
	QSet<QString> fSet = filterList.toSet();
	filterList = fSet.toList();
	qSort(filterList);
	return filterList;
}
Esempio n. 6
0
void
MetaQueryWidget::populateComboBox( QStringList results )
{
    QObject* query = sender();
    if( !query )
        return;

    QWeakPointer<KComboBox> combo = m_runningQueries.value(query);
    if( combo.isNull() )
        return;

    // note: adding items seems to reset the edit text, so we have
    //   to take care of that.
    disconnect( combo.data(), 0, this, 0 );

    // want the results unique and sorted
    const QSet<QString> dataSet = results.toSet();
    QStringList dataList = dataSet.toList();
    dataList.sort();
    combo.data()->addItems( dataList );

    KCompletion* comp = combo.data()->completionObject();
    comp->setItems( dataList );

    // reset the text and re-enable the signal
    combo.data()->setEditText( m_filter.value );
    connect( combo.data(), SIGNAL(editTextChanged( const QString& ) ),
            SLOT(valueChanged(const QString&)) );
}
void CompanionTable::init()
{
    QStringList companionList = GetConfigFromLuaState(Sanguosha->getLuaState(), "companion_pairs").toStringList();
    foreach (const QString &companions, companionList) {
        QStringList ones_others = companions.split("+");

        QStringList ones = ones_others.first().split("|");
        QStringList others = ones_others.last().split("|");

        foreach (const QString &one, ones) {
            m_companions[one] += others.toSet();
        }

        foreach (const QString &other, others) {
            m_companions[other] += ones.toSet();
        }
    }
Esempio n. 8
0
void DataSpecTest::test_operator_additiveAssignment()
{
    // Use Case:
    // Test for merging two requirements objects.
    {
        DataSpec d1, d2, d3;
        QStringList req;
        req << "one" << "two";

        d1.addStreamData(req.at(0));
        d2.addStreamData(req.at(1));
        d3.addStreamData(req.toSet());
        d1 += d2;
        CPPUNIT_ASSERT(d1 == d3);
    }

    // Use Case:
    // Test for merging two requirements objects in a different order.
    {
        DataSpec d1, d2, d3;
        QStringList req;
        req << "one" << "two";

        d1.addStreamData(req.at(0));
        d2.addStreamData(req.at(1));
        d3.addStreamData(req.toSet());
        d2 += d1;
        CPPUNIT_ASSERT(d2 == d3);
    }

    // Use Case:
    // Test for merging two requirements objects, removing duplicates.
    {
        DataSpec d, d1, d2;
        QSet<QString> req, req1, req2;
        req  << "one" << "two" << "three";
        req1 << "one" << "two";
        req2 << "two" << "three";

        d.addStreamData(req);
        d1.addStreamData(req1);
        d2.addStreamData(req2);
        d2 += d1;
        CPPUNIT_ASSERT(d == d2);
    }
}
 virtual bool isAllowed(const QStringList& serviceCaps) 
 {
     //client must have at least service caps;
     QSet<QString> sub = serviceCaps.toSet() - clientCaps;;
     if (sub.isEmpty())
         return true;
     else
         return false;
 }
Esempio n. 10
0
QStringList QgsExpressionContext::variableNames() const
{
  QStringList names;
  Q_FOREACH ( const QgsExpressionContextScope* scope, mStack )
  {
    names << scope->variableNames();
  }
  return names.toSet().toList();
}
Esempio n. 11
0
QStringList QgsExpressionContext::functionNames() const
{
  QStringList result;
  Q_FOREACH ( const QgsExpressionContextScope* scope, mStack )
  {
    result << scope->functionNames();
  }
  result = result.toSet().toList();
  result.sort();
  return result;
}
void SelectableFilesModel::setInitialMarkedFiles(const QStringList &files)
{
    m_files = files.toSet();
    m_outOfBaseDirFiles.clear();
    QString base = m_baseDir + '/';
    foreach (const QString &file, m_files)
        if (!file.startsWith(base))
            m_outOfBaseDirFiles.append(file);

    m_allFiles = false;
}
Esempio n. 13
0
void RunnerModel::setRunners(const QStringList &runners)
{
    if (m_runners.toSet() != runners.toSet()) {
        m_runners = runners;

        if (m_runnerManager) {
            m_runnerManager->setAllowedRunners(runners);
        }

        emit runnersChanged();
    }
}
/*!
    Returns a key matching messages whose serverUid is a member of \a uids, according to \a cmp.

    \sa QMailMessage::copyServerUid()
*/
QMailMessageKey QMailMessageKey::copyServerUid(const QStringList &uids, QMailDataComparator::InclusionComparator cmp)
{
#ifndef USE_ALTERNATE_MAILSTORE_IMPLEMENTATION
    if (uids.count() >= IdLookupThreshold) {
        // If there are a large number of UIDs, they will be inserted into a temporary table
        // with a uniqueness constraint; ensure only unique values are supplied
        return QMailMessageKey(uids.toSet().toList(), CopyServerUid, QMailKey::comparator(cmp));
    }
#endif

    return QMailMessageKey(uids, CopyServerUid, QMailKey::comparator(cmp));
}
Esempio n. 15
0
bool HAvTransportAdapterPrivate::getDeviceCapabilities(
    HClientAction*, const HClientActionOp& op)
{
    H_Q(HAvTransportAdapter);

    HDeviceCapabilities capabilities;
    if (op.returnValue() == UpnpSuccess)
    {
        const HActionArguments& outArgs = op.outputArguments();

        QStringList pmedia = outArgs.value("PlayMedia").toString().split(",");
        QStringList rmedia = outArgs.value("RecMedia").toString().split(",");
        QStringList rqMode = outArgs.value("RecQualityModes").toString().split(",");

        capabilities =
            HDeviceCapabilities(pmedia.toSet(), rmedia.toSet(), rqMode.toSet());
    }
    emit q->getDeviceCapabilitiesCompleted(q, takeOp(op, capabilities));

    return false;
}
DB::ValueCategoryMatcher::ValueCategoryMatcher( const QString& category, const QString& value )
{
    // Unescape doubled "&"s and restore the original value
    QString unEscapedValue = value;
    unEscapedValue.replace(QString::fromUtf8("&&"), QString::fromUtf8("&"));

    m_category = category ;
    m_option = unEscapedValue;

    const MemberMap& map = DB::ImageDB::instance()->memberMap();
    const QStringList members = map.members(m_category, m_option, true);
    m_members = members.toSet();
}
Esempio n. 17
0
void PluginManager::loadPlugins()
{
    QStringList plugins = settings().value("plugins" SUFFIX).toStringList();
    plugins = plugins.toSet().toList(); /* Remove duplicates */

    foreach(QString plugin, plugins) {
        try {
            addPlugin(plugin);
        } catch (const std::runtime_error &err) {
            qDebug() << err.what();
        }
    }
}
Esempio n. 18
0
void UIMediumEnumerator::sltHandleMachineUpdate(QString strMachineID)
{
    LogRel2(("GUI: UIMediumEnumerator: Machine (or snapshot) event received, ID = %s\n",
             strMachineID.toUtf8().constData()));

    /* Gather previously used UIMedium IDs: */
    QStringList previousUIMediumIDs;
    calculateCachedUsage(strMachineID, previousUIMediumIDs, true /* take into account current state only */);
    LogRel2(("GUI: UIMediumEnumerator:  Old usage: %s\n",
             previousUIMediumIDs.isEmpty() ? "<empty>" : previousUIMediumIDs.join(", ").toUtf8().constData()));

    /* Gather currently used CMediums and their IDs: */
    CMediumMap currentCMediums;
    QStringList currentCMediumIDs;
    calculateActualUsage(strMachineID, currentCMediums, currentCMediumIDs, true /* take into account current state only */);
    LogRel2(("GUI: UIMediumEnumerator:  New usage: %s\n",
             currentCMediumIDs.isEmpty() ? "<empty>" : currentCMediumIDs.join(", ").toUtf8().constData()));

    /* Determine excluded mediums: */
    const QSet<QString> previousSet = previousUIMediumIDs.toSet();
    const QSet<QString> currentSet = currentCMediumIDs.toSet();
    const QSet<QString> excludedSet = previousSet - currentSet;
    const QStringList excludedUIMediumIDs = excludedSet.toList();
    if (!excludedUIMediumIDs.isEmpty())
        LogRel2(("GUI: UIMediumEnumerator:  Items excluded from usage: %s\n", excludedUIMediumIDs.join(", ").toUtf8().constData()));
    if (!currentCMediumIDs.isEmpty())
        LogRel2(("GUI: UIMediumEnumerator:  Items currently in usage: %s\n", currentCMediumIDs.join(", ").toUtf8().constData()));

    /* Update cache for excluded UIMediums: */
    recacheFromCachedUsage(excludedUIMediumIDs);

    /* Update cache for current CMediums: */
    recacheFromActualUsage(currentCMediums, currentCMediumIDs);

    LogRel2(("GUI: UIMediumEnumerator: Machine (or snapshot) event processed, ID = %s\n",
             strMachineID.toUtf8().constData()));
}
Esempio n. 19
0
bool lmcCore::receiveAppMessage(const QString& szMessage) {
	bool doNotExit = true;

	if(szMessage.isEmpty()) {
		pMainWindow->restore();
		return doNotExit;
	}

	QStringList messageList = szMessage.split("\n", QString::SkipEmptyParts);
	//	remove duplicates
	messageList = messageList.toSet().toList();

	if(messageList.contains("/new", Qt::CaseInsensitive)) {
		if(messageList.contains("/loopback", Qt::CaseInsensitive))
			pMessaging->setLoopback(true);
	}
	if(messageList.contains("/nohistory", Qt::CaseInsensitive)) {
		QFile::remove(History::historyFile());
		if(pHistoryWindow)
			pHistoryWindow->updateList();
	}
	if(messageList.contains("/nofilehistory", Qt::CaseInsensitive)) {
		QFile::remove(StdLocation::transferHistory());
		if(pTransferWindow)
			pTransferWindow->updateList();
	}
	if(messageList.contains("/noconfig", Qt::CaseInsensitive)) {
		QFile::remove(StdLocation::avatarFile());
		QFile::remove(pSettings->fileName());
		pSettings->sync();
		settingsChanged();
	}
	if(messageList.contains("/sync", Qt::CaseInsensitive)) {
		bool autoStart = pSettings->value(IDS_AUTOSTART, IDS_AUTOSTART_VAL).toBool();
		lmcSettings::setAutoStart(autoStart);
	}
	if(messageList.contains("/unsync", Qt::CaseInsensitive)) {
		lmcSettings::setAutoStart(false);
	}
	if(messageList.contains("/term", Qt::CaseInsensitive)) {
		doNotExit = false;
		exitApp();
	}
	if(messageList.contains("/quit", Qt::CaseInsensitive)) {
		doNotExit  = false;
	}

	return doNotExit;
}
Esempio n. 20
0
QSet<QString> QgsSymbolLayerV2::usedAttributes() const
{
  QStringList columns;

  QMap< QString, QgsDataDefined* >::const_iterator ddIt = mDataDefinedProperties.constBegin();
  for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
  {
    if ( ddIt.value() && ddIt.value()->isActive() )
    {
      columns.append( ddIt.value()->referencedColumns() );
    }
  }

  return columns.toSet();
}
Esempio n. 21
0
/**
 * Ends the import. Reimplementations should call this base
 * implementation first since this commits the transaction
 * after importing entities into the document.
 */
void RImporter::endImport() {
    transaction.end();

    // ground all directly recursive block references:
    int counter = 0;
    QStringList blockNames;
    QSet<RBlock::Id> blockIds = document->queryAllBlocks();
    QSet<RBlock::Id>::const_iterator it;
    for (it=blockIds.constBegin(); it!=blockIds.constEnd(); it++) {
        RBlock::Id blockId = *it;

        QSet<REntity::Id> ids = document->queryBlockEntities(blockId);
        QSet<REntity::Id>::const_iterator it2;
        for (it2=ids.constBegin(); it2!=ids.constEnd(); it2++) {
            REntity::Id entityId = *it2;

            QSharedPointer<REntity> entity = document->queryEntityDirect(entityId);
            QSharedPointer<RBlockReferenceEntity> blockRef = entity.dynamicCast<RBlockReferenceEntity>();
            if (blockRef.isNull()) {
                // ignore non block reference entities:
                continue;
            }

            RBlock::Id refBlockId = blockRef->getReferencedBlockId();

            if (refBlockId==blockId) {
                blockNames.append(document->getBlockName(refBlockId));
                blockRef->setReferencedBlockId(RBlock::INVALID_ID);
                counter++;
            }
        }
    }

    if (RMainWindow::hasMainWindow() && counter>0) {
        blockNames = blockNames.toSet().toList();
        RMainWindow::getMainWindow()->handleUserWarning(
            QString("Grounded %1 recursive block references in blocks: %2")
                .arg(counter)
                .arg(blockNames.join(", "))
        );
    }

    //qDebug() << "rebuilding spatial index";
    document->rebuildSpatialIndex();
    //qDebug() << "rebuilding spatial index: OK";
}
Esempio n. 22
0
void TrialWidget::buildComboBoxes(QDomDocument* domDoc)
{
    QStringList args;
    XMLelement arg = XMLelement(*domDoc)["arguments"].firstChild();
    while (!arg.isNull())
    {
        args.append(arg.label());
        defs.insert(arg.label(), defs.keys().contains(arg.label()) && (arg.value().isNull() || arg.value() == "NULL") ?
                    defs[arg.label()] : arg.value());
//        defs[arg.label()]=(arg.value());
        arg = arg.nextSibling();
    }
    foreach(QString label, defs.keys().toSet().subtract(args.toSet()))
        defs.remove(label);

    if (args.size())
        execBuildComboBoxes(args);
}
Esempio n. 23
0
void DatabaseFileWatcher::notifyChanges(ServiceDatabase *database, DatabaseManager::DbScope scope)
{
    #ifdef Q_OS_SYMBIAN
        scope = DatabaseManager::SystemScope;
    #endif

    QString dbPath = database->databasePath();
    if (!QFile::exists(dbPath)) {
        m_knownServices.remove(dbPath);
        restartDirMonitoring(dbPath, QString());
        return;
    }

    QStringList currentServices = database->getServiceNames(QString());
    if (database->lastError().code() !=DBError::NoError) {
        qWarning("QServiceManager: failed to get current service names for serviceAdded() and serviceRemoved() signals");
        return;
    }

    const QStringList &knownServicesRef = m_knownServices[dbPath];

    QSet<QString> currentServicesSet = currentServices.toSet();
    QSet<QString> knownServicesSet = knownServicesRef.toSet();
    if (currentServicesSet == knownServicesSet)
        return;

    QStringList newServices;
    for (int i=0; i<currentServices.count(); i++) {
        if (!knownServicesSet.contains(currentServices[i]))
            newServices << currentServices[i];
    }

    QStringList removedServices;
    for (int i=0; i<knownServicesRef.count(); i++) {
        if (!currentServicesSet.contains(knownServicesRef[i]))
            removedServices << knownServicesRef[i];
    }

    m_knownServices[dbPath] = currentServices;
    for (int i=0; i<newServices.count(); i++)
        emit m_manager->serviceAdded(newServices[i], scope);
    for (int i=0; i<removedServices.count(); i++)
        emit m_manager->serviceRemoved(removedServices[i], scope);
}
Esempio n. 24
0
void BookmarksManager::updateUrls()
{
	QStringList urls;

	for (int i = 0; i < m_allBookmarks.count(); ++i)
	{
		if (m_allBookmarks.at(i) && m_allBookmarks.at(i)->type == UrlBookmark)
		{
			const QUrl url(m_allBookmarks.at(i)->url);

			if (url.isValid())
			{
				urls.append(url.toString(QUrl::RemovePassword | QUrl::RemoveFragment));
			}
		}
	}

	m_urls = urls.toSet();
}
Esempio n. 25
0
bool KonsoleKalendar::printCalendarList()
{
    Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(),
            Akonadi::CollectionFetchJob::Recursive);
    QStringList mimeTypes = QStringList() << QStringLiteral("text/calendar")
                            << KCalCore::Event::eventMimeType()
                            << KCalCore::Todo::todoMimeType()
                            << KCalCore::Journal::journalMimeType();
    job->fetchScope().setContentMimeTypes(mimeTypes);
    QEventLoop loop;
    QObject::connect(job, &Akonadi::CollectionFetchJob::result, &loop, &QEventLoop::quit);
    job->start();
    loop.exec();

    if (job->error() != 0) {
        return false;
    }

    Akonadi::Collection::List collections = job->collections();

    if (collections.isEmpty()) {
        cout << i18n("There are no calendars available.").toLocal8Bit().data() << endl;
    } else {
        cout << "--------------------------" << endl;
        QSet<QString> mimeTypeSet = mimeTypes.toSet();
        foreach (const Akonadi::Collection &collection, collections) {
            if (!mimeTypeSet.intersect(collection.contentMimeTypes().toSet()).isEmpty()) {
                QString colId = QString::number(collection.id()).leftJustified(6, QLatin1Char(' '));
                colId += QLatin1String("- ");

                bool readOnly = !(collection.rights() & Akonadi::Collection::CanCreateItem ||
                                  collection.rights() & Akonadi::Collection::CanChangeItem ||
                                  collection.rights() & Akonadi::Collection::CanDeleteItem);

                QString readOnlyString = readOnly ? i18n("(Read only)") + QLatin1Char(' ') : QString();

                cout << colId.toLocal8Bit().data() << readOnlyString.toLocal8Bit().constData() << collection.displayName().toLocal8Bit().data() << endl;
            }
        }
    }

    return true;
}
Esempio n. 26
0
void FolderWatcher::changeDetected( const QStringList& paths )
{
    // qDebug() << Q_FUNC_INFO << paths;

    // TODO: this shortcut doesn't look very reliable:
    //   - why is the timeout only 1 second?
    //   - what if there are more than one file being updated frequently?
    //   - why do we skip the file alltogether instead of e.g. reducing the upload frequency?

    // Check if the same path was reported within the last second.
    QSet<QString> pathsSet = paths.toSet();
    if( pathsSet == _lastPaths && _timer.elapsed() < 1000 ) {
        // the same path was reported within the last second. Skip.
        return;
    }
    _lastPaths = pathsSet;
    _timer.restart();

    QSet<QString> changedFolders;

    // ------- handle ignores:
    for (int i = 0; i < paths.size(); ++i) {
        QString path = paths[i];
        if( pathIsIgnored(path) ) {
            continue;
        }

        QFileInfo fi(path);
        if (fi.isDir()) {
            changedFolders.insert(path);
        } else {
            changedFolders.insert(fi.dir().path());
        }
    }
    if (changedFolders.isEmpty()) {
        return;
    }

    qDebug() << "detected changes in folders:" << changedFolders;
    foreach (const QString &path, changedFolders) {
        emit folderChanged(path);
    }
Esempio n. 27
0
void BattleLogsWidget::done()
{
    QStringList tiers = this->tiers->toPlainText().split(",", QString::SkipEmptyParts);
    for(int i = 0; i < tiers.size(); i++) {
        tiers[i] = tiers[i].trimmed();
    }

    master->tiers = tiers.toSet();
    master->saveMixedTiers = mixedTiers->isChecked();
    master->saveRawFiles = rawFile->isChecked();
    master->saveTextFiles = textFile->isChecked();

    QSettings s("config_battleLogs", QSettings::IniFormat);
    s.setValue("save_mixed_tiers", mixedTiers->isChecked());
    s.setValue("save_raw_files", rawFile->isChecked());
    s.setValue("save_text_files", textFile->isChecked());
    s.setValue("tiers", tiers);

    close();
}
void KJotsComponent::cleanupOldBackups()
{
  QDir dir(KStandardDirs::locateLocal("data","kjots"));

  QStringList filter;
  filter << "*.book";

  QStringList backupFilter;
  backupFilter << "*.book.*~";

  //Read in books from disk
  QStringList files = dir.entryList(filter, QDir::Files|QDir::Readable);
  QStringList backupFiles = dir.entryList(backupFilter, QDir::Files|QDir::Readable);

  int maxBackups = 10; // The default amount of numbered backups saved by KSaveFile::numberedBackupFile
  QSet<QString> fileSet;
  foreach( const QString &file, files )
  {
    for( int bkup=1; bkup <= maxBackups; bkup++)
    {
      fileSet << file + '.' + QString::number(bkup) + '~';
    }
  }

  QSet<QString> backupFileSet = backupFiles.toSet();

  // deletedFileBackups is a list of backup files whose original has already been deleted.
  // If the backup file is older than AGE days, delete it.
  QSet<QString> deletedFileBackups = backupFileSet - fileSet;

  const int AGE = 7;

  foreach ( const QString &backupFile, deletedFileBackups ) {
    QString filepath = dir.absoluteFilePath(backupFile);
    QFileInfo fi(filepath);
    if (fi.lastModified().addDays(AGE) < QDateTime::currentDateTime() )
    {
      QFile::remove(filepath);
    }
  }
Esempio n. 29
0
void lmcCore::init(const QString& szCommandArgs) {
	//	prevent auto app exit when last visible window is closed
	qApp->setQuitOnLastWindowClosed(false);

	QStringList arguments = szCommandArgs.split("\n", QString::SkipEmptyParts);
	//	remove duplicates
	arguments = arguments.toSet().toList();

	pInitParams = new XmlMessage();
	if(arguments.contains("/silent", Qt::CaseInsensitive))
		pInitParams->addData(XN_SILENTMODE, LMC_TRUE);
	if(arguments.contains("/trace", Qt::CaseInsensitive)) {
		pInitParams->addData(XN_TRACEMODE, LMC_TRUE);
		pInitParams->addData(XN_LOGFILE, StdLocation::freeLogFile());
	}
	for(int index = 0; index < arguments.count(); index++) {
		if(arguments.at(index).startsWith("/port=", Qt::CaseInsensitive)) {
			QString port = arguments.at(index).mid(QString("/port=").length());
			pInitParams->addData(XN_PORT, port);
			continue;
		}
		if(arguments.at(index).startsWith("/config=", Qt::CaseInsensitive)) {
			QString configFile = arguments.at(index).mid(QString("/config=").length());
			pInitParams->addData(XN_CONFIG, configFile);
			continue;
		}
	}

	lmcTrace::init(pInitParams);
	lmcTrace::write("Application initialized");

	loadSettings();

	lmcTrace::write("Settings loaded");

	pMessaging->init(pInitParams);
	pMainWindow->init(pMessaging->localUser, &pMessaging->groupList, pMessaging->isConnected());
	pPublicChatWindow->init(pMessaging->localUser, pMessaging->isConnected());
}
Esempio n. 30
0
void CodeArea::onTextChange()
 {
     QStringList lineList = toPlainText().split("\n");
     QString cleanData;
     foreach (QString str, lineList)
     {
         if(!str.startsWith("--"))
         {
             cleanData+=str+" ";
         }
     }
     QRegExp ex("(\\s|\\(|\\)|\\=|,|\\[|\\]|\\{|\\}|\\.|-)");
     QStringList wordList = cleanData.split(ex);
     wordList.removeAll("");
     wordList.removeAll(textUnderCursor());
     wordList.append(mWordList);
     wordList.append( AutoComplete::autoCompleteList.toSet().toList());
     wordList.append( AutoComplete::autoCompleteUOList.toSet().toList());
     wordList.sort();

     if(mCompleter)
        mCompleter->setModel(new QStringListModel(wordList.toSet().toList(), mCompleter));
 }