コード例 #1
0
ファイル: realpass.cpp プロジェクト: IJHack/qtpass
/**
 * @brief RealPass::Move move a file (or folder)
 * @param src source file or folder
 * @param dest destination file or folder
 * @param force overwrite
 */
void RealPass::Move(const QString src, const QString dest, const bool force) {
  QFileInfo srcFileInfo = QFileInfo(src);
  QFileInfo destFileInfo = QFileInfo(dest);

  // force mode?
  // pass uses always the force mode, when call from eg. QT. so we have to check
  // if this are to files
  // and the user didnt want to move force
  if (!force && srcFileInfo.isFile() && destFileInfo.isFile()) {
    return;
  }

  QString passSrc = QDir(QtPassSettings::getPassStore())
                        .relativeFilePath(QDir(src).absolutePath());
  QString passDest = QDir(QtPassSettings::getPassStore())
                         .relativeFilePath(QDir(dest).absolutePath());

  // remove the .gpg because pass will not work
  if (srcFileInfo.isFile() && srcFileInfo.suffix() == "gpg") {
    passSrc.replace(QRegExp("\\.gpg$"), "");
  }
  if (destFileInfo.isFile() && destFileInfo.suffix() == "gpg") {
    passDest.replace(QRegExp("\\.gpg$"), "");
  }

  QStringList args;
  args << "mv";
  if (force) {
    args << "-f";
  }
  args << passSrc;
  args << passDest;
  executePass(PASS_MOVE, args);
}
コード例 #2
0
ファイル: QBtWorkspace.cpp プロジェクト: sclown/bsc
//*******************************************************************
// compare_files                                             PRIVATE
//*******************************************************************
void QBtWorkspace::compare_files()
{
    QBtView* const v1 = left_panel_ ->current_view();
    QBtView* const v2 = right_panel_->current_view();
    if( !v1 || !v2 ) return;

    SelectionsSet d1 = SelectionsSet();
    SelectionsSet d2 = SelectionsSet();
    get_selections( v1, d1 );
    get_selections( v2, d2 );
    if( d1.size() != 1 ) return;
    if( d2.size() != 1 ) return;

    const QFileInfo f1( *d1.begin() );
    const QFileInfo f2( *d2.begin() );

    if( f1.isFile() && f2.isFile() ) {
        const QString fpath1 = f1.absoluteFilePath();
        const QString fpath2 = f2.absoluteFilePath();

        QBtCompareFileDialog dialog( this, fpath1, fpath2 );
        if( QDialog::Accepted == dialog.exec() ) {
            diff( fpath1, fpath2 );
        }
    }
    else {
        QMessageBox::information( this, tr( CompareFiles ), tr( NoFiles ) );
    }
}
コード例 #3
0
ファイル: thirdstep.cpp プロジェクト: Akon32/leechcraft
			void ThirdStep::initializePage ()
			{
				TotalSize_ = 0;
				QString path = field ("RootPath").toString ();

				QFileInfo pathInfo (path);
				if (pathInfo.isDir ())
				{
					QDirIterator it (path,
							QDirIterator::Subdirectories);
					while (it.hasNext ())
					{
						it.next ();
						QFileInfo info = it.fileInfo ();
						if (info.isFile () && info.isReadable ())
							TotalSize_ += info.size ();
					}
				}
				else if (pathInfo.isFile () &&
						pathInfo.isReadable ())
					TotalSize_ += pathInfo.size ();

				quint64 max = std::log (static_cast<long double> (TotalSize_ / 102400)) * 80;

				quint32 pieceSize = 32 * 1024;
				int shouldIndex = 0;
				for (; TotalSize_ / pieceSize >= max; pieceSize *= 2, ++shouldIndex) ;

				if (shouldIndex > PieceSize_->count () - 1)
					shouldIndex = PieceSize_->count () - 1;

				PieceSize_->setCurrentIndex (shouldIndex);

				on_PieceSize__currentIndexChanged ();
			}
コード例 #4
0
// Try to resolve files of a QML stack (resource files).
void StackFrame::fixQmlFrame(const DebuggerStartParameters &sp)
{
    if (language != QmlLanguage)
        return;
    QFileInfo aFi(file);
    if (aFi.isAbsolute()) {
        usable = aFi.isFile();
        return;
    }
    if (!file.startsWith(QLatin1String("qrc:/")))
        return;
    const QString relativeFile = file.right(file.size() - 5);
    if (!sp.projectSourceDirectory.isEmpty()) {
        const QFileInfo pFi(sp.projectSourceDirectory + QLatin1Char('/') + relativeFile);
        if (pFi.isFile()) {
            file = pFi.absoluteFilePath();
            usable = true;
            return;
        }
        const QFileInfo cFi(QDir::currentPath() + QLatin1Char('/') + relativeFile);
        if (cFi.isFile()) {
            file = cFi.absoluteFilePath();
            usable = true;
            return;
        }
    }
}
コード例 #5
0
// Locate a binary in a directory, applying all kinds of
// extensions the operating system supports.
static QString checkBinary(const QDir &dir, const QString &binary)
{
    // naive UNIX approach
    const QFileInfo info(dir.filePath(binary));

    if (info.isFile() && info.isExecutable()) {
        return info.absoluteFilePath();
    }

    // Does the OS have some weird extension concept or does the
    // binary have a 3 letter extension?
    if (pathOS == OS_Unix) {
        return QString();
    }
    const int dotIndex = binary.lastIndexOf(QLatin1Char('.'));
    if (dotIndex != -1 && dotIndex == binary.size() - 4) {
        return QString();
    }

    switch (pathOS) {
    case OS_Unix:
        break;
    case OS_Windows:
    {
        static const char *windowsExtensions[] = { ".cmd", ".bat", ".exe", ".com" };
        // Check the Windows extensions using the order
        const int windowsExtensionCount = sizeof(windowsExtensions) / sizeof(const char *);
        for (int e = 0; e < windowsExtensionCount; e++) {
            const QFileInfo windowsBinary(dir.filePath(binary + QLatin1String(windowsExtensions[e])));
            if (windowsBinary.isFile() && windowsBinary.isExecutable()) {
                return windowsBinary.absoluteFilePath();
            }
        }
    }
    break;
    case OS_Mac:
    {
        // Check for Mac app folders
        const QFileInfo appFolder(dir.filePath(binary + QLatin1String(".app")));
        if (appFolder.isDir()) {
            QString macBinaryPath = appFolder.absoluteFilePath();
            macBinaryPath += QLatin1String("/Contents/MacOS/");
            macBinaryPath += binary;
            const QFileInfo macBinary(macBinaryPath);
            if (macBinary.isFile() && macBinary.isExecutable()) {
                return macBinary.absoluteFilePath();
            }
        }
    }
    break;
    }
    return QString();
}
コード例 #6
0
ファイル: content.cpp プロジェクト: doglover129/mythtv
/** \fn     Content::RenameFile(const QString &sStorageGroup,
 *                              const QString &sFileName,
 *                              const QString &sNewFile)
 *  \brief  Renames the file to the new name.
 *  \param  sStorageGroup The storage group name where the image is located
 *  \param  sFileName The filename including the path that shall be renamed
 *  \param  sNewName  The new name of the file (only the name, no path)
 *  \return bool True if renaming was successful, otherwise false
 */
bool Content::RenameFile( const QString &sStorageGroup,
                          const QString &sFileName,
                          const QString &sNewName)
{
    QFileInfo fi = QFileInfo();
    fi = GetFile(sStorageGroup, sFileName);

    // Check if the file exists and is writable.
    // Only then we can actually delete it.
    if (!fi.isFile() && !QFile::exists(fi.absoluteFilePath()))
    {
        LOG(VB_GENERAL, LOG_ERR, "RenameFile - File does not exist.");
        return false;
    }

    // Check if the new filename has no path stuff specified
    if (sNewName.contains("/") || sNewName.contains("\\"))
    {
        LOG(VB_GENERAL, LOG_ERR, "RenameFile - New file must not contain a path.");
        return false;
    }
    
    // The newly renamed file must be in the same path as the original one.
    // So we need to check if a file of the new name exists and would be 
    // overwritten by the new filename. To to this get the path from the 
    // original file and append the new file name, Then check 
    // if it exists in the given storage group
    
    // Get the everthing until the last directory separator
    QString path = sFileName.left(sFileName.lastIndexOf("/"));
    // Append the new file name to the path
    QString newFileName = path.append("/").append(sNewName);
    
    QFileInfo nfi = QFileInfo();
    nfi = GetFile(sStorageGroup, newFileName);
    
    // Check if the target file is already present.
    // If is there then abort, overwriting is not supported
    if (nfi.isFile() || QFile::exists(nfi.absoluteFilePath()))
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("RenameFile - New file %1 would overwrite "
                    "existing one, not renaming.").arg(sFileName));
        return false;
    }

    // All checks have been passed, rename the file
    QFile file; 
    file.setFileName(fi.fileName());
    QDir::setCurrent(fi.absolutePath());
    return file.rename(sNewName);
}
コード例 #7
0
ファイル: configpackagepage.cpp プロジェクト: CyberSys/qutim
void addFilesToArchive(const QDir &dir, const QFileInfo &info, QStringList &files)
{
	qDebug() << info.absoluteFilePath() << info.isDir() << info.isFile();
	if(info.isFile())
		files << dir.relativeFilePath(info.absoluteFilePath());
	else if(info.isDir())
	{
		qDebug() << info.absoluteFilePath() << QDir(info.absoluteFilePath()).entryList(QDir::AllEntries | QDir::NoDotAndDotDot);
		QFileInfoList file_infos = QDir(info.absoluteFilePath()).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
		foreach(const QFileInfo &file_info, file_infos)
		{
			addFilesToArchive(dir, file_info, files);
		}
コード例 #8
0
ファイル: qtranslator.cpp プロジェクト: fluxer/katie
bool QTranslator::load(const QString & filename, const QString & directory,
                       const QString & search_delimiters,
                       const QString & suffix)
{
    Q_D(QTranslator);
    d->clear();

    QString fname = filename;
    QString prefix;
    if (QFileInfo(filename).isRelative()) {
        prefix = directory;
        if (prefix.length() && !prefix.endsWith(QLatin1Char('/')))
            prefix += QLatin1Char('/');
    }


    QString realname;
    QString delims;
    delims = search_delimiters.isNull() ? QString::fromLatin1("_.") : search_delimiters;

    for (;;) {
        QFileInfo fi;


        realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix);
        fi.setFile(realname);
        if (fi.isReadable() && fi.isFile())
            break;

        realname = prefix + fname;
        fi.setFile(realname);
        if (fi.isReadable() && fi.isFile())
            break;

        int rightmost = 0;
        for (int i = 0; i < (int)delims.length(); i++) {
            int k = fname.lastIndexOf(delims[i]);
            if (k > rightmost)
                rightmost = k;
        }

        // no truncations? fail
        if (rightmost == 0)
            return false;

        fname.truncate(rightmost);
    }

    // realname is now the fully qualified name of a readable file.
    return d->do_load(realname);
}
コード例 #9
0
QString KStandardDirs::findExe( const QString& appname,
				const QString& pstr, bool ignore)
{
#ifdef Q_WS_WIN
    QString real_appname = appname + ".exe";
#else
    QString real_appname = appname;
#endif
    QFileInfo info;

    // absolute or relative path given
    if (real_appname.find(QDir::separator()) >= 0)
    {
        info.setFile( real_appname );
        if( info.exists() && ( ignore || info.isExecutable() )
            && info.isFile() ) {
            return info.absFilePath();
        }
        return QString::null;
    }

    QString p = QString("%1/%2").arg(kfsstnd_defaultbindir()).arg(real_appname);
    info.setFile( p );
    if( info.exists() && ( ignore || info.isExecutable() )
         && ( info.isFile() || info.isSymLink() )  ) {
         return p;
    }

    QStringList exePaths = systemPaths( pstr );
    for (QStringList::ConstIterator it = exePaths.begin(); it != exePaths.end(); ++it)
    {
	p = (*it) + "/";
	p += real_appname;

	// Check for executable in this tokenized path
	info.setFile( p );

	if( info.exists() && ( ignore || info.isExecutable() )
           && ( info.isFile() || info.isSymLink() )  ) {
	    return p;
	}
    }

    // If we reach here, the executable wasn't found.
    // So return empty string.

    return QString::null;
}
コード例 #10
0
ファイル: kscope.cpp プロジェクト: VicHao/kkscope
/**
 * Parses the command line, after it was stripped of its KDE options.
 * The command line may contain one of the following options:
 * 1. A project file (named cscope.proj)
 * 2. A Cscope cross-reference database
 * 3. A list of source files
 * @param	pArgs	Command line arguments
 */
void KScope::parseCmdLine(KCmdLineArgs* pArgs)
{
	QString sArg;
	QFileInfo fi;
	int i;

	// Loop over all arguments
	for (i = 0; i < pArgs->count(); i++) {
		// Verify the argument is a file or directory name
		sArg = pArgs->arg(i);
		fi.setFile(sArg);
		if (!fi.exists())
			continue;
			
		// Handle the current argument
		if (fi.isFile()) {
			if (fi.fileName() == "cscope.proj") {
				// Open a project file
				openProject(fi.dirPath(true));
				return;
			} else if (openCscopeOut(sArg)) {
				// Opened the file as a cross-reference database
				return;
			} else {
				// Assume this is a source file
				slotShowEditor(sArg, 0);
			}
		} else if (fi.isDir()) {
			// Treat the given path as a project directory
			openProject(fi.absFilePath());
			return;
		}
	}
}
コード例 #11
0
void MainWindow::dropEvent(QDropEvent *event)
{
   QList<QUrl> urlList;
   QString fName;
   QFileInfo info;
   QStringList dtaFiles;
   QString sessionFile = "";

   // Dateinamen extrahieren
   if( event->mimeData()->hasUrls())
   {
      urlList = event->mimeData()->urls();
      for( int i=0; i<urlList.size(); i++)
      {
         fName = urlList.at(i).toLocalFile(); // convert first QUrl to local path
         info.setFile(fName); // information about file
         if(info.isFile())
         {
            if( fName.endsWith(".dta",Qt::CaseInsensitive))
               dtaFiles << fName;
         }
      }

      // DTA-Dateien laden
      if(!dtaFiles.isEmpty()) readDataFiles(dtaFiles, true);
   }

   if( (sessionFile!="") && (!dtaFiles.isEmpty()))
      event->acceptProposedAction();
}
コード例 #12
0
ファイル: filebrowser.cpp プロジェクト: arnold8/liteide
void FileBrowser::activatedFolderView(const QModelIndex &index)
{
    QFileInfo info = m_folderView->fileInfo(index);
    if (info.isFile()) {
        m_liteApp->fileManager()->openEditor(info.filePath());
    }
}
コード例 #13
0
/// Display a file dialog.  If `directory` is an invalid file or directory the browser will start at the current
/// working directory.
/// \param const QString& title title of the window
/// \param const QString& directory directory to start the file browser at
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
QScriptValue WindowScriptingInterface::showBrowse(const QString& title, const QString& directory, const QString& nameFilter,
                                                  QFileDialog::AcceptMode acceptMode) {
    // On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus
    // filename if the directory is valid.
    QString path = "";
    QFileInfo fileInfo = QFileInfo(directory);
    qDebug() << "File: " << directory << fileInfo.isFile();
    if (fileInfo.isDir()) {
        fileInfo.setFile(directory, "__HIFI_INVALID_FILE__");
        path = fileInfo.filePath();
    }
    
    QFileDialog fileDialog(Application::getInstance()->getWindow(), title, path, nameFilter);
    fileDialog.setAcceptMode(acceptMode);
    qDebug() << "Opening!";
    QUrl fileUrl(directory);
    if (acceptMode == QFileDialog::AcceptSave) {
        fileDialog.setFileMode(QFileDialog::Directory);
        fileDialog.selectFile(fileUrl.fileName());
    }
    if (fileDialog.exec()) {
        return QScriptValue(fileDialog.selectedFiles().first());
    }
    return QScriptValue::NullValue;
}
コード例 #14
0
ファイル: glwidget.cpp プロジェクト: cheque/s3d
void GLWidget::dropEvent(QDropEvent *event)
{
    const QMimeData *mimeData = event->mimeData();
    if (mimeData->hasUrls()) {
        QList<QUrl> urlList = mimeData->urls();
        QString filename;
        QFileInfo info;
        for (int i = 0; i < urlList.size(); ++i) {
            filename = urlList.at(i).toLocalFile();
            info.setFile(filename);
            if (info.isFile()) {
                QString ext = info.suffix();
                if (ext == "scn") {
                    QDir::setCurrent(info.absolutePath());
                    if (load_scene_file(filename.toLatin1().data()))
                        event->acceptProposedAction();
                    else
                        qDebug() << "No scene";
                    lastfile = filename.toLatin1().data();
                }
             } else
                 qDebug() << "Unable to load file";
             update();
          }
      }
}
コード例 #15
0
ファイル: dirgrinder.cpp プロジェクト: szkrawcz/aInf
QMultiMap<QString,FileAttributes> ListFilesInDirectoryTest(QDir dir, bool Hash)
{
    extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
    qt_ntfs_permission_lookup++; // turn checking on
    QMultiMap<QString, FileAttributes> fileAttHashTable; //making hash table to store file attributes
    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    dir.setSorting(QDir::Name);
    QFileInfoList list = dir.entryInfoList();
    for (int i = 0; i < list.size(); ++i)
    {
       QFileInfo fileInfo = list.at(i);
       if (fileInfo.isFile())
       {
           FileAttributes tempFileAttributes;
           QDateTime date = fileInfo.lastModified();
           QString lastModified = date.toString();

            tempFileAttributes.absoluteFilePath = fileInfo.absoluteFilePath();
            tempFileAttributes.fileName = fileInfo.fileName();
            tempFileAttributes.filePath= fileInfo.path();
            if (Hash) tempFileAttributes.md5Hash = GetFileMd5hash(fileInfo.absoluteFilePath());
            tempFileAttributes.lastModified  = fileInfo.lastModified();
            tempFileAttributes.lastRead = fileInfo.lastRead();
            tempFileAttributes.created = fileInfo.created();
            tempFileAttributes.isHidden =  fileInfo.isHidden();
            tempFileAttributes.size = fileInfo.size();
            tempFileAttributes.owner = fileInfo.owner();
            fileAttHashTable.insert(fileInfo.absoluteFilePath(),tempFileAttributes);
       }

    }
return fileAttHashTable;
}
コード例 #16
0
ファイル: main.cpp プロジェクト: zarmin/KeePassX_zmod
QString findPlugin(const QString& filename) {
    QFileInfo info;
    info.setFile(AppDir+"/../lib/"+filename);
    if(info.exists() && info.isFile())
        return AppDir+"/../lib/"+filename;
    return QString();
}
コード例 #17
0
void CollectionScanner::scanDirectory(QDir directory) {

    QStack<QDir> stack;
    stack.push(directory);
    while(!stack.empty()) {

        const QDir dir = stack.pop();
        const QFileInfoList flist = dir.entryInfoList(
                    QDir::NoDotAndDotDot |
                    QDir::Dirs | QDir::Files | QDir::Readable
                    );

        QFileInfo fileInfo;
        Q_FOREACH(fileInfo, flist) {
            if(fileInfo.isFile() ) {
                processFile(fileInfo);
            } else if (fileInfo.isDir()) {
                QString subDirPath = fileInfo.absoluteFilePath();
#ifdef APP_MAC
                if (directoryBlacklist.contains(subDirPath)) {
                    qDebug() << "Skipping directory" << subDirPath;
                    continue;
                }
#endif
                QDir subDir(subDirPath);
                stack.push(subDir);
            }
        }
    }

}
コード例 #18
0
ファイル: utils_p.cpp プロジェクト: FlavioFalcao/qt-creator
QString normalizeFileName(const QFileInfo &fileInfo)
{
    if (!fileInfo.isFile())
        return QString();

    return QDir::cleanPath(fileInfo.absoluteFilePath());
}
コード例 #19
0
ファイル: main.cpp プロジェクト: jasp-stats/jasp-desktop
void recursiveFileOpener(QFileInfo file, int & failures, int & total, int & timeOut, int argc, char *argv[])
{
	const QString jaspExtension(".jasp");

	//std::cout << "recursiveFileOpener in " << file.absoluteFilePath().toStdString() << std::endl;

	if(file.isDir())
	{
		//std::cout << "it is a directory and " << (file.exists() ? "exists" : "does not exist") << std::endl;

		QDir dir(file.absoluteFilePath());

		//std::cout << "QDir dir: " << dir.path().toStdString() << " has " << files.size() << " subfiles!" << std::endl;

		for(QFileInfo subFile : dir.entryInfoList(QDir::Filter::NoDotAndDotDot | QDir::Files | QDir::Dirs))
			recursiveFileOpener(subFile, failures, total, timeOut, argc, argv);

	}
	else if(file.isFile())
	{
		//std::cout << "it is a file" << std::endl;

		if(file.absoluteFilePath().indexOf(jaspExtension) == file.absoluteFilePath().size() - jaspExtension.size())
		{
			//std::cout << "it has the .jasp extension so we will start JASP" << std::endl;
#ifndef SEPARATE_PROCESS
			std::cout << "Found a JASP file (" << file.absoluteFilePath().toStdString() << ") going to start JASP" << std::endl;
#endif

			int result = 1;

			try{
#ifdef SEPARATE_PROCESS
				QProcess subJasp;
				subJasp.setProgram(argv[0]);
				subJasp.setArguments({file.absoluteFilePath(), "--unitTest", QString::fromStdString("--timeOut="+std::to_string(timeOut)), "-platform", "minimal" });
				subJasp.start();

				subJasp.waitForFinished((timeOut * 60000) + 10000);

				std::cerr << subJasp.readAllStandardError().toStdString() << std::endl;

				result = subJasp.exitCode();
#else
				//This seems to crash for some reason
				result = Application(argc, argv, file.absoluteFilePath(), true, timeOut).exec();
#endif
			}
			catch(...) { result = -1; }


			std::cout << "JASP file " << file.absoluteFilePath().toStdString() << (result == 0 ? " succeeded!" : " failed!") << std::endl;

			if(result != 0)
				failures++;

			total++;
		}
	}
}
コード例 #20
0
void
DialogCleanup::Cleanup(
	)
{
	// Get size before.
	unsigned int startSize = FileUtils::GetFolderSize( m_Path );
	m_UI.output->appendPlainText( "Cleaning '" + m_Path + "' ..." );

	// Go through files.
	QDir directory( m_Path );
	QFileInfoList files = directory.entryInfoList();
	for ( QFileInfoList::iterator i = files.begin(); i != files.end(); i++ ) {
		QFileInfo file = *i;
		if ( !file.isReadable() ) continue;
		if ( file.fileName() == "." || file.fileName() == ".." ) continue;
		if ( std::find( m_Preserved.begin(), m_Preserved.end(), file.fileName() ) == m_Preserved.end() ) {
			m_UI.output->appendPlainText( "Removing: " + file.fileName() );
			if ( file.isDir() ) FileUtils::DeleteFolder( file.absoluteFilePath() );
			if ( file.isFile() ) QFile::remove(file.absoluteFilePath());
		}
	}

	// Get size after.
	unsigned int endSize = FileUtils::GetFolderSize( m_Path );
	m_UI.output->appendPlainText( "Cleaning complete." );
	m_UI.output->appendPlainText( "Cleaned " + QString::number( startSize - endSize ) + " megabytes." );

	// Change UI to reflect completion.
	m_UI.btnDone->setText( "Close" );
}
コード例 #21
0
void scanDirectory(FileInfoList &fileEntries, const QString &name, const QString &strDir)
{
   QDir dir(strDir);
   if (!dir.exists()) return;

   QFileInfoList *newEntries = (QFileInfoList *) dir.entryInfoList();

   if (!newEntries) return; // Directory not accessible ??

   for(QFileInfo *qFileInfo = newEntries->first();
       qFileInfo;
       qFileInfo = newEntries->next())
   {
       if (qFileInfo->isFile())
       {
          FileInfo *fileInfo = readEntry( strDir + "/" + qFileInfo->fileName());
          if (fileInfo)
          {
             fileInfo->name = name + "/" + qFileInfo->fileName();
             fileInfo->size = (qFileInfo->size() + 1023) / 1024;
             fileEntries.append(fileInfo);
          }
       }
   }
}
コード例 #22
0
void Indexer::buildIndex()
{
	if (path == "") return; // Path must be set
	
	clearIndex();
	
	// Index all files in path
	QDir dir(path);
	QFileInfoList list = dir.entryInfoList();
	emit startedIndexing(list.size());
	for (int i = 0; i < list.size(); i++) {
		QFileInfo fileInfo = list.at(i);
		if (!fileInfo.isFile()) continue;
		if (fileInfo.suffix().toLower() != "jpg") continue;
		
		//qDebug() << "Indexing "<<fileInfo.fileName();
		emit indexingFile(fileInfo.fileName());
		FeatureVector fv;
		fv=getFV(fileInfo.filePath());
		putInIndex(fileInfo.fileName(), fv);
	}
	
	// Initialize whatever datastructures need to be initialized after putting in index
	indexPostInit();
	
	// Serialize index to an index file
	writeIndex();
	pathIndexed = true;
	emit finishedIndexing();
}
コード例 #23
0
void QCustomLineEdit::dropEvent(QDropEvent *event)
{
    QList<QUrl> urlList;
    QString fName;
    QFileInfo info;

    if(event->mimeData()->hasUrls())
    {
        urlList = event->mimeData()->urls(); // returns list of QUrls

        // if just text was dropped, urlList is empty (size == 0)
        if(urlList.size() > 0) // if at least one QUrl is present in list
        {
            fName = urlList[0].toLocalFile(); // convert first QUrl to local path
            info.setFile(fName); // information about file
            if(info.isFile())
            {
                setText(fName); // if is file, setText
            }

        }
    }

    event->acceptProposedAction();
}
コード例 #24
0
ファイル: fileList.cpp プロジェクト: Leesam/OpenExpertSDR
void fileList::onStop()
{
	if(isRecorded)
	{
		pIqWriter->close();
		ui.pbPlay->setEnabled(true);
		ui.pbLoop->setEnabled(true);
		ui.pbBack->setEnabled(true);
		ui.pbRec->setChecked(false);
		ui.slIqTrack->setMaximum(0);
		isRecorded = false;
		emit isRec(false);
		QFileInfo info;
		info.setFile(pIqWriter->getFileName());
		if(info.isFile())
			addFile(info);
	}
	else if(isPlayed)
	{
		ui.pbRec->setEnabled(true);
		killTimer(timerId);
		ui.pbPlay->setChecked(false);
		pIqReader->close();
		ui.slIqTrack->setMaximum(0);
		isPlayed = false;
		emit isPlay(false);
	}
	ui.pbPause->setEnabled(false);
	ui.slIqTrack->setValue(0);
}
コード例 #25
0
void ThothWindow::on_pushButton_4_clicked()
{
    //Select build model

    QModelIndex indx = ui->treeViewBuild->currentIndex();
    QFileInfo info = m_buildModel->fileInfo(indx);
    if(info.isFile())
    {
        if(info.suffix() == QString("obj"))
        {
            qDebug("Create model with path: %s", qPrintable(info.absoluteFilePath()));
            if(info.absoluteFilePath().contains(QString("wall"),Qt::CaseInsensitive))
            {
                CScenary::getInstance()->setActiveModel(info.canonicalFilePath().toStdString());
                CScenary::getInstance()->setActiveType(WALL);
            }
            if(info.absoluteFilePath().contains(QString("stair"), Qt::CaseInsensitive))
            {
                CScenary::getInstance()->setActiveModel(info.canonicalFilePath().toStdString());
                CScenary::getInstance()->setActiveType(STAIR);
            }
            RenderManager::GetInstance()->GetRenderMode(EDITOR_2D)->setEditMode(INSERTING);
        }
    }
    ui->contextGL->setFocus();
}
コード例 #26
0
int KStandardDirs::findAllExe( QStringList& list, const QString& appname,
			const QString& pstr, bool ignore )
{
#ifdef Q_WS_WIN
    QString real_appname = appname + ".exe";
#else
    QString real_appname = appname;
#endif
    QFileInfo info;
    QString p;
    list.clear();

    QStringList exePaths = systemPaths( pstr );
    for (QStringList::ConstIterator it = exePaths.begin(); it != exePaths.end(); ++it)
    {
	p = (*it) + "/";
	p += real_appname;

	info.setFile( p );

	if( info.exists() && (ignore || info.isExecutable())
	    && info.isFile() ) {
	    list.append( p );
	}
    }

    return list.count();
}
コード例 #27
0
ファイル: ModelBaker.cpp プロジェクト: ZappoMan/hifi
QUrl ModelBaker::getTextureURL(const QFileInfo& textureFileInfo, QString relativeFileName, bool isEmbedded) {
    QUrl urlToTexture;

    // use QFileInfo to easily split up the existing texture filename into its components
    auto apparentRelativePath = QFileInfo(relativeFileName.replace("\\", "/"));

    if (isEmbedded) {
        urlToTexture = _modelURL.toString() + "/" + apparentRelativePath.filePath();
    } else {
        if (textureFileInfo.exists() && textureFileInfo.isFile()) {
            // set the texture URL to the local texture that we have confirmed exists
            urlToTexture = QUrl::fromLocalFile(textureFileInfo.absoluteFilePath());
        } else {
            // external texture that we'll need to download or find

            // this is a relative file path which will require different handling
            // depending on the location of the original model
            if (_modelURL.isLocalFile() && apparentRelativePath.exists() && apparentRelativePath.isFile()) {
                // the absolute path we ran into for the texture in the model exists on this machine
                // so use that file
                urlToTexture = QUrl::fromLocalFile(apparentRelativePath.absoluteFilePath());
            } else {
                // we didn't find the texture on this machine at the absolute path
                // so assume that it is right beside the model to match the behaviour of interface
                urlToTexture = _modelURL.resolved(apparentRelativePath.fileName());
            }
        }
    }

    return urlToTexture;
}
コード例 #28
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);
}
コード例 #29
0
ファイル: webview.cpp プロジェクト: hytham/qt-webkit-kiosk
void WebView::loadCustomPage(QString uri)
{
    QFileInfo finfo = QFileInfo();
    finfo.setFile(uri);

    qDebug() << "Page: check local file = " <<
                uri <<
                ", absolute path = " <<
                finfo.absoluteFilePath() <<
                ", local uri = " <<
                QUrl::fromLocalFile(
                    uri
                ).toString();

    if (finfo.isFile()) {
        qDebug() << "Page: Local FILE";
        this->stop();
        this->load(QUrl::fromLocalFile(
            finfo.absoluteFilePath()
        ));
    } else {
        qDebug() << "Page: Remote URI";
        this->stop();
        this->load(QUrl(uri));
    }
}
コード例 #30
0
bool CommonFunctions::checkIfFileExists(QFileInfo checkFile) {
    if (checkFile.exists() && checkFile.isFile()) {
        return true;
    } else {
        return false;
    }
}