Esempio n. 1
0
/*!
    \internal
*/
void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo)
{
    QString path = fileInfo.filePath();

#ifdef Q_OS_WIN
    if (fileInfo.isSymLink())
        path = fileInfo.canonicalFilePath();
#endif

    if (iteratorFlags & QDirIterator::FollowSymlinks)
        visitedLinks << fileInfo.canonicalFilePath();

    if (engine) {
        engine->setFileName(path);
        QAbstractFileEngineIterator *it = engine->beginEntryList(filters, nameFilters);
        if (it) {
            it->setPath(path);
            fileEngineIterators << it;
        } else {
            // No iterator; no entry list.
        }
    } else {
#ifndef QT_NO_FILESYSTEMITERATOR
        QFileSystemIterator *it = new QFileSystemIterator(fileInfo.d_ptr->fileEntry,
            filters, nameFilters, iteratorFlags);
        nativeIterators << it;
#endif
    }
}
Esempio n. 2
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();
}
Esempio n. 3
0
void SubComponentManager::parseDirectories()
{
    if (!m_filePath.isEmpty()) {
        const QString file = m_filePath.toLocalFile();
        QFileInfo dirInfo = QFileInfo(QFileInfo(file).path());
        if (dirInfo.exists() && dirInfo.isDir())
            parseDirectory(dirInfo.canonicalFilePath());

        foreach (const QString &subDir, QDir(QFileInfo(file).path()).entryList(QDir::Dirs | QDir::NoDot | QDir::NoDotDot)) {
            parseDirectory(dirInfo.canonicalFilePath() + "/" + subDir, true, subDir.toUtf8());
        }
    }

    foreach (const Import &import, m_imports) {
        if (import.isFileImport()) {
            QFileInfo dirInfo = QFileInfo(m_filePath.resolved(import.file()).toLocalFile());
            if (dirInfo.exists() && dirInfo.isDir())
                parseDirectory(dirInfo.canonicalFilePath(), true, dirInfo.baseName().toUtf8());
        } else {
            QString url = import.url();
            url.replace(QLatin1Char('.'), QLatin1Char('/'));
            QFileInfo dirInfo = QFileInfo(url);
            foreach (const QString &path, importPaths()) {
                QString fullUrl  = path + QLatin1Char('/') + url;
                dirInfo = QFileInfo(fullUrl);
                if (dirInfo.exists() && dirInfo.isDir()) {
                    //### todo full qualified names QString nameSpace = import.uri();
                    parseDirectory(dirInfo.canonicalFilePath(), false);
                }
            }
        }
    }
Esempio n. 4
0
QString Configuration::getMimeType(const QFileInfo& info) {
    QString result("application/octet-stream");
    magic_t magicMimePredictor;
    magicMimePredictor = magic_open(MAGIC_MIME_TYPE); // Open predictor
    if (!magicMimePredictor) {
        qDebug() << "libmagic: Unable to initialize magic library";
    }
    else
    {
        if (magic_load(magicMimePredictor, 0)) { // if not 0 - error
            qDebug() << "libmagic: Can't load magic database - " +
                        QString(magic_error(magicMimePredictor));
            magic_close(magicMimePredictor); // Close predictor
        }
        else
        {
            char *file = info.canonicalFilePath().toAscii().data();
            const char *mime;
            mime = magic_file(magicMimePredictor, file); // getting mime-type
            result = QString(mime);
            magic_close(magicMimePredictor); // Close predictor
        }
    }
    qDebug() << "libmagic: result mime type - " + result + "for file: " +
                info.canonicalFilePath();
    return result;
}
Esempio n. 5
0
/*!
    \internal
*/
void QDirIteratorPrivate::advance()
{
    // Store the current entry
    if (!fileEngineIterators.isEmpty())
        currentFilePath = fileEngineIterators.top()->currentFilePath();

    // Advance to the next entry
    if (followNextDir) {
        // Start by navigating into the current directory.
        followNextDir = false;

        QAbstractFileEngineIterator *it = fileEngineIterators.top();

        QString subDir = it->currentFilePath();
#ifdef Q_OS_WIN
        if (currentFileInfo.isSymLink())
            subDir = currentFileInfo.canonicalFilePath();
#endif
        pushSubDirectory(subDir, it->nameFilters(), it->filters());
    }

    while (!fileEngineIterators.isEmpty()) {
        QAbstractFileEngineIterator *it = fileEngineIterators.top();

        // Find the next valid iterator that matches the filters.
        bool foundDirectory = false;
        while (it->hasNext()) {
            it->next();
            if (matchesFilters(it)) {
                currentFileInfo = nextFileInfo;
                nextFileInfo = it->currentFileInfo();
                // Signal that we want to follow this entry.
                followNextDir = shouldFollowDirectory(nextFileInfo);
                //We found a matching entry.
                return;

            } else if (iteratorFlags & QDirIterator::Subdirectories) {
                QFileInfo fileInfo = it->currentFileInfo();

                if (!shouldFollowDirectory(fileInfo))
                    continue;
                QString subDir = it->currentFilePath();
#ifdef Q_OS_WIN
                if (fileInfo.isSymLink())
                    subDir = fileInfo.canonicalFilePath();
#endif
                pushSubDirectory(subDir, it->nameFilters(), it->filters());
                
                foundDirectory = true;
                break;
            }
        }
        if (!foundDirectory)
            delete fileEngineIterators.pop();
    }
    currentFileInfo = nextFileInfo;
    done = true;
}
Esempio n. 6
0
QIcon QFileIconProviderPrivate::getHaikuIcon(const QFileInfo &fi) const
{
    QIcon retIcon;
    
	BNode node(fi.canonicalFilePath().toUtf8().constData());
	if (node.InitCheck() == B_OK) {
		BNodeInfo nodeinfo(&node);
		
		BBitmap *hIcon = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32);
		nodeinfo.GetTrackerIcon(hIcon, B_MINI_ICON);
		if(hIcon) {
			QPixmap p = QPixmap::fromHaikuBitmap(hIcon);
			retIcon.addPixmap(p);
			delete hIcon;
		}

		BBitmap *hIconBig = new BBitmap(BRect(0, 0, 31, 31), B_RGBA32);
		nodeinfo.GetTrackerIcon(hIcon, B_LARGE_ICON);
		if(hIconBig) {
			QPixmap p = QPixmap::fromHaikuBitmap(hIconBig);
			retIcon.addPixmap(p);
			delete hIconBig;
		}		
	}	
    return retIcon;
}
Esempio n. 7
0
/*!
    \overload
*/
bool QFileInfo::operator==(const QFileInfo &fileinfo) const
{
    Q_D(const QFileInfo);
    // ### Qt 5: understand long and short file names on Windows
    // ### (GetFullPathName()).
    if (fileinfo.d_ptr == d_ptr)
        return true;
    if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
        return false;
    if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
        return false;
    if (fileinfo.size() == size()) { //if the size isn't the same...
        QString file1 = canonicalFilePath(),
                file2 = fileinfo.canonicalFilePath();
        if (file1.length() == file2.length()) {
            if (!fileinfo.d_ptr->fileEngine->caseSensitive()) {
                for (int i = 0; i < file1.length(); i++) {
                    if (file1.at(i).toLower() != file2.at(i).toLower())
                        return false;
                }
                return true;
            }
            return (file1 == file2);
        }
    }
    return false;
}
Esempio n. 8
0
void VideoInput::execute()
{
    QFileInfo path = mIn;
    if(mCurrentFile != path)
    {
        if(mCapture.isOpened()){
            mCapture.release();
        }
        if(!mCapture.open(path.canonicalFilePath().toStdString())){
            throw std::runtime_error("Could not open video stream 1");
        }
        if(!mCapture.isOpened()){
            throw std::runtime_error("Could not open video stream 2");
        }

        mCurrentFile = path;
        int framePos = qRound(mCapture.get(CV_CAP_PROP_FRAME_COUNT) * (double)mStart);
        mCapture.set(CV_CAP_PROP_POS_FRAMES, framePos);

    }
    double elapsedFrames = mCapture.get(CV_CAP_PROP_POS_FRAMES) / mCapture.get(CV_CAP_PROP_FRAME_COUNT);
    if(!mCapture.grab() || elapsedFrames > (double) mEnd){
        // Check if *.avi has finished
        if((bool)mRepeat){
            // Reset frame pos to start pos
            int framePos = qRound(mCapture.get(CV_CAP_PROP_FRAME_COUNT) * (double)mStart);
            mCapture.set(CV_CAP_PROP_POS_FRAMES, framePos);
            if(!mCapture.grab()){
                return;
            }
        } else {
            return;
        }
    }
    double realFps = mCapture.get(CV_CAP_PROP_FPS);
    double factor = mSpeed;
    if(factor == 0){
        factor = 0.001;
    }
    double duration = 1000.0 / (realFps * factor);
    double elapsed = mTimer.elapsed();
    if(elapsed < duration && duration > 0){
        msleep(duration-elapsed);
    }

    // Restart timer
    mTimer.restart();

    // Send image
    cv::Mat img;
    if(!mCapture.retrieve(img)){
        return;
    }

    mFpsOut.send(realFps);
    mPositionOut.send(mCapture.get(CV_CAP_PROP_POS_FRAMES) / mCapture.get(CV_CAP_PROP_FRAME_COUNT));
    mElapsedOut.send(mCapture.get(CV_CAP_PROP_POS_MSEC)/1000.0);

    mOut.send(img.clone());
}
Esempio n. 9
0
/*!
    \internal
 */
void QDirIteratorPrivate::checkAndPushDirectory(const QFileInfo &fileInfo)
{
    // If we're doing flat iteration, we're done.
    if (!(iteratorFlags & QDirIterator::Subdirectories))
        return;

    // Never follow non-directory entries
    if (!fileInfo.isDir())
        return;

    // Follow symlinks only when asked
    if (!(iteratorFlags & QDirIterator::FollowSymlinks) && fileInfo.isSymLink())
        return;

    // Never follow . and ..
    QString fileName = fileInfo.fileName();
    if (QLatin1String(".") == fileName || QLatin1String("..") == fileName)
        return;

    // No hidden directories unless requested
    if (!(filters & QDir::AllDirs) && !(filters & QDir::Hidden) && fileInfo.isHidden())
        return;

    // Stop link loops
    if (!visitedLinks.isEmpty() &&
        visitedLinks.contains(fileInfo.canonicalFilePath()))
        return;

    pushDirectory(fileInfo);
}
Esempio n. 10
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // Populate port list
    QVector<QString> ports;

#if (defined (Q_OS_MAC) || defined (Q_OS_LINUX))

    // Add USB serial port adapters
    // TODO Strangely usb serial port adapters are not enumerated, even when connected
    QString devdir = "/dev";
    QDir dir(devdir);
    dir.setFilter(QDir::System);

    QFileInfoList list = dir.entryInfoList();
    for (int i = list.size() - 1; i >= 0; i--) {
        QFileInfo fileInfo = list.at(i);
        if ((fileInfo.fileName().contains(QString("ttyUSB")) || fileInfo.fileName().contains(QString("ttyS")) || fileInfo.fileName().contains(QString("tty.")) || fileInfo.fileName().contains(QString("ttyACM")))
            && !fileInfo.fileName().contains(QString("tty.B")))
        {
            ports.append(fileInfo.canonicalFilePath());
        }
    }
#endif

    foreach (QString port, ports)
    {
        ui->comboBox->addItem(port);
    }
Esempio n. 11
0
/* private slots */
qint64 ShredThread::getDirSize(QString &dir)
{
    uint _size = 0;
    QDir::Filters flags =
            QDir::AllEntries |
            QDir::NoDotAndDotDot |
            QDir::Hidden |
            QDir::System |
            QDir::AllDirs;
    QDir d;
    d.setPath(dir);
    QList<QFileInfo> entry = d.entryInfoList(flags);
    if ( !entry.isEmpty() ) {
        QList<QFileInfo>::const_iterator i;
        for ( i=entry.constBegin(); i<entry.constEnd(); i++ ) {
            QFileInfo item = *i;
            if ( !item.exists() ) continue;
            QString path = item.canonicalFilePath();
            if ( path==d.absoluteFilePath(dir)
                 || item.isSymLink() )
                continue;
            if ( item.isDir() ) {
                _size += getDirSize(path);
            } else {
                _size += item.size();
            };
        };
    };
    return _size;
}
Esempio n. 12
0
void
M3uLoader::getTags( const QFileInfo& info )
{
    QByteArray fileName = QFile::encodeName( info.canonicalFilePath() );
    const char *encodedName = fileName.constData();

    TagLib::FileRef f( encodedName );
    TagLib::Tag *tag = f.tag();

    QString artist = TStringToQString( tag->artist() ).trimmed();
    QString album  = TStringToQString( tag->album() ).trimmed();
    QString track  = TStringToQString( tag->title() ).trimmed();

    if ( artist.isEmpty() || track.isEmpty() )
    {
        qDebug() << "Error parsing" << info.fileName();
        return;
    }
    else
    {
        qDebug() << Q_FUNC_INFO << artist << track << album;
        Tomahawk::query_ptr q = Tomahawk::Query::get( artist, track, album, uuid(), !m_createNewPlaylist );
        if ( !q.isNull() )
            m_tracks << q;
    }
}
Esempio n. 13
0
/*!
    \overload
*/
bool QFileInfo::operator==(const QFileInfo &fileinfo) const
{
    Q_D(const QFileInfo);
    // ### Qt 5: understand long and short file names on Windows
    // ### (GetFullPathName()).
    if (fileinfo.d_ptr == d_ptr)
        return true;
    if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
        return false;

    // Assume files are the same if path is the same
    if (d->fileEntry.filePath() == fileinfo.d_ptr->fileEntry.filePath())
        return true;

    Qt::CaseSensitivity sensitive;
    if (d->fileEngine == 0 || fileinfo.d_ptr->fileEngine == 0) {
        if (d->fileEngine != fileinfo.d_ptr->fileEngine) // one is native, the other is a custom file-engine
            return false;

        sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
    } else {
        if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
            return false;
        sensitive = d->fileEngine->caseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
    }

    if (fileinfo.size() != size()) //if the size isn't the same...
        return false;

   // Fallback to expensive canonical path computation
   return canonicalFilePath().compare(fileinfo.canonicalFilePath(), sensitive) == 0;
}
Esempio n. 14
0
/*!
    \internal
 */
bool QDirIteratorPrivate::shouldFollowDirectory(const QFileInfo &fileInfo)
{
    // If we're doing flat iteration, we're done.
    if (!(iteratorFlags & QDirIterator::Subdirectories))
        return false;
    
    // Never follow non-directory entries
    if (!fileInfo.isDir())
        return false;


    // Never follow . and ..
    if (fileInfo.fileName() == QLatin1String(".") || fileInfo.fileName() == QLatin1String(".."))
        return false;

      
    // Check symlinks
    if (fileInfo.isSymLink() && !(iteratorFlags & QDirIterator::FollowSymlinks)) {
        // Follow symlinks only if FollowSymlinks was passed
        return false;
    }

    // Stop link loops
    if (visitedLinks.contains(fileInfo.canonicalFilePath()))
        return false;
    
    return true;
}
Esempio n. 15
0
int main(int argc, char **argv) {
	QApplication app(argc, argv);
	QApplication::setApplicationName("ViewDown");
	QApplication::setApplicationVersion("1.0");
	app.setWindowIcon(QIcon("qrc:///viewdown.ico"));

	QCommandLineParser parser;
	parser.setApplicationDescription("Markdown viewer, reloading on changes.");
	parser.addPositionalArgument("file", "markdown file to view and reload on change.");
	parser.addPositionalArgument("watch", "files or directories to watch as trigger for reload.", "[watch...]");
	const QCommandLineOption styleOption("s", "css file to use as stylesheet.", "css");
	parser.addOption(styleOption);
	parser.addHelpOption();
	parser.addVersionOption();

	parser.process(app);

	QUrl styleUrl;
	if (parser.isSet(styleOption)) {
		const QString path = parser.value(styleOption);
		QFileInfo info = QFileInfo(path);
		if (info.exists())
		        styleUrl = QUrl::fromLocalFile(info.canonicalFilePath());
		else
			qWarning("No such file: %s", qPrintable(path));
	}
	if (styleUrl.isEmpty())
		styleUrl = QUrl("qrc:///github.css");

	MainWindow *browser = new MainWindow(parser.positionalArguments(), styleUrl);
	browser->show();
	return app.exec();
}
Esempio n. 16
0
void FileBrowser::on_treeFiles_doubleClicked(QModelIndex index)
{
    QFileInfo info = model->fileInfo(index);
    if(!info.isReadable() || !info.isDir())
        return;
    setPath(info.canonicalFilePath());
}
Esempio n. 17
0
void MainWindow::initHashFile(QString path)
{
    QDir dir(path);
    dir.setFilter(QDir::Files);
    QDirIterator it(dir, QDirIterator::Subdirectories);

    QString dirName = dir.dirName();

    QString baseName;
    QString filePath;
    while(it.hasNext()) {
        it.next();
        QFileInfo fileInfo = it.fileInfo();
        filePath = fileInfo.canonicalFilePath();
        filePath = filePath.right(filePath.length() - path.length() + dirName.length() + 1);

        baseName = fileInfo.fileName();
        int index = baseName.lastIndexOf(".");
        if (index != -1) {
            baseName = baseName.replace(index, 1, "_");
        }
        //        //        if(baseName.indexOf(""))
        //        baseNam
        hashFile[baseName.toUpper()] = filePath;
    }
    initModelWithHashFile();
}
Esempio n. 18
0
void FileList::AddDirectory(const QString &directory, bool recursive)
{
    QDir dir(directory);
    dir.setSorting(QDir::Name);
    const QStringList filters = FileList::GetDefaultFilters();
    const QStringList origNameFilters = dir.nameFilters();
    dir.setNameFilters(filters);
    if (!recursive) {
        dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
        QFileInfoList items = dir.entryInfoList();
        mFileList += items;
    } else {
        dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
        QFileInfoList items = dir.entryInfoList();
        mFileList += items;

        dir.setNameFilters(origNameFilters);
        dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
        QFileInfoList list = dir.entryInfoList();
        QFileInfo item;
        foreach(item, list) {
            const QString path = item.canonicalFilePath();
            AddDirectory(path, recursive);
        }
    }
}
Esempio n. 19
0
DocumentWatcher::Details::Details(const QFileInfo& info) :
	path(info.canonicalFilePath()),
	modified(info.lastModified()),
	permissions(info.permissions()),
	ignored(false)
{
}
static void addPathToHash(PathHash &pathHash, const QString &key, const QFileInfo &fileInfo,
                          const QString &path)
{
    PathInfoList &list = pathHash[key];
    list.push_back(PathInfo(path,
                            fileInfo.canonicalFilePath().normalized(QString::NormalizationForm_D).toUtf8()));
    pathHash.insert(key, list);
}
 foreach (const QFileInfo &d, dirs)
 {
     QString dn = d.canonicalFilePath();
     if (dn != dirName)
     {
         findDesktopFiles(dn, QString::fromLatin1("%1%2-").arg(prefix, d.fileName()));
     }
 }
void DownloadItemViewModel::play()
{
    if (m_state != Done)
        return;

    QFileInfo info = QFileInfo(m_resultFileName);
    QString url = info.canonicalFilePath();
    QDesktopServices::openUrl(QUrl("file:///"+url));
}
Esempio n. 23
0
void TrackExportWorker::copyFile(const QFileInfo& source_fileinfo,
                                 const QString& dest_filename) {
    QString sourceFilename = source_fileinfo.canonicalFilePath();
    const QString dest_path = QDir(m_destDir).filePath(dest_filename);
    QFileInfo dest_fileinfo(dest_path);

    if (dest_fileinfo.exists()) {
        switch (m_overwriteMode) {
        // Give the user the option to overwrite existing files in the destination.
        case OverwriteMode::ASK:
            switch (makeOverwriteRequest(dest_path)) {
            case OverwriteAnswer::SKIP:
            case OverwriteAnswer::SKIP_ALL:
                qDebug() << "skipping" << sourceFilename;
                return;
            case OverwriteAnswer::OVERWRITE:
            case OverwriteAnswer::OVERWRITE_ALL:
                break;
            case OverwriteAnswer::CANCEL:
                m_errorMessage = tr("Export process was canceled");
                stop();
                return;
            }
            break;
        case OverwriteMode::SKIP_ALL:
            qDebug() << "skipping" << sourceFilename;
            return;
        case OverwriteMode::OVERWRITE_ALL:;
        }

        // Remove the existing file in preparation for overwriting.
        QFile dest_file(dest_path);
        qDebug() << "Removing existing file" << dest_path;
        if (!dest_file.remove()) {
            const QString error_message = tr(
                    "Error removing file %1: %2. Stopping.").arg(
                    dest_path, dest_file.errorString());
            qWarning() << error_message;
            m_errorMessage = error_message;
            stop();
            return;
        }
    }

    qDebug() << "Copying" << sourceFilename << "to" << dest_path;
    QFile source_file(sourceFilename);
    if (!source_file.copy(dest_path)) {
        const QString error_message = tr(
                "Error exporting track %1 to %2: %3. Stopping.").arg(
                sourceFilename, dest_path, source_file.errorString());
        qWarning() << error_message;
        m_errorMessage = error_message;
        stop();
        return;
    }
}
Esempio n. 24
0
bool DetectionManual::isType(const QFileInfo &fi, QString &type, QString &subtype) {
	QString sSuffix = fi.suffix().toUpper();
	QString sPath = fi.canonicalFilePath().toUpper();
	QString sName = fi.fileName().toUpper();
	// TODO: look inside file (search structure)
	bool bType = (sSuffix == "1" && sPath.contains("/DOCS/MAN/"));
	if (bType) {
		type = "Manual";
		subtype = "todo"; // version and another information
	}
	return bType;
}
Esempio n. 25
0
bool DetectionBinaryData::isType(const QFileInfo &fi, QString &type, QString &subtype) {
	QString sSuffix = fi.suffix().toUpper();
	QString sPath = fi.canonicalFilePath().toUpper();
	QString sName = fi.fileName().toUpper();
	// TODO: look inside file (search structure)
	bool bType = (sSuffix == "DAT");
	if (bType) {
		type = "Binary Data";
		subtype = "todo"; // version and another information
	}
	return bType;
}
void RunProgramProtocol::run(const QFileInfo &fileToRun)
{
	mProtocol->setAction(mWaitingForUploadingComplete, [this, fileToRun](auto &communicator) {
		communicator.uploadProgram(fileToRun.canonicalFilePath());
	});

	mProtocol->setAction(mWaitingForRunComplete, [this, fileToRun](auto &communicator) {
		communicator.runProgram(fileToRun.fileName());
	});

	mProtocol->run();
}
Esempio n. 27
0
bool DetectionPerl::isType(const QFileInfo &fi, QString &type, QString &subtype) {
	QString sSuffix = fi.suffix().toUpper();
	QString sPath = fi.canonicalFilePath().toUpper();
	QString sName = fi.fileName().toUpper();
	// TODO: look inside file (search structure)
	bool bType = (sSuffix == "PL");
	// read first line...  "#!/usr/bin/perl"
	if (bType) {
		type = "Perl";
		subtype = "todo"; // version and another information
	}
	return bType;
}
void FileManagerAddDlg::grepNewFiles(const QTreeWidgetItem* parentItem, QDir* currentDir, QListWidget* listView, const QList<QString>* filesInDb)
{
	// files in this directory
	if( parentItem->isSelected() ) {
		// TODO: make this a global function?
		QList<QFileInfo> files = currentDir->entryInfoList(QStringList() << "*.mp3" << "*.ogg" << "*.flac" << "*.wav" << "*.m4a" << "*.wma", QDir::Files);
		QListIterator<QFileInfo> i(files);
		while (i.hasNext()) {
			QFileInfo curFileInfo = i.next();
			if(! filesInDb->contains( curFileInfo.canonicalFilePath() ) )
			 listView->addItem( curFileInfo.canonicalFilePath() );
		}
	}

	// recurse
	for(int i=0; i<parentItem->childCount(); i++)
	{
		currentDir->cd(parentItem->child(i)->text(0));
		grepNewFiles(parentItem->child(i), currentDir, listView, filesInDb);
		currentDir->cdUp();
	}
}
Esempio n. 29
0
/*!
    \internal
*/
void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo)
{
    QString path = fileInfo.filePath();

#ifdef Q_OS_WIN
    if (fileInfo.isSymLink())
        path = fileInfo.canonicalFilePath();
#endif

    if (iteratorFlags & QDirIterator::FollowSymlinks)
        visitedLinks << fileInfo.canonicalFilePath();

    if (engine) {
        engine->setFileName(path);
        QAbstractFileEngineIterator *it = engine->beginEntryList(filters, nameFilters);
        if (it) {
            it->setPath(path);
            fileEngineIterators << it;
        } else {
            // No iterator; no entry list.
        }
    }
}
Esempio n. 30
0
void ImageInput::execute()
{

    QFileInfo path = mIn;
    if(path != lastInfo || mAlwaysRead.getValue())
    {
        image = cv::imread(path.canonicalFilePath().toStdString(), -1);
        lastInfo = path;
    }
    if(!image.empty()) // if matrix is valid
        mOut.send(image);
    else
        throw std::runtime_error(QString("Could not load image: %1").arg(path.absoluteFilePath()).toStdString());
}