Пример #1
0
static QVector< deviceList > _getDevices()
{
	const char * p = "/dev/disk/by-id/" ;

	QDir d( p ) ;
	QDir e ;

	QStringList l = d.entryList() ;

	l.removeOne( "." ) ;
	l.removeOne( ".." ) ;

	QVector< deviceList > devices ;

	if( l.isEmpty() ){

		return devices ;
	}else{
		for( const auto& it : l ){

			e.setPath ( p + it ) ;

			devices.append( deviceList( e.canonicalPath(),it ) ) ;
		}
	}

	return devices ;
}
Пример #2
0
QString TrustAI::askForKingdom() {
    QString role;
    ServerPlayer *lord = room->getLord();
    QStringList kingdoms = Sanguosha->getKingdoms();
    kingdoms.removeOne("god");
    if (!lord) return kingdoms.at(qrand() % kingdoms.length());

    switch(self->getRoleEnum()) {
    case Player::Lord: role = kingdoms.at(qrand() % kingdoms.length()); break;
    case Player::Renegade:
    case Player::Rebel: {
            if ((lord->hasLordSkill("xueyi") && self->getRoleEnum() == Player::Rebel) || lord->hasLordSkill("shichou"))
                role = "wei";
            else
                role = lord->getKingdom();
            break;
    }
    case Player::Loyalist: {
            if (lord->getGeneral()->isLord())
                role = lord->getKingdom();
            else if (lord->getGeneral2() && lord->getGeneral2()->isLord())
                role = lord->getGeneral2()->getKingdom();
            else {
                if (lord->hasSkill("yongsi")) kingdoms.removeOne(lord->getKingdom());
                role = kingdoms.at(qrand() % kingdoms.length());
            }
            break;
        }
    default:
            break;
    }

    return role;
}
Пример #3
0
//---------------------------------------
void FRDialog::removeItemListBook(QStringList &list)
{
    QStringList listb;
    int i = 1;
    while (i < list.size())
    {
        if (
                ( list.at(i).indexOf(GL_PROJECT_FILE) >= 0 ) or
                ( list.at(i).indexOf("chapter") >= 0) or
                ( list.at(i).indexOf("export") >= 0 )
                )
        {
            list.removeAt(i);
            --i;
        }
        else
        {
            QString filename = Config::configuration()->CurPrjDir() + "/" +
                    list.at(i);
//            qDebug() << "filename = " << filename
//                     << " param = " << getParamBook(filename, "FullName");
            QString bookfilename = QString(list.at(i)).remove("book_").remove(".htm");
            QString app = getParamBook(filename, "FullName");
            listb << app;
            bookfiles << bookfilename;
        }
        ++i;
    }
    listb.removeOne(GL_PROJECT_FILE);
    listb.removeOne("");
    listb.removeOne("help");
    listb.removeDuplicates();
    list = listb;
}
Пример #4
0
// Originally user templates were stored whereever the user wanted and maintained in the option "User/Templates".
// This behavior has now been changed to always store user templates in [config]/templates/user/ The advantage is
// that we don't have to maintain the template list and it's not lost when resetting the configuration.
// This function allows to move existing templates to the the new location.
void TemplateManager::checkForOldUserTemplates() {
	ConfigManagerInterface *cfg = ConfigManager::getInstance();
	if (!cfg) return;
	QStringList userTemplateList = cfg->getOption("User/Templates").toStringList();
	if (!userTemplateList.isEmpty()) {
		bool move = txsConfirmWarning(tr("TeXstudio found user templates in deprecated locations.\n"
							"From now on user templates are hosted at\n%1\n"
							"Should TeXstudio move the existing user templates there?\n"
							"If not, they will not be available via the Make Template dialog.").arg(userTemplateDir()));
		if (move) {
			foreach (const QString &fname, userTemplateList) {
				QFileInfo fi(fname);
				if (!fi.exists()) {
					userTemplateList.removeOne(fname);
					continue;
				}
				QString newName = userTemplateDir() + fi.fileName();
				if (!QFile::copy(fname, newName)) {
					txsWarning(tr("Copying template from\n%1\nto\n%2\nfailed.").arg(fname).arg(newName));
				} else {
					if (!QFile::remove(fname)) {
						txsInformation(tr("File\n%1\n could not be removed.").arg(fname));
					}
					userTemplateList.removeOne(fname);
				}
			}
		}
Пример #5
0
QStringList availableLanguages()
{
    QDir dir;
    dir.setPath(datadir() + LANGUAGEROOT);

    // add all translations
    QStringList filters;
    filters << "*.qm";
    dir.setNameFilters(filters);
    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);

    // remove extension
    QStringList list = dir.entryList();
    list.replaceInStrings(".qm", "");

    // remove system translations
    foreach (QString str, list)
    {
        if (str.startsWith("qt_"))
            list.removeOne(str);
        if (str.startsWith("plugin_"))
            list.removeOne(str);
    }

    return list;
}
Пример #6
0
//---------------------------------------
QStringList FRDialog::findFiles(const QStringList &files, const QString &text)
{
    QProgressDialog progressDialog(this);
    progressDialog.setCancelButtonText(tr("&Cancel"));
    progressDialog.setRange(0, files.size());
    progressDialog.setWindowTitle(tr("Find Files"));
    QStringList foundFiles;
    for (int i = 0; i < files.size(); ++i) {
        progressDialog.setValue(i);
        progressDialog.setLabelText(tr("Searching file number %1 of %2...")
                                    .arg(i).arg(files.size()));
        qApp->processEvents();

        if (progressDialog.wasCanceled())
            break;

        QFile file(currentDir.absoluteFilePath(files[i]));
        if (file.open(QIODevice::ReadOnly)) {
            QString line;
            QTextStream in(&file);
            while (!in.atEnd()) {
                if (progressDialog.wasCanceled())
                    break;
                line = in.readLine();
                if (line.contains(text)) {
                    foundFiles << files[i];
                    break;
                }
            }
        }
    }
    foundFiles.removeOne("   ___Instruction");
    foundFiles.removeOne(Config::configuration()->CurProject().split("/").last());
    return foundFiles;
}
Пример #7
0
void RemoteActivatable::propertiesChanged(const QVariantMap &changedProperties)
{
    Q_D(RemoteActivatable);
    QStringList propKeys = changedProperties.keys();
    QLatin1String deviceUniKey("deviceUni"),
                  activatableTypeKey("activatableType"),
                  sharedKey("shared");
    QVariantMap::const_iterator it = changedProperties.find(deviceUniKey);
    if (it != changedProperties.end())
    {
        d->deviceUni = it->toString();
        propKeys.removeOne(deviceUniKey);
    }
    it = changedProperties.find(activatableTypeKey);
    if (it != changedProperties.end())
    {
        d->activatableType = (Knm::Activatable::ActivatableType)it->toUInt();
        propKeys.removeOne(activatableTypeKey);
    }
    it = changedProperties.find(sharedKey);
    if (it != changedProperties.end())
    {
        d->shared = it->toBool();
        propKeys.removeOne(sharedKey);
    }
    /*if (propKeys.count()) {
        qDebug() << "Unhandled properties: " << propKeys;
    }*/
}
Пример #8
0
/*!
 * Verifica si la aplicación ha sido invocada de manera correcta.
 * En caso afirmativo, retorna los paths de las imágenes a procesar y setea los flags correspondientes.
 * En caso negativo, se imprime la ayuda por pantalla.
 */
void checkCall(int argc, char *argv[], QString &path1, QString &path2)
{
    QString arg;
    QStringList qArgs;   
    for(int i=1; i<argc; i++)
        qArgs << QString(argv[i]).toLower();
    if(qArgs.contains("-h"))
        printHelp();
    if(qArgs.contains("--build")){
        BUILD = true;
        qArgs.removeOne("--build");
        if(qArgs.size() != 1)
            printHelp();
        path1 = qArgs[0];
    }else{
        if(qArgs.contains("--add")){
            ADD = true;
            qArgs.removeOne("--add");
            if(qArgs.size() != 1)
                printHelp();
            path1 = qArgs[0];
        }else{
            if(qArgs.contains("--search")){
                SEARCH = true;
                qArgs.removeOne("--search");
                if(qArgs.size() != 1)
                    printHelp();
                path1 = qArgs[0];
            }else{
                for(int i=0; i<qArgs.size(); i++){
                    arg = qArgs[i];
                    if(arg == "-v"){
                        VERBOSE = true;
                        qArgs.removeAt(i--);
                        continue;
                    }
                    if(arg == "-g"){
                        GRAPHIC = true;
                        qArgs.removeAt(i--);
                    }
                }
                if(qArgs.size() != 2)
                    printHelp();
                path1 = qArgs[0];
                path2 = qArgs[1];
            }
        }
    }
}
Пример #9
0
QString TrustAI::askForKingdom()
{
    QString role;
    ServerPlayer *lord = room->getLord();
    QStringList kingdoms = Sanguosha->getKingdoms();
    kingdoms.removeOne("zhu");
    kingdoms.removeOne("touhougod");
    QString selfKingdom = self->getGeneral()->getKingdom();
    if (!lord) return kingdoms.at(qrand() % kingdoms.length());

    switch (self->getRoleEnum()) {
    case Player::Lord: role = kingdoms.at(qrand() % kingdoms.length()); break;
    case Player::Renegade:{
        if (lord->getGeneral()->isLord() || self->hasSkill("hongfo"))
            role = lord->getKingdom();
        else if (lord->getGeneral2() && lord->getGeneral2()->isLord())
            role = lord->getGeneral2()->getKingdom();
        else
            role = kingdoms.at(qrand() % kingdoms.length());
        break;
    }
    case Player::Rebel: {
        if (self->hasSkill("hongfo")) {
            kingdoms.removeOne(lord->getKingdom());
            role = kingdoms.at(qrand() % kingdoms.length());
        } else if (lord->getGeneral()->isLord())
            role = lord->getKingdom();
        else
            role = kingdoms.at(qrand() % kingdoms.length());
        break;
    }
    case Player::Loyalist: {
        if (lord->getGeneral()->isLord() || self->hasSkill("hongfo"))
            role = lord->getKingdom();
        else if (lord->getGeneral2() && lord->getGeneral2()->isLord())
            role = lord->getGeneral2()->getKingdom();
        else {
            role = kingdoms.at(qrand() % kingdoms.length());
        }
        break;
    }
    default:
        break;
    }
    if (kingdoms.contains(role))
        return role;
    else
        return "wai";
}
Пример #10
0
QVariant SongsDataModel::data(const QVariantList& indexPath)
{
    QVariantMap data;
    QDir dir = QDir::home();
    if (dir.cd("songs")) {
        QStringList listOfFiles = dir.entryList(QDir::Dirs);
        listOfFiles.removeOne(".");
        listOfFiles.removeOne("..");
//		data["albumName"] = listOfFiles.at(indexPath[0].toInt());
//		data["itemsCount"] = getItemsCount(listOfFiles.at(indexPath[0].toInt()));
        data["albumName"] = "songs";
        //data["itemsCount"] = getItemsCount(listOfFiles.at(indexPath[0].toInt()));
    }
    return data;
}
Пример #11
0
QString TrustAI::askForKingdom()
{
    QString role;
    ServerPlayer *lord = room->getLord();
    QStringList kingdoms = Sanguosha->getKingdoms();
    kingdoms.removeOne("god");
    if (!lord) return kingdoms.at(qrand() % kingdoms.length());

    switch (self->getRoleEnum()) {
    case Player::Lord: role = kingdoms.at(qrand() % kingdoms.length()); break;
    case Player::Renegade:
    case Player::Rebel: {
            role = lord->getKingdom();
        break;
    }
    case Player::Loyalist: {
            role = kingdoms.at(qrand() % kingdoms.length());
        break;
    }
    default:
        break;
    }

    return role;
}
Пример #12
0
void QOfonoRadioSettings::setModemPath(const QString &path)
{
    if (path == d_ptr->modemPath ||
            path.isEmpty())
        return;

    QStringList removedProperties = d_ptr->properties.keys();

    delete d_ptr->radioSettings;
    d_ptr->radioSettings = new OfonoRadioSettings("org.ofono", path, QDBusConnection::systemBus(),this);

    if (d_ptr->radioSettings->isValid()) {
        d_ptr->modemPath = path;

        connect(d_ptr->radioSettings,SIGNAL(PropertyChanged(QString,QDBusVariant)),
                this,SLOT(propertyChanged(QString,QDBusVariant)));

        QVariantMap properties = d_ptr->radioSettings->GetProperties().value();
        for (QVariantMap::ConstIterator it = properties.constBegin();
             it != properties.constEnd(); ++it) {
            updateProperty(it.key(), it.value());
            removedProperties.removeOne(it.key());
        }

        Q_EMIT modemPathChanged(path);
    }

    foreach (const QString &p, removedProperties)
        updateProperty(p, QVariant());
}
Пример #13
0
void QgsComposerPictureWidget::on_mRemoveDirectoryButton_clicked()
{
  QString directoryToRemove = mSearchDirectoriesComboBox->currentText();
  if ( directoryToRemove.isEmpty() )
  {
    return;
  }
  mSearchDirectoriesComboBox->removeItem( mSearchDirectoriesComboBox->currentIndex() );

  //remove entries from back to front (to have the indices of existing items constant)
  for ( int i = ( mPreviewListWidget->count() - 1 ); i >= 0; --i )
  {
    QListWidgetItem* currentItem = mPreviewListWidget->item( i );
    if ( currentItem && currentItem->data( Qt::UserRole ).toString().startsWith( directoryToRemove ) )
    {
      delete( mPreviewListWidget->takeItem( i ) );
    }
  }

  //update the image directory list in the settings
  QSettings s;
  QStringList userDirList = s.value( "/Composer/PictureWidgetDirectories" ).toStringList();
  userDirList.removeOne( directoryToRemove );
  s.setValue( "/Composer/PictureWidgetDirectories", userDirList );
}
Пример #14
0
void WinetricksModel::makeData()
{
	//run winetricks
	QProcess p;
	if (wtricks.isEmpty() || (!QFileInfo(wtricks).isFile()))
		wtricks = "winetricks";
	p.start(wtricks, QStringList("help"));
	p.waitForFinished();
	QStringList rawStr = QString (p.readAllStandardOutput()).split("\n", QString::SkipEmptyParts);
	//Remove non-splittable entries from the array
	while (rawStr.first() != "Packages:")
	{
		rawStr.removeFirst();
	}

	// parse list step by step
	foreach (QString str, rawStr)
	{
		if (str.endsWith(":")) //packages: pseudopackages: etc
		{
			rawStr.removeOne(str);
			continue;
		}
	list.append(getTrix (str));
	}
}
Пример #15
0
bool DcRawQT::GetRawImage(QString filename, QStringList args)
{
    int argc;
    char **argv;


	if(args.contains("-i")){
		args.removeOne("-i");
		qDebug("-i passed to GetRawImage");
	}

    args += filename;
    argc = BuildCommandLine(args, &argv);

	if(GetRawImage(argc, argv))
	{
		buildHistogram();

		return true;
	}

	return false;


}
Пример #16
0
void Parser::parseFieldsSelect(QStringList& fields)
{
    if(_query.contains(" from ", Qt::CaseInsensitive))
    {
        int end = _query.indexOf(" from ", 6, Qt::CaseInsensitive);
        QString substring = _query.mid(6, end - 6).trimmed();

        fields = substring.split(',', QString::KeepEmptyParts, Qt::CaseInsensitive);

        foreach(QString field, fields)
        {
            fields.removeOne(field);
            field = field.trimmed();

            if(field.contains(' ', Qt::CaseInsensitive) || hasPunct(field) ||
               field.isEmpty() || field.isNull())
            {
                if(field != "*")
                {
                    fields.clear();
                    break;
                }
            }

            fields.append(field);
        }
Пример #17
0
void MovedFilmsWindow::ShowFounded( QStringList fileNames )
{
    DebugPrintFunc( "MovedFilmsWindow::ShowFounded", fileNames.size() );

      // Flip button
    bScan->setText( tr("Scan") );
    progressBar->hide();

      // Show
    for( FilmItem* film : unavailableFilms )
    {
        QString unavailFilePath = film->GetFileName();
        QString unavailFileName = QFileInfo(unavailFilePath).fileName();

        for( QString newFilePath : fileNames )
        {
            QString newFileName = QFileInfo( newFilePath ).fileName();

            if( newFileName == unavailFileName && newFilePath != unavailFilePath ) // Protection from multiple moving
            {
                gbFounded->AddItem( newFilePath, qVariantFromValue( (void*)film ) );
                fileNames.removeOne( newFilePath );
                break;
            }
        }
    }

    if( gbFounded->GetItemsCount() == 0 )
    {
        QMessageBox::information( this, tr("Moved films"), tr("Nothing was found.") );
    }

    DebugPrintFuncDone( "MovedFilmsWindow::ShowFounded" );
}
Пример #18
0
/*!
  UpdateTaskJob
*/
UpdateTaskJob::UpdateTaskJob(Service* service, const Task& task)
	: Job(service,
		  Job::Put, task.selfLink(),
		  SIGNAL(result(GTasks::Task, GTasks::Error)))
{

	QVariantMap fullData = task.serialize();
	QVariantMap savedData;

	QStringList savedFields;
	savedFields << "id" << "title" <<  "notes" <<  "status" <<  "due";

	// Don't update the due date if it's empty. TODO: How do we clear the due date?
	if (fullData.value("due").toString().isEmpty()) {
		savedFields.removeOne("due");
	}

	foreach (const QString& field, savedFields) {
		if (fullData.contains(field)) {
			savedData.insert(field, fullData.value(field));
		}
	}

	setRequestData(savedData);
}
Пример #19
0
void keyDialog::Plugin()
{
	QStringList list ;

	// ZULUCRYPTpluginPath is set at config time and it equals $prefix/lib(64)/zuluCrypt

	QDir dir( QString( ZULUCRYPTpluginPath ) ) ;

	if( dir.exists() ){
		list = dir.entryList() ;
	}

	list.removeOne( QString( "zuluCrypt-testKey" ) ) ;
	list.removeOne( QString( "." ) ) ;
	list.removeOne( QString( ".." ) ) ;
	list.removeOne( "keyring" ) ;
	list.removeOne( "kwallet" ) ;

	if( LxQt::Wallet::backEndIsSupported( LxQt::Wallet::secretServiceBackEnd ) ){
		list.prepend( tr( GNOME_WALLET ) ) ;
	}
	if( LxQt::Wallet::backEndIsSupported( LxQt::Wallet::kwalletBackEnd ) ){
		list.prepend( tr( KWALLET ) ) ;
	}

	list.prepend( tr( INTERNAL_WALLET ) ) ;

	m_menu->clear() ;

	int j = list.size()  ;

	if( j == 0 ){
		return ;
	}
	for( int i = 0 ; i < j ; i++ ){
		m_menu->addAction( list.at( i ) ) ;
	}
	m_menu->addSeparator() ;

	m_menu->addAction( tr( "cancel" ) ) ;

	connect( m_menu,SIGNAL( triggered( QAction * ) ),this,SLOT( pbPluginEntryClicked( QAction * ) ) ) ;

	m_menu->exec( QCursor::pos() ) ;
}
Пример #20
0
FrameObject::~FrameObject()
{
	if (p_source != NULL)
    {
        clearCurrentCache();
		duplicateList.removeOne(p_source->getName());
		delete p_source;
    }
}
Пример #21
0
void mygeneral::propertymap_get(QMap<QString,QString> &strmap,bool b4remark){
    if(b4remark){}
    strmap.insert(property2str(Name),name);
    strmap.insert(property2str(Translation),translation);
    QStringList strlist;
    strlist=kingdomstrlist();
    strlist.removeOne(kingdom2str(kingdom));
    strlist.prepend(kingdom2str(kingdom));
    strmap.insert(property2str(Kingdom),strlist.join("|"));
    strlist=sexstrlist();
    strlist.removeOne(sex2str(sex));
    strlist.prepend(sex2str(sex));
    strmap.insert(property2str(Sex),strlist.join("|"));
    strmap.insert(property2str(HP),QString::number(hp));
    strmap.insert(property2str(Title),title);
    strmap.insert(property2str(Word),word);
    strmap.insert(property2str(CV),cv);
}
Пример #22
0
void MakeStep::setBuildTarget(const QString &buildTarget, bool on)
{
    QStringList old = m_buildTargets;
    if (on && !old.contains(buildTarget))
        old << buildTarget;
    else if (!on && old.contains(buildTarget))
        old.removeOne(buildTarget);
    setBuildTargets(old);
}
Пример #23
0
void Settings::addRecentCodec(QString host)
{
    QStringList recents = recentCodecs();
    if (recents.contains(host))
        recents.removeOne(host);
    int topOfList = 0;
    recents.insert(topOfList, host);
    saveValue(KeyRecentCodecs, recents);
}
bool SettingsOperation::performOperation()
{
    // Arguments:
    // 1. path=settings file path or registry path
    // 2. method=set|remove|add_array_value|remove_array_value
    // 3. key=can be prepended by a category name separated by slash
    // 4. value=just the value
    // optional arguments are
    // formate=native or ini TODO
    // backup=true or false (default is true) TODO
    // NOTE: remove and remove_array_value will do nothing at the undostep

    if (!checkArguments())
        return false;
    const QString path = argumentKeyValue(QLatin1String("path"));
    const QString method = argumentKeyValue(QLatin1String("method"));
    const QString key = argumentKeyValue(QLatin1String("key"));
    const QString aValue = argumentKeyValue(QLatin1String("value"));

    // use MkdirOperation to get the path so it can remove it with MkdirOperation::undoOperation later
    KDUpdater::MkdirOperation mkDirOperation;
    mkDirOperation.setArguments(QStringList() << QFileInfo(path).absolutePath());
    mkDirOperation.backup();
    if (!mkDirOperation.performOperation()) {
        setError(mkDirOperation.error());
        setErrorString(mkDirOperation.errorString());
        return false;
    }
    setValue(QLatin1String("createddir"), mkDirOperation.value(QLatin1String("createddir")));

    QSettingsWrapper settings(path, QSettingsWrapper::IniFormat);
    if (method == QLatin1String("set"))
        settings.setValue(key, aValue);
    else if (method == QLatin1String("remove"))
        settings.remove(key);
    else if (method == QLatin1String("add_array_value")) {
        QVariant valueVariant = settings.value(key);
        if (valueVariant.canConvert<QStringList>()) {
            QStringList array = valueVariant.toStringList();
            array.append(aValue);
            settings.setValue(key, array);
        } else {
            settings.setValue(key, aValue);
        }
    } else if (method == QLatin1String("remove_array_value")) {
        QVariant valueVariant = settings.value(key);
        if (valueVariant.canConvert<QStringList>()) {
            QStringList array = valueVariant.toStringList();
            array.removeOne(aValue);
            settings.setValue(key, array);
        } else {
            settings.remove(key);
        }
    }

    return true;
}
Пример #25
0
const QStringList& rasterImageMimeTypes()
{
    static QStringList list;
    if (list.isEmpty()) {
        list = KImageIO::mimeTypes(KImageIO::Reading);
        resolveAliasInList(&list);
        // We don't want svg images to be considered as raster images
        Q_FOREACH(const QString& mimeType, svgImageMimeTypes()) {
            list.removeOne(mimeType);
        }
QStringList LXQt::Wallet::internalWallet::managedWalletList()
{
	char path[ 4096 ] ;
	lxqt_wallet_application_wallet_path( path,4096,m_applicationName.toLatin1().constData() ) ;
	QDir d( path ) ;
	QStringList l = d.entryList() ;
	l.removeOne( "." ) ;
	l.removeOne( ".." ) ;

	if( l.size() > 0 ){
		/*
		 * remove the extension part of a file name
		 */
		const QString& q = l.at( 0 ) ;
		l.replaceInStrings( q.mid( q.indexOf( "." ) ),"" ) ;
	}

	return l ;
}
Пример #27
0
void WSGI::proc()
{
    static QProcess *process = nullptr;
    if (!process) {
        process = new QProcess(this);
        connect(process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
                this, &WSGI::childFinished);
    }

    const QString app = QCoreApplication::applicationFilePath();
    QStringList args = QCoreApplication::arguments();
    args.takeFirst();
    args.removeOne(QStringLiteral("-M"));
    args.removeOne(QStringLiteral("--master"));

    process->setProcessChannelMode(QProcess::ForwardedChannels);

    process->start(app, args);
}
Пример #28
0
void GenericMakeStep::setBuildTarget(const QString &target, bool on)
{
    QStringList old = m_buildTargets;
    if (on && !old.contains(target))
         old << target;
    else if (!on && old.contains(target))
        old.removeOne(target);

    m_buildTargets = old;
}
Пример #29
0
QHash<int,QString> ReceiptsManager::getPercentages()
{
  QHash<int,QString> hash;
  receiptsEngine io;
  QHash<QString,QString> hashFromModel;
  hashFromModel = io.getPercentagesAccordingToUser();
  QStringList values = hashFromModel.values();
  if (hashFromModel.size()==0)
  {
    hash.insert(1,"0.00");
        hash.insert(2,"10.00");
        hash.insert(3,"20.00");
        hash.insert(4,"30.00");
        hash.insert(5,"33.33");
        hash.insert(6,"70.00");
        hash.insert(7,"100.00");
      }
  else{
    int count = values.count();
    QStringList listOfPercents;
    listOfPercents << "0.00";
    while (listOfPercents.size() < count +1)
    {
       QString minValue ;
       for (int i = 0; i < values.size(); ++i)
       {
           for (int j = 0; j < values.size(); j += 1)
           {
            if (values[i].toDouble() < values[j].toDouble())
            {
                minValue = values[i];
                }
               }
            }
        if (values.size()<2)
        {
              minValue = values[0];
            }
        if (WarnDebugMessage)
            qDebug() << __FILE__ << QString::number(__LINE__) << " minValue =" << minValue ;
        if (!listOfPercents.contains(minValue))
        {
              listOfPercents.append(minValue);
              values.removeOne(minValue)  ;
            }
        }
    listOfPercents << "100.00";
    for (int i = 0; i < listOfPercents.size() ; ++i)
    {
        hash.insert(i+1,listOfPercents[i]);
        }
    }

  return hash;
}
Пример #30
0
void
PartitionPage::editExistingPartition( Device* device, Partition* partition )
{
    QStringList mountPoints = getCurrentUsedMountpoints();
    mountPoints.removeOne( PartitionInfo::mountPoint( partition ) );

    QPointer<EditExistingPartitionDialog> dlg = new EditExistingPartitionDialog( device, partition, mountPoints, this );
    if ( dlg->exec() == QDialog::Accepted )
        dlg->applyChanges( m_core );
    delete dlg;
}