Esempio n. 1
0
void ScriptService::runScript(QString input) {
    QList<QString> args = input.split(" ");
    QString fileName = args.takeFirst();

    QStringList filter;
    filter << "*.rb";

    QDir myDir(QApplication::applicationDirPath() + "/scripts");
    QStringList fileList = myDir.entryList(filter, QDir::Files, QDir::Name);

    if(fileList.contains(fileName + ".rb")) {
        if(!script->isRunning()) {
            windowFacade->scriptRunning(true);
            windowFacade->writeGameWindow("[Executing script: " +
                                           fileName.toLocal8Bit() +
                                           ".rb, Press ESC to abort.]");
            timer.start();
            terminateFlag = false;
            script->execute(fileName, args);
        } else {
            windowFacade->writeGameWindow("[Script " +
                                           script->currentFileName().toLocal8Bit() +
                                           ".rb already executing.]");
        }
    } else {
        windowFacade->writeGameWindow("[Script not found.]");
    }
}
Esempio n. 2
0
Stored::Stored(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Stored)
{
    ui->setupUi(this);

    setWindowTitle(tr("Stored Files"));

    QDir myDir("d:/file/remind");
    qint8 count=myDir.count()-2;




    for(qint8 i=1;i<=count;i++)
    {


        QString str=QString::number(i);
        QString file="d:/file/remind/"+str+".txt";

        ui->listWidget->addItem("("+str+")"+Read(file));

    }
}
Esempio n. 3
0
// ---------------------------------------------------------------
int PackageDialog::insertDirectory(const QString& DirName,
                           QDataStream& Stream)
{
  QFile File;
  QDir myDir(DirName);

  // Put all files of this directory into the package.
  QStringList Entries = myDir.entryList("*", QDir::Files, QDir::Name);
  QStringList::iterator it;
  for(it = Entries.begin(); it != Entries.end(); ++it) {
    File.setName(myDir.absFilePath(*it));
    Stream << Q_UINT32(CODE_FILE);
    if(insertFile(*it, File, Stream) < 0)
      return -1;
  }

  // Put all subdirectories into the package.
  Entries = myDir.entryList("*", QDir::Dirs, QDir::Name);
  Entries.pop_front();  // delete "." from list
  Entries.pop_front();  // delete ".." from list
  for(it = Entries.begin(); it != Entries.end(); ++it) {
    Stream << Q_UINT32(CODE_DIR) << (*it).latin1();
    if(insertDirectory(myDir.absPath()+QDir::separator()+(*it), Stream) < 0)
      return -1;
    Stream << Q_UINT32(CODE_DIR_END) << Q_UINT32(0);
  }
  return 0;
}
Esempio n. 4
0
QStringList EcgEntry::GetEcgList(QString directory)
{
    QDir myDir(directory);
    QRegExp *are = new QRegExp(".dat");
    QRegExp *cre = new QRegExp("c.txt");
    QRegExp *dre = new QRegExp("d.txt");

    QStringList datafiles = myDir.entryList().filter(*are);
    QStringList *records = new QStringList();
    QStringList fa, fb, fc, fd;

    //sprawdzenie czy wszystkie 3 pliki z danymi sa w folderze

    fc = myDir.entryList().filter(*cre);
    fd = myDir.entryList().filter(*dre);

    for(int i = 0; i < datafiles.count(); i++)
    {
        QString index = datafiles.at(i).mid(0,3);
        if(fc.contains(index + "c.txt") && fd.contains(index + "d.txt"))
        {
            records->append(index);
        }
    }

    return *records;

}
Esempio n. 5
0
void MainWindow::on_goBT_clicked()
{
    QDir myDir(wpath);
    QStringList filter;
    filter<<"*.cpp"<<"*.h";
    QStringList list = myDir.entryList (filter);

    foreach(QString str,list)
    {
        bool go=true;
        if(ui->confirmCB->isChecked())
            if(QMessageBox::question(this,"Process File?:",str,QMessageBox::Yes,QMessageBox::No)==QMessageBox::No)go=false;
        if(go){
            ui->cfileL->setText("Current File:"+str);
            QFile file(wpath+QDir::separator()+str);
            if (!file.open(QIODevice::ReadWrite)) {
                ui->output->append("Cannot open file "+str+" for writing");
            }
            else
            {
                ui->output->append("Processing file "+str);
                QTextStream out(&file);
                QStringList filestr;
                out.seek(0);
                while(!out.atEnd()) filestr<<out.readLine();
                out.seek(0);
                if(ui->licenseCB->isChecked())
                {

                    bool haslicense=false;
                    foreach(QString str,filestr)
                    {
                        if(str.contains("The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010"))
                        {
                            haslicense=true;
                            ui->output->append("File Already has License Info");
                        }
                    }

                    if(!haslicense)
                    {
                        bool process=true;
                        if(ui->confirmCB->isChecked())
                            if(QMessageBox::question(this,"Add license Info?:",str,QMessageBox::Yes,QMessageBox::No)==QMessageBox::No) process=false;
                        if(process)
                        {
                            ui->output->append("Added License info to file");
                            out.seek(0);
                            foreach(QString line,license)
                            {
                                line.replace("%file",str);
                                line.replace("%defgroup",ui->defgroup->text());
                                out<<line<<"\r\n";
                            }
                            foreach(QString str,filestr) out<<str+"\r\n";
                        }
                    }
                    out.flush();
                }
@@ -60,7 +60,7 @@ QString QgsApplication::mConfigPath = QD
 QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled, QString customConfigPath )
     : QApplication( argc, argv, GUIenabled )
 {
-#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
+#if defined(Q_WS_WIN32) || defined(WIN32)
   setPrefixPath( applicationDirPath(), true );
 #else
   QDir myDir( applicationDirPath() );
Esempio n. 7
0
QTreeWidgetItem * Widget::scanDirectory(QString path)
{
    QTreeWidgetItem * root;
    QDir myDir(path);
    QTreeWidgetItem * tmp;
    root = new QTreeWidgetItem(0);
    root->setText(0, myDir.dirName());
    QString dir = qApp->applicationDirPath();
    QDirIterator * scanDir= new QDirIterator(path, QDir::AllEntries|QDir::NoDotAndDotDot);
    QString nxt;


    while(scanDir->hasNext())
    {
        nxt = scanDir->next();

        qDebug(scanDir->filePath().toAscii());

        if(scanDir->fileInfo().isDir())
        {
            root->addChild(scanDirectory(scanDir->filePath()));
            totalDownloads++;
        }
        else
        {
            tmp = new QTreeWidgetItem(0);
            tmp->setText(0, scanDir->fileName());
            root->addChild(tmp);
            totalDownloads++;
        }
    }


    /*if(!nxt.isNull())
    {
        qDebug(scanDir->filePath().toAscii());
        if(scanDir->fileInfo().isDir())
        {
            root->addChild(scanDirectory(scanDir->filePath()));
        }
        else
        {
            tmp = new QTreeWidgetItem(0);
            tmp->setText(0, scanDir->fileName());
            root->addChild(tmp);
        }
    }*/

   return root;
}
Esempio n. 8
0
// ---------------------------------------------------------------
int PackageDialog::insertLibraries(QDataStream& Stream)
{
  QFile File;
  QDir myDir(QucsSettings.QucsHomeDir.absPath() + QDir::separator() + "user_lib");
  QStringList Entries = myDir.entryList("*", QDir::Files, QDir::Name);
  QStringList::iterator it;
  for(it = Entries.begin(); it != Entries.end(); ++it) {
    File.setName(myDir.absFilePath(*it));
    Stream << Q_UINT32(CODE_LIBRARY);
    if(insertFile(*it, File, Stream) < 0)
      return -1;
  }
  return 0;
}
Esempio n. 9
0
void command(char* s, LinkedList* historyList)
{
	int preCount = 0, postCount = 0, pipeCount = 0, argc;
	char **prePipe = NULL, **postPipe = NULL, **argv = NULL;

	while(strcmp(s, "exit") != 0)
	{
		char s2[50];
		strcpy(s2, s);
		strip(s2);
		argc = makeargs(s2, &argv);
		addLast(historyList, buildNode_Type(buildType_Args(argc, argv)));
		memset(&s2[0], 0, sizeof(s2));

		pipeCount = containsPipe(s);
		if(pipeCount > 0)
		{
			prePipe = parsePrePipe(s, &preCount);
			postPipe = parsePostPipe(s, &postCount);
			pipeIt(prePipe, postPipe, historyList);
			clean(preCount, prePipe);
			clean(postCount, postPipe);
		}// end if pipeCount

		else
		{
			if(strcmp(argv[0],"cd") != 0) {
				if (argc != -1)
					forkIt(argv, historyList);
			}
			else
				myDir(argv);
		}
		//	clean(argc, argv);
		//	argv = NULL;

		//printList(historyList,printType);

		memset(&s[0], 0, sizeof(s));
		printf("\ncommand?: ");
		fgets(s, MAX, stdin);
		strip(s);

	}// end while




}
Esempio n. 10
0
QStringList QgsOptions::i18nList()
{
  QStringList myList;
  myList << "en_US"; //there is no qm file for this so we add it manually
  QString myI18nPath = QgsApplication::i18nPath();
  QDir myDir( myI18nPath, "qgis*.qm" );
  QStringList myFileList = myDir.entryList();
  QStringListIterator myIterator( myFileList );
  while ( myIterator.hasNext() )
  {
    QString myFileName = myIterator.next();
    myList << myFileName.replace( "qgis_", "" ).replace( ".qm", "" );
  }
  return myList;
}
Esempio n. 11
0
void MyFileSystemView::startDrag()
{
	QModelIndex index = currentIndex();
	if (index.isValid())
	{
		QFileInfo myFileInfo = qobject_cast<QFileSystemModel*>(this->model())->fileInfo(index);
		if (!myFileInfo.suffix().contains("css", Qt::CaseInsensitive) && !myFileInfo.suffix().contains("js", Qt::CaseInsensitive))
		{
			m_boolIsWatched = false;
			return;
		}
		// construct relative source path
		QDir myDir("./");
		m_strRelativeSourceFilePath = myDir.relativeFilePath(myFileInfo.absoluteFilePath());
		m_boolIsWatched = true;
	}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimScriptCollection::pathsAndSubPaths(QStringList& pathList)
{
    if (!this->directory().isEmpty())
    {
        QDir myDir(this->directory());
        if (myDir.isReadable())
        {
            pathList.append(this->directory());
        }
    }

    for (size_t i= 0; i < this->subDirectories.size(); ++i)
    {
        if (this->subDirectories[i])
        {
            this->subDirectories[i]->pathsAndSubPaths(pathList);
        }
    }
}
Esempio n. 13
0
void MyFileSystemView::dropEvent(QDropEvent *event)
{
	QTreeView::dropEvent(event);
	if (!m_boolIsWatched)
	{
		return;
	}
	auto mypos = event->pos();
	auto mysrc = event->source();
	if (qobject_cast<MyFileSystemView*>(mysrc))
	{
		QModelIndex index = this->indexAt(mypos); // show only the target folder
		if (index.isValid())
		{
			QFileInfo destFileInfo = qobject_cast<QFileSystemModel*>(this->model())->fileInfo(index);
			QString strAbsoluteDestinationDir;
			if (destFileInfo.isFile())
			{
				strAbsoluteDestinationDir = destFileInfo.absolutePath();
			}
			else
			{
				strAbsoluteDestinationDir = destFileInfo.absoluteFilePath();
			}
			QFileInfo sourceFileInfo(m_strRelativeSourceFilePath);
			QString strAbsoluteDestinationFilePath = strAbsoluteDestinationDir + "/" + sourceFileInfo.fileName();
			// construct relative destination path
			QDir myDir("./");
			m_strRelativeDestinationFilePath = myDir.relativeFilePath(strAbsoluteDestinationFilePath);
			// send signal
			if (m_strRelativeSourceFilePath.compare(m_strRelativeDestinationFilePath) != 0 && QFileInfo(m_strRelativeDestinationFilePath).exists())
			{
				Q_EMIT trackedFileWasMoved(m_strRelativeSourceFilePath, m_strRelativeDestinationFilePath);
			}
			// clean
			m_strRelativeSourceFilePath.clear();
			m_strRelativeDestinationFilePath.clear();
			m_boolIsWatched = false;
		}
	}
}
Esempio n. 14
0
void MainWindow::ListReload()
{
    ui->listWidget->clear();
    QStringList filters;
    filters <<"*RJ*";
    QDir myDir(currentDirectory);
    myDir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    myDir.setNameFilters(filters);
    currentFileList=myDir.entryList();
    currentFileList = currentFileList.filter(QRegExp("(R|r)(J|j)\\d{6}"));

    for(int i=0;i<currentFileList.size();i++)
    {
        QFileInfo fileInfo(currentDirectory,currentFileList.at(i)) ;
        QListWidgetItem *item = new QListWidgetItem(ui->listWidget);
        QString name = fileInfo.fileName();
        item->setText(name);
        QFileIconProvider iconSource;
        QIcon icon = iconSource.icon(fileInfo);
        item->setIcon(icon);
    }
}
Esempio n. 15
0
void QgsApplication::init( QString customConfigPath )
{
  if ( customConfigPath.isEmpty() )
  {
    if ( getenv( "QGIS_CUSTOM_CONFIG_PATH" ) )
    {
      customConfigPath = getenv( "QGIS_CUSTOM_CONFIG_PATH" );
    }
    else
    {
      customConfigPath = QStringLiteral( "%1/.qgis3/" ).arg( QDir::homePath() );
    }
  }

  qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
  qRegisterMetaType<QgsProcessingFeatureSourceDefinition>( "QgsProcessingFeatureSourceDefinition" );
  qRegisterMetaType<QgsProcessingOutputLayerDefinition>( "QgsProcessingOutputLayerDefinition" );

  QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() );
  // QgsDebugMsg( QString( "prefixPath(): %1" ).arg( prefixPath ) );

  // check if QGIS is run from build directory (not the install directory)
  QFile f;
  // "/../../.." is for Mac bundled app in build directory
  Q_FOREACH ( const QString &path, QStringList() << "" << "/.." << "/bin" << "/../../.." )
  {
    f.setFileName( prefixPath + path + "/qgisbuildpath.txt" );
    if ( f.exists() )
      break;
  }
  if ( f.exists() && f.open( QIODevice::ReadOnly ) )
  {
    ABISYM( mRunningFromBuildDir ) = true;
    ABISYM( mBuildSourcePath ) = f.readLine().trimmed();
    ABISYM( mBuildOutputPath ) = f.readLine().trimmed();
    qDebug( "Running from build directory!" );
    qDebug( "- source directory: %s", ABISYM( mBuildSourcePath ).toUtf8().data() );
    qDebug( "- output directory of the build: %s", ABISYM( mBuildOutputPath ).toUtf8().data() );
#ifdef _MSC_VER
    ABISYM( mCfgIntDir ) = prefixPath.split( '/', QString::SkipEmptyParts ).last();
    qDebug( "- cfg: %s", ABISYM( mCfgIntDir ).toUtf8().data() );
#endif
  }

  if ( ABISYM( mRunningFromBuildDir ) )
  {
    // we run from source directory - not installed to destination (specified prefix)
    ABISYM( mPrefixPath ) = QString(); // set invalid path
#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
    setPluginPath( ABISYM( mBuildOutputPath ) + '/' + QString( QGIS_PLUGIN_SUBDIR ) + '/' + ABISYM( mCfgIntDir ) );
#else
    setPluginPath( ABISYM( mBuildOutputPath ) + '/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
#endif
    setPkgDataPath( ABISYM( mBuildSourcePath ) ); // directly source path - used for: doc, resources, svg
    ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) + '/' + QGIS_LIB_SUBDIR + '/';
#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
    ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) + '/' + QGIS_LIBEXEC_SUBDIR + '/' + ABISYM( mCfgIntDir ) + '/';
#else
    ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) + '/' + QGIS_LIBEXEC_SUBDIR + '/';
#endif
  }
  else
  {
    char *prefixPath = getenv( "QGIS_PREFIX_PATH" );
    if ( !prefixPath )
    {
#if defined(Q_OS_MACX) || defined(Q_OS_WIN)
      setPrefixPath( applicationDirPath(), true );
#elif defined(ANDROID)
      // this is  "/data/data/org.qgis.qgis" in android
      QDir myDir( QDir::homePath() );
      myDir.cdUp();
      QString myPrefix = myDir.absolutePath();
      setPrefixPath( myPrefix, true );
#else
      QDir myDir( applicationDirPath() );
      myDir.cdUp();
      QString myPrefix = myDir.absolutePath();
      setPrefixPath( myPrefix, true );
#endif
    }
    else
    {
      setPrefixPath( prefixPath, true );
    }
  }

  if ( !customConfigPath.isEmpty() )
  {
    ABISYM( mConfigPath ) = customConfigPath + '/'; // make sure trailing slash is included
  }

  ABISYM( mDefaultSvgPaths ) << qgisSettingsDirPath() + QStringLiteral( "svg/" );

  ABISYM( mAuthDbDirPath ) = qgisSettingsDirPath();
  if ( getenv( "QGIS_AUTH_DB_DIR_PATH" ) )
  {
    setAuthDatabaseDirPath( getenv( "QGIS_AUTH_DB_DIR_PATH" ) );
  }


  // store system environment variables passed to application, before they are adjusted
  QMap<QString, QString> systemEnvVarMap;
  QString passfile( QStringLiteral( "QGIS_AUTH_PASSWORD_FILE" ) ); // QString, for comparison
  Q_FOREACH ( const QString &varStr, QProcess::systemEnvironment() )
  {
    int pos = varStr.indexOf( QLatin1Char( '=' ) );
    if ( pos == -1 )
      continue;
    QString varStrName = varStr.left( pos );
    QString varStrValue = varStr.mid( pos + 1 );
    if ( varStrName != passfile )
    {
      systemEnvVarMap.insert( varStrName, varStrValue );
    }
  }
Esempio n. 16
0
//Initial global settings setup
void Global::setup(StartupConfig startupConfig) {
    fileManager.setup(startupConfig.homeDirPath, startupConfig.programDirPath, startupConfig.accountId);
    shortcutKeys = new ShortcutKeys();
    QString settingsFile = fileManager.getHomeDirPath("") + "nixnote.conf";

    globalSettings = new QSettings(settingsFile, QSettings::IniFormat);
    int accountId = startupConfig.accountId;
    if (accountId <=0) {
        globalSettings->beginGroup("SaveState");
        accountId = globalSettings->value("lastAccessedAccount", 1).toInt();
        globalSettings->endGroup();
    }

    QString key = "1b73cc55-9a2f-441b-877a-ca1d0131cd2"+
            QString::number(accountId);
    QLOG_DEBUG() << "Shared memory key: " << key;
    sharedMemory = new QSharedMemory(key);


    settingsFile = fileManager.getHomeDirPath("") + "nixnote-"+QString::number(accountId)+".conf";

    settings = new QSettings(settingsFile, QSettings::IniFormat);

    this->forceNoStartMimized = startupConfig.forceNoStartMinimized;
    this->forceSystemTrayAvailable = startupConfig.forceSystemTrayAvailable;
    this->startupNewNote = startupConfig.startupNewNote;
    this->syncAndExit = startupConfig.syncAndExit;
    this->forceStartMinimized = startupConfig.forceStartMinimized;
    this->startupNote = startupConfig.startupNoteLid;
    startupConfig.accountId = accountId;
    accountsManager = new AccountsManager(startupConfig.accountId);
    enableIndexing = startupConfig.enableIndexing;

    cryptCounter = 0;
    attachmentNameDelimeter = "------";
    username = "";
    password = "";
    connected = false;

    server = accountsManager->getServer();

    // Cleanup any temporary files from the last time
    QDir myDir(fileManager.getTmpDirPath());
    QStringList list = myDir.entryList();
    for (int i=0; i<list.size(); i++) {
        if (list[i] != "." && list[i] != "..") {
            QString file = fileManager.getTmpDirPath()+ list[i];
            myDir.remove(file);
        }
    }

    settings->beginGroup("Debugging");
    disableUploads = settings->value("disableUploads", false).toBool();
    nonAsciiSortBug = settings->value("nonAsciiSortBug", false).toBool();
    settings->endGroup();

    setupDateTimeFormat();

    settings->beginGroup("Appearance");
    int countbehavior = settings->value("countBehavior", CountAll).toInt();
    if (countbehavior==1)
        countBehavior = CountAll;
    if (countbehavior==2)
        countBehavior = CountNone;
    pdfPreview = settings->value("showPDFs", true).toBool();
    defaultFont = settings->value("defaultFont","").toString();
    defaultFontSize = settings->value("defaultFontSize",0).toInt();
    defaultGuiFontSize = settings->value("defaultGuiFontSize", 0).toInt();
    defaultGuiFont = settings->value("defaultGuiFont","").toString();
    disableEditing = false;
    if (settings->value("disableEditingOnStartup",false).toBool() || startupConfig.disableEditing)
        disableEditing = true;
    settings->endGroup();

    if (defaultFont != "" && defaultFontSize > 0) {
        QWebSettings *settings = QWebSettings::globalSettings();
        settings->setFontFamily(QWebSettings::StandardFont, defaultFont);
        // QWebkit DPI is hard coded to 96. Hence, we calculate the correct
        // font size based on desktop logical DPI.
        settings->setFontSize(QWebSettings::DefaultFontSize,
            defaultFontSize * (QApplication::desktop()->logicalDpiX() / 96.0)
            );
    }

    settings->beginGroup("Appearance");
    QString theme = settings->value("themeName", "").toString();
    loadTheme(resourceList,theme);
    autoHideEditorToolbar = settings->value("autoHideEditorToolbar", true).toBool();
    settings->endGroup();

    minIndexInterval = 5000;
    maxIndexInterval = 120000;
    indexResourceCountPause=2;
    indexNoteCountPause=100;
}
Esempio n. 17
0
void QgsApplication::init( QString customConfigPath )
{
  // check if QGIS is run from build directory (not the install directory)
  QDir appDir( applicationDirPath() );
  if ( appDir.exists( "source_path.txt" ) )
  {
    QFile f( applicationDirPath() + "/source_path.txt" );
    if ( f.open( QIODevice::ReadOnly ) )
    {
      mRunningFromBuildDir = true;
      mBuildSourcePath = f.readAll();
#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
      mBuildOutputPath = applicationDirPath();
#else
      mBuildOutputPath = applicationDirPath() + "/.."; // on linux
#endif
      qDebug( "Running from build directory!" );
      qDebug( "- source directory: %s", mBuildSourcePath.toAscii().data() );
      qDebug( "- output directory of the build: %s", mBuildOutputPath.toAscii().data() );
    }
  }

  if ( mRunningFromBuildDir )
  {
    // we run from source directory - not installed to destination (specified prefix)
    mPrefixPath = QString(); // set invalid path
    setPluginPath( mBuildOutputPath + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
    setPkgDataPath( mBuildSourcePath ); // directly source path - used for: doc, resources, svg
    mLibraryPath = mBuildOutputPath + "/" + QGIS_LIB_SUBDIR + "/";
    mLibexecPath = mBuildOutputPath + "/" + QGIS_LIBEXEC_SUBDIR + "/";
  }
  else
  {
#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
    setPrefixPath( applicationDirPath(), true );
#else
    QDir myDir( applicationDirPath() );
    myDir.cdUp();
    QString myPrefix = myDir.absolutePath();
    setPrefixPath( myPrefix, true );
#endif
  }

  if ( !customConfigPath.isEmpty() )
  {
    mConfigPath = customConfigPath + "/"; // make sure trailing slash is included
  }

  mDefaultSvgPaths << qgisSettingsDirPath() + QString( "svg/" );

  // set a working directory up for gdal to write .aux.xml files into
  // for cases where the raster dir is read only to the user
  // if the env var is already set it will be used preferentially
  QString myPamPath = qgisSettingsDirPath() + QString( "gdal_pam/" );
  QDir myDir( myPamPath );
  if ( !myDir.exists() )
  {
    myDir.mkpath( myPamPath ); //fail silently
  }


#if defined(Q_WS_WIN32) || defined(WIN32)
  CPLSetConfigOption( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
#else
  //under other OS's we use an environment var so the user can
  //override the path if he likes
  int myChangeFlag = 0; //whether we want to force the env var to change
  setenv( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
#endif
}
void BubbleProcessDialog::on_But_fetchBubbleFiles_clicked()
{
    QString rootPath = bubbleProcess::getBubblesRootDirectory();

    // if rootPath is not set, there is nothing i can do!!
    if(rootPath == NULL)return;

    vector <vector <bubblePoint> > bubbles = bubbleProcess::getBubbles();

    // Clear previous bubbles, new ones are coming
    if(bubbles.size() > 0)bubbles.erase(bubbles.begin(),bubbles.end());

    // Get the folder List
    QStringList folderList = bubbleProcess::getBubblesFolderList();

    // create a new vector that will hold the read bubbles
    vector < vector < bubblePoint > > readBubbles;

    // This part is c0, c1, c2, ....
    if(folderList.size()>0){

        for(int i = 0; i < folderList.size(); i++){

            QString folderName = folderList.at(i);

            QString path = rootPath;

            // Create the path: "path/folder/"
            path.append(folderName).append("/");

            //qDebug()<<path;

            // create a directory object with path
            QDir myDir(path);

            // First check if we have a directory in the root file
            QStringList list = myDir.entryList(QDir::Dirs | QDir::NoDotDot |QDir::NoDot,QDir::NoSort);

            // This part is apes0
            if(list.size() > 0){

                for(int k = 0; k < list.size(); k++){

                    // Create a filter for the given extensions
                    QStringList filters(ui->Edit_bubbleFilesExtension->text());

                    // the path becomes "root/cx/apes0/"
                    path.append(list.at(k)).append("/");

                    //qDebug()<<filters;

                    //qDebug()<<path;

                    QDir dir(path);

                    // List the bubbles in that directory
                    QStringList list2 = dir.entryList(filters);


                    if(list2.size()>0){

                        for(int j = 0; j< list2.size(); j++){

                            QString totPath = path.append(list2.at(j));

                            qDebug()<<"Total Path is: "<<totPath;


                            QFile file(totPath);

                            file.open(QFile::ReadOnly);

                            vector<bubblePoint> aBubb =  bubbleProcess::readBubble(&file);

                            readBubbles.push_back(aBubb);

                            qDebug()<<"I have read a bubble";




                        }

                    }
                }


            }

        }


    }
    else{

        QString path = rootPath;

        // Create the path: "path/folder/"
        path.append("/");

        QStringList fileList = bubbleProcess::getBubblesFileList();

        if(fileList.size()>0){

            for(int i = 0; i < fileList.size(); i++){

                QString totPath = path.append(fileList.at(i));

                qDebug()<<"Total Path is: "<<totPath;


                QFile file(totPath);

                if(file.open(QFile::ReadOnly)){

                    vector<bubblePoint> aBubb =  bubbleProcess::readBubble(&file);

                    readBubbles.push_back(aBubb);
                }
            }

        }



    }

    bubbleProcess::setBubbles(readBubbles);


    bubbles = bubbleProcess::getBubbles();

    /// Fill the listview with loaded bubbles
    for(unsigned int i = 0; i < bubbles.size(); i ++)
    {
        ui->ComboBox_fetchedBubbles->addItem(QString::number(i));



    }

}
Esempio n. 19
0
void QgsApplication::init( QString customConfigPath )
{
  if ( customConfigPath.isEmpty() )
  {
    customConfigPath = QDir::homePath() + QString( "/.qgis/" );
  }
  qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );

  // check if QGIS is run from build directory (not the install directory)
  QDir appDir( applicationDirPath() );
#ifndef _MSC_VER
#define SOURCE_PATH "source_path.txt"
#else
#define SOURCE_PATH "../source_path.txt"
#endif
  if ( appDir.exists( SOURCE_PATH ) )
  {
    QFile f( applicationDirPath() + "/" + SOURCE_PATH );
    if ( f.open( QIODevice::ReadOnly ) )
    {
      ABISYM( mRunningFromBuildDir ) = true;
      ABISYM( mBuildSourcePath ) = f.readAll();
#if _MSC_VER
      QStringList elems = applicationDirPath().split( "/", QString::SkipEmptyParts );
      ABISYM( mCfgIntDir ) = elems.last();
      ABISYM( mBuildOutputPath ) = applicationDirPath() + "/../..";
#elif defined(Q_WS_MACX)
      ABISYM( mBuildOutputPath ) = applicationDirPath();
#else
      ABISYM( mBuildOutputPath ) = applicationDirPath() + "/.."; // on linux
#endif
      qDebug( "Running from build directory!" );
      qDebug( "- source directory: %s", ABISYM( mBuildSourcePath ).toAscii().data() );
      qDebug( "- output directory of the build: %s", ABISYM( mBuildOutputPath ).toAscii().data() );
    }
  }

  if ( ABISYM( mRunningFromBuildDir ) )
  {
    // we run from source directory - not installed to destination (specified prefix)
    ABISYM( mPrefixPath ) = QString(); // set invalid path
#ifdef _MSC_VER
    setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) + "/" + ABISYM( mCfgIntDir ) );
#else
    setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
#endif
    setPkgDataPath( ABISYM( mBuildSourcePath ) ); // directly source path - used for: doc, resources, svg
    ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) + "/" + QGIS_LIB_SUBDIR + "/";
    ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) + "/" + QGIS_LIBEXEC_SUBDIR + "/";
  }
  else
  {
    char *prefixPath = getenv( "QGIS_PREFIX_PATH" );
    if ( !prefixPath )
    {
#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
      setPrefixPath( applicationDirPath(), true );
#else
      QDir myDir( applicationDirPath() );
      myDir.cdUp();
      QString myPrefix = myDir.absolutePath();
      setPrefixPath( myPrefix, true );
#endif
    }
    else
    {
      setPrefixPath( prefixPath, true );
    }
  }

  if ( !customConfigPath.isEmpty() )
  {
    ABISYM( mConfigPath ) = customConfigPath + "/"; // make sure trailing slash is included
  }

  ABISYM( mDefaultSvgPaths ) << qgisSettingsDirPath() + QString( "svg/" );

  // set a working directory up for gdal to write .aux.xml files into
  // for cases where the raster dir is read only to the user
  // if the env var is already set it will be used preferentially
  QString myPamPath = qgisSettingsDirPath() + QString( "gdal_pam/" );
  QDir myDir( myPamPath );
  if ( !myDir.exists() )
  {
    myDir.mkpath( myPamPath ); //fail silently
  }


#if defined(Q_WS_WIN32) || defined(WIN32)
  CPLSetConfigOption( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
#else
  //under other OS's we use an environment var so the user can
  //override the path if he likes
  int myChangeFlag = 0; //whether we want to force the env var to change
  setenv( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
#endif
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimScriptCollection::readContentFromDisc()
{
    calcScripts.deleteAllChildObjects();

    if (directory().isEmpty())
    {
        for (size_t i = 0; i < subDirectories.size(); ++i)
        {
            if (subDirectories[i]) subDirectories[i]->readContentFromDisc();
        }
        return;
    }

    QDir myDir(this->directory());
    if (!myDir.isReadable())
    {
        return;
    }

    // Build a list of all scripts in the specified directory
    {
        QString filter = "*.m";
        QStringList fileList = caf::Utils::getFilesInDirectory(directory, filter, true);

        int i;
        for (i = 0; i < fileList.size(); i++)
        {
            QString fileName = fileList.at(i);

            QFileInfo fi(fileName);
            if (fi.exists())
            {
                RimCalcScript* calcScript = new RimCalcScript;
                calcScript->absolutePath = fileName;
                calcScript->setUiName(fi.baseName());

                calcScripts.push_back(calcScript);
            }
        }
    }

    // Add subfolders
    {
        QDir dir(directory);
        QFileInfoList fileInfoList = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Readable);
        subDirectories.deleteAllChildObjects();

        QStringList retFileNames;

        QListIterator<QFileInfo> it(fileInfoList);
        while (it.hasNext())
        {
            QFileInfo fi = it.next();

            RimScriptCollection* scriptLocation = new RimScriptCollection;
            scriptLocation->directory = fi.absoluteFilePath();
            scriptLocation->setUiName(fi.baseName());
            scriptLocation->readContentFromDisc();
        
            subDirectories.push_back(scriptLocation);
        }
    }
}
void BubbleProcessDialog::on_But_bubbleFilesSetRootDir_clicked()
{
    // Get the root directory
    QString path =   QFileDialog::getExistingDirectory(this, tr("Open Directory"),
                                                       "home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);

    if(path != NULL){


        // append a slash
        path.append("/");

        // create a directory object with path
        QDir myDir(path);

        // Set the root directory for bubbleProcess
        bubbleProcess::setBubblesRootDirectory(path);

        ui->Edit_bubbleFilesRootDir->setText(path);

        // Create a filter for the given extensions
        QStringList filters(ui->Edit_bubbleFilesExtension->text());

        qDebug()<<filters;

        // List the bubbles in that directory
        // QStringList list = myDir.entryList(filters);

        // First check if we have a directory in the root file
        QStringList tempList = myDir.entryList(QDir::Dirs | QDir::NoDotDot |QDir::NoDot,QDir::Name);

        QStringList list =tempList;
        // If we have directory or directories (This part is specific to cx\apes0\bubble0.m format!!!)
        if(tempList.size() > 0){

            bool startsfromZero = false;

            for(unsigned int i = 0; i < tempList.size(); i++)
            {
                QString charr = "c";

                QString tmp = tempList.at(i);

                tmp.remove(0,1);

                int num = tmp.toInt();

                if(i==0 && i==num)startsfromZero = true;

                charr.append(tmp);

                if(!startsfromZero) list[num-1] = charr;

                else list[num] = charr;

            }
            // set the file list of the bubbles
            bubbleProcess::setBubblesFolderList(list);
        }
        else{

            // Create a filter for the given extensions
            QStringList filters(ui->Edit_bubbleFilesExtension->text());

            qDebug()<<filters;

            // List the bubbles in that directory
            QStringList list = myDir.entryList(filters);

            if(list.size()>0) bubbleProcess::setBubblesFileList(list);

        }


        qDebug()<<list;

    }



}