コード例 #1
0
QString RotoCanvas::getLayersFolderPath(QFileInfo frameFI, int frameNumber, bool createEnable)
{
    //such as <sequenceName>/frames/<frameNumber>/layers
    QString seqName=RotoCanvas::getSeqName(frameFI);
    //qInfo() << "seqName:" << seqName; //see also qInfo,qDebug,qWarning,qCritical,qFatal
    QString seqPath=frameFI.dir().filePath(seqName);
    QDir seqDir(seqPath);
    if (createEnable) {
        if (!seqDir.exists()) frameFI.dir().mkdir(seqName);
    }
    QString framesPath=seqDir.filePath("frames");
    //qInfo()<<"framesPath:"<<framesPath;
    QDir framesDir(framesPath);
    if (createEnable) {
        if (!framesDir.exists()) seqDir.mkdir("frames");
    }
    QString thisFramePath=framesDir.filePath(QString::number(frameNumber));
    //qInfo()<<"thisFramePath:"<<thisFramePath;
    QDir thisFrameDir=QDir(thisFramePath);
    if (createEnable) {
        if (!thisFrameDir.exists()) framesDir.mkdir(QString::number(frameNumber));
    }
    QString layersPath=QDir(thisFramePath).filePath("layers");
    //qInfo()<<"layersPath:"<<layersPath;
    QDir layersDir=QDir(layersPath);
    if (createEnable) {
        if (!layersDir.exists()) thisFrameDir.mkdir("layers");
    }
    return layersPath;
}
コード例 #2
0
ファイル: dumbsync.cpp プロジェクト: panter-dsd/leechcraft
	SyncConfLevel Plugin::CouldSync (const QString& path)
	{
		QFileInfo fi (path);
		if (!fi.isDir () || !fi.isWritable ())
			return SyncConfLevel::None;

		if (fi.dir ().entryList (QDir::Dirs).contains (".rockbox", Qt::CaseInsensitive) ||
			fi.dir ().entryList (QDir::Dirs).contains ("music", Qt::CaseInsensitive))
			return SyncConfLevel::High;

		return SyncConfLevel::Medium;
	}
コード例 #3
0
ファイル: addtoarchive.cpp プロジェクト: Zeirison/ark
QString AddToArchive::detectBaseName(const QStringList &paths) const
{
    QFileInfo fileInfo = QFileInfo(paths.first());
    QDir parentDir = fileInfo.dir();
    QString base = parentDir.absolutePath() + QLatin1Char('/');

    if (paths.size() > 1) {
        if (!parentDir.isRoot()) {
            // Use directory name for the new archive.
            base += parentDir.dirName();
        }
    } else {
        // Strip filename of its extension, but only if present (see #362690).
        if (!QMimeDatabase().mimeTypeForFile(fileInfo.fileName(), QMimeDatabase::MatchExtension).isDefault()) {
            base += fileInfo.completeBaseName();
        } else {
            base += fileInfo.fileName();
        }
    }

    // Special case for compressed tar archives.
    if (base.right(4).toUpper() == QLatin1String(".TAR")) {
        base.chop(4);
    }

    if (base.endsWith(QLatin1Char('/'))) {
        base.chop(1);
    }

    return base;
}
コード例 #4
0
ファイル: ConfigForm.cpp プロジェクト: ElbinP/QLocate
bool ConfigForm::validateDBLocate()
{
    QFileInfo theFile;
    QDir theDir;
    QString warningStr = "";

    ui->LineEditDBLocate->setText( ui->LineEditDBLocate->text().trimmed() );
    theFile = QFileInfo(ui->LineEditDBLocate->text());
    theDir = theFile.dir();
    if ( !theDir.exists() )
    {
        warningStr += tr("The directory selected for create DB index not exists !\n");
    }

    if ( theFile.fileName().isEmpty() )
    {
        warningStr += tr("The file name selected for create DB index is empty !\n");
    }

    if ( !theDir.exists() || theFile.fileName().isEmpty() )
    {
        warningStr += tr("Invalide input:") + QString(" \"") + ui->LineEditDBLocate->text() + QString("\"\n\n") + tr("Operation is aborded !") ;
        QMessageBox::warning( this, tr("Invalide Input"), warningStr );
        ui->LineEditDBLocate->selectAll();
        return FALSE;
    }
    else
    {
        return TRUE;
    }
}
コード例 #5
0
//------------------------------------------------------------------------------
void MainWindow::getTargetFiles(QListWidget *listWidget, QLineEdit *labelFileStatus, QStringList files)
{
    for (int ii = 0; ii < files.count(); ii++) {
        QFileInfo *fileinfo = new QFileInfo(files[ii]);
        if(fileinfo->isFile()){
            if(! getTargetFile(listWidget, files[ii], files.count() - ii - 1)){
                break;
            }
            inputFilesPath = fileinfo->dir().absolutePath();
        }
        else{
            QMessageBox::StandardButton reply;
            reply = QMessageBox::information(this, tr("Confirm"),
                     tr("Select all files in the folder?") + "\n\n" + files[ii],
                    QMessageBox::Yes | QMessageBox::No | QMessageBox::Abort);
            if (reply == QMessageBox::Yes){
                if(! getTargetFolder(listWidget, files[ii])){
                    break;
                }
                inputFilesPath = files[ii];
            }
            else if(reply == QMessageBox::No){
                continue;
            }
            else{
                break;
            }
        }
    }
    rewriteFileStatus(listWidget, labelFileStatus);
}
コード例 #6
0
ファイル: modes.cpp プロジェクト: alinelena/aten
// Export all currently loaded models in the referenced format
void Aten::exportModels()
{
	Messenger::enter("Aten::exportModels");
	QFileInfo fileInfo;
	QString newFilename;

	// Loop over loaded models
	for (Model* m = models_.first(); m != NULL; m = m->next)
	{
		// Set current model
		setCurrentModel(m);

		// Generate new filename for model, with new suffix
		fileInfo.setFile(m->filename());
		newFilename = fileInfo.dir().absoluteFilePath(fileInfo.baseName() + "." + exportModelPlugin_->extensions().first());

		QFileInfo newFileInfo(newFilename);
		// Make sure that the new filename is not the same as the old filename
		if (fileInfo == newFileInfo)
		{
			Messenger::print("Exported file would overwrite the original (%s) - not converted.", qPrintable(m->filename()));
			continue;
		}

		if (exportModel(m, newFilename, exportModelPlugin_, FilePluginStandardImportOptions(), exportModelPluginOptions_)) Messenger::print("Model '%s' saved to file '%s' (%s)", qPrintable(m->name()), qPrintable(newFilename), qPrintable(exportModelPlugin_->name()));
		else Messenger::print("Failed to save model '%s'.", qPrintable(m->name()));
		m->enableUndoRedo();
	}
	Messenger::exit("Aten::exportModels");
}
コード例 #7
0
ファイル: ExportCommon.cpp プロジェクト: jdbcdev/gideros
bool ExportCommon::download(ExportContext *ctx, QString url, QString to) {
	QString filePath = QDir::cleanPath(ctx->outputDir.absoluteFilePath(to));
	QFileInfo fi = QFileInfo(filePath);
	ctx->outputDir.mkpath(fi.dir().absolutePath());
	QFile file(filePath);
	if (file.exists())
		return true;
	if (file.open(QIODevice::WriteOnly)) {
		exportInfo("Downloading %s\n", url.toStdString().c_str());

		QUrl imageUrl(url);
		FileDownloader *m_pImgCtrl = new FileDownloader(imageUrl);

		QEventLoop loop;
		loop.connect(m_pImgCtrl, SIGNAL(downloaded()), &loop, SLOT(quit()));
		loop.exec();

		QByteArray data = m_pImgCtrl->downloadedData();

		delete m_pImgCtrl;

		if (data.length() > 0) {
			file.write(data);
			return true;
		} else
			exportError("Failed to download %s\n", url.toStdString().c_str());
	} else
		exportError("Can't open file %s\n", to.toStdString().c_str());
	return false;
}
コード例 #8
0
bool JasonQt_File::copyFile(const QFileInfo &sourcePath, const QFileInfo &targetPath, const bool &cover)
{
    if(sourcePath.filePath()[sourcePath.filePath().size() - 1] == '/')
    {
        return false;
    }

    if(targetPath.filePath()[targetPath.filePath().size() - 1] == '/')
    {
        return false;
    }

    if(!targetPath.dir().isReadable())
    {
        if(!QDir().mkpath(targetPath.path()))
        {
            return false;
        }
    }

    if(targetPath.isFile() && !cover)
    {
        return true;
    }

    return QFile::copy(sourcePath.filePath(), targetPath.filePath());
}
コード例 #9
0
bool JasonQt_File::writeFile(const QFileInfo &targetFilePath, const QByteArray &data, const bool &cover)
{
    if(!targetFilePath.dir().isReadable())
    {
        if(!QDir().mkpath(targetFilePath.path()))
        {
            return false;
        }
    }

    if(targetFilePath.isFile() && !cover)
    {
        return true;
    }

    QFile file(targetFilePath.filePath());
    if(!file.open(QIODevice::WriteOnly))
    {
        return false;
    }

    file.write(data);
    file.waitForBytesWritten(10000);

    return true;
}
コード例 #10
0
bool W3cXmlPlugin::process(const QString *infoListfile)
{
    LOG("BEGIN W3cXmlPlugin::process infoListfile=" << infoListfile);

    if (infoListfile == NULL && m_dir.exists()) {
        LOG("W3cXmlPlugin::process search for config.xml");
        // Search for config.xml file

        QFileInfoList tempExtract = m_dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
        LOG("W3cXmlPlugin::process got entryInfoList");

        foreach (const QFileInfo &isWidgetDir, tempExtract ) {
            if (!isWidgetDir.fileName().compare("config.xml", Qt::CaseSensitive)) {
                // We found the config.xml
                QString filePath = isWidgetDir.absoluteFilePath();
                if (!filePath.isEmpty()) {
                    QFileInfo f = filePath;
                    m_dir = f.dir();
                    LOG("W3cXmlPlugin::process found config.xml at " << filePath);
                    m_parser->setFile(filePath);
                    if (m_parser->parseFile()) {
                       setAttributeMap();
                       LOG("END W3cXmlPlugin::process xml parsing successful");
                       return true;
                    }
                }
            }
        }   // end of foreach
    }
コード例 #11
0
ファイル: mainwindow.cpp プロジェクト: malikazoo/codesample
void MainWindow::on_cmdRun_clicked()
{
    if (selectedFile != "")
    {
        VideoCapture vid(selectedFile.toStdString().c_str());

        VideoWriter vout;

        vout.open((selectedFile + "out.mpeg").toStdString().c_str(),CV_FOURCC('M','P','E','G'),30,Size(vid.get(CV_CAP_PROP_FRAME_WIDTH), vid.get(CV_CAP_PROP_FRAME_HEIGHT)));

        qDebug() << "Frame cnt " << frame_count;

        QFileInfo filedir = QFileInfo(selectedFile);
        QDir currdir = filedir.dir();

        int sample_size = frame_count;
        if (sample_size <= 0)
            return;

        int sample_interval = frame_count / sample_size;
        int sample_cnt = 0;
        ui->prog->setMaximum(frame_count);

        bool undistorted = ui->chkDistort->isChecked();
        Mat cammatrix;
        Mat distortion;
        double rms;
        if (undistorted)
        {
            FileStorage file(calibFile.toStdString().c_str(),FileStorage::READ);
            file["rms"] >> rms;
            file["cameramatrix"] >> cammatrix;
            file["distortion"] >> distortion;
        }

        for (int i = 0; i < frame_count; i++)
        {
            Mat r;
            vid >> r;
            QString writepath = selectedFile + "-" + QString::number(i) + ".png";

            Mat c;

            if (undistorted)
            {
                undistort(r, c, cammatrix, distortion);
            }
            else
            {
                c = r;
            }

            imwrite(writepath.toStdString().c_str(), c);
            vout << c;
            ui->prog->setValue(i);
        }

        ui->prog->setValue(frame_count);
    }
コード例 #12
0
ファイル: CertTableModel.cpp プロジェクト: Emercoin/emercoin
QString CertTableModel::Item::loadFromTemplateFile(const QFileInfo & entry) {//QString::isEmpty -> ok
	//file example: /CN=Konstantine Kozachuk/[email protected]/UID=123
	_templateFile = entry.filePath();
	_dir = entry.dir();
	_baseName = entry.baseName();
	QFile file(_templateFile);
	if(!file.open(QFile::ReadOnly))
		return file.errorString();
	const QByteArray arr = file.readAll();
	const QString str = arr;
	auto lines = str.split('\n', QString::SkipEmptyParts);
	if(lines.count()!=1)
		return tr("Invalid file format: more than 1 non-empty line in %1")
		.arg(QDir::toNativeSeparators(_templateFile));
	const QString line = lines[0];
	_templateLine.append(line.toUtf8());
	auto parts = line.split('/', QString::SkipEmptyParts);
	bool formatOk = parts.size() == 2 || parts.size() == 3;
	if(!formatOk)
		return tr("Invalid format of file %1: %2 parts, looking for 2 or 3")
		.arg(QDir::toNativeSeparators(_templateFile))
		.arg(parts.size());
	for(QString part: parts) {
		if(!part.contains('='))
			return tr("Invalid format: must be key=value in %1")
			.arg(QDir::toNativeSeparators(_templateFile));
		auto kv = part.split('=', QString::SkipEmptyParts);
		if(kv.size() != 2)
			return tr("Invalid format: must be key=value in %1")
			.arg(QDir::toNativeSeparators(_templateFile));
		const QString key = kv.first();
		const QString value = kv.last();
		if(key == "CN") {
			_name = value;
		} else if(key == "emailAddress") {
			_mail = value;
		} else if(key == "UID") {
			_InfoCardId = value;
		} else {
			return tr("Unknown key %1 in %2").arg(key)
				.arg(QDir::toNativeSeparators(_templateFile));
		}
	}
	_name = _name.trimmed();
	_mail = _mail.trimmed();
	if(_name.isEmpty())
		return tr("Invalid format: empty name in %1")
			.arg(QDir::toNativeSeparators(_templateFile));
	if(_mail.isEmpty())
		return tr("Invalid format: empty email in %1")
			.arg(QDir::toNativeSeparators(_templateFile));
	_certPair = pathByExt("p12");
	QFileInfo cert(_certPair);
	if(cert.exists()) {
		_certCreated = cert.lastModified();
	}
	return QString();
}
コード例 #13
0
    //Pack every subdirectory
    foreach (QFileInfo sourceDirectory, directories) {
        if (sourceDirectory.dir().count() == 0) continue; //ignore empty folders

        qint64 startByte = file.size();
        if (!this->Pack_Directory(file, sourceDirectory.filePath())) return false;

        //Update the table entry with the new pointers
        if (!this->Write_Buffer_To_File(file, this->Get_Byte_Array_From_qint64(startByte), directoryTable.value(sourceDirectory.fileName()))) return false;
    }
コード例 #14
0
void medDatabaseRemover::removeSeries ( int patientDbId, int studyDbId, int seriesDbId )
{
    QSqlDatabase db(d->db);
    QSqlQuery query ( db );

    query.prepare ( "SELECT thumbnail, path, name  FROM " + d->T_SERIES + " WHERE id = :series " );
    query.bindValue ( ":series", seriesDbId );
    EXEC_QUERY ( query );

    QString thumbnail;
    if ( query.next() )
    {
        thumbnail = query.value ( 0 ).toString();
        this->removeFile ( thumbnail );
        QString path = query.value ( 1 ).toString();

        // if path is empty then it was an indexed series
        if ( !path.isNull() && !path.isEmpty() )
            this->removeDataFile ( medDataIndex::makeSeriesIndex ( d->index.dataSourceId(), patientDbId, studyDbId, seriesDbId ) , path );
    }

    if( removeTableRow ( d->T_SERIES, seriesDbId ) )
        emit removed(medDataIndex(1, patientDbId, studyDbId, seriesDbId, -1));

    // we want to remove the directory if empty
    QFileInfo seriesFi ( medStorage::dataLocation() + thumbnail );
    if ( seriesFi.dir().exists() )
    {
        bool res = seriesFi.dir().rmdir ( seriesFi.absolutePath() ); // only removes if empty

        // the serie's directory has been deleted, let's check if the patient directory is empty
        // this can happen after moving series
        if(res)
        {
            QDir parentDir = seriesFi.dir();
            res = parentDir.cdUp();

            if ( res && parentDir.exists() )
            {
                res = seriesFi.dir().rmdir ( parentDir.absolutePath() ); // only removes if empty
            }
        }
    }
}
コード例 #15
0
ファイル: qfs.cpp プロジェクト: epiktetov/microMup07
/*---------------------------------------------------------------------------*/
bool QfsIsWritable (QFileInfo Qi)     /* no file => check if dir is writable */
{
       if ( Qi      .exists()) return Qi.isWritable();
  else if (!Qi.dir().exists()) return false;
  else { 
    QFileInfo Qd(Qi.path());   return Qd.isWritable();
//+
//  fprintf(stderr, "Dir(%s)%s[%x]\n",                Qd.fileName().cStr(),
//-     Qd.isWritable() ? "writable" : "read-only", (int)Qd.permissions());
} }
コード例 #16
0
ファイル: KmzHandler.cpp プロジェクト: Earthwings/marble
bool KmzHandler::open( const QString &kmz )
{
    QuaZip zip( kmz );
    if ( !zip.open( QuaZip::mdUnzip ) ) {
        mDebug() << "Failed to extract " << kmz;
        return false;
    }

    QTemporaryFile outputDir ( QDir::tempPath() + "/marble-kmz-XXXXXX" );
    outputDir.setAutoRemove( false );
    outputDir.open();
    if ( !QFile::remove( outputDir.fileName() ) || !QDir("/").mkdir( outputDir.fileName() ) ) {
        mDebug() << "Failed to create temporary storage for extracting " << kmz;
        return false;
    }

    m_kmzPath = outputDir.fileName();
    QuaZipFile zipFile( &zip );
    for ( bool moreFiles=zip.goToFirstFile(); moreFiles; moreFiles=zip.goToNextFile() ) {
        QFileInfo output = QFileInfo( outputDir.fileName() + "/" + zip.getCurrentFileName() );
        if ( !output.dir().exists() ) {
            QDir::root().mkpath( output.dir().absolutePath() );
        }

        QFile outputFile( output.absoluteFilePath() );
        outputFile.open( QIODevice::WriteOnly );
        zipFile.open( QIODevice::ReadOnly );
        outputFile.write( zipFile.readAll() );
        outputFile.close();
        zipFile.close();
        m_kmzFiles << output.absoluteFilePath();

        if ( output.suffix().toLower() == "kml" ) {
            if ( !m_kmlFile.isEmpty() ) {
                mDebug() << "File" << kmz << "contains more than one .kml files";
            }
            m_kmlFile = output.absoluteFilePath();
        }
    }
    zip.close();
    return true;
}
コード例 #17
0
ファイル: gtmainwindow.cpp プロジェクト: gcypds/gtgenerator
bool GTMainWindow::saveAs() {
	/*QString fileName = QFileDialog::getSaveFileName(this, tr("Save GTProject"), data->gtProject->name+".gtp", tr("GTProject files (*.gtp)"));
	if (fileName.isEmpty())
		return false;*/

	xmlProcessor->saveGTProjectToXML(data->gtProject, openGTProjectPath);
	QFileInfo fileInfo = QFileInfo(openGTProjectPath);
	taggingWidget->selectGTProject(fileInfo.dir().path());
	taggingWidget->loadData();
	return true;
}
コード例 #18
0
ファイル: wcoverartmenu.cpp プロジェクト: chegestar/mixxx
void WCoverArtMenu::slotChange() {
    QFileInfo fileInfo;
    if (!m_trackLocation.isEmpty()) {
        fileInfo = QFileInfo(m_trackLocation);
    } else if (!m_coverInfo.trackLocation.isEmpty()) {
        fileInfo = QFileInfo(m_coverInfo.trackLocation);
    }

    QString initialDir;
    if (m_coverInfo.type == CoverInfo::FILE) {
        QFileInfo coverFile(fileInfo.dir(), m_coverInfo.coverLocation);
        initialDir = coverFile.absolutePath();
    } else {
        // Default to the track's directory if the cover is not
        // stored in a separate file.
        initialDir = fileInfo.absolutePath();
    }

    QStringList extensions = CoverArtUtils::supportedCoverArtExtensions();
    for (auto&& extension : extensions) {
        extension.prepend("*.");
    }
    QString supportedText = QString("%1 (%2)").arg(tr("Image Files"))
            .arg(extensions.join(" "));

    // open file dialog
    QString selectedCoverPath = QFileDialog::getOpenFileName(
        this, tr("Change Cover Art"), initialDir, supportedText);
    if (selectedCoverPath.isEmpty()) {
        return;
    }

    // TODO(rryan): Ask if user wants to copy the file.

    CoverArt art;
    // Create a security token for the file.
    QFileInfo selectedCover(selectedCoverPath);
    SecurityTokenPointer pToken = Sandbox::openSecurityToken(
        selectedCover, true);
    art.image = QImage(selectedCoverPath);
    if (art.image.isNull()) {
        // TODO(rryan): feedback
        return;
    }
    art.info.type = CoverInfo::FILE;
    art.info.source = CoverInfo::USER_SELECTED;
    art.info.coverLocation = selectedCoverPath;
    // TODO() here we may introduce a duplicate hash code
    art.info.hash = CoverArtUtils::calculateHash(art.image);
    qDebug() << "WCoverArtMenu::slotChange emit" << art;
    emit(coverArtSelected(art));
}
コード例 #19
0
ファイル: ConfigForm.cpp プロジェクト: ElbinP/QLocate
void ConfigForm::changeSearchIn_slot()
{
    QFileDialog * myDiag;
    QStringList filterList;
    QString fileName;

    myDiag = new QFileDialog( this );

    myDiag->setWindowTitle( tr("Select slocate database for querying.") );
    myDiag->setFileMode( QFileDialog::ExistingFile );
    myDiag->setViewMode( QFileDialog::List );
    QStringList filters;
    filters << tr("db files (*.db *.DB)")
            << tr("All files (*)");
    myDiag->setNameFilters(filters);

    QFileInfo tmpFile = QFileInfo( ui->LineEditSearchIn->text() );
    if ( !ui->LineEditSearchIn->text().isEmpty() && tmpFile.dir().exists() )
    {
        myDiag->setDirectory( tmpFile.dir() );
    }
    else
    {
        myDiag->setDirectory( QDir::homePath() + QString("/.qlocate/") );
    }

    myDiag->exec();

    if( !myDiag->selectedFiles().isEmpty() )
        fileName = myDiag->selectedFiles().first();

    delete (myDiag);

    if ( !fileName.isEmpty() )
    {
        ui->LineEditSearchIn->setText(fileName);
    }
}
コード例 #20
0
ファイル: preview.cpp プロジェクト: caivega/tao-3D
void PreviewThread::savePreview()
// ----------------------------------------------------------------------------
//   Save a preview of the image, and wait until awoken again
// ----------------------------------------------------------------------------
{
    // Acquire input parameters
    mutex.lock();
    QImage toSave = image;
    QString filePath = path;
    uint width = maxWidth;
    uint height = maxHeight;
    image = QImage();
    mutex.unlock();

    // Check if there is anything interesting to save
    if (!toSave.isNull() && filePath != "")
    {
        // Arm singles shot time for next save
        nextSave.start(timeInterval);

        // Rescale image to maximum dimensions
        if ((uint) toSave.width() > maxWidth)
            toSave = toSave.scaledToWidth(width);
        if ((uint) toSave.height() > maxHeight)
            toSave = toSave.scaledToHeight(height);
        
        // Save image in a temporary file
        QFileInfo fileInfo (filePath);
        QFileInfo tmpInfo(fileInfo.dir(), "tmp-" + fileInfo.fileName());
        toSave.save(tmpInfo.filePath());

        // Rename file to target (automic or near-atomic operation)
        QDir dir = fileInfo.dir();
        dir.remove(fileInfo.fileName());
        dir.rename(tmpInfo.fileName(), fileInfo.fileName());
    }
}
コード例 #21
0
bool QgsOfflineEditing::createSpatialiteDB( const QString& offlineDbPath )
{
  int ret;
  sqlite3 *sqlite_handle;
  char *errMsg = NULL;
  QFile newDb( offlineDbPath );
  if ( newDb.exists() )
  {
    QFile::remove( offlineDbPath );
  }

  // see also QgsNewSpatialiteLayerDialog::createDb()

  QFileInfo fullPath = QFileInfo( offlineDbPath );
  QDir path = fullPath.dir();

  // Must be sure there is destination directory ~/.qgis
  QDir().mkpath( path.absolutePath( ) );

  // creating/opening the new database
  QString dbPath = newDb.fileName();
  spatialite_init( 0 );
  ret = sqlite3_open_v2( dbPath.toUtf8().constData(), &sqlite_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL );
  if ( ret )
  {
    // an error occurred
    QString errCause = tr( "Could not create a new database\n" );
    errCause += QString::fromUtf8( sqlite3_errmsg( sqlite_handle ) );
    sqlite3_close( sqlite_handle );
    showWarning( errCause );
    return false;
  }
  // activating Foreign Key constraints
  ret = sqlite3_exec( sqlite_handle, "PRAGMA foreign_keys = 1", NULL, 0, &errMsg );
  if ( ret != SQLITE_OK )
  {
    showWarning( tr( "Unable to activate FOREIGN_KEY constraints" ) );
    sqlite3_free( errMsg );
    sqlite3_close( sqlite_handle );
    return false;
  }
  initializeSpatialMetadata( sqlite_handle );

  // all done: closing the DB connection
  sqlite3_close( sqlite_handle );

  return true;
}
コード例 #22
0
ファイル: kfilebrowser.cpp プロジェクト: phofman/kfile
/*=========================================================================
  slot handleRenameAction 
=========================================================================*/
void KFileBrowser::handleRenameAction (void)
  {
  QStringList names = getSelectedItems ();
  if (names.count() != 1)
    {
    error (tr("Please select exactly one file or folder to rename"));
    }
  else
    { 
    QString sourcePath = path + "/" + names[0];
    QFileInfo sourceInfo (sourcePath);
    QDir sourceDir = sourceInfo.dir();
    QString sourceFilename = sourceInfo.fileName();
    bool ok = false;
    QString newName = QInputDialog::getText (this, tr("Rename"),
    tr("Enter new name for") + " " + sourceFilename, 
      QLineEdit::Normal, "", &ok);
    if (ok && !newName.isEmpty())
      {
      QString targetPath = sourceDir.path() + "/" + newName;
      bool ok = false;
      if (sourceInfo.isDir())
        {
        QDir d (sourcePath);
        ok = sourceDir.rename (sourcePath, targetPath);
        }
      else
        {
        QFile f(sourcePath);
        ok = f.rename (targetPath);
        }
      if (ok)
        {
        emit statusUpdate (tr("Renamed") + " " + sourcePath + " " 
          + tr("to") + " " + targetPath);
        emit dirContentsChanged();
        }
      else
        {
        QString msg = (tr("Failed to rename") + " " + sourcePath + " " 
          + tr("to") + " " + targetPath);
        emit statusUpdate (msg);
        error (msg);
        }
      }
    }
  }
コード例 #23
0
ファイル: gtmainwindow.cpp プロジェクト: gcypds/gtgenerator
void GTMainWindow::open() {
	openGTProjectPath = QFileDialog::getOpenFileName(this, tr("Open GTProject"), ".", tr("GTProject files (*.gtp)"));
	if (!openGTProjectPath.isEmpty()) {
		xmlProcessor->readGTProjectFromXML(data->gtProject, openGTProjectPath);
		ui->gtProjectName_title->setFont(QFont("Newyork", 10, QFont::Bold));
		ui->gtProjectName_title->setText(data->gtProject->name);

		taggingWidget = new TaggingWidget();
		QFileInfo fileInfo = QFileInfo(openGTProjectPath);
		taggingWidget->selectGTProject(fileInfo.dir().path());
		taggingWidget->loadData();		
		setCentralWidget(taggingWidget);

		ui->gtStatusWidget->setVisible(true);
		fileToolBar->addWidget(ui->gtStatusWidget);
	}
}
コード例 #24
0
ファイル: galleryutil.cpp プロジェクト: DaveDaCoda/mythtv
static QFileInfo MakeUnique(const QFileInfo &dest)
{
    QFileInfo newDest = dest;

    for (uint i = 0; newDest.exists(); i++)
    {
        QString basename = QString("%1_%2.%3")
            .arg(dest.baseName()).arg(i).arg(dest.completeSuffix());

        newDest.setFile(dest.dir(), basename);

        LOG(VB_GENERAL, LOG_ERR, LOC +
            QString("Need to find a new name for '%1' trying '%2'")
                .arg(dest.absoluteFilePath()).arg(newDest.absoluteFilePath()));
    }

    return newDest;
}
コード例 #25
0
ファイル: gopathbrowser.cpp プロジェクト: hfeeki/liteide
void GopathBrowser::removeFolder()
{
    QFileInfo info = contextFileInfo();
    if (!info.isDir()) {
        return;
    }

    int ret = QMessageBox::warning(m_liteApp->mainWindow(),tr("Remove Folder"),
                          tr("Confirm remove the foler and continue"),
                          QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::No);
    if (ret == QMessageBox::Yes) {
        QDir dir = info.dir();
        if (!dir.rmdir(info.fileName())) {
            QMessageBox::information(m_liteApp->mainWindow(),tr("Remove Folder"),
                                     tr("Failed to remove the folder!"));
        }
    }
}
コード例 #26
0
/**
 * @brief RsCollectionDialog::directoryLoaded: called when ui._treeView have load an directory as QFileSystemModel don't load all in one time
 * @param dirLoaded: Name of directory just loaded
 */
void RsCollectionDialog::directoryLoaded(QString dirLoaded)
{
    if(!_dirLoaded)
    {

        QFileInfo lastDir = Settings->getLastDir(RshareSettings::LASTDIR_EXTRAFILE);
        if (lastDir.absoluteFilePath() == "") return;
        if (lastDir.absoluteFilePath() == dirLoaded) _dirLoaded = true;

        // Check all parent directory to see if it is loaded
        //as QFileSystemModel don't load all
        do {
            if(lastDir.absolutePath()==dirLoaded) {
                //Only expand loaded directory
                QModelIndex lastDirIdx = _dirModel->index(lastDir.absoluteFilePath());
                //Select LASTDIR_EXTRAFILE or last parent found when loaded
                if (!lastDirIdx.isValid()){
                    _dirLoaded = true;
                    break;
                }

                //Ask dirModel to load next parent directory
                while (_dirModel->canFetchMore(lastDirIdx)) _dirModel->fetchMore(lastDirIdx);

                //Ask to Expand last loaded parent
                lastDirIdx = _tree_proxyModel->mapFromSource(lastDirIdx);
                if (lastDirIdx.isValid()){
                    ui._systemFileTW->expand(lastDirIdx);
                    ui._systemFileTW->setCurrentIndex(lastDirIdx);
                }
                break;
            }
            //std::cerr << "lastDir = " << lastDir.absoluteFilePath().toStdString() << std::endl;

            QDir c = lastDir.dir() ;
            if(!c.cdUp())
                break ;

            lastDir = QFileInfo(c.path());
        } while (true); //(lastDir.absoluteFilePath() != lastDir.absolutePath());
    }
}
コード例 #27
0
ファイル: configLoader.cpp プロジェクト: Pechckin/test
void ConfigLoader::loadIncludes(QDomDocument const &config, QFileInfo const &currentFile)
{
    QDomNodeList includes = config.elementsByTagName("include");
    for (unsigned i = 0; i < includes.length(); i++) {
        QDomElement includeElement = includes.at(i).toElement();
        QString includeName = includeElement.attribute("name");
        QFileInfo included = QFileInfo(currentFile.dir(), includeName);
        if (included.exists()) {
            load(included.canonicalFilePath());
        } else {
            fprintf(stderr, "Error 13 (%s:%d,%d) : Include '%s' is unknown.\n",
                    currentFile.fileName().toLatin1().constData(),
                    includeElement.lineNumber(),
                    includeElement.columnNumber(),
                    includeName.toLatin1().constData()
            );
        }

    }
}
コード例 #28
0
void FileSystemWidget::removeFolder()
{
    QFileInfo info = contextFileInfo();
    if (!info.isDir()) {
        return;
    }

    int ret = QMessageBox::warning(m_liteApp->mainWindow(),tr("Remove Folder"),
                          tr("Confirm remove the foler and continue"),
                          QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::No);
    if (ret == QMessageBox::Yes) {
        QDir dir = info.dir();
        m_model->fileWatcher()->removePath(info.filePath());
        if (!dir.rmdir(info.fileName())) {
            QMessageBox::information(m_liteApp->mainWindow(),tr("Remove Folder"),
                                     tr("Failed to remove the folder!"));
            m_model->fileWatcher()->addPath(info.filePath());
        }
    }
}
コード例 #29
0
ファイル: filesystemwidget.cpp プロジェクト: is00hcw/liteide
void FileSystemWidget::removeFolder()
{
    QFileInfo info = contextFileInfo();
    if (!info.isDir()) {
        return;
    }
	
    int ret = QMessageBox::warning(m_liteApp->mainWindow(),tr("Delete Folder"),
                          tr("Are you sure that you want to permanently delete this folder and all of its contents?"),
                          QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
    if (ret == QMessageBox::Yes) {
        QDir dir = info.dir();
        m_model->fileWatcher()->removePath(info.filePath());
        if (!dir.rmdir(info.fileName())) {
            QMessageBox::information(m_liteApp->mainWindow(),tr("Delete Folder"),
                                     tr("Failed to delete the folder!"));
            m_model->fileWatcher()->addPath(info.filePath());
        }
    }
}
コード例 #30
0
ファイル: facetracknoir.cpp プロジェクト: vheathen/opentrack
void FaceTrackNoIR::fill_profile_cbx()
{
    if (looping)
        return;
    looping++;
    QSettings settings("opentrack");
    QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
    qDebug() << "Config file now" << currentFile;
    QFileInfo pathInfo ( currentFile );
    setWindowTitle(QString( OPENTRACK_VERSION " :: ") + pathInfo.fileName());
    QDir settingsDir( pathInfo.dir() );
    QStringList filters;
    filters << "*.ini";
    auto iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name );
    ui.iconcomboProfile->clear();
    for ( int i = 0; i < iniFileList.size(); i++)
        ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i));
    ui.iconcomboProfile->setCurrentText(pathInfo.fileName());
    looping--;
}