コード例 #1
0
QString KeyboardLayout::findSymbolBaseDir()
{
    QString xkbParentDir;

    QString base(XLIBDIR);
    if( base.count('/') >= 3 ) {
        // .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb
        QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11";
        QDir baseDir(base + delta);
        if( baseDir.exists() ) {
            xkbParentDir = baseDir.absolutePath();
        }
        else {
            QDir baseDir(base + "/X11");	// .../usr/X11/lib/X11/xkb (old XFree)
            if( baseDir.exists() ) {
                xkbParentDir = baseDir.absolutePath();
            }
        }
    }

    if( xkbParentDir.isEmpty() ) {
        xkbParentDir = "/usr/share/X11";
    }

    return QString("%1/xkb/symbols/").arg(xkbParentDir);
}
コード例 #2
0
ファイル: keyaliases.cpp プロジェクト: KDE/kde-workspace
QString Aliases::findaliasdir(){

    QString aliasdir;
    QString xkbParentDir;

    QString base(XLIBDIR);
    if( base.count('/') >= 3 ) {
        // .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb
        QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11";
        QDir baseDir(base + delta);
        if( baseDir.exists() ) {
            xkbParentDir = baseDir.absolutePath();
        }
        else {
            QDir baseDir(base + "/X11");	// .../usr/X11/lib/X11/xkb (old XFree)
            if( baseDir.exists() ) {
                xkbParentDir = baseDir.absolutePath();
            }
        }
    }

    if( xkbParentDir.isEmpty() ) {
        xkbParentDir = "/usr/share/X11";
    }
    aliasdir=QString("%1/xkb/keycodes/aliases").arg(xkbParentDir);
    return(aliasdir);
}
コード例 #3
0
	bool ViewHTML::determineTarget()
	{
		if (target().isNull())
		{
			//setRelativeBaseDir(S());
			QString dir = readEntry("relDir");
			QString trg = readEntry("target");

			if ( !dir.isEmpty() )
			{
				translate(dir);
				setRelativeBaseDir(dir);
			}

			if ( !trg.isEmpty() )
			{
				translate(trg);
				setTarget(trg);
			}

			//auto-detect the file to view
			if ( dir.isEmpty() && trg.isEmpty() )
			{
				QFileInfo file1 = QFileInfo(baseDir() + '/' + S() + "/index.html");
				QFileInfo file2 = QFileInfo(baseDir() + '/' + S() + ".html");

				bool read1 = file1.isReadable();
				bool read2 = file2.isReadable();

				if ( !read1 && !read2 )
				{
					sendMessage(Error, i18n("Unable to find %1 or %2; if you are trying to view some other HTML file, go to Settings->Configure Kile->Tools->ViewHTML->Advanced.").arg(file1.absFilePath()).arg(file2.absFilePath()));
					return false;
				}

				//both exist, take most recent
				if ( read1 && read2 )
				{
					read1 = file1.lastModified() > file2.lastModified();
					read2 = !read1;
				}

				if ( read1 )
				{
					dir = S();
					trg = "index.html";

					translate(dir);
					setRelativeBaseDir(dir);
					translate(trg);
					setTarget(trg);
				}
			}
		}

		return View::determineTarget();
	}
コード例 #4
0
void IconFromUrlReader::parseTransformedStream(QByteArray transformedData){

    //Create iconfrom raw data
    QPixmap pm;
    pm.loadFromData(transformedData);
    QIcon ic;
    ic.addPixmap(pm);

    //Get path for image cache
    QDir baseDir(PUSER_APP_DIR);
    QString iconPath = baseDir.absoluteFilePath(ICON_SUBDIR_NAME);
    QDir d(iconPath);
    if(!d.exists()){ d.mkdir(iconPath); }
    int id = stringHash(getRequestURL());
    QString iconName = iconPath + PATH_SEP + "netcached" + QString("%1").arg(id);

    //Create thumbnail for image
    QPixmap thumbMap = ic.pixmap(QSize(64,64));
    thumbMap.save(iconName);

    //Connect to item
    m_filt.setOverrideIcon(iconName);
    m_results.append(m_filt);

}
コード例 #5
0
	bool LaTeX::filterLogfile()
	{
		manager()->info()->outputFilter()->setSource(source());
		QString log = baseDir() + '/' + S() + ".log";

		return manager()->info()->outputFilter()->Run(log);
	}
コード例 #6
0
void tst_ProFileWriter::multiVar()
{
    QDir baseDir(BASE_DIR);
    QString input = QLatin1String(
            "SOURCES = foo bar\n"
            "# comment line\n"
            "HEADERS = baz bak"
            );
    QStringList lines = input.split(QLatin1String("\n"));
    QString output = QLatin1String(
            "SOURCES = bar\n"
            "# comment line\n"
            "HEADERS = baz"
            );
    QStringList files; files
            << QString::fromLatin1(BASE_DIR "/foo")
            << QString::fromLatin1(BASE_DIR "/bak");
    QStringList vars; vars << QLatin1String("SOURCES") << QLatin1String("HEADERS");

    ProFileOption option;
    ProFileEvaluator reader(&option);
    ProFile *proFile = reader.parsedProFile(BASE_DIR "/test.pro", input);
    QVERIFY(proFile);
    Qt4ProjectManager::Internal::ProWriter::removeFiles(proFile, &lines, baseDir, files, vars);

    QCOMPARE(lines.join(QLatin1String("\n")), output);
}
コード例 #7
0
bool PathHelper::setPermissionForFilesOfDirectory(const QString& baseDirPath, QFile::Permissions permission, bool addPermission, bool recursively)
{
    QDir baseDir(baseDirPath);
    QStringList qsl = baseDir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::NoSymLinks | QDir::Hidden);

    for(int i = 0; i < qsl.count(); i++) {
        QString currentFilePath = PathHelper::combineAndCleanPathes(baseDirPath, qsl[i]);
        QFileInfo finfo(currentFilePath);

        // If we've found a directory
        if (finfo.isDir()) {
            // Call it recursively if we have to

            if (recursively) {
                if (!PathHelper::setPermissionForFilesOfDirectory(currentFilePath, permission, addPermission, recursively)) {
                    return false;   // Some error occured
                }
            }
        } else if (finfo.isFile()) {
            if(!PathHelper::setPermissionForFile(currentFilePath, permission, addPermission)) {
//                DLog("Set permission for file failed: ") << currentFilePath << permission << addPermission;
                return false;
            }
        }
    }

    return true;
}
コード例 #8
0
void SphereGenerator::genObj()
{
    isCircle = 0;
    QFileInfo fileInfo(fileName);
    if(!fileInfo.exists())
    {
        std::cout << "error: file does not exist" << std::endl;
        return;
    }
    QDir baseDir(fileInfo.absoluteDir());
    QSettings settings(fileInfo.absoluteFilePath(),QSettings::IniFormat);
    // read in width
    sX = settings.value("sample/numX").toInt();
    sZ = settings.value("sample/numZ").toInt();
    sMatrixFile = QDir::cleanPath(QDir(baseDir).filePath(settings.value("sample/matrixfile").toString()));
    sTexture = QDir::cleanPath(QDir(baseDir).filePath(settings.value("sample/texture").toString()));
    sObj = QDir::cleanPath(QDir(baseDir).filePath(settings.value("sample/outputobj").toString()));
    isCircle = settings.value("circle/circle").toInt();

    // initialize
    projList.clear();
    mvList.clear();
    centerList.clear();

    readMatrix(sMatrixFile);
    deComposeMV();

    output();
}
コード例 #9
0
void tst_ProFileWriter::multiVar()
{
    QDir baseDir(BASE_DIR);
    QString input = QLatin1String(
            "SOURCES = foo bar\n"
            "# comment line\n"
            "HEADERS = baz bak"
            );
    QStringList lines = input.split(QLatin1String("\n"));
    QString output = QLatin1String(
            "SOURCES = bar\n"
            "# comment line\n"
            "HEADERS = baz"
            );
    QStringList files; files
            << QString::fromLatin1(BASE_DIR "/foo")
            << QString::fromLatin1(BASE_DIR "/bak");
    QStringList vars; vars << QLatin1String("SOURCES") << QLatin1String("HEADERS");

    QMakeVfs vfs;
    QMakeParser parser(0, &vfs, &parseHandler);
    ProFile *proFile = parser.parsedProBlock(input, QLatin1String(BASE_DIR "/test.pro"), 1);
    QVERIFY(proFile);
    QmakeProjectManager::Internal::ProWriter::removeFiles(proFile, &lines, baseDir, files, vars);
    proFile->deref();

    QCOMPARE(lines.join(QLatin1String("\n")), output);
}
コード例 #10
0
fileName distributionFunctionObject::dataDir()
{
    if(startup_) {
        return baseDir()/startTime_;
    } else {
        return timelineFunctionObject::dataDir();
    }
}
コード例 #11
0
QJsonObject OperatorParameterDirectory::save(const QString &baseDirStr)
{
    QDir baseDir(baseDirStr);
    QJsonObject obj;
    obj["type"] = QString("directory");
    obj["name"] = m_name;
    obj["target"] = baseDir.relativeFilePath(m_currentValue);
    return obj;
}
コード例 #12
0
    void run()
    {
        QProcess process;
        QString dir = QCoreApplication::applicationDirPath() + "/plugins/hilec";
        process.setWorkingDirectory(dir);
        process.start(dir + "/compile.bat", QStringList(QFileInfo(mFile).canonicalFilePath()) << mBase);
        if(!process.waitForFinished(5000))
        {
            QByteArray standardOutput = process.readAllStandardOutput();
            if(!standardOutput.isEmpty()){
                qDebug() << standardOutput;
            }
            QByteArray standardError = process.readAllStandardError();
            if(!standardError.isEmpty()){
                qDebug() << standardError;
            }
            process.kill();
            return;
        }

        QString str = process.readAllStandardOutput();
        QStringList errors = str.split("\n", QString::SkipEmptyParts);
        ScriptCompileInfo info;
        info.file = mFile;
        QDir baseDir(mBase);
        foreach(QString line, errors)
        {
            ScriptCompileProblem problem;
            QStringList parts = line.split(":");
            if(parts.size() < 3)
                continue;
            QString file = parts.takeFirst();
            if(file.size() == 1) // this is a windows disc
                file += ":" + parts.takeFirst();
            if(QFileInfo(baseDir.absoluteFilePath(file)) != QFileInfo(mFile))
                continue;
            if(parts.size() < 2)
                continue;
            problem.line = parts.takeFirst().toInt();
            QString msg = parts.join(":").trimmed().mid(1);
            int pos = msg.indexOf("]");
            if(pos < 1)
                continue;
            QChar mode = msg[0];
            if(mode == 'E' || mode == 'F')
                problem.mode = ScriptCompileProblem::Error;
            else if(mode == 'W')
                problem.mode = ScriptCompileProblem::Warning;
            else if(mode == 'C')
                problem.mode = ScriptCompileProblem::Info;
            else
                continue;
            problem.msg = msg.mid(pos + 1).trimmed();
            info.problems << problem;
            //qDebug() << mode << msg;
        }
コード例 #13
0
ファイル: PlaylistImporter.cpp プロジェクト: arestarh/LameXP
bool PlaylistImporter::importPlaylist(QStringList &fileList, const QString &playlistFile)
{
	QFileInfo file(playlistFile);
	QDir baseDir(file.canonicalPath());

	QDir rootDir(baseDir);
	while(rootDir.cdUp());

	//Sanity check
	if(file.size() < 3 || file.size() > 512000)
	{
		return false;
	}
	
	//Detect playlist type
	playlist_t playlistType = isPlaylist(file.canonicalFilePath());

	//Exit if not a playlist
	if(playlistType == notPlaylist)
	{
		return false;
	}
	
	QFile data(playlistFile);

	//Open file for reading
	if(!data.open(QIODevice::ReadOnly))
	{
		return false;
	}

	//Skip very large files (parsing could take very long)
	if(data.size() >= 10485760i64)
	{
		qWarning("File is very big. Probably not a Playlist. Rejecting...");
		return false;
	}

	//Parse playlist depending on type
	switch(playlistType)
	{
	case m3uPlaylist:
		return parsePlaylist_m3u(data, fileList, baseDir, rootDir);
		break;
	case plsPlaylist:
		return parsePlaylist_pls(data, fileList, baseDir, rootDir);
		break;
	case wplPlaylist:
		return parsePlaylist_wpl(data, fileList, baseDir, rootDir);
		break;
	default:
		return false;
		break;
	}
}
コード例 #14
0
	bool LaTeX::updateBibs()
	{
		KileDocument::TextInfo *docinfo = manager()->info()->docManager()->textInfoFor(source());
                if ( docinfo )
                {
			if ( manager()->info()->allBibliographies()->count() > 0 )
				return needsUpdate ( baseDir() + '/' + S() + ".bbl" , manager()->info()->lastModifiedFile(docinfo) );
		}

		return false;
	}
コード例 #15
0
ファイル: historykeeper.cpp プロジェクト: CuiZhicheng/qTox
QString HistoryKeeper::getHistoryPath(QString currentProfile, int encrypted)
{
    QDir baseDir(Settings::getInstance().getSettingsDirPath());
    if (currentProfile.isEmpty())
        currentProfile = Settings::getInstance().getCurrentProfile();

    if (encrypted == 1 || (encrypted == -1 && Nexus::getProfile()->isEncrypted()))
        return baseDir.filePath(currentProfile + ".qtox_history.encrypted");
    else
        return baseDir.filePath(currentProfile + ".qtox_history");
}
コード例 #16
0
// Create a new token
/*static*/ OSToken* OSToken::createToken(const std::string basePath, const std::string tokenDir, const ByteString& label, const ByteString& serial)
{
	Directory baseDir(basePath);

	if (!baseDir.isValid())
	{
		return NULL;
	}

	// Create the token directory
	if (!baseDir.mkdir(tokenDir))
	{
		return NULL;
	}

	// Create the token object
	ObjectFile tokenObject(NULL, basePath + OS_PATHSEP + tokenDir + OS_PATHSEP + "token.object", basePath + OS_PATHSEP + tokenDir + OS_PATHSEP + "token.lock", true);

	if (!tokenObject.valid)
	{
		baseDir.rmdir(tokenDir);

		return NULL;
	}

	// Set the initial attributes
	CK_ULONG flags = 
		CKF_RNG |
		CKF_LOGIN_REQUIRED | // FIXME: check
		CKF_RESTORE_KEY_NOT_NEEDED |
		CKF_TOKEN_INITIALIZED |
		CKF_SO_PIN_LOCKED |
		CKF_SO_PIN_TO_BE_CHANGED;

	OSAttribute tokenLabel(label);
	OSAttribute tokenSerial(serial);
	OSAttribute tokenFlags(flags);

	if (!tokenObject.setAttribute(CKA_OS_TOKENLABEL, tokenLabel) ||
	    !tokenObject.setAttribute(CKA_OS_TOKENSERIAL, tokenSerial) ||
	    !tokenObject.setAttribute(CKA_OS_TOKENFLAGS, tokenFlags))
	{
		baseDir.remove(tokenDir + OS_PATHSEP + "token.object");
		baseDir.remove(tokenDir + OS_PATHSEP + "token.lock");
		baseDir.rmdir(tokenDir);

		return NULL;
	}

	DEBUG_MSG("Created new token %s", tokenDir.c_str());

	return new OSToken(basePath + OS_PATHSEP + tokenDir);
}
コード例 #17
0
	bool LaTeX::updateIndex()
	{
		KileDocument::TextInfo *docinfo = manager()->info()->docManager()->textInfoFor(source());
		if ( docinfo )
		{
			const QStringList *pckgs = manager()->info()->allPackages();
				if ( pckgs->contains("makeidx") )
					return needsUpdate ( baseDir() + '/' + S() + ".ind", manager()->info()->lastModifiedFile(docinfo) );
		}

		return false;
	}
コード例 #18
0
ファイル: kdmpixmap.cpp プロジェクト: serghei/kde3-kdebase
void KdmPixmap::loadPixmap(const QString &fileName, QPixmap &map, QString &fullName)
{
    if(fileName.isEmpty())
        return;

    fullName = fileName;
    if(fullName.at(0) != '/')
        fullName = baseDir() + "/" + fileName;

    if(!fullName.endsWith(".svg")) // we delay it for svgs
        if(!map.load(fullName))
            fullName = QString::null;
}
コード例 #19
0
// TestFunction_Speed
//------------------------------------------------------------------------------
void TestProjectGeneration::TestFunction_Speed() const
{
	VSProjectGenerator pg;
	AStackString<> baseDir( "C:\\Windows\\System32" );
	Array< AString > baseDirs;
	baseDirs.Append( baseDir );

	// project name
	pg.SetProjectName( AStackString<>( "Big" ) );
	pg.SetBasePaths( baseDirs );

	// platforms
	Array< VSProjectConfig > configs;
	VSProjectConfig cfg;
	cfg.m_Platform = "Win32";
	cfg.m_Config = "Debug";
	configs.Append( cfg );

	// files (about 5,000)
	Array< AString > files;
	FileIO::GetFiles( baseDir, AStackString<>( "*.mui" ), true, &files );
	FileIO::GetFiles( baseDir, AStackString<>( "*.exe" ), true, &files );
	FileIO::GetFiles( baseDir, AStackString<>( "*.dll" ), true, &files );
	pg.AddFiles( files );

	Array< VSProjectFileType > fileTypes;
	{
		VSProjectFileType ft;
		ft.m_FileType = "CppForm";
		ft.m_Pattern = "Code\\Forms\\*.h";
		fileTypes.Append( ft );
		ft.m_FileType = "CppControl";
		ft.m_Pattern = "Controls\\*.h";
		fileTypes.Append( ft );
	}

	AStackString<> projectFileName( "C:\\Windows\\System\\dummy.vcxproj" );

	{
		Timer t;
		pg.GenerateVCXProj( projectFileName, configs, fileTypes );
		float time = t.GetElapsed();
		OUTPUT( "Gen vcxproj        : %2.3fs\n", time );
	}
	{
		Timer t;
		pg.GenerateVCXProjFilters( projectFileName );
		float time = t.GetElapsed();
		OUTPUT( "Gen vcxproj.filters: %2.3fs\n", time );
	}
}
コード例 #20
0
void RiuMultiCaseImportDialog::appendEGRIDFilesRecursively(const QString& folderName, QStringList& gridFileNames)
{
    {
        QDir baseDir(folderName);
        baseDir.setFilter(QDir::Files);

        QStringList nameFilters;
        nameFilters << "*.egrid" << ".EGRID";
        baseDir.setNameFilters(nameFilters);

        QStringList fileNames = baseDir.entryList();

        for (int i = 0; i < fileNames.size(); ++i)
        {
            QString fileName = fileNames[i];

            QString absoluteFolderName = baseDir.absoluteFilePath(fileName);

            gridFileNames.append(absoluteFolderName);
        }
    }


    {
        QDir baseDir(folderName);
        baseDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);

        QStringList subFolders = baseDir.entryList();

        for (int i = 0; i < subFolders.size(); ++i)
        {
            QString folderName = subFolders[i];

            QString absoluteFolderName = baseDir.absoluteFilePath(folderName);
            appendEGRIDFilesRecursively(absoluteFolderName, gridFileNames);
        }
    }
}
コード例 #21
0
bool LayoutMemoryPersister::save()
{
    QFileInfo fileInfo(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + REL_SESSION_FILE_PATH);

    QDir baseDir(fileInfo.absoluteDir());
    if( ! baseDir.exists() ) {
        if( ! QDir().mkpath(baseDir.absolutePath()) ) {
            qWarning() << "Failed to create directory" << baseDir.absolutePath();
        }
    }

    QFile file(fileInfo.absoluteFilePath());
    return saveToFile(file);
}
コード例 #22
0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfExportVisibleCells::buildExportSettings(const QString& exportFolder, RicSaveEclipseInputVisibleCellsUi* exportSettings)
{
    QDir baseDir(exportFolder);
    exportSettings->exportFilename = baseDir.absoluteFilePath(QString("%1.grdecl").arg(m_exportKeyword().text()));

    if (m_exportKeyword == ExportKeyword::FLUXNUM)
        exportSettings->exportKeyword = RicSaveEclipseInputVisibleCellsUi::FLUXNUM;
    else if (m_exportKeyword == ExportKeyword::MULTNUM)
        exportSettings->exportKeyword = RicSaveEclipseInputVisibleCellsUi::MULTNUM;

    exportSettings->visibleActiveCellsValue = m_visibleActiveCellsValue;
    exportSettings->hiddenActiveCellsValue  = m_hiddenActiveCellsValue;
    exportSettings->inactiveCellsValue      = m_inactiveCellsValue;
}
コード例 #23
0
void OperatorParameterDirectory::load(const QJsonObject &obj)
{
    if ( obj["type"].toString() != "directory" ) {
        dflWarning(tr("Directory: invalid parameter type"));
        return;
    }
    if ( obj["name"].toString() != m_name ) {
        dflWarning(tr("Directory: invalid parameter name"));
        return;
    }
    QDir baseDir(m_baseDir);
    QString relativeDir = obj["target"].toString();
    m_currentValue = baseDir.absoluteFilePath(relativeDir);
    emit updated();
}
コード例 #24
0
ファイル: main.cpp プロジェクト: Nicholas-NVS/hyphy
int main(int argc, char *argv[])
{
    GlobalStartup();
    DoApplicationSettings ();

    char    curWd[4096],
            dirSlash = GetPlatformDirectoryChar ();
    getcwd (curWd,4096);

    _String baseDir (curWd);

    if (baseDir.getChar (baseDir.sLength-1) != dirSlash) {
        baseDir=baseDir & dirSlash;
    }

    _String libDir (_HYPHY_LIBDIRECTORY_);

    if (libDir.getChar (libDir.sLength-1) != dirSlash) {
        libDir=libDir & dirSlash;
    }

    pathNames&& &libDir;

    libDirectory  = libDir;
    libArgDir     = libDirectory;
    baseDirectory = baseDir;
    baseArgDir    = baseDirectory;


    QApplication app(argc, argv);
    HyphyMain mainWindow;
    ReadInTemplateFiles     ();

    _hyPrimaryConsoleWindow = & mainWindow;

    /*mainWindow.setGeometry(
    QStyle::alignedRect(
        Qt::LeftToRight,
        Qt::AlignCenter,
        mainWindow.size(),
        qApp->desktop()->availableGeometry()
    ));*/

    mainWindow.show();
    mainWindow.raise();
    return app.exec();
}
コード例 #25
0
ファイル: installwindow.cpp プロジェクト: divan/wgames
//
// Step 5
// Copy binary to bindir, create symlinks
//
bool InstallWindow::Step5PrepareFiles()
{
    PrintStep(tr("Prepare files and symlinks"));

    QString binaryBase = _game->JsonBinary().section('/', 0, -2);
    QString binaryFilename = _game->JsonBinary().section('/', -1, -1);
    QString fullDataDir(_game->DataPath() +
                        "/usr/palm/applications/" +
                        _game->JsonID() + "/");

    // Copy binary to BinDir
    QFile bin(fullDataDir + _game->JsonBinary());
    QString toPath(_game->BinPath() + "/" + binaryFilename);
    qDebug() << "Copying binary " << bin.fileName() << " to " <<
            toPath;
    if (!bin.copy(toPath))
        return Failed(tr("Cannot copy binary file ") +
                      bin.fileName() + " to " +
                      toPath);
    QFile copiedBin(toPath);
    copiedBin.setPermissions(copiedBin.permissions() | QFile::ExeOwner | QFile::ExeGroup);

    // Create symlinks
    // Assuming main game directory is the basedir for binary
    QDir baseDir(fullDataDir + binaryBase);
    baseDir.setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
    QStringList filesList = baseDir.entryList();
    for (int i = 0; i < filesList.size(); ++i)
    {
        if (filesList.at(i) != binaryFilename)
        {
            QFile::link(fullDataDir + binaryBase + "/" + filesList.at(i),
                        _game->BinPath() + "/" + filesList.at(i));
            qDebug() << "Creating symlink from " <<
                    fullDataDir + binaryBase + "/" + filesList.at(i) <<
                    " to " << _game->BinPath() + "/" + filesList.at(i);
        }
    }

    PrintOK();
    Sync();

    return Step6CreateShortcuts();
}
コード例 #26
0
ファイル: qgcide.cpp プロジェクト: radekp/qgcide
bool QDictWidget::ensureDictFile()
{
    if(dictFile.exists())
    {
        return true;
    }
    QDir baseDir("/media/card");
    if(!baseDir.exists())
    {
        baseDir = QDir::home();
    }
    QDir dictDir(baseDir.path() + "/.qgcide");
    if(!dictDir.exists())
    {
        if(!baseDir.mkdir(".qgcide"))
        {
            showErr(tr("Unable to create dictionary dir ") + dictDir.absolutePath());
            return false;
        }
    }
    dictFile.setFileName(dictDir.absolutePath() + "/gcide-entries.xml");
    if(dictFile.exists())
    {
        return true;
    }
    if(QMessageBox::question(this, tr("English dictionary"),
                          tr("Dictionary must be downloaded. Please make sure you have internet connection and press yes to confirm download (14MB)."),
                          QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
    {
        return false;
    }
    progress->setVisible(true);
    QString gzFile = dictFile.fileName() + ".gz";
    if(!download("http://dl.linuxphone.ru/openmoko/qtmoko/packages/gcide-entries.xml.gz", gzFile, "gcide-entries.xml.gz"))
    {
        return false;
    }
    if(!ungzip(gzFile))
    {
        return false;
    }
    progress->setVisible(false);
    return true;
}
コード例 #27
0
ファイル: sddmauthhelper.cpp プロジェクト: KDE/sddm-kcm
ActionReply SddmAuthHelper::uninstalltheme(const QVariantMap &args)
{
    const QString themePath = args["filePath"].toString();
    const QString themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "sddm/themes", QStandardPaths::LocateDirectory);

    QDir dir(themePath);
    if (!dir.exists()) {
        return ActionReply::HelperErrorReply();
    }

    //validate the themePath is directly inside the themesBaseDir
    QDir baseDir(themesBaseDir);
    if(baseDir.absoluteFilePath(dir.dirName()) != dir.absolutePath()) {
        return ActionReply::HelperErrorReply();
    }

    if (!dir.removeRecursively()) {
        return ActionReply::HelperErrorReply();
    }

    return ActionReply::SuccessReply();
}
コード例 #28
0
ファイル: qgeotilecache.cpp プロジェクト: MarianMMX/MarianMMX
QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent)
    : QObject(parent), directory_(directory),
      minTextureUsage_(0), extraTextureUsage_(0)
{
    qRegisterMetaType<QGeoTileSpec>();
    qRegisterMetaType<QList<QGeoTileSpec> >();
    qRegisterMetaType<QSet<QGeoTileSpec> >();

    // We keep default values here so that they are in one place
    // rather than in each individual plugin (the plugins can
    // of course override them)

    const QString basePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)
                 + QLatin1String("/QtLocation");

    // delete old tiles from QtLocation 5.4 or prior
    // TODO Remove cache cleanup in Qt 6
    QDir baseDir(basePath);
    if (baseDir.exists()) {
        const QStringList oldCacheFiles = baseDir.entryList(QDir::Files);
        foreach (const QString& file, oldCacheFiles)
            baseDir.remove(file);
    }

    if (directory_.isEmpty()) {
        directory_ = basePath;
        qWarning() << "Plugin uses uninitialized directory for QGeoTileCache"
                      " which will was deleted during startup";
    }

    QDir::root().mkpath(directory_);

    // default values
    setMaxDiskUsage(20 * 1024 * 1024);
    setMaxMemoryUsage(3 * 1024 * 1024);
    setExtraTextureUsage(6 * 1024 * 1024);

    loadTiles();
}
コード例 #29
0
void tst_ProFileWriter::edit()
{
    QFETCH(bool, add);
    QFETCH(QStringList, files);
    QFETCH(QString, input);
    QFETCH(QString, output);

    QDir baseDir(BASE_DIR);
    QStringList lines = input.split(QLatin1String("\n"));
    QStringList vars; vars << QLatin1String("SOURCES");

    ProFileOption option;
    ProFileEvaluator reader(&option);
    ProFile *proFile = reader.parsedProFile(BASE_DIR "/test.pro", input);
    QVERIFY(proFile);
    if (add)
        Qt4ProjectManager::Internal::ProWriter::addFiles(proFile, &lines, baseDir, files, vars);
    else
        Qt4ProjectManager::Internal::ProWriter::removeFiles(proFile, &lines, baseDir, files, vars);

    QCOMPARE(lines.join(QLatin1String("\n")), output);
}
コード例 #30
0
	bool ForwardDVI::determineTarget()
	{
		if (!View::determineTarget())
			return false;

		int para = manager()->info()->lineNumber();
		Kate::Document *doc = manager()->info()->activeTextDocument();
		QString filepath;

		if (doc)
			filepath = doc->url().path();
		else
			return false;

		QString texfile = manager()->info()->relativePath(baseDir(),filepath);
		m_urlstr = "file:" + targetDir() + '/' + target() + "#src:" + QString::number(para+1) + ' ' + texfile; // space added, for files starting with numbers
		addDict("%dir_target", QString::null);
		addDict("%target", m_urlstr);
		KILE_DEBUG() << "==KileTool::ForwardDVI::determineTarget()=============\n" << endl;
		KILE_DEBUG() << "\tusing  " << m_urlstr << endl;

		return true;
	}