예제 #1
0
void
wCatalogEditor::checkUserFields( QStringList &lst)
{
	aCfgItem item = md->find(catId);
	int fid;
	if(item.isNull()) return;
	item = md->findChild(item,md_element);
	for(int i=0; i< md->count(item,md_field); i++)
  	{
		aCfgItem mdi = md->findChild(item,md_field,i);
		int ind = lst.findIndex(QString("uf%1").arg(md->attr(mdi,mda_id)));
		if(ind!=-1)
		{
			lst.insert(lst.at(i),lst[ind]);
			lst.remove(lst.at(ind+1));
			
		}
		else
		{
			ind = lst.findIndex(QString("text_uf%1").arg(md->attr(mdi,mda_id)));
			if(ind!=-1)
			{
				lst.insert(lst.at(i),lst[ind]);
				lst.remove(lst.at(ind+1));
			
			}
		}
  	}
	
}
예제 #2
0
int help(QStringList commands) {
    //qDebug() << "help(" << commands.join(" ") << ")" << endl;

    /**
     * Check input
     */
    if(commands.size() < 2 ) {

        errorStream << "Error: help(" << commands.join(" ") << ") has not enough parameters (help cmd ...)" << endl;
        return 1;
    }

    if(commands.at(0)!="help") {

        errorStream << "Error: help(" << commands.join(" ") << ") is no valid call (help cmd ...)" << endl;
        return 1;
    }

    commands.pop_front();
    commands.insert(0, "usage");

    usage(commands);

    commands.pop_front();
    commands.insert(0, "description");

    description(commands);

    return 0;
}
예제 #3
0
QStringList NFCHandler::parseIngredient(QString ing){
	QStringList list;
	QStringList result;
	list = ing.split(")", QString::SkipEmptyParts);

	for(int i=0; i<list.length(); i++){
			QStringList looplist;
			looplist = list.at(i).split(",", QString::SkipEmptyParts);

			// Get rid of leading (
			QString type = looplist.at(0);
			type = type.remove(QChar('('), Qt::CaseInsensitive).trimmed();


			if(type.toStdString() == "name"){

				result.insert(0, looplist.at(1).trimmed());

			} else if(type.toStdString() == "amount"){
				result.insert(1,looplist.at(1).trimmed());

			}

		}

	return result;

}
void TREE_SECIM_KERNEL::ADD_CHILD_ITEM (QStringList column_datas,int number_of_child, bool select_item_if_multi_row_enable)
{
    bool item_is_selected = false;

    if (m_is_multi_row EQ true) {
        if (select_item_if_multi_row_enable EQ false) {
            column_datas.insert   (0 , QString("ADD_CHECK_BOX"));
            column_datas       <<      QString("ADD_CHECK_BOX");
        }
        else {
            column_datas.insert   (0 , QString("ADD_SELECTED_CHECK_BOX"));
            column_datas            << QString("ADD_SELECTED_CHECK_BOX");
            item_is_selected       = true;
        }
    }

    BASE_TREE_KERNEL::ADD_CHILD_ITEM(column_datas,number_of_child);

    if (item_is_selected EQ true) {
        QTreeWidgetItem * item = GET_LAST_ADDED_ITEM();
        if ( item NE NULL ) {
            m_selected_items << item;
        }
    }
}
예제 #5
0
void ConnectionDialog::saveAndAccept ()
{
	if (serverEdit->currentText ().isEmpty ()
		|| roomEdit->currentText ().isEmpty ()
		|| nickEdit->currentText ().isEmpty ()) {

		QMessageBox::critical (this, "", tr ("Parameters is not valid"));
		return;
	}

	fSettings settings;
	if (serverEdit->findText (serverEdit->currentText (), Qt::MatchFixedString) == -1) {
		QStringList l = settings.value("Connection/Servers", QStringList ()).toStringList ();
		l.insert(0, serverEdit->currentText ());
		settings.setValue("Connection/Servers", l);
	}
	if (roomEdit->findText (roomEdit->currentText (), Qt::MatchFixedString) == -1) {
		QStringList l = settings.value("Connection/Rooms_" + serverEdit->currentText (), QStringList ()).toStringList ();
		l.insert(0, roomEdit->currentText ());
		settings.setValue("Connection/Rooms_" + serverEdit->currentText (), l);
	}
	if (nickEdit->findText (nickEdit->currentText (), Qt::MatchFixedString) == -1) {
		QStringList l = settings.value("Connection/Nicks_" + serverEdit->currentText (), QStringList ()).toStringList ();
		l.insert(0, nickEdit->currentText ());
		settings.setValue("Connection/Nicks_" + serverEdit->currentText (), l);
	}

	settings.setValue("Connection/LastServer", serverEdit->currentIndex ());
	settings.setValue("Connection/LastRoom_" + serverEdit->currentText (), roomEdit->currentIndex ());
	settings.setValue("Connection/LastNick_" + serverEdit->currentText (), nickEdit->currentIndex ());

	accept ();
}
void Ut_MApplicationExtensionManager::testOrdering()
{
    MWidget extensionWidget1;
    setupGoodExtension(true, &extensionWidget1);
    gMDesktopEntryStub->stubSetReturnValue("fileName", QString(APPLICATION_EXTENSION_DATA_DIR) + "/test");
    QSharedPointer<const MApplicationExtensionMetaData> metaData(new MApplicationExtensionMetaData(""));

    // order with one entry
    QStringList order;
    order << "test";
    setupTestSubject(QString(), QString(), order);
    setupGoodExtension(true, &extensionWidget1);
    QCOMPARE(manager->instantiateInProcessExtension(metaData), true);
    verifyOrderCreatedInDataStore(0);

    // order with three entries
    order.insert(0, "test2");
    order.insert(1, "");
    setupTestSubject(QString(), QString(), order);
    setupGoodExtension(true, &extensionWidget1);
    QCOMPARE(manager->instantiateInProcessExtension(metaData), true);
    verifyOrderCreatedInDataStore(2);
    // check that unordered entry goes to correct place
    gMDesktopEntryStub->stubSetReturnValue("fileName", QString(APPLICATION_EXTENSION_DATA_DIR) + "/unordered");
    setupGoodExtension(true, &extensionWidget1);
    QCOMPARE(manager->instantiateInProcessExtension(metaData), true);
    verifyOrderCreatedInDataStore(1);
    // check the first entry
    gMDesktopEntryStub->stubSetReturnValue("fileName", QString(APPLICATION_EXTENSION_DATA_DIR) + "/test2");
    setupGoodExtension(true, &extensionWidget1);
    QCOMPARE(manager->instantiateInProcessExtension(metaData), true);
    verifyOrderCreatedInDataStore(0);
}
예제 #7
0
static bool alsactl(QStringList & args)
{
    if(usePulse) {
        QProcess p;
        args.insert(0, "alsactl");
        args.insert(0, "--");
        qLog(AudioState) << "pasuspender " << args;
        p.start("pasuspender", args);
        p.waitForFinished(-1);
        return true;
    }
    
    qLog(AudioState) << "alsactl " << args;

    for(int i = 0; i < 8; i++) {
        
        QProcess p;
        p.start("alsactl", args);
        p.waitForFinished(-1);
        QString output = p.readAllStandardOutput();
        output += p.readAllStandardError();

        if(output.length() == 0)
            return true;

        qWarning() << "alsactl returned " << output << ", running kill-snd-card-users.sh";
        QProcess::execute("kill-snd-card-users.sh");
    }
    return false;
}
예제 #8
0
bool MQLUtil::rewriteMetadata(QString &query,      const QString &group,
                              const QString &name, const QString &notes)
{
  QStringList lines = query.split("\n");
  QString groupline;
  QString nameline;

  for (int i = 0; i < lines.size(); i++)
  {
    if (groupRE.indexIn(lines.at(i)) >= 0)
    {
      if (groupRE.cap(2).trimmed().compare(group.trimmed(), Qt::CaseInsensitive) == 0)
        groupline = lines.takeAt(i--);
      else
        lines.removeAt(i--);
    }
    else if (nameRE.indexIn(lines.at(i)) >= 0)
    {
      if (nameRE.cap(2).trimmed().compare(name.trimmed(), Qt::CaseInsensitive) == 0)
        nameline = lines.takeAt(i--);
      else
        lines.removeAt(i--);
    }
    else if (notesRE.indexIn(lines.at(i)) >= 0)
    {
      lines.removeAt(i--);
      while (dashdashRE.indexIn(lines.at(++i)) >= 0)
        lines.removeAt(i--);
    }
  }

  QStringList noteslines = notes.split("\n");
  if (noteslines.size() > 0)
  {
    if (! noteslines.at(0).contains(notesRE))
      noteslines.replace(0, "-- Notes: " + noteslines.at(0));

    for (int i = 1; i < noteslines.size(); i++)
      if (dashdashRE.indexIn(noteslines.at(i)) < 0)
        noteslines.replace(i, "--        " + noteslines.at(i));
  }

  if (groupline.isEmpty())
    lines.insert(0, "-- Group: " + group);
  else
    lines.insert(0, groupline);

  if (nameline.isEmpty())
    lines.insert(1, "-- Name:  " + name);
  else
    lines.insert(1, nameline);

  for (int i = 0; i < noteslines.size(); i++)
    lines.insert(i + 2, noteslines.at(i));

  query = lines.join("\n");

  return true;
}
vCardProperty vCardProperty::createGeographicPosition(qreal latitude, qreal longitude, const vCardParamList& params)
{
    QStringList values;
    values.insert(vCardProperty::Latitude, QString("%1").arg(latitude));
    values.insert(vCardProperty::Longitude, QString("%1").arg(longitude));

    return vCardProperty(VC_GEOGRAPHIC_POSITION, values, params);
}
예제 #10
0
GDB::GDB() 
: sawPrompt_(false), currentCmd_(0)
{
    process_ = new KProcess(this);
    process_->setOutputChannelMode( KProcess::SeparateChannels ); 
    connect(process_, SIGNAL(readyReadStandardOutput()), 
            SLOT(readyReadStandardOutput()));
    connect(process_, SIGNAL(readyReadStandardError()), 
            SLOT(readyReadStandardError()));
    connect(process_, 
            SIGNAL(finished(int, QProcess::ExitStatus)),
            SLOT(processFinished(int, QProcess::ExitStatus)));
    connect(process_, SIGNAL(error(QProcess::ProcessError)),
            SLOT(processErrored(QProcess::ProcessError)));

    KConfigGroup config(KGlobal::config(), "GDB Debugger");    
    QString gdb = config.readEntry("GDB Path", "gdb");

    QStringList arguments;
    arguments << "--interpreter=mi2" << "-quiet";

    QString shell = config.readEntry("Debugger Shell");
    if( !shell.isEmpty() )
    {
        shell = shell.simplified();
        QString shell_without_args = shell.split(QChar(' ')).first();

        QFileInfo info( shell_without_args );
        /*if( info.isRelative() )
        {
            shell_without_args = build_dir + "/" + shell_without_args;
            info.setFile( shell_without_args );
        }*/
        if( !info.exists() )
        {
            KMessageBox::information(
                qApp->activeWindow(),
                i18n("Could not locate the debugging shell '%1'.", shell_without_args ),
                i18n("Debugging Shell Not Found") );
            // FIXME: throw, or set some error message.
            return;
        }

        arguments.insert(0, gdb );
        arguments.insert(0, shell);
        process_->setShellCommand( KShell::joinArgs( arguments ) );
    }
    else
    {
        process_->setProgram( gdb, arguments );
    }

    process_->start();

    emit userCommandOutput(shell + " " + gdb
                           + " --interpreter=mi2 -quiet\n" );
}
QString ClawsMailSettings::writeColor(const QColor& col)
{
    QStringList list;
    list.insert(0, QString::number(col.red()));
    list.insert(1, QString::number(col.green()));
    list.insert(2, QString::number(col.blue()));
    if (col.alpha() != 255)
        list.insert(3, QString::number(col.alpha()));
    return list.join(QLatin1String(","));
}
예제 #12
0
	bool UserCommandManager::VerifyMessage (const QString& msg, 
			const QString& channelName)
	{
		const int pos = msg.indexOf (' ');
		QString cmd;
		if (msg.startsWith ('/'))
			cmd = msg.mid (1, pos).trimmed ().toLower ();
		else
			cmd = msg.left (pos).trimmed ().toLower ();

		if (!Command2Action_.contains (cmd))
			return false;

		QString message;
		QStringList messageList;
		if (pos != -1)
		{
			message = msg.mid (pos).trimmed ();
			messageList = message.split (' ');
		}

		if (cmd == "me")
		{
			messageList.insert (1, channelName);
			messageList.insert (2, "ACTION");
		}
		else if (cmd == "part" && message.isEmpty ())
			messageList << channelName; //TODO message for part
		else if (cmd == "join" && !message.isEmpty ())
		{
			QStringList channelList = messageList.first ().split (',');

			for (int i = 0; i < channelList.count (); ++i)
			{
				const QString& channel = channelList.at (i);
				if (!channel.startsWith ('#') && 
						!channel.startsWith ('+') && 
						!channel.startsWith ('&') && 
						!channel.startsWith ('!'))
					channelList [i].prepend ('#');
			}

			QString passwords;
			if (messageList.count () == 2)
				passwords = messageList.last ();
			messageList.clear ();
			messageList << channelList.join (",")
					<< passwords;
		}
		else if (cmd == "kick" && !message.isEmpty ())
			if (ISH_->IsParticipantExists (messageList.first ()))
				messageList.insert (0, channelName);
		Command2Action_ [cmd] (messageList);
		return true;
	}
예제 #13
0
vCardProperty vCardProperty::createName(const QString& firstname, const QString& lastname, const QString& additional, const QString& prefix, const QString& suffix, const vCardParamList& params)
{
    QStringList values;
    values.insert(vCardProperty::Lastname, lastname);
    values.insert(vCardProperty::Firstname, firstname);
    values.insert(vCardProperty::Additional, additional);
    values.insert(vCardProperty::Prefix, prefix);
    values.insert(vCardProperty::Suffix, suffix);

    return vCardProperty(VC_NAME, values, params);
}
NCSLocalApplicationBridge::~NCSLocalApplicationBridge()
{
    m_process->disconnect();
    if (m_destroyProcess)
    {
        m_process->kill();
        m_process->waitForFinished();

        QProcess checker;
        QStringList checkParams;
        checkParams << m_name;
        #ifdef Q_OS_LINUX
            checker.start("pidof",checkParams,QIODevice::ReadOnly);
            checker.waitForFinished(-1);

        #elif Q_OS_WINDOWS
            params.insert(0,"/v");
            params.insert(1,"/fo");
            params.insert(2,"csv");
            params.insert(3,"|");
            params.insert(4,"findstr");
            params.insert(5,"/i");
            checker.start("tasklist",checkParams,QIODevice::ReadOnly);
            checker.waitForFinished(-1);
        #endif

        QStringList pids = QString(checker.readAllStandardOutput()).split( " ");
        QString pidString = pids.first();
        pidString.replace("\r\n","");
        pidString.replace('\n',"");
        if (pidString != "")
        {
            QProcess killer;
            QStringList killParams;
            killParams << pidString;
            #ifdef Q_OS_LINUX
                killer.start("kill",killParams,QIODevice::ReadOnly);
                killer.waitForFinished(-1);

            #elif Q_OS_WINDOWS
                killParams.insert(0,"-f");
                killParams.insert(1,"/PID");
                killer.start("taskkill",killParams,QIODevice::ReadOnly);
                killer.waitForFinished(-1);
            #endif
        }

    }
}
예제 #15
0
void QMplayer::play(QStringList & args)
{
    showScreen(QMplayer::ScreenPlay);

    if(useBluetooth < 0)
    {
        QFile f("/etc/asound.conf");
        if(f.exists() && f.open(QIODevice::ReadOnly | QIODevice::Text))
        {
            QByteArray text = f.readAll();
            f.close();
            useBluetooth = ((text.indexOf("pcm.bluetooth") >= 0) &&
                            QMessageBox::question(this, tr("qmplayer"), tr("Use bluetooth headset?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes);
        }
    }
    if(useBluetooth > 0)
    {
        args.insert(0, "alsa:device=bluetooth");
        args.insert(0, "-ao");
    }

    PLAY:

    process = new QProcess(this);
    connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus)));
    process->setProcessChannelMode(QProcess::ForwardedChannels);
    process->start("mplayer", args, QIODevice::ReadWrite);

    if(!process->waitForStarted(5000))
    {
       delete(process);
       process = NULL;

       if(QMessageBox::question(this, tr("qmplayer"),
                             tr("Program MPlayer must be downloaded. Please make sure you have internet connection and press yes to confirm download"),
                             QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
       {
           showScreen(QMplayer::ScreenDownload);
           if(installMplayer())
           {
               QMessageBox::information(this, tr("qmplayer"), tr("MPlayer installed sucessfully"));
               goto PLAY;
           }
           QMessageBox::warning(this, tr("qmplayer"), tr("Failed to install MPlayer"));
           showScreen(QMplayer::ScreenInit);
       }
       return;
    }
}
예제 #16
0
/**
 * @brief Adds the VALARM block to the ics data
 */
bool CalendarItem::addVALARMBlockToICS() {
    // make a copy of the data
    QHash<QString, QString> icsDataHashCopy = icsDataHash;
    QStringList icsDataKeyListCopy = icsDataKeyList;

    bool foundBegin = false;

    for (int i = 0; i < icsDataKeyList.size(); ++i) {
        QString key = icsDataKeyList.at(i);
        QString value = icsDataHash.value(key);

        // look for the VTODO begin block
        if (key.startsWith("BEGIN") && (value == "VTODO")) {
            foundBegin = true;
        }

        // add the VALARM block at the end of the VTODO block
        if (foundBegin && key.startsWith("END") && (value == "VTODO")) {
            QString addKey;
            addKey = findFreeHashKey(&icsDataHashCopy, "BEGIN");
            icsDataHashCopy[addKey] = "VALARM";
            icsDataKeyListCopy.insert(i, addKey);

            addKey = findFreeHashKey(&icsDataHashCopy, "ACTION");
            icsDataHashCopy[addKey] = "DISPLAY";
            icsDataKeyListCopy.insert(++i, addKey);

            addKey = findFreeHashKey(&icsDataHashCopy, "DESCRIPTION");
            icsDataHashCopy[addKey] = "Reminder";
            icsDataKeyListCopy.insert(++i, addKey);

            addKey = findFreeHashKey(&icsDataHashCopy, "TRIGGER;VALUE=DATE-TIME");
            icsDataHashCopy[addKey] = alarmDate.toUTC().toString(ICS_DATETIME_FORMAT);
            icsDataKeyListCopy.insert(++i, addKey);

            addKey = findFreeHashKey(&icsDataHashCopy, "END");
            icsDataHashCopy[addKey] = "VALARM";
            icsDataKeyListCopy.insert(++i, addKey);

            // write the data back and end
            icsDataHash = icsDataHashCopy;
            icsDataKeyList = icsDataKeyListCopy;
            return true;
        }
    }

    return false;
}
예제 #17
0
//### KDE5:Consider merging the setApplicationPath and setApplicationName methods into one.
void
KCrash::setApplicationPath(const QString& path)
{
    s_appPath = qstrdup(QFile::encodeName(path).constData());

    //if the appName has also been specified, update s_autoRestartCommand to be in the form "absolutePath/appName"
    if (s_appName) {
        delete[] s_autoRestartCommand;
        QFileInfo appExecutable(QDir(path), QFile::decodeName(s_appName));
        QByteArray cmd = QFile::encodeName(appExecutable.absoluteFilePath());
        s_autoRestartCommand = qstrdup(cmd.constData());
    }

    QStringList args = KCmdLineArgs::allArguments();
    args[0] = s_autoRestartCommand; // replace argv[0] with full path above
    if (!args.contains("--nocrashhandler"))
         args.insert(1, "--nocrashhandler");
    delete[] s_autoRestartCommandLine;
    s_autoRestartArgc = args.count();
    s_autoRestartCommandLine = new char* [args.count() + 1];
    for (int i = 0; i < args.count(); ++i) {
        s_autoRestartCommandLine[i] = qstrdup(QFile::encodeName(args.at(i)).constData());
    }
    s_autoRestartCommandLine[args.count()] = 0;
}
예제 #18
0
void SettingsTab::loadSettings()
{
    settings->beginGroup(plugin->getPluginId());

    recDevBox->setCurrentText(settings->value("device", "").toString());
    recsDir->setText(settings->value("recsDir", "").toString());
    channels->setCurrentIndex(settings->value("channels", 1).toInt()-1);
    bitrate->setCurrentText(QString("%1 kbit/s").arg(settings->value("bitrate", 64).toInt()));
    sampleRate->setCurrentText(QString("%1 Hz").arg(settings->value("sampleRate", 44100).toInt()));

    QString fmt = settings->value("filenameFormat", "%n% %yyyy%-%MM%-%dd% %hh%.%mm%").toString();
    QStringList fmts;
    fmts << "%n% %yyyy%-%MM%-%dd% %hh%.%mm%"
         << "%yyyy%-%MM%-%dd% %n%"
         << "%n%";

    if(!fmts.contains(fmt))
    {
        fmts.insert(0, fmt);
    }

    filenameFmt->clear();
    filenameFmt->addItems(fmts);
    filenameFmt->setCurrentIndex(fmts.indexOf(fmt));

    settings->endGroup();
}
예제 #19
0
void PluginChoooserWidget::loadImpl()
{
	clear();
	Config group = Config().group("plugins/list");
	QStandardItem *parent_item = m_model->invisibleRootItem();

    QList<QWeakPointer<Plugin> > plugins = pluginsList();
	QStringList helper;
    for (int i = 0; i < plugins.size(); i++) {
        const PluginInfo &info = plugins.at(i).data()->info();
        QLatin1String class_name(plugins.at(i).data()->metaObject()->className());
        if (!m_plugin_items.contains(info.name())) {
			QIcon icon = info.icon();
			if (icon.isNull() || !icon.availableSizes().count())
				icon = Icon("applications-system");
			QString name = info.name();
			int index = qLowerBound(helper, name) - helper.constBegin();
			helper.insert(index, name);
			ServiceItem *item = new ServiceItem(icon, name);
			item->setToolTip(html(info));
			item->setCheckable(true);
			item->setData(true,ServiceItem::ExclusiveRole);
			item->setData(info.description().toString(), DescriptionRole);
			item->setCheckState((group.value(class_name, true) ? Qt::Checked : Qt::Unchecked));
			parent_item->insertRow(index, item);
			m_plugin_items.insert(class_name, item);
            m_plugins.insert(class_name, plugins.at(i).data());
		}
	}
}
예제 #20
0
QStringList QgsDelimitedTextProvider::splitLine( QString line, QString delimiterType, QString delimiter )
{
  QgsDebugMsgLevel( "Attempting to split the input line: " + line + " using delimiter " + delimiter, 3 );

  QStringList parts;
  if ( delimiterType == "regexp" )
    parts = line.split( QRegExp( delimiter ) );
  else
    parts = line.split( delimiter );

  QgsDebugMsgLevel( "Split line into " + QString::number( parts.size() ) + " parts", 3 );

  if ( delimiterType == "plain" )
  {
    QChar delim;
    int i = 0, first = parts.size();
    while ( i < parts.size() )
    {
      if ( delim == 0 && ( parts[i][0] == '"' || parts[i][0] == '\'' ) )
      {
        delim = parts[i][0];
        first = i;
        continue;
      }

      if ( delim != 0 && parts[i][ parts[i].length() - 1 ] == delim )
      {
        parts[first] = parts[first].mid( 1 );
        parts[i] = parts[i].left( parts[i].length() - 1 );

        if ( first < i )
        {
          QStringList values;
          while ( first <= i )
          {
            values << parts[first];
            parts.takeAt( first );
            i--;
          }

          parts.insert( first, values.join( delimiter ) );
        }

        first = -1;
        delim = 0;
      }

      i++;

      if ( i == parts.size() && first >= 0 )
      {
        i = first + 1;
        first = -1;
        delim = 0;
      }
    }
  }

  return parts;
}
예제 #21
0
//Change the current Cursor Theme
bool LTHEME::setCursorTheme(QString cursorname){
//qDebug() << "Set Cursor Theme:" << cursorname;
  QStringList info = LUtils::readFile(QDir::homePath()+"/.icons/default/index.theme");
    bool insection = false;
    bool changed = false;
    QString newval = "Inherits="+cursorname;
    for(int i=0; i<info.length() && !changed; i++){
      if(info[i]=="[Icon Theme]"){ 
	insection = true;
      }else if( info[i].startsWith("[") && insection){ 
	//Section does not have the setting - add it
	info.insert(i, newval); 
	changed =true;
      }else if( info[i].startsWith("[") ){ 
	insection = false;
      }else if(insection && info[i].startsWith("Inherits=")){
        info[i] = newval; //replace the current setting
        changed = true;
      }
    } //end loop over file contents
    if(!changed){ //Could not change the file contents for some reason
      if(insection){ info << newval; } //end of file while in the section
      else{ info << "[Icon Theme]" << newval; } //entire section missing from file
    }
    //Now save the file
    //qDebug() << "Done saving the cursor:" << info;
    return LUtils::writeFile(QDir::homePath()+"/.icons/default/index.theme", info, true);
}
/******************************************************************************
* Called when the New From Template action is clicked.
* Creates a popup menu listing all alarm templates, in sorted name order.
*/
void TemplateMenuAction::slotInitMenu()
{
	KMenu* m = menu();
	m->clear();
	mOriginalTexts.clear();

	// Compile a sorted list of template names
	int i, end;
	QStringList sorted;
	KAEvent::List templates = KAlarm::templateList();
	for (i = 0, end = templates.count();  i < end;  ++i)
	{
		QString name = templates[i]->templateName();
		int j = 0;
		for (int jend = sorted.count();
		     j < jend  &&  QString::localeAwareCompare(name, sorted[j]) > 0;
		     ++j) ;
		sorted.insert(j, name);
	}

	for (i = 0, end = sorted.count();  i < end;  ++i)
	{
		QAction* act = m->addAction(sorted[i]);
		mOriginalTexts[act] = sorted[i];   // keep original text, since action text has shortcuts added
	}
}
QString tvNetworkControl::byteArrayToHexaString(const QByteArray &array, bool needHexConversion) const
{
    QString hex;
    if (needHexConversion) {
        hex = QString(array.toHex());
    } else {
        hex = QString(array);
    }

    int byteCount = 0;
    for (int i = 0; i < hex.size() + 1; i++) { //add a space to make groups of bytes
        if ((i+1) % 3) {
            hex.insert(i++, ' ');
            byteCount++;
        }
    }

    // big hack to break lines, ugly but it works
    QStringList byteList = hex.split(' ');
    for (double i = 1; i < (byteCount / 16.0) + 1; i++) {
        byteList.insert(i * 17, "<br>");
    }

    // make it nicer, still super hacky but it does the trick
    hex = byteList.join(" ");
    hex.replace(QString("<br> "), QString("<br>"));
    return hex;
}
예제 #24
0
void SakbotWrapper::saveResult(QString path)
{
    // get the path
    QStringList components = path.split('/');
    components.insert(components.length()-1,"Method1");
    path = components.join("/");

    // get the image and masks
    cv::Mat image;
    cv::Mat shadow;
    cv::Mat segmentation;

    m_sakbot.getImage( image );
    m_sakbot.getShadowMask( shadow );
    m_sakbot.getSegmentationMask( segmentation );

    // draw the shadow's contours
    std::vector<std::vector<cv::Point> > contours;
    cv::findContours(shadow,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);
    cv::drawContours(image,contours,-1,cv::Scalar(0,255,0),1);

    // draw the segmentation's contours
    cv::findContours(segmentation,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);
    cv::drawContours(image,contours,-1,cv::Scalar(0,0,255),1);

    // save the image
    cv::imwrite(path.toStdString(), image);
}
예제 #25
0
bool PhDocumentWindow::openDocument(const QString &fileName)
{
	if(fileName != _settings->currentDocument())
		resetDocument();

	if(_watcher.addPath(fileName))
		PHDEBUG << "now watching " << fileName;
	_settings->setCurrentDocument(fileName);
	if(!fileName.isEmpty())
		_settings->setLastDocumentFolder(QFileInfo(fileName).absolutePath());
	this->setWindowTitle(fileName);

	QStringList recentDocList = _settings->recentDocumentList();
	recentDocList.removeAll(fileName);
	recentDocList.insert(0, fileName);
	while(recentDocList.size() > _settings->maxRecentDocument())
		recentDocList.removeLast();

	_settings->setRecentDocumentList(recentDocList);

	updateRecentDocumentMenu();

	addFilePermission(fileName);

	return true;
}
예제 #26
0
void Terminal::doExecute()
{
    logMessage("Terminal::doExecute()");

    if (!txtCommand->text().isEmpty())
    {
        QSettings settings;
        QStringList list = settings.value("CommandDialog/RecentCommands").value<QStringList>();

        list.insert(0, txtCommand->text());

        // remove last item (over 50), empty strings and duplicates
        list.removeAll("");
        // list.removeDuplicates();
        while (list.count() > 50)
            list.removeAt(list.count()-1);

        txtCommand->model()->setStringList(list);
        settings.setValue("CommandDialog/RecentCommands", list);

        // command
        doPrintStdout(">>> " + txtCommand->text() + "\n", Qt::black);

        // execute command
        doWriteResult(runPythonScript(txtCommand->text()));
    }
    txtCommand->clear();
    txtCommand->setFocus();
}
예제 #27
0
QString BApplicationPrivate::findImage(const QString &subdir, const QString &name, const QStringList &preferredFormats)
{
    if (!testInit("BApplicationPrivate"))
        return "";
    if (subdir.isEmpty() || name.isEmpty())
        return "";
    QString bfn = QFileInfo(name).baseName();
    QStringList suffixes;
    foreach (const QByteArray &ba, QImageReader::supportedImageFormats())
        suffixes << QString(ba);
    int indsvg = suffixes.indexOf("svg");
    if (indsvg >= 0)
        suffixes.insert(indsvg, "svgz");
    for (int i = preferredFormats.size() - 1; i >= 0; --i) {
        const QString &fmt = preferredFormats.at(i);
        if (suffixes.contains(fmt)) {
            suffixes.removeAll(fmt);
            suffixes.prepend(fmt);
        }
    }
    foreach (const QString &suff, suffixes) {
        if (suff.isEmpty())
            continue;
        QString fn = BDirTools::findResource(subdir + "/" + bfn + "." + suff, BDirTools::GlobalOnly);
        if (!fn.isEmpty())
            return fn;
    }
    return "";
}
예제 #28
0
void CreatorDialog::printVars()
{
    // print vars
    QStringList list;
    for (unsigned i = 0; i < m_varsCount; i++)
        list.insert(0, QString(m_vars[i]));
    m_varsLine->setText(list.join(","));
}
예제 #29
0
static void entryCreated(const QString &url, int insertChildAt, QStringList &existingEntries)
{
    const QString fileName = Functions::fileName(url);
    if (insertChildAt < 0 || insertChildAt >= existingEntries.count())
        existingEntries.append(fileName);
    else
        existingEntries.insert(insertChildAt, fileName);
}
예제 #30
0
void MainWindow::on_add_clicked()
{
    QStringList options = QFileDialog::getOpenFileNames();
    options.insert(0, "add"); //The fires option is the command.

    sendToDaemon(options);
//    addItems(core->addSong());
}