Esempio n. 1
0
QString opposite_color(QStringList list, int *error)
{
    if(list.filter("blue").count() == 0)
    {
        return "blue";
    }
    else if(list.filter("red").count() == 0)
    {
        return "red";
    }
    else if(list.filter("green").count() == 0)
    {
        return "green";
    }
    else if(list.filter("white").count() == 0)
    {
        return "white";
    }
    else if(list.filter("orange").count() == 0)
    {
        return "orange";
    }
    else
    {
        //Incorrect color selection
        *error = 11;
        return "error";
    }
}
Esempio n. 2
0
QStringList CSite::traffic(quint16 &busy) const {
    QStringList zeeiList = m_zeei.split("\n");
    QStringList btsList = zeeiList.filter("BTS-");

    busy = 0;
    QStringList btss;

    for (int i = 0; i < btsList.count(); i++) {
        QStringList btsLine = btsList[i].split(" ");
        btsLine.removeAll("");

        QString state = btsLine[btsLine.indexOf(btsLine.filter("BTS-").first()) + 2];
        if (state.contains("BL-")) {
            btss << state;
            continue;
        }

        QString fr = btsLine.takeLast();
        QString hr = btsLine.takeLast();

        quint8 btsBusy = fr.toUShort() + hr.toUShort();

        if (!btsBusy)
            btss << "EMPTY";
        else if (i < m_caps.count() && btsBusy > m_caps[i] - BUSY_LIMIT)
            btss << "FULL";
        else
            btss << QString::number(btsBusy);

        busy += btsBusy;
    }

    return btss;
}
Esempio n. 3
0
//================
//    PUBLIC SLOTS
//================
void page_fluxbox_settings::SaveSettings(){
  QStringList FB;
  if(ui->radio_simple->isChecked()){
    FB = readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-init");
    // - window placement
    int index = FB.indexOf( FB.filter("session.screen0.windowPlacement:").join("") );
    QString line = "session.screen0.windowPlacement:\t"+ui->combo_session_wloc->itemData( ui->combo_session_wloc->currentIndex() ).toString();
    if(index < 0){ FB << line; } //add line to the end of the file
    else{ FB[index] = line; } //replace the current setting with the new one
    // - window focus
    index = FB.indexOf( FB.filter("session.screen0.focusModel:").join("") );
    line = "session.screen0.focusModel:\t"+ui->combo_session_wfocus->itemData( ui->combo_session_wfocus->currentIndex() ).toString();
    if(index < 0){ FB << line; } //add line to the end of the file
    else{ FB[index] = line; } //replace the current setting with the new one
    // - window theme
    index = FB.indexOf( FB.filter("session.styleFile:").join("") );
    line = "session.styleFile:\t"+ui->combo_session_wtheme->itemData( ui->combo_session_wtheme->currentIndex() ).toString();
    if(index < 0){ FB << line; } //add line to the end of the file
    else{ FB[index] = line; } //replace the current setting with the new one
    // - workspace number
    index = FB.indexOf( FB.filter("session.screen0.workspaces:").join("") );
    line = "session.screen0.workspaces:\t"+QString::number(ui->spin_session_wkspaces->value());
    if(index < 0){ FB << line; } //add line to the end of the file
    else{ FB[index] = line; } //replace the current setting with the new one
  }else{
    //advanced editor
    FB = ui->text_file->toPlainText().split("\n");
  }
  //Save the fluxbox settings
  bool ok = overwriteFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-init", FB);
  if(!ok){ qDebug() << "Warning: Could not save fluxbox-init"; }
  emit HasPendingChanges(false);
}
Esempio n. 4
0
/**
 * get MSSQL ODBC drivers name and version, every item such as:
 * -------------------------------------------------------------
 *     10.00/SQL Server Native Client 10.0
 *     09.00/SQL Native Client
 *     03.50/SQL Server
 * -------------------------------------------------------------
 * @author  XChinux<*****@*****.**>
 * @final   2013-04-18
 * @return  QStringList         desc sorted ver/drivername lists
 */
QStringList TcMSSQL::availableODBCDrivers()
{
    QStringList slDrivers;
#ifdef Q_OS_WIN
    QSettings  sts("HKEY_LOCAL_MACHINE\\SOFTWARE\\ODBC\\ODBCINST.INI"
            "\\ODBC Drivers", QSettings::NativeFormat);
    QStringList slKeys = sts.allKeys();

    QStringList slKeys2;
    slKeys2 << slKeys.filter("SQL Server") << slKeys.filter("Native Client");
    slKeys2.removeDuplicates();
    QStringListIterator it(slKeys2);

    while (it.hasNext())
    {
        QString strV = it.next();
        if (sts.value(strV).toString() == "Installed")
        {
            QSettings sts2("HKEY_LOCAL_MACHINE\\SOFTWARE\\ODBC\\ODBCINST.INI\\"
                + strV, QSettings::NativeFormat);
            strV.prepend(sts2.value("DriverODBCVer").toString() + "/");
            slDrivers << strV;
        }
    }
    qSort(slDrivers.begin(), slDrivers.end(), qGreater<QString>());
#endif
    return slDrivers;
}
Esempio n. 5
0
gpu::driver gpu::detectDriver() {
    QStringList out = globalStuff::grabSystemInfo("lsmod");

    if (!out.filter("radeon").isEmpty())
        return XORG;
    if (!out.filter("fglrx").isEmpty())
        return FGLRX;

    return DRIVER_UNKNOWN;
}
Esempio n. 6
0
QStringList Backend::disktypeInfo(QString node){
  //Run disktype on the device and return any info
  QStringList info = runShellCommand("disktype /dev/"+node);
  //In case there are multiple partitions on the device, remove all the invalid ones (EFI boot partitions for instance)
  QStringList parts = info.join("\n").split("\nPartition ");
  //qDebug() << "DiskType Partitions:" << node << parts;
  if(parts.filter("Volume name ").length()>0){
    parts = parts.filter("Volume name ");
    if(parts.length()>1 && parts.filter("file system").isEmpty()){ parts = parts.filter("file system"); }
  }
  for(int i=0; i<parts.length(); i++){
    if(parts[i].contains("Partition GUID ") ){ parts.removeAt(i); i--; } //EFI boot partition
  }
  if(!parts.isEmpty()){
    info = parts[0].split("\n"); //only use the first partition with both a label and a file system
  }
  //qDebug() << " - Filtered:" << info;
  //qDebug() << "Disktype Detection:" << node;
  QStringList dsDetection = DEVDB::disktypeDetectionStrings();
  QString bytes, fs, type, label; 
  bool blankDisk=false;
  for(int i=0; i<info.length(); i++){
    //qDebug() << "Line:" << info[i];
    if(info[i].isEmpty() || info[i].startsWith("---")){ continue; } //skip this line
    else if( info[i].startsWith("Character device,") && !info[i].contains("unknown size") ){
      //Get the size if possible
      QString tmp = info[i].section("(",1,1).section(")",0,0);
      if(tmp.contains("bytes")){ bytes = tmp.section(" ",0,0,QString::SectionSkipEmpty); }
      //qDebug() << " - bytes:" << bytes;
    }else if( info[i].contains("Blank disk/medium") ){ 
      blankDisk = true;
      //qDebug() << " - Blank disk";
    }else if( info[i].contains("file system") ){
      if(fs.isEmpty() || !fs.contains("(hints")){
        QString tmp = info[i].section("file system",0,0);
        for(int j=0; j<dsDetection.length(); j++){
          if(tmp.contains(dsDetection[j].section("::::",0,0))){ fs = dsDetection[j].section("::::",1,1); break; }
        }
      }
      //qDebug() << " - File System:" << fs;
    }else if( info[i].contains("Volume name") ){
      label = info[i].section("\"",1,1).section("\"",0,0).simplified(); //name is within quotes
      //qDebug() << " - Label:" << label;
    }
    //stop if all info found (size is always the first to be found in info)
    if(!fs.isEmpty() && !label.isEmpty()){ break; }
  }
  if( (blankDisk || (bytes.toInt()<2049) ) && (node.startsWith("cd") || node.startsWith("acd")) && label.isEmpty() && fs.isEmpty() ){ type = "CD-BLANK"; }
  if( (node.startsWith("cd")||node.startsWith("acd")) && (bytes.isEmpty()) ){ type = "CD-NONE"; }
  //Format the outputs
  //qDebug() << "Results:" << fs << label << type;
  return (QStringList() << fs << label << type);
}
Esempio n. 7
0
void PreferencesDialog::updateSyntaxElementLabel(QLabel* Label, const QStringList& Decorations,
  const QString& ColorName)
{
  QStringList Font = Decorations.filter(QRegExp("bold|italic"));
  QStringList TextDecoration = Decorations.filter(QRegExp("underline|strike-through"));

  QString Stylesheet = QString("QLabel {font: %1;text-decoration: %2;color: %3}")
          .arg(Font.isEmpty() ? "none" : Font.join(" "))
          .arg(TextDecoration.isEmpty() ? "none" : TextDecoration.join(" ").replace("strike-through","line-through"))
          .arg(ColorName);

  Label->setStyleSheet(Stylesheet);

  Label->setProperty("ColorName",ColorName);
}
Esempio n. 8
0
void Firefox::reloadConfiguration()
{
    KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), QLatin1String("General") );
    if (QSqlDatabase::isDriverAvailable("QSQLITE")) {
        KConfigGroup grp = config;
        /* This allows the user to specify a profile database */
        m_dbFile = grp.readEntry<QString>("dbfile", "");
        if (m_dbFile.isEmpty() || QFile::exists(m_dbFile)) {
            //Try to get the right database file, the default profile is used
            KConfig firefoxProfile(QDir::homePath() + "/.mozilla/firefox/profiles.ini",
                                   KConfig::SimpleConfig);
            QStringList profilesList = firefoxProfile.groupList();
            profilesList = profilesList.filter(QRegExp("^Profile\\d+$"));
            int size = profilesList.size();

            QString profilePath;
            if (size == 1) {
                // There is only 1 profile so we select it
                KConfigGroup fGrp = firefoxProfile.group(profilesList.first());
                profilePath = fGrp.readEntry("Path", "");
            } else {
                // There are multiple profiles, find the default one
                foreach(const QString & profileName, profilesList) {
                    KConfigGroup fGrp = firefoxProfile.group(profileName);
                    if (fGrp.readEntry<int>("Default", 0)) {
                        profilePath = fGrp.readEntry("Path", "");
                        break;
                    }
                }
            }
Esempio n. 9
0
ScriptFunction ScriptParser::findFunction(QString functionName, int nbArgs, bool &ok)
{
    QStringList functionNames = _functions.keys();
    functionNames = functionNames.filter(functionName,Qt::CaseInsensitive);

    if(functionNames.isEmpty())
    {
        ok = false;
        return ScriptFunction(QString(),QStringList());
    }
    else
    {
        ScriptFunction function = _functions.value(functionNames.first());
        if(nbArgs==function.args.size())
        {
            ok = true;
            return function;
        }
        else
        {
            ok = false;
            return ScriptFunction(QString(),QStringList());
        }
    }
}
Esempio n. 10
0
QStringList DiskUtil::dataDirFileList(const QString &subdirectory) {

    QDir dir(DiskUtil::dataDir() + subdirectory);
    QStringList entries = dir.entryList(QDir::Files);
    return entries.filter(QRegExp("^[^.].*$")); // extra filter to remove files starting
                                                // with a dot on Windows
}
void QtVCardPhotoAndNameFields::setEditable(bool editable) {
    this->editable = editable;

    ui->avatarWidget->setEditable(editable);
    ui->lineEditFN->setVisible(editable);
    ui->labelFN->setVisible(!editable);

    ui->lineEditNICKNAME->setVisible(editable);
    ui->labelNICKNAME->setVisible(!editable);

    // prefix given middle last suffix
    ui->lineEditPREFIX->setVisible(editable);
    ui->lineEditGIVEN->setVisible(editable);
    ui->lineEditMIDDLE->setVisible(editable);
    ui->lineEditFAMILY->setVisible(editable);
    ui->lineEditSUFFIX->setVisible(editable);
    ui->labelFULLNAME->setVisible(!editable);

    QStringList fullname;
    fullname << ui->lineEditPREFIX->text() << ui->lineEditGIVEN->text() << ui->lineEditMIDDLE->text();
    fullname << ui->lineEditFAMILY->text() << ui->lineEditSUFFIX->text();
    for (QStringList::iterator i = fullname.begin(); i != fullname.end(); i++) {
        *i = i->trimmed();
    }
    ui->labelFULLNAME->setText((fullname.filter(QRegExp(".+"))).join(" "));
}
Esempio n. 12
0
			CommandResult_t operator() (const UrlComposite& rx) const
			{
				QStringList urls;
				try
				{
					urls = boost::apply_visitor (RxableRangesVisitor { AzothProxy_, Entry_ }, rx.Range_);
				}
				catch (const StringCommandResult& res)
				{
					return res;
				}

				if (rx.Pat_)
					urls = urls.filter (QRegExp { QString::fromStdString (*rx.Pat_) });

				for (const auto& url : urls)
				{
					if (url.isEmpty ())
						continue;

					const auto& entity = Util::MakeEntity (QUrl::fromEncoded (url.toUtf8 ()),
							{},
							Params_ | FromUserInitiated);
					IEM_->HandleEntity (entity);
				}

				return true;
			}
Esempio n. 13
0
/**
 * @fn childrenPids
 */
QList<Q_PID> QueuedProcess::childrenPids() const
{
    QStringList allDirectories
        = QDir("/proc").entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
    QStringList directories = allDirectories.filter(QRegExp("(\\d+)"));

    QList<Q_PID> pids
        = std::accumulate(directories.cbegin(), directories.cend(), QList<Q_PID>(),
                          [this](QList<Q_PID> &list, const QString &dir) {
                              QFile statFile(QString("/proc/%1/stat").arg(dir));
                              if (!statFile.open(QIODevice::ReadOnly | QIODevice::Text))
                                  return list;

                              QString output = statFile.readAll();
                              output.remove(QRegExp("\\d+ \\(.*\\) . "));
                              Q_PID ppid = output.split(' ').first().toLongLong();
                              if (ppid == pid())
                                  list.append(dir.toLongLong());

                              statFile.close();

                              return list;
                          });

    return pids;
}
Esempio n. 14
0
void MainWindow::on_filterText_textChanged(const QString & text)
{
    QMapIterator<QString, QStringList> it(m_extMap);

    //
    // Build extension tree (eventually apply a filter)
    //
    while (it.hasNext()) {
        it.next();
        QString key = it.key();
        QStringList valueList = it.value();
        if (text!="") {
            valueList = valueList.filter(text, Qt::CaseInsensitive);
        }
        if (!valueList.empty()) {
            QTreeWidgetItem * corpItem = new QTreeWidgetItem(m_ui->extensionsTree);
            corpItem->setText(0, key + " ("+QString::number(valueList.count())+")");
            QStringListIterator it(valueList);
            while (it.hasNext()) {
                QTreeWidgetItem * child = new QTreeWidgetItem(corpItem);
                child->setText(0, it.next());
            }
        }
    }
    if(text!="") {
        m_ui->extensionsTree->expandAll();
    }
}
Esempio n. 15
0
void RootMount::read_mtab()
{
    p->hash.clear();

    QProcess process;
    process.start( "mount" );
        process.waitForFinished();

    QStringList output = QString(process.readAll()).split("\n");

    QRegExp reg;
        reg.setPattern( "^(/.*)\\son\\s(/.*)\\stype\\siso\\S*\\s\\(ro\\)" );

    output = output.filter( reg );

    for( int i=0 ; i<output.count() ; i++ )
    {
        QString str = output.at(i);
        int pos;

        pos = reg.indexIn( str );
        if( pos == -1 )
            continue;

        p->hash.insert( reg.cap(1) , reg.cap(2) );
    }
}
Esempio n. 16
0
QStringList LXDG::listFileMimeDefaults(){
  //This will spit out a itemized list of all the mimetypes and relevant info
  // Output format: <mimetype>::::<extension>::::<default>::::<localized comment>
  QStringList mimes = LXDG::loadMimeFileGlobs2();
  //Remove all the application files from the list (only a single app defines/uses this type in general)
  /*QStringList apps = mimes.filter(":application/");
  //qDebug() << "List Mime Defaults";
  for(int i=0; i<apps.length(); i++){ mimes.removeAll(apps[i]); }*/
  //Now start filling the output list
  QStringList out;
  for(int i=0; i<mimes.length(); i++){
    QString mimetype = mimes[i].section(":",1,1);
    QStringList tmp = mimes.filter(mimetype);
    //Collect all the different extensions with this mimetype
    QStringList extlist;
    for(int j=0; j<tmp.length(); j++){
      mimes.removeAll(tmp[j]);
      extlist << tmp[j].section(":",2,2);
    }
    extlist.removeDuplicates(); //just in case
    //Now look for a current default for this mimetype
    QString dapp = LXDG::findDefaultAppForMime(mimetype); //default app;
    
    //Create the output entry
    //qDebug() << "Mime entry:" << i << mimetype << dapp;
    out << mimetype+"::::"+extlist.join(", ")+"::::"+dapp+"::::"+LXDG::findMimeComment(mimetype);
    
    i--; //go back one (continue until the list is empty)
  }
  return out;
}
void Skill::initMediaSource()
{
    sources.clear();
    QDir dir;
    dir.setPath("./audio/skill");
    dir.setFilter(QDir::Files | QDir::Hidden);
    dir.setSorting(QDir::Name);
    QStringList names = dir.entryList();
    QStringList newnames = names.filter(objectName() + "_");
    foreach (QString name, newnames) {
        if (QFile::exists("audio/skill/" + name))
            sources << "audio/skill/" + name;
    }

    for (int i = 1;; ++i) {
        QString effect_file = QString("audio/skill/%1%2.mp3").arg(objectName()).arg(QString::number(i));
        if (QFile::exists(effect_file) && !sources.contains(effect_file))
            sources << effect_file;
        else
            break;
    }

    if (sources.isEmpty()) {
        QString effect_file = QString("audio/skill/%1.mp3").arg(objectName());
        if (QFile::exists(effect_file) && !sources.contains(effect_file))
            sources << effect_file;
    }
}
Esempio n. 18
0
void MainWindow::loadFile(QString filename)
{

	QFile inputFile(filename);
	QString line;
	QStringList pose;
	int curColumn, curRow;

	inputFile.open(QIODevice::ReadWrite);

	QTextStream in(&inputFile);

	curRow = m_ui->poseEditor->rowCount(); //It might be zero or appending to a previous file
	while (!in.atEnd())
	{
		line = in.readLine();
		pose = line.split("%");
		pose = pose.filter(QRegExp("[-]?[0-9]+[.][0-9]+"));

		m_ui->poseEditor->insertRow(m_ui->poseEditor->rowCount());

		curColumn = 0;
		foreach(QString str,pose)
		{
			QTableWidgetItem * item = new QTableWidgetItem(str);
			item->setTextAlignment(Qt::AlignCenter);
			m_ui->poseEditor->setItem(curRow,curColumn, item);
			curColumn++;
		}
		curRow++;
	}
Esempio n. 19
0
Mpris2Engine::Mpris2Engine(QObject *parent)
    : QObject(parent)
{
    const QDBusConnection bus = QDBusConnection::sessionBus();
    const QStringList services = bus.interface()->registeredServiceNames();

    for (const QString &name: services.filter(mprisInterface)) {
        qCDebug(MPRIS2) << "Found player" << name;
        m_players.append(new Mpris2Player(name));
        Q_EMIT playersChanged();
    }

    m_watcher = new QDBusServiceWatcher(this);
    connect(m_watcher, &QDBusServiceWatcher::serviceOwnerChanged, [=](const QString &name, const QString &oldOwner, const QString &newOwner) {
        if (oldOwner.isEmpty() && name.startsWith(mprisPrefix)) {
            qCDebug(MPRIS2) << "Found new player" << name;
            m_players.append(new Mpris2Player(name));
        } else if (newOwner.isEmpty() && name.startsWith(mprisPrefix)) {
            for (int i = 0; i < m_players.size(); i++) {
                if (m_players.at(i)->serviceName() == name) {
                    qCDebug(MPRIS2) << "Remove player" << name;
                    m_players.takeAt(i)->deleteLater();
                    Q_EMIT playersChanged();
                    break;
                }
            }
        }
    });
}
Esempio n. 20
0
Calamares::JobResult
ClearMountsJob::exec()
{
    QStringList goodNews;

    QString deviceName = m_device->deviceNode().split( '/' ).last();

    QProcess process;
    process.setProgram( "sh" );
    process.setArguments( {
                              "-c",
                              QString( "echo $(awk '{print $4}' /proc/partitions | sed -e '/name/d' -e '/^$/d' -e '/[1-9]/!d' | grep %1)" )
                                      .arg( deviceName )
                          } );
    process.start();
    process.waitForFinished();

    QString partitions = process.readAllStandardOutput();
    QStringList partitionsList = partitions.simplified().split( ' ' );

    // Build a list of partitions of type 82 (Linux swap / Solaris).
    // We then need to clear them just in case they contain something resumable from a
    // previous suspend-to-disk.
    QStringList swapPartitions;
    process.start( "sfdisk", { "-d", m_device->deviceNode() } );
    process.waitForFinished();
    // Sample output:
    //    % sudo sfdisk -d /dev/sda
    //    label: dos
    //    label-id: 0x000ced89
    //    device: /dev/sda
    //    unit: sectors

    //    /dev/sda1 : start=          63, size=    29329345, type=83, bootable
    //    /dev/sda2 : start=    29331456, size=     2125824, type=82

    swapPartitions = QString::fromLocal8Bit( process.readAllStandardOutput() )
                        .split( '\n' );
    swapPartitions = swapPartitions.filter( "type=82" );
    for ( QStringList::iterator it = swapPartitions.begin();
          it != swapPartitions.end(); ++it )
    {
        *it = (*it).simplified().split( ' ' ).first();
    }

    // First we umount all LVM logical volumes we can find
    process.start( "lvscan", { "-a" } );
    process.waitForFinished();
    if ( process.exitCode() == 0 ) //means LVM2 tools are installed
    {
        QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' );
        foreach ( const QString& lvscanLine, lvscanLines )
        {
            QString lvPath = lvscanLine.simplified().split( ' ' ).value( 1 ); //second column
            lvPath = lvPath.replace( '\'', "" );

            QString news = tryUmount( lvPath );
            if ( !news.isEmpty() )
                goodNews.append( news );
        }
Esempio n. 21
0
void TagGuesser::guessTags(MPDSong &song) {
	QString pattern = Config::instance()->guessPattern();

	// Check that we have a pattern at all
	if (pattern.isEmpty())
		return;

	// Cant guess from URL's
	if (song.url().contains("://"))
		return;

	// Return if we already have everything we can guess
	if (!(song.title().isEmpty() || song.album().isEmpty() || song.artist().isEmpty() || song.track().isEmpty()))
		return;

	DEBUG4("Guessing..");
	// Tokens to expand. %a=album, %b=band, %n=tracknr, %t=title, %i=ignore
	QStringList matchers = pattern.split(QRegExp("%[abnti]"), QString::SkipEmptyParts);
	QStringList markers = pattern.split('%', QString::SkipEmptyParts);

	// Check that we actually have any matchers, if not, return filename as title, the rest empty.

	DEBUG4("Matchers size: %d %d", matchers.size(), markers.size());
	if (matchers.isEmpty() || markers.isEmpty()) {

		DEBUG4("No matchers or no markers");
		if (song.title().isEmpty())
			song.setTitle(song.url());
		return;
	}

	// Remove bogus markers

	DEBUG4("Removing bogus markers");
	markers = markers.filter(QRegExp("^[abnti]"));
	// Remove trailing garbage on markers

	DEBUG4("Removing trailing garbage on markers");
	markers = markers.replaceInStrings(QRegExp("^([abnti]).*"), "%\\1");


	DEBUG4("Adding greedy front matcher");
	// If pattern does not have leading characters, add a greedy matcher at front so we get the whole start
	if (pattern.contains(QRegExp("^%[abnti]")))
		matchers.push_front("^");

	// If pattern contains trailing characters, add a dummy marker at the end.
	DEBUG4("Finding last matcher");
	QString lastMarker = markers.last();

	DEBUG4("Finding end of last marker");
	int endOfLastMatcher = pattern.lastIndexOf(lastMarker) + lastMarker.size();

	DEBUG4("Adding dummy end marker");
	if (endOfLastMatcher < pattern.size())
		markers += "trailingcharacters";

	foreach (QString p, markers) {
		DEBUG4("marker : %s", qPrintable(p));
	}
Esempio n. 22
0
QStringList gpu::getGLXInfo(QString gpuName) const {
    QStringList data, gpus = globalStuff::grabSystemInfo("lspci").filter(QRegExp(".+VGA.+|.+3D.+"));
    gpus.removeAt(gpus.indexOf(QRegExp(".+Audio.+"))); //remove radeon audio device

    // loop for multi gpu
    for (int i = 0; i < gpus.count(); i++)
        data << "VGA:"+gpus[i].split(":",QString::SkipEmptyParts)[2];

    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    if (!gpuName.isEmpty())
        env.insert("DRI_PRIME",gpuName.at(gpuName.length()-1));
    QStringList driver = globalStuff::grabSystemInfo("xdriinfo",env).filter("Screen 0:",Qt::CaseInsensitive);
    if (!driver.isEmpty())  // because of segfault when no xdriinfo
        data << "Driver:"+ driver.filter("Screen 0:",Qt::CaseInsensitive)[0].split(":",QString::SkipEmptyParts)[1];

    switch (currentDriver) {
    case XORG:
        data << dXorg::getGLXInfo(gpuName, env);
        break;
    case FGLRX:
        data << dFglrx::getGLXInfo();
        break;
    case DRIVER_UNKNOWN:
        break;
    }
    return data;
}
Esempio n. 23
0
QFile *BookmarksManager::bookmarkFile(const QString &url, bool createIfMissing)
{
    QFile *file = new QFile("");
    bool urlIsMissing = true;
    
    //Find bookmark file for the specified url
    QStringList fileIndex = bookmarkFileIndex();
    QStringList indexOfUrl = fileIndex.filter(url);
    if (indexOfUrl.count() > 0) {
        QStringList urlBookmarkFile = indexOfUrl.at(0).split(":::");
        if (urlBookmarkFile.count() == 2) {
            file = new QFile(urlBookmarkFile.at(1));
            urlIsMissing = false;
        }
    }
    
    //Add new bookmark file for the specified url to the index if none exists
    if (urlIsMissing && createIfMissing) {
        QString bookmarkFileName = QDateTime::currentDateTime().toString("yyyyMMddhhmmss");
        QString bookmarkFilePath = KStandardDirs::locateLocal("data", QString("bangarang/bookmarks/%1").arg(bookmarkFileName), true);
        fileIndex.append(QString("%1:::%2").arg(url).arg(bookmarkFilePath));
        writeBookmarkFileIndex(fileIndex);
        file = new QFile(bookmarkFilePath);
    }
    return file;
}
Esempio n. 24
0
/*!
    Creates a QByteArray of the \a environment.
*/
static QByteArray qt_create_environment(const QStringList &environment)
{
    QByteArray envlist;
    if (environment.isEmpty())
        return envlist;

    int pos = 0;
    // add PATH if necessary (for DLL loading)
    QByteArray path = qgetenv("PATH");
    if (environment.filter(QRegExp("^PATH=",Qt::CaseInsensitive)).isEmpty() && !path.isNull()) {
            QString tmp = QString(QLatin1String("PATH=%1")).arg(QString::fromLocal8Bit(path));
            uint tmpSize = sizeof(wchar_t) * (tmp.length() + 1);
            envlist.resize(envlist.size() + tmpSize);
            memcpy(envlist.data() + pos, tmp.utf16(), tmpSize);
            pos += tmpSize;
    }
    // add the user environment
    for (QStringList::ConstIterator it = environment.begin(); it != environment.end(); it++ ) {
            QString tmp = *it;
            uint tmpSize = sizeof(wchar_t) * (tmp.length() + 1);
            envlist.resize(envlist.size() + tmpSize);
            memcpy(envlist.data() + pos, tmp.utf16(), tmpSize);
            pos += tmpSize;
    }
    // add the 2 terminating 0 (actually 4, just to be on the safe side)
    envlist.resize(envlist.size() + 4);
    envlist[pos++] = 0;
    envlist[pos++] = 0;
    envlist[pos++] = 0;
    envlist[pos++] = 0;

    return envlist;
}
Esempio n. 25
0
    void run() {
        QStringList list;
        QString text;
        QProcess ping;
        QStringList result;
        QRegExp rx("(\\d+)% loss");

        while(true) {
            if(window->stop) {
                window->stop = false;
                window->StartButton->setEnabled(true);
                window->StopButton->setEnabled(false);
                window->IPInput->setEnabled(true);
                break;
            }

            #ifdef _WIN32
                ping.start("ping.exe " + window->IPInput->text() + " -n 10");
            #else
                ping.start("ping " + window->IPInput->text() + " -c 10");
            #endif

            ping.waitForFinished();
            text = ping.readAll();
            if (!text.isEmpty()) {
                list = text.split("\n");
                if(list.length() < 5) {
                    window->stop = true;
                } else {
                    result = list.filter("unreachable");
                    if(result.length() > 0) {
                        window->stop = true;
                    } else {
                        result = list.filter("loss");
                        if(result.length() > 0) {
                           if(rx.indexIn(result[0], 0) != -1) {
                              if(rx.cap(1) == "100") {
                                 window->stop = true;
                              }
                           }
                        }
                    }
                }
            }
            ping.deleteLater();
        }
    }
void UARTQtCommunication::getCurrentComPortsList()
{
	HKEY keyHandle;
	DWORD Type;
	DWORD BufferSize = TOTALBYTES;
	DWORD cbData;
	DWORD dwRet;

	comPorts.clear();

	QSettings settings("HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM", QSettings::NativeFormat);	
	//QString sReturnedValue = settings.value( "/Device/VCP0", "0" ).toString();
	QStringList allKeys = settings.allKeys();
#if 1   // since windows does not use the same names on different PCs we use all keys we found
	QStringList keys = allKeys;
#else
	// get only virtual com ports
	QStringList keys = allKeys.filter("VCP");
	// get also SiLabs CP210x USB to UART bridge, they use a different identification string
	keys += allKeys.filter("slabser");
	// one and the same SiLabs chip has different names under different PCs on windows
	keys += allKeys.filter("Silabser");
#endif

	if(!keys.isEmpty())
	{
		// make the key names windows like
		keys.replaceInStrings("/", "\\");
		if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_QUERY_VALUE, &keyHandle) == ERROR_SUCCESS )
		{
			char * rgValue = (char*)malloc(BufferSize * sizeof(char));
			cbData = BufferSize;

			foreach(QString key, keys)
			{
				dwRet = RegQueryValueEx( keyHandle, key.toAscii(), NULL, &Type, (LPBYTE)rgValue, &cbData);
				while(dwRet == ERROR_MORE_DATA)
				{
					// get a buffer that is big enough
					BufferSize += BYTEINCREMENT;
					rgValue = (char*)realloc(rgValue, BufferSize * sizeof(char));
					cbData = BufferSize;
					dwRet = RegQueryValueEx( keyHandle, key.toAscii(), NULL, &Type, (LPBYTE)rgValue, &cbData);
				}
				if(dwRet == ERROR_SUCCESS)
					comPorts += rgValue;
			}
Esempio n. 27
0
void RenderCommand::doRender(bool isPreview)
{
	bool isWritable = true;
	bool isMultiFrame;
	/*-- 初期化処理。フレーム範囲の計算や、Renderの場合はOutputSettingsから保存先パスも作る --*/
	if (!init(isPreview))
		return;
	if (m_fp.getDots() == ".") {
		isMultiFrame = false;
		TFileStatus fs(m_fp);
		if (fs.doesExist())
			isWritable = fs.isWritable();
	} else {
		isMultiFrame = true;
		TFilePath dir = m_fp.getParentDir();
		QDir qDir(QString::fromStdWString(dir.getWideString()));
		QString levelName = QRegExp::escape(QString::fromStdWString(m_fp.getWideName()));
		QString levelType = QString::fromStdString(m_fp.getType());
		QString exp(levelName + ".[0-9]{1,4}." + levelType);
		QRegExp regExp(exp);
		QStringList list = qDir.entryList(QDir::Files);
		QStringList livelFrames = list.filter(regExp);

		int i;
		for (i = 0; i < livelFrames.size() && isWritable; i++) {
			TFilePath frame = dir + TFilePath(livelFrames[i].toStdWString());
			if (frame.isEmpty() || !frame.isAbsolute())
				continue;
			TFileStatus fs(frame);
			isWritable = fs.isWritable();
		}
	}
	if (!isWritable) {
		string str = "It is not possible to write the output:  the file";
		str += isMultiFrame ? "s are read only." : " is read only.";
		MsgBox(WARNING, QString::fromStdString(str));
		return;
	}

	ToonzScene *scene = 0;
	TCamera *camera = 0;

	try {
		/*-- Xsheetノードに繋がっている各ラインごとに計算するモード。
			MultipleRender で Schematic Flows または Fx Schematic Terminal Nodes が選択されている場合
		--*/
		if (m_multimediaRender && m_fp.getType() != "swf") //swf is not currently supported on multimedia...
			multimediaRender();
		else if (!isPreview && m_fp.getType() == "swf")
			flashRender();
		else
			/*-- 通常のRendering --*/
			rasterRender(isPreview);
	} catch (TException &e) {
		MsgBox(WARNING, QString::fromStdString(toString(e.getMessage())));
	} catch (...) {
		MsgBox(WARNING, QObject::tr("It is not possible to complete the rendering."));
	}
}
Esempio n. 28
0
QStringList PBIBackend::browserApps( QString catID ){
  if(!CATHASH.contains(catID)){ return QStringList(); }
  QStringList apps = APPHASH.keys();
  apps.append(PKGHASH.keys());
  apps = apps.filter(catID+"/"); //catID should be the raw port category
  apps.removeDuplicates();
  return apps;
}
QStringList UBPlatformUtils::availableTranslations()
{
	QString translationsPath = applicationResourcesDirectory() + "/" + "i18n" + "/";
	QStringList translationsList = UBFileSystemUtils::allFiles(translationsPath);
	QRegExp sankoreTranslationFiles(".*sankore_.*.qm");
	translationsList=translationsList.filter(sankoreTranslationFiles);
	return translationsList.replaceInStrings(QRegExp("(.*)sankore_(.*).qm"),"\\2");
}
Esempio n. 30
0
int StringList::filter ( lua_State * L )
{
	QStringList* lhs = ValueInstaller2<QStringList>::check( L, 1 );
	QStringList* res = ValueInstaller2<QStringList>::create( L );
	if ( const QRegExp* rx = ValueInstaller2<QRegExp>::cast( L, 2 ) )
	{
		*res = lhs->filter( *rx );//( const QRegExp & rx ) const QStringList
	}
	else
	{
		//QString* str = ValueInstaller2<QString>::check( L, 2 );
		Enums enums( L );
		Qt::CaseSensitivity cs = ( Qt::CaseSensitivity )enums.CaseSensitivity( 3 );
		*res = lhs->filter( Util::toString( L, 2 ), cs );//QStringList filter ( const QString & str, Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
	}
	return 1;
}