Example #1
0
void CProject::updateLdPath()
{
	// ldPathList
	QStringList paths = libraryPathList;
	QStringList files = libraryFileList;

	if (!paths.isEmpty()) {
		// 去除 paths 中开头的"-L", 开头的双引号, 末尾的双引号
		paths.replaceInStrings(QRegExp("^-L\\s*"), "");
		paths.replaceInStrings(QRegExp("^\""), "");
		paths.replaceInStrings(QRegExp("\"$"), "");
		ldPathList << paths;
	}

	if (!files.isEmpty()) {
		// 去除 files 中开头的"-l", 开头的双引号, 末尾的双引号 
		files.replaceInStrings(QRegExp("^-l\\s*"), "");
		files.replaceInStrings(QRegExp("^\""), "");
		files.replaceInStrings(QRegExp("\"$"), "");
		
		// 如果 files 中的链接文件不是单独的"-l名称", 而是"-l路径/名称", 则将路径加入到ldPathList中.
		QStringList::const_iterator constIterator = files.constBegin();
		QStringList::const_iterator endIterator = files.constEnd();
		while (constIterator != endIterator) {
			QString str = *constIterator;
			if (str.contains("/")) { // 如果包含"/"
				str.remove(str.lastIndexOf("/"), str.length() - 1); // 去掉最后一个"/" 到末尾
				if (!ldPathList.contains(str))						// 如果ldPathList没有包含str
					ldPathList << str;
			}
			++constIterator;
		}
	}
}
QStringList Kopete::ChatSession::findUrls(const Kopete::Message &msg )
{
	Kopete::Message message = msg;
	//we check the message for every pattern
	QString tempstr = message.plainBody();
	QStringList regexppatterns = message.regexpPatterns();
	QRegExp linkregexp;
	QMap<int,QString> mapUrl;

	for (int i = 0; i < regexppatterns.size(); ++i) {
	  linkregexp.setPattern(regexppatterns[i]);
	  int pos = 0;
	  while ((pos = linkregexp.indexIn(tempstr, pos)) != -1) {
	    mapUrl.insert(pos,linkregexp.cap(0));
	    pos += linkregexp.matchedLength(); }
	}
	//we use QMap to sort links as they are in the message (if there are many links in one message)
	//lasturllist[0] - is the earliest
	QStringList lasturllist;
	QMapIterator< int, QString > i(mapUrl);
	while (i.hasNext()) { i.next(); lasturllist << i.value(); }
	lasturllist.replaceInStrings(" ", "");
	//add "http://" to link if needed to open it with a browser
	lasturllist.replaceInStrings(QRegExp( regexppatterns[1] ), QLatin1String("\\1http://\\2\\3" ));

	return lasturllist;
}
Example #3
0
  TablaModelR::TablaModelR(QObject *parent, QString ** &vec, QStringList &cabecH, QStringList &cabecV):QAbstractTableModel(parent)
  {
    distances = vec;
    cabeceraH = cabecH.replaceInStrings(".", ",");
    cabeceraV = cabecV.replaceInStrings(".", ",");
	Todos = true;    
  }
Example #4
0
QProcess * Engine::run(QFileInfo input, QObject * parent /* = nullptr */)
{
	QString exeFilePath = programPath(program());
	if (exeFilePath.isEmpty())
		return nullptr;

	QStringList env = QProcess::systemEnvironment();
	QProcess * process = new QProcess(parent);

	QString workingDir = input.canonicalPath();
#if defined(Q_OS_WIN)
	// files in the root directory of the current drive have to be handled specially
	// because QFileInfo::canonicalPath() returns a path without trailing slash
	// (i.e., a bare drive letter)
	if (workingDir.length() == 2 && workingDir.endsWith(QChar::fromLatin1(':')))
		workingDir.append(QChar::fromLatin1('/'));
#endif
	process->setWorkingDirectory(workingDir);


#if !defined(Q_OS_DARWIN) // not supported on OS X yet :(
	// Add a (customized) TEXEDIT environment variable
	env << QString::fromLatin1("TEXEDIT=%1 --position=%d %s").arg(QCoreApplication::applicationFilePath());

	#if defined(Q_OS_WIN) // MiKTeX apparently uses it's own variable
	env << QString::fromLatin1("MIKTEX_EDITOR=%1 --position=%l \"%f\"").arg(QCoreApplication::applicationFilePath());
	#endif
#endif

	QStringList args = arguments();

#if !defined(MIKTEX)
	// for old MikTeX versions: delete $synctexoption if it causes an error
	static bool checkedForSynctex = false;
	static bool synctexSupported = true;
	if (!checkedForSynctex) {
		QString pdftex = programPath(QString::fromLatin1("pdftex"));
		if (!pdftex.isEmpty()) {
			int result = QProcess::execute(pdftex, QStringList() << QString::fromLatin1("-synctex=1") << QString::fromLatin1("-version"));
			synctexSupported = (result == 0);
		}
		checkedForSynctex = true;
	}
	if (!synctexSupported)
		args.removeAll(QString::fromLatin1("$synctexoption"));
#endif

	args.replaceInStrings(QString::fromLatin1("$synctexoption"), QString::fromLatin1("-synctex=1"));
	args.replaceInStrings(QString::fromLatin1("$fullname"), input.fileName());
	args.replaceInStrings(QString::fromLatin1("$basename"), input.completeBaseName());
	args.replaceInStrings(QString::fromLatin1("$suffix"), input.suffix());
	args.replaceInStrings(QString::fromLatin1("$directory"), input.absoluteDir().absolutePath());

	process->setEnvironment(env);
	process->setProcessChannelMode(QProcess::MergedChannels);

	process->start(exeFilePath, args);

	return process;
}
Example #5
0
 void TablaModelR::setCurrencyCabec(QStringList &cabecH, QStringList &cabecV)   // cuando modifiquemos las cabeceras
 {
    beginResetModel();
    cabeceraH = cabecH.replaceInStrings(".", ",");
    cabeceraV = cabecV.replaceInStrings(".", ",");
    endResetModel();     
 }
Example #6
0
void KOpenBabel::slotAddFile()
{
    QStringList InputType;
    vector<string> InputFormat = OBConvObject->GetSupportedInputFormat();
    for (vector<string>::iterator it = InputFormat.begin(); it!=InputFormat.end(); ++it) {
        InputType << QString((*it).c_str());
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // InputType is now something like this:                                                                                    //
    // "acr -- ACR format [Read-only]", "alc -- Alchemy format", "arc -- Accelrys/MSI Biosym/Insight II CAR format [Read-only]" //
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    QStringList tmpList = InputType;
    tmpList.replaceInStrings(QRegExp("^"), "*.");
    tmpList.replaceInStrings(QRegExp(" -- "), "|");
    tmpList.replaceInStrings(QRegExp("/"), "\\/"); //escape all '/' (because of MimeTypes)
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // tmpList is now something like this:                                                                                      //
    // "*.acr|ACR format [Read-only]", "*.alc|Alchemy format"                                                                   //
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    QList<QUrl> fl = KFileDialog::getOpenUrls(
            QUrl(),
            "*|" +i18n("All Files") + '\n' + tmpList.join("\n") //add all possible extensions like "*.cml *.mol"
            );

    foreach (const QUrl &u , fl) {
        new QListWidgetItem(u.toDisplayString(), ui.FileListView);
    }
Example #7
0
AboutDialog::AboutDialog(QWidget *parent)
  : QDialog(parent) {
   setupUi(this);

#ifdef KST_HAVE_REVISION_H
   QStringList utf8Authors = QString::fromUtf8(kst_authors).trimmed().split(';');
   QStringList authors;
   foreach(const QString& a, utf8Authors) {
     if (!a.startsWith('#')) {
      authors << a;
     }
   }
#else
// qmake support
  QStringList authors = QStringList()
    << "Barth Netterfield"
    << "Joshua Netterfield"
    << "Matthew Truch"
    << "Nicolas Brisset"
    << "Staikos Computing Services Inc."
    << "Rick Chern"
    << "Sumus Technology Limited"
    << "Ted Kisner"
    << "The University of British Columbia"
    << "The University of Toronto"
    << "Andrew Walker"
    << "Peter Kümmel"
    << "Zongyi Zang";
#endif

  authors.sort();
  authors.replaceInStrings("<", "&lt;");
  authors.replaceInStrings(">", "&gt;");
  authors.replaceInStrings(QRegExp("^(.*)"), "<li>\\1</li>");

  QStringList msg = QStringList()
  << tr("<qt><h2>Kst "KSTVERSION" - A data viewing program.</h2>")
#ifdef KST_REVISION
  << tr("Revision "KST_REVISION"<br><hr>")
#endif
  << tr("Copyright &copy; 2000-2014 Barth Netterfield<br><hr>")
  << tr("Homepage: <a href=\"http://kst-plot.kde.org/\">http://kst-plot.kde.org/</a><br>")
  << tr("Please report bugs with the 'Bug Report Wizard' of the 'Help' menu.<br>")
  << tr("<br>Authors and contributors (sorted alphabetically):")
  << QString("<ul>")
  << authors
  << QString("</ul>");
  
  text->setText(msg.join("\n"));
  connect(text, SIGNAL(anchorClicked(QUrl)), this, SLOT(launchURL(QUrl)));
}
Example #8
0
void Jmplayer::loadToAppend()
{
    QStringList tempFilesList = QFileDialog::getOpenFileNames(this,tr("Open File"),".",tr("audios et videos (*.mp3 *.wma *.ogg *.wave *.midi *.mp4 *.flv *.ogv *.mpeg *.mpg *.avi *.divx *.wmv *.mov)"));
    QStringList tempFilesList2 = tempFilesList; 
    tempFilesList.replaceInStrings(" ", "\\ ");    
    tempFilesList.replaceInStrings("(", "\\(");  
    tempFilesList.replaceInStrings(")", "\\)");    
    tempFilesList.replaceInStrings("'", "\\'"); 
    for (int i = 0; i < tempFilesList2.size(); ++i) {
        QString append = "loadfile "+tempFilesList2.at(i)+" 1\n";
        myProcess->write(append.toLatin1().data());     
    }
    getFilesInfosToAppend(tempFilesList,tempFilesList2);
}
void ListView::dropEvent(QDropEvent *event)
{
  const QMimeData *mimeData = event->mimeData();

  QStringList imagePaths;
  QList<QUrl> imageUrls = mimeData->urls();
  QList<QUrl>::const_iterator end = imageUrls.constEnd();

  for (QList<QUrl>::const_iterator count = imageUrls.constBegin(); count != end; count++) {
    QString path = (*count).toLocalFile();
    if (!path.isEmpty() && path.contains(GCore::Data::self()->supportedFormats()))
      imagePaths << path;
  }

  QString image = imagePaths.first();
  image.remove(QRegExp("^.+/"));
  QString path = imagePaths.first();
  path.remove(image);

  QStringList pictures = imagePaths;
  pictures.replaceInStrings(path, QString());

  QAction *choice = Data::self()->dropContextMenu()->exec(mapToGlobal(event->pos()));

  if (!choice)
    return;

  if (choice->data().toInt() == 0) {
    NewGalleryWizard *wizard = new NewGalleryWizard(path, pictures, this);
    wizard->show();
  } else if (choice->data().toInt() == 1) {
    Job job = JobManager::self()->addImages(rootIndex(), imagePaths);
    connect(job.jobPtr(), SIGNAL(progress(int, int, const QString&, const QImage&)), GCore::Data::self()->imageAddProgress(), SLOT(setProgress(int, int, const QString&, const QImage&)));
  }
Example #10
0
void PerforceSubmitEditor::updateFields()
{
    PerforceSubmitEditorWidget *widget = submitEditorWidget();
    widget->setData(m_entries.value(QLatin1String("Change")).trimmed(),
                    m_entries.value(QLatin1String("Client")).trimmed(),
                    m_entries.value(QLatin1String("User")).trimmed());

    const QString newLine = QString(QLatin1Char('\n'));
    QStringList lines = m_entries.value(QLatin1String("Description")).split(newLine);
    lines.removeFirst(); // that is the line break after 'Description:'
    lines.removeLast(); // that is the empty line at the end

    const QRegExp leadingTabPattern = QRegExp(QLatin1String("^\\t"));
    QTC_ASSERT(leadingTabPattern.isValid(), /**/);

    lines.replaceInStrings(leadingTabPattern, QString());
    widget->setDescriptionText(lines.join(newLine));

    lines = m_entries.value(QLatin1String("Files")).split(newLine);
    // split up "file#add" and store complete spec line as user data
    foreach (const QString &specLine, lines) {
        const QStringList list = specLine.split(QLatin1Char('#'));
        if (list.size() == 2) {
            const QString file = list.at(0).trimmed();
            const QString state = list.at(1).trimmed();
            m_fileModel->addFile(file, state).at(0)->setData(specLine, FileSpecRole);
        }
    }
}
Example #11
0
QStringList GeneralSettingsPage::findQmFiles()
{
    QDir dir(translationPath);
    QStringList fileNames = dir.entryList(QStringList(translationPrefix + "_*.qm"), QDir::Files, QDir::Name);
    fileNames.replaceInStrings(QRegExp(translationPrefix + "_(.*)\\.qm"), "\\1");
    return fileNames;
}
int main2(int argc, char**argv)
{
    QStringList list;
    list << "foo" << "bar" << "baz";

    QString all = list.join(";");

    QStringList::const_iterator listIterator;

    for(listIterator = list.begin(); listIterator != list.end(); ++listIterator)
        qDebug() << *listIterator;

    qDebug() << "joined value: " << all;

    //replace a with oo in all strings of list
    list.replaceInStrings("a", "oo");

    for(listIterator = list.begin(); listIterator != list.end(); ++listIterator)
        qDebug() << *listIterator;

    list << all.split(";");

    qDebug() << "\n";
    for(listIterator = list.begin(); listIterator != list.end(); ++listIterator)
        qDebug() << *listIterator;

    return 0;
}
Example #13
0
void TagsReadWriteTest::testTagSeparatorWrite()
{
    DMetadata dmeta;

    DMetadataSettingsContainer dmsettings;
    QStringList readResult;
    QStringList expected;

    NamespaceEntry tagNs3;
    tagNs3.namespaceName   = QLatin1String("Xmp.lr.hierarchicalSubject");
    tagNs3.tagPaths        = NamespaceEntry::TAGPATH;
    tagNs3.separator       = QLatin1Char('|');
    tagNs3.nsType          = NamespaceEntry::TAGS;
    tagNs3.index           = 2;
    tagNs3.specialOpts     = NamespaceEntry::TAG_XMPBAG;
    tagNs3.subspace        = NamespaceEntry::XMP;
    tagNs3.alternativeName = QLatin1String("Xmp.lr.HierarchicalSubject");
    tagNs3.secondNameOpts  = NamespaceEntry::TAG_XMPSEQ;

    dmsettings.getWriteMapping(QString::fromUtf8(DM_TAG_CONTAINER)).clear();
    dmsettings.getWriteMapping(QString::fromUtf8(DM_TAG_CONTAINER))
             << tagNs3;

    dmeta.setItemTagsPath(tagSet1, dmsettings);

    readResult = dmeta.getXmpTagStringBag("Xmp.lr.hierarchicalSubject", false);

    expected   = tagSet1;
    expected   = expected.replaceInStrings(QLatin1String("/"), QLatin1String("|"));

    QCOMPARE(readResult, expected);
}
Example #14
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;
}
Example #15
0
QString getGSLinuxPath( QString apps  )
{
    QStringList potential_paths;
    potential_paths.append("/usr/local/bin");
    potential_paths.append("/sw/bin");   /* to use on mac as same */
    potential_paths.append("/opt/bin");
    QProcess *process = new QProcess(NULL);
    process->setReadChannelMode(QProcess::MergedChannels);
    QStringList env = process->systemEnvironment();
    env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=\\1;"+potential_paths.join(";"));
    process->setEnvironment(env);
    
        process->start( QString("which") ,  QStringList() << apps , QIODevice::ReadOnly );
          if (!process->waitForFinished()) {
          return QString();
          } else {
              QString finder = process->readAll().trimmed();
              if (finder.endsWith(apps,Qt::CaseInsensitive)) {
                 ///////////// qDebug() << "### finder " <<  finder;
                return finder;  
              } else {
                return QString(); 
              }
          }
}
void ITmagesApplet::dropEvent(QGraphicsSceneDragDropEvent *e)
{
  // preventing next files drop
  setAcceptDrops(false);

  QString tempText = e->mimeData()->text();
  QStringList paths = tempText.split("\n");
  if (paths.count()>1) paths.removeLast();
  // remove "file://", because we get 'file:///path_to_file'
  paths.replaceInStrings(QRegExp("file://"),"");

  // add supported files recursive
  QStringList imagesPaths;
  QFileInfo info;
  for (int i = 0; i<paths.count(); ++i) {
    info.setFile(paths.at(0));
    if (info.isDir()) {
      imagesPaths = loadImgFromFolder(info.absoluteFilePath());
    } else if (info.isFile()) {
      if (paths.at(i).contains(QRegExp("png$|jpg$|jpeg$|gif$", Qt::CaseInsensitive)))
        imagesPaths.append(paths.at(i));
    }
  }

  // start ITmages context menu extension
  if (!imagesPaths.isEmpty()) {
    QProcess load;
    load.startDetached(path,imagesPaths);
  }

  setAcceptDrops(true);
}
void Process::addEnvironmentPath(const QString &path)
{
    QStringList env = QProcess::systemEnvironment();
    env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive),
                         "PATH=" + path + ";\\1");
    this->setEnvironment(env);
}
Example #18
0
/*  Fonction pour recuperer les données de la requete HTTP
    Pour chaque couple de devises, on crée un objet 'CoupleDevise'
    et on y stocke les valeurs récupéré du web service.
    On accède aux valeurs par le biais des CSSselector grace à un QWebElement
*/
void Principal::recupereDonnees()
{
    QWebElement element ;

    // On parse 'urlChoixDevises' pour savoir sur quel couple de devises il faut boucler
    QStringList listeCouples ;
    listeCouples = urlChoixDevises.split(";");
    listeCouples.removeLast();
    listeCouples.replaceInStrings(" ", "");

    // Boucle pour recuperer les valeurs pour chaque couple de devises
    foreach (QString index, listeCouples) {
        CoupleDevise couple ;
        element = webView->page()->mainFrame()->findFirstElement("tr#pair_" + index + " span.ftqa11bb") ; // CSSselector pour le nom du couple de devises
        couple.coupleDevise = element.toPlainText() ;
        element = webView->page()->mainFrame()->findFirstElement("tr#pair_" + index + ">td[class*=bid]") ; // CSSselector pour la valeur d'achat
        couple.valeurAchat = element.toPlainText() ;
        element = webView->page()->mainFrame()->findFirstElement("tr#pair_" + index + ">td[class*=ask]") ; // CSSselector pour la valeur de vente
        couple.valeurVente = element.toPlainText() ;
        element = webView->page()->mainFrame()->findFirstElement("tr#pair_" + index + ">td[class*=pcp]") ; // CSSselector pour le pourcentage de variation de la cotation
        couple.variation = element.toPlainText() ;

        // Puis on demande a l'objet 'CoupleDevise' de se sauvegarder dans la bdd
        couple.save(&db) ;
    }
Example #19
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));
	}
Example #20
0
void AssociationsDialog::setGraph(Graph *g)
{
	graph = g;

	int index = 0;
	for (int i = 0; i < graph->curveCount(); i++){
		const QwtPlotItem *it = (QwtPlotItem *)graph->plotItem(i);
		if (!it)
			continue;
		if (it->rtti() != QwtPlotItem::Rtti_PlotCurve){
			index++;
			continue;
		}

		if (((PlotCurve *)it)->type() == Graph::Function){
			index++;
			continue;
		}

		QStringList lst = ((DataCurve *)it)->plotAssociation();
		if (((DataCurve *)it)->table()){
			QString tableName = ((DataCurve *)it)->table()->objectName();
			lst.replaceInStrings(tableName + "_", "").replaceInStrings(",", ".");
			plotAssociationsList << tableName + ": " + lst.join(",");
			curvesIndicesList << index;
			index++;
		}
	}
	associations->addItems(plotAssociationsList);
	associations->setMaximumHeight((plotAssociationsList.count() + 1)*associations->visualItemRect(associations->item(0)).height());
}
Example #21
0
void PerforceSubmitEditor::updateEntries()
{
    const QString newLine = QString(QLatin1Char('\n'));
    const QString tab = QString(QLatin1Char('\t'));

    QStringList lines = submitEditorWidget()->descriptionText().split(newLine);

    while (!lines.empty() && lines.last().isEmpty())
            lines.removeLast();
    // Description
    lines.replaceInStrings(QRegExp(QLatin1String("^")), tab);
    m_entries.insert(QLatin1String("Description"), newLine + lines.join(newLine) + QLatin1String("\n\n"));
    QString files = newLine;
    // Re-build the file spec '<tab>file#add' from the user data
    const int count = m_fileModel->rowCount();
    for (int r = 0; r < count; r++) {
        const QStandardItem *item = m_fileModel->item(r, 0);
        if (item->checkState() == Qt::Checked) {
            files += item->data(FileSpecRole).toString();
            files += newLine;
        }
    }
    files += newLine;
    m_entries.insert(QLatin1String("Files"), files);
}
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");
}
Example #23
0
QStringList FileParser::readConf(const QString &text)
{
  QStringList conf;
  if (text.contains('=')) {
    conf = text.split('='); // in this time, conf has 2 str at least
    conf.replaceInStrings(" ", "");
  }
  return conf;
}
Example #24
0
void	SComponent::handleOption(QStringList listArg)
{
  if (listArg.size() == 1 && listArg.at(0) == "")
    listArg.clear();
  if (optionDesc.isEmpty())
    return;
  listArg.replaceInStrings(QRegExp("^(.*)$"), "--\\1");
  SQArg::fillWithDesc(optionValue, listArg, optionDesc);
}
Example #25
0
bool OfflineAstrometryParser::startSovler(const QString &filename,  const QStringList &args, bool generated)
{
    INDI_UNUSED(generated);

    #ifdef Q_OS_OSX
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QStringList envlist = env.toStringList();
    envlist.replaceInStrings(QRegularExpression("^(?i)PATH=(.*)"), "PATH=/usr/local/bin:\\1");
    solver.setEnvironment(envlist);
    #endif

    QStringList solverArgs = args;
    // Add parity option if none is give and we already know parity before
    if (parity.isEmpty() == false && args.contains("parity") == false)
        solverArgs << "--parity" << parity;
    QString solutionFile = QDir::tempPath() + "/solution.wcs";
    solverArgs << "-W" <<  solutionFile << filename;

    fitsFile = filename;

    connect(&solver, SIGNAL(finished(int)), this, SLOT(solverComplete(int)));
    connect(&solver, SIGNAL(readyReadStandardOutput()), this, SLOT(logSolver()));

    // Reset parity on solver failure
    connect(this, &OfflineAstrometryParser::solverFailed, this, [&]() { parity = QString();});

#if QT_VERSION > QT_VERSION_CHECK(5,6,0)
    connect(&solver, &QProcess::errorOccurred, this, [&]()
    {
        align->appendLogText(i18n("Error starting solver: %1", solver.errorString()));
        emit solverFailed();
    });
#else
    connect(&solver, SIGNAL(error(QProcess::ProcessError)), this, SIGNAL(solverFailed()));
#endif

    solverTimer.start();

    QString solverPath;

    if(Options::astrometrySolverIsInternal())
        solverPath=QCoreApplication::applicationDirPath()+"/astrometry/bin/solve-field";
    else
        solverPath=Options::astrometrySolver();

    solver.start(solverPath, solverArgs);

    align->appendLogText(i18n("Starting solver..."));

    if (Options::solverVerbose())
    {
        QString command = solverPath + " " + solverArgs.join(" ");
        align->appendLogText(command);
    }

    return true;
}
Example #26
0
    // Returns a QProcess with the environment set up
    // so as to reflect the correct Androidiness of the
    // installed Shashlik
    QProcess* environment(QObject* parent)
    {
        QProcess* process = new QProcess(parent);
        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();

        // TODO make this a little less assumptioney
        // Heuristic: Unless we're told otherwise, the android root is one level up from the
        // installation location, and inside lib64/android. Yup, not entirely sensible, but
        // works for now.

        QStringList path = QStringList() << env.value("PATH") << appDir << "ANDROID_ROOT/sbin" << "ANDROID_ROOT/vendor/bin" << "ANDROID_ROOT/system/sbin" << "ANDROID_ROOT/system/bin" << "ANDROID_ROOT/system/xbin";
        path.replaceInStrings("ANDROID_ROOT", androidRootDir);
        env.insert("PATH", path.join(QLatin1String(":")));

        QStringList ldpath = QStringList() << env.value("LD_LIBRARY_PATH") <<  "/usr/lib" << "LIBPATH/lib64" << "LIBPATH/lib64/egl" << "ANDROID_ROOT/vendor/lib" << "ANDROID_ROOT/system/lib";
        ldpath.replaceInStrings("LIBPATH", libraryRoot);
        ldpath.replaceInStrings("ANDROID_ROOT", androidRootDir);
        env.insert("LD_LIBRARY_PATH", ldpath.join(QLatin1String(":")));

        QString jarPath = QString("/system/framework").prepend(androidRootDir);
        QStringList bootclasspath = QStringList() << "JARPATH/core.jar" << "JARPATH/conscrypt.jar" << "JARPATH/bouncycastle.jar" << "JARPATH/okhttp.jar" << "JARPATH/ext.jar" << "JARPATH/framework.jar" << "JARPATH/telephony-common.jar" << "JARPATH/voip-common.jar" << "JARPATH/framework2.jar" << "JARPATH/shashlik.jar";
        bootclasspath.replaceInStrings("JARPATH", jarPath);
        env.insert("BOOTCLASSPATH", bootclasspath.join(QLatin1String(":")));

        env.insert("SHASHLIK_ROOT", androidRootDir);
        env.insert("ANDROID_ROOT", QString("/system").prepend(androidRootDir));
        env.insert("ANDROID_ASSETS", QString("/system/app").prepend(androidRootDir));
        env.insert("ANDROID_DATA", QString("/data").prepend(androidRootDir));
        env.insert("ANDROID_STORAGE", QString("/storage").prepend(androidRootDir));
        env.insert("ASEC_MOUNTPOINT", QString("/mnt/asec").prepend(androidRootDir));
        env.insert("LOOP_MOUNTPOINT", QString("/mnt/obb").prepend(androidRootDir));
        env.insert("HAL_LIBRARY_PATH1", QString("/system/lib/hw").prepend(androidRootDir));
        env.insert("DOWNLOAD_CACHE", QString("/cache").prepend(androidRootDir));

//         env.insert("ANDROID_BOOTLOGO", "1");
        env.insert("ANDROID_WINDOW_SIZE", "200x200");
        env.insert("EGL_PLATFORM", "wayland");

        // TODO this should probably use some XDG type thing to sniff what this really is...
        env.insert("EXTERNAL_STORAGE", "/mnt");

        process->setProcessEnvironment(env);
        return process;
    }
Example #27
0
int StringList::replaceInStrings ( lua_State * L )
{
    QStringList* lhs = QtValue<QStringList>::check( L, 1 );
    QStringList* res = QtValue<QStringList>::create( L );
    //if ( QString* before = QtValue<QString>::cast( L, 2 ) )
	if( Util::isStr( L, 2 ) )
	{
        //QString* after = QtValue<QString>::check( L, 3 );
        Qt::CaseSensitivity cs = ( Qt::CaseSensitivity )Util::toInt( L, 4 );
        *res = lhs->replaceInStrings( QtValueBase::toString( L, 2 ), QtValueBase::toString( L, 3 ), cs );//QStringList & replaceInStrings ( const QString & before, const QString & after, Qt::CaseSensitivity cs = Qt::CaseSensitive )
	}
	else
	{
        QRegExp* rx = QtValue<QRegExp>::check( L, 2 );
        //QString* after = QtValue<QString>::check( L, 3 );
        *res = lhs->replaceInStrings( *rx, QtValueBase::toString( L, 3 ) );//QStringList & replaceInStrings ( const QRegExp & rx, const QString & after )
	}
	return 1;
}
Example #28
0
QStringList Core::splitLine(QString line){

    QStringList FieldList;

    line.begin();
    FieldList=line.split(",");

    FieldList.replaceInStrings(QChar('"'), "");
    return FieldList;
}
Example #29
0
/**
 * Returns the a list of the custom note file extensions
 */
QStringList Note::customNoteFileExtensionList(QString prefix) {
    QSettings settings;
    QStringList list = settings.value(
            "customNoteFileExtensionList").toStringList();

    if (!prefix.isEmpty()) {
        list.replaceInStrings(QRegularExpression("^"), prefix);
    }

    return list;
}
Example #30
0
/**
 * research a regular expression in the entire vocabulary
 */
bool QSearchItemModel::searchVoc( QRegExp searchRegExp )
{
	this->restoreModel();
	insertRow( 0 );//status row
	setData( index(0, 0), tr("search in progress...") );
	setData( index(0, 0), QColor( 255, 240, 240 ), Qt::BackgroundRole);
	setData( index(0, 1), QColor( 255, 240, 240 ), Qt::BackgroundRole);


	QDir vocDir(m_vocName);
	QStringList topicFileNames = vocDir.entryList( QStringList("*.vok"), QDir::Files );
	QStringList topicNames = topicFileNames;
	topicNames.replaceInStrings( ".vok", "" );

	QDir::setCurrent(m_vocName);
	for (short i=0; i < topicFileNames.size(); ++i)
	{
		QFile topicFile( topicFileNames.at(i) );

		if ( topicFile.open(QIODevice::ReadOnly | QFile::Text) )
		{
			//Do a text stream out of the file
			QTextStream stream(&topicFile);
			QString line;
			
			//search for searchRegExp
			while ( line = stream.readLine(), !line.isEmpty() )
			{
				QStringList tokens = line.split(" == ");
				QString lang1 = tokens.value(0);
				QString lang2 = tokens.value(1);
				
				if ( lang1.contains( searchRegExp ) || lang2.contains( searchRegExp ) )
					this->setSearchCouple( lang1, lang2, topicNames.at(i), searchRegExp );

			}
			topicFile.close();
		} 
		else
			continue;
	}
	QDir::setCurrent("..");

	if ( m_rowCount == 0 )
	{
		setData( index(0, 0), tr("No result found.") );
		setData( index(0, 0), QColor( 255, 255, 240 ), Qt::BackgroundRole);
		setData( index(0, 1), QColor( 255, 255, 240 ), Qt::BackgroundRole);
	}
	else
		removeRow( rowCount()-1 );

	return true;
}