예제 #1
0
bool QFSFileEngineIterator::hasNext() const
{
    if (!done && !nativeIterator) {
        nativeIterator.reset(new QFileSystemIterator(QFileSystemEntry(path()),
                    filters(), nameFilters()));
        advance();
    }

    return !done;
}
예제 #2
0
//-----------------------------------------------------------------------------
ctkPathLineEdit::ctkPathLineEdit(QWidget *parentWidget)
  : QWidget(parentWidget)
  , d_ptr(new ctkPathLineEditPrivate(*this))
{
  Q_D(ctkPathLineEdit);
  d->init();

  this->setNameFilters(nameFilters());
  this->setFilters(filters());
}
예제 #3
0
TextureDirWidget::TextureDirWidget(QWidget *parent) :
    QWidget(parent),
    m_toolBar(new Manhattan::StyledBar),
    m_view(new QTreeView),
    m_model(new QFileSystemModel)
{
//    QAction *small = m_toolBar->addAction(tr("Small icon size"));
//    small->setCheckable(true);
//    connect(small, SIGNAL(triggered()), this, SLOT(setSmallIconSize()));

//    QAction *medium = m_toolBar->addAction(tr("Medium icon size"));
//    medium->setCheckable(true);
//    connect(medium, SIGNAL(triggered()), this, SLOT(setMediumIconSize()));

//    QAction *big = m_toolBar->addAction(tr("Big icon size"));
//    big->setCheckable(true);
//    connect(big, SIGNAL(triggered()), this, SLOT(setBigIconSize()));

//    QActionGroup *group = new QActionGroup(m_toolBar);
//    group->addAction(small);
//    group->addAction(medium);
//    group->addAction(big);

//    m_toolBar->setSingleRow(false);
    {
        QHBoxLayout *layout = new QHBoxLayout(m_toolBar);
        layout->setMargin(0);
        layout->setSpacing(4);
        layout->setContentsMargins(5, 0, 0, 0);
        layout->addWidget(new QLabel(tr(LabelText)));
    }

    connect(m_model, SIGNAL(directoryLoaded(QString)), m_view, SLOT(expandAll()));
    m_model->setRootPath(QDir::currentPath());
    m_model->setNameFilterDisables(false);
    m_model->setNameFilters(nameFilters());
    m_model->setIconProvider(new TextureIconProvider);

    m_view->setDragEnabled(true);
    m_view->setDragDropMode(QAbstractItemView::DragOnly);
    m_view->setHeaderHidden(true);
    m_view->setIconSize(IconSize);
    m_view->setModel(m_model);
    m_view->setRootIndex(m_model->index(QDir::currentPath()));
    for(int i = 1; i < m_model->columnCount(); ++i) {
        m_view->setColumnHidden(i, true);
    }
    m_view->setStyleSheet("QTreeView { border: 0; }");

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);
    layout->addWidget(m_toolBar);
    layout->addWidget(m_view);
}
예제 #4
0
bool QNapiOpenDialog::selectFiles() {
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
  files = getOpenFileNames(this, windowTitle(), directory().path(),
                           nameFilters().join("\n"));
  return !files.isEmpty();
#else
  if (!placeWindow()) return false;
  setFileMode(QFileDialog::ExistingFiles);
  return exec();
#endif
}
예제 #5
0
int QDeclarativeFolderListModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractListModel::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 6)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 6;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QUrl*>(_v) = folder(); break;
        case 1: *reinterpret_cast< QUrl*>(_v) = parentFolder(); break;
        case 2: *reinterpret_cast< QStringList*>(_v) = nameFilters(); break;
        case 3: *reinterpret_cast< SortField*>(_v) = sortField(); break;
        case 4: *reinterpret_cast< bool*>(_v) = sortReversed(); break;
        case 5: *reinterpret_cast< bool*>(_v) = showDirs(); break;
        case 6: *reinterpret_cast< bool*>(_v) = showDotAndDotDot(); break;
        case 7: *reinterpret_cast< bool*>(_v) = showOnlyReadable(); break;
        case 8: *reinterpret_cast< int*>(_v) = count(); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setFolder(*reinterpret_cast< QUrl*>(_v)); break;
        case 2: setNameFilters(*reinterpret_cast< QStringList*>(_v)); break;
        case 3: setSortField(*reinterpret_cast< SortField*>(_v)); break;
        case 4: setSortReversed(*reinterpret_cast< bool*>(_v)); break;
        case 5: setShowDirs(*reinterpret_cast< bool*>(_v)); break;
        case 6: setShowDotAndDotDot(*reinterpret_cast< bool*>(_v)); break;
        case 7: setShowOnlyReadable(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 9;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
예제 #6
0
QStringList Configurator::getPresetFilesNames(bool fullpath)
{
    QDir::SortFlags sort = QDir::Name;
    QDir::Filters filters = QDir::Files | QDir::Readable;
    QStringList nameFilters("*.json");

    QFileInfoList fileInfos = presetsDir.entryInfoList(nameFilters, filters, sort);

    QStringList filesPaths;
    foreach (const QFileInfo &item, fileInfos) {
        if (item.isFile()) {
            if (fullpath)
                filesPaths.append(item.absoluteFilePath());
            else
                filesPaths.append(item.fileName());
        }
    }
    return filesPaths;
}
예제 #7
0
void Widget::onSelectSong()
{
    QString strPath = QDir::currentPath();
    QStringList nameFilters("*.mp3");
    nameFilters << "*.wma" << "*.ape" << "*.ogg"
                << "*.aac" << "*.wav" << "*.mid"
                << "*.amr" << "*.3gp" << "*.mp4";

    m_fileSelector = new OpenFileWidget(strPath, nameFilters);
    m_layout->addWidget(m_fileSelector);
    m_layout->setCurrentWidget(m_fileSelector);

    m_fileSelector->setAttribute(Qt::WA_DeleteOnClose);
    connect(m_fileSelector, SIGNAL(selected(QString))
            , this, SLOT(onFileSelected(QString)));
    connect(m_fileSelector, SIGNAL(canceled())
            , this, SLOT(onFileSelectCanceled()));

    m_fileSelector->setStyleSheet("QListWidget{ background: #303030; border: 1px solid white}");
}
예제 #8
0
bool QNapiOpenDialog::selectFile()
{
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
	files.clear();
	QString file = getOpenFileName(this, windowTitle(), directory().path(),
#if QT_VERSION >= 0x040400
		nameFilters().join("\n")
#else
		filters().join("\n")
#endif
					);

	if(!file.isEmpty())
		files << file;

	return !file.isEmpty();
#else
	if(!placeWindow()) return false;
	setFileMode(QFileDialog::ExistingFile);
	return exec();
#endif
}
예제 #9
0
void BrowseThread::populateModel() {
    m_path_mutex.lock();
    QString thisPath = m_path;
    BrowseTableModel* thisModelObserver = m_model_observer;
    m_path_mutex.unlock();

    // Refresh the name filters in case we loaded new SoundSource plugins.
    QStringList nameFilters(SoundSourceProxy::supportedFileExtensionsString().split(" "));

    QDirIterator fileIt(thisPath, nameFilters, QDir::Files | QDir::NoDotAndDotDot);

    // remove all rows
    // This is a blocking operation
    // see signal/slot connection in BrowseTableModel
    emit(clearModel(thisModelObserver));

    QList< QList<QStandardItem*> > rows;

    int row = 0;
    // Iterate over the files
    while (fileIt.hasNext()) {
        // If a user quickly jumps through the folders
        // the current task becomes "dirty"
        m_path_mutex.lock();
        QString newPath = m_path;
        m_path_mutex.unlock();

        if(thisPath != newPath) {
            qDebug() << "Abort populateModel()";
            return populateModel();
        }

        QString filepath = fileIt.next();
        TrackInfoObject tio(filepath);
        QList<QStandardItem*> row_data;

        QStandardItem* item = new QStandardItem(tio.getFilename());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_FILENAME, item);

        item = new QStandardItem(tio.getArtist());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_ARTIST, item);

        item = new QStandardItem(tio.getTitle());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_TITLE, item);

        item = new QStandardItem(tio.getAlbum());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_ALBUM, item);

        item = new QStandardItem(tio.getAlbumArtist());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_ALBUMARTIST, item);

        item = new QStandardItem(tio.getTrackNumber());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_TRACK_NUMBER, item);

        item = new QStandardItem(tio.getYear());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_YEAR, item);

        item = new QStandardItem(tio.getGenre());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_GENRE, item);

        item = new QStandardItem(tio.getComposer());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_COMPOSER, item);

        item = new QStandardItem(tio.getGrouping());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_GROUPING, item);

        item = new QStandardItem(tio.getComment());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_COMMENT, item);

        QString duration = Time::formatSeconds(qVariantValue<int>(
                tio.getDuration()), false);
        item = new QStandardItem(duration);
        item->setToolTip(item->text());
        row_data.insert(COLUMN_DURATION, item);

        item = new QStandardItem(tio.getBpmStr());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_BPM, item);

        item = new QStandardItem(tio.getKeyText());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_KEY, item);

        item = new QStandardItem(tio.getType());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_TYPE, item);

        item = new QStandardItem(tio.getBitrateStr());
        item->setToolTip(item->text());
        row_data.insert(COLUMN_BITRATE, item);

        item = new QStandardItem(filepath);
        item->setToolTip(item->text());
        row_data.insert(COLUMN_LOCATION, item);

        rows.append(row_data);
        ++row;
        // If 10 tracks have been analyzed, send it to GUI
        // Will limit GUI freezing
        if(row % 10 == 0){
            // this is a blocking operation
            emit(rowsAppended(rows, thisModelObserver));
            //qDebug() << "Append " << rows.count() << " from " << filepath;
            rows.clear();
        }
        // Sleep additionally for 10ms which prevents us from GUI freezes
        msleep(20);
    }
    emit(rowsAppended(rows, thisModelObserver));
    //qDebug() << "Append last " << rows.count() << " from " << thisPath;
}
예제 #10
0
void ConfigDialog::_getTranslations(QStringList & _translationFiles) const
{
    QDir pluginFolder(m_strIniPath);
    QStringList nameFilters("gliden64_*.qm");
    _translationFiles = pluginFolder.entryList(nameFilters, QDir::Files, QDir::Name);
}
예제 #11
0
void BrowseThread::populateModel() {
    m_path_mutex.lock();
    MDir thisPath = m_path;
    BrowseTableModel* thisModelObserver = m_model_observer;
    m_path_mutex.unlock();

    // Refresh the name filters in case we loaded new SoundSource plugins.
    QStringList nameFilters(SoundSourceProxy::getSupportedFileNamePatterns());

    QDirIterator fileIt(thisPath.dir().absolutePath(), nameFilters,
                        QDir::Files | QDir::NoDotAndDotDot);

    // remove all rows
    // This is a blocking operation
    // see signal/slot connection in BrowseTableModel
    emit(clearModel(thisModelObserver));

    QList< QList<QStandardItem*> > rows;

    int row = 0;
    // Iterate over the files
    while (fileIt.hasNext()) {
        // If a user quickly jumps through the folders
        // the current task becomes "dirty"
        m_path_mutex.lock();
        MDir newPath = m_path;
        m_path_mutex.unlock();

        if (thisPath.dir() != newPath.dir()) {
            qDebug() << "Abort populateModel()";
            return populateModel();
        }

        QList<QStandardItem*> row_data;

        QStandardItem* item = new QStandardItem("0");
        item->setData("0", Qt::UserRole);
        row_data.insert(COLUMN_PREVIEW, item);

        const QString filepath = fileIt.next();
        {
            const TrackPointer pTrack =
                    SoundSourceProxy::importTemporaryTrack(
                            filepath,
                            thisPath.token());

            item = new QStandardItem(pTrack->getFileName());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_FILENAME, item);

            item = new QStandardItem(pTrack->getArtist());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_ARTIST, item);

            item = new QStandardItem(pTrack->getTitle());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_TITLE, item);

            item = new QStandardItem(pTrack->getAlbum());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_ALBUM, item);

            item = new QStandardItem(pTrack->getAlbumArtist());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_ALBUMARTIST, item);

            item = new QStandardItem(pTrack->getTrackNumber());
            item->setToolTip(item->text());
            item->setData(item->text().toInt(), Qt::UserRole);
            row_data.insert(COLUMN_TRACK_NUMBER, item);

            const QString year(pTrack->getYear());
            item = new YearItem(year);
            item->setToolTip(year);
            // The year column is sorted according to the numeric calendar year
            item->setData(mixxx::TrackMetadata::parseCalendarYear(year), Qt::UserRole);
            row_data.insert(COLUMN_YEAR, item);

            item = new QStandardItem(pTrack->getGenre());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_GENRE, item);

            item = new QStandardItem(pTrack->getComposer());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_COMPOSER, item);

            item = new QStandardItem(pTrack->getGrouping());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_GROUPING, item);

            item = new QStandardItem(pTrack->getComment());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_COMMENT, item);

            QString duration = pTrack->getDurationText(mixxx::Duration::Precision::SECONDS);
            item = new QStandardItem(duration);
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_DURATION, item);

            item = new QStandardItem(pTrack->getBpmText());
            item->setToolTip(item->text());
            item->setData(pTrack->getBpm(), Qt::UserRole);
            row_data.insert(COLUMN_BPM, item);

            item = new QStandardItem(pTrack->getKeyText());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_KEY, item);

            item = new QStandardItem(pTrack->getType());
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_TYPE, item);

            item = new QStandardItem(pTrack->getBitrateText());
            item->setToolTip(item->text());
            item->setData(pTrack->getBitrate(), Qt::UserRole);
            row_data.insert(COLUMN_BITRATE, item);

            QString location = pTrack->getLocation();
            QString nativeLocation = QDir::toNativeSeparators(location);
            item = new QStandardItem(nativeLocation);
            item->setToolTip(nativeLocation);
            item->setData(location, Qt::UserRole);
            row_data.insert(COLUMN_NATIVELOCATION, item);

            QDateTime modifiedTime = pTrack->getFileModifiedTime().toLocalTime();
            item = new QStandardItem(modifiedTime.toString(Qt::DefaultLocaleShortDate));
            item->setToolTip(item->text());
            item->setData(modifiedTime, Qt::UserRole);
            row_data.insert(COLUMN_FILE_MODIFIED_TIME, item);

            QDateTime creationTime = pTrack->getFileCreationTime().toLocalTime();
            item = new QStandardItem(creationTime.toString(Qt::DefaultLocaleShortDate));
            item->setToolTip(item->text());
            item->setData(creationTime, Qt::UserRole);
            row_data.insert(COLUMN_FILE_CREATION_TIME, item);

            const mixxx::ReplayGain replayGain(pTrack->getReplayGain());
            item = new QStandardItem(
                    mixxx::ReplayGain::ratioToString(replayGain.getRatio()));
            item->setToolTip(item->text());
            item->setData(item->text(), Qt::UserRole);
            row_data.insert(COLUMN_REPLAYGAIN, item);
        } // implicitly release track pointer and unlock cache

        rows.append(row_data);
        ++row;
        // If 10 tracks have been analyzed, send it to GUI
        // Will limit GUI freezing
        if (row % 10 == 0) {
            // this is a blocking operation
            emit(rowsAppended(rows, thisModelObserver));
            qDebug() << "Append " << rows.count() << " from " << filepath;
            rows.clear();
        }
        // Sleep additionally for 10ms which prevents us from GUI freezes
        msleep(20);
    }
    emit(rowsAppended(rows, thisModelObserver));
    qDebug() << "Append last " << rows.count();
}
예제 #12
0
void FileSaveDialog::open()
{
    if (!valid()) return;

    QQuickItem *parent = this->parentItem();
    Q_ASSERT(parent);

    QQuickWindow *window = parent->window();
    Q_ASSERT(window);

    m_parentWindow = window;

    m_options->setFileMode(QFileDialogOptions::AnyFile);
    m_options->setAcceptMode(QFileDialogOptions::AcceptSave);
    m_options->setWindowTitle(title());
    m_options->setNameFilters(nameFilters());

    /*
     * Mac:
     * Set filename incl. directory via setInitiallySelectedFiles()
     *
     * Windows:
     * Set filename via setInitiallySelectedFiles() and let Windows choose the directory.
     * Default directory: C:\\Users\XYZ\Downloads
     *
     * Gnome:
     * Set directory via QPlatformFileDialogHelper::setDirectory() and leave
     * filename empty, since QGtk2FileDialogHelper can not set non-existing filenames.
     *
     */
    const QString folder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
    const QString name = filename();

#ifdef Q_OS_OSX
    QUrl initialSelection = QUrl::fromLocalFile(QFileInfo(folder, name).absoluteFilePath());
    qDebug() << "Initial file:" << initialSelection;
    m_options->setInitiallySelectedFiles(QList<QUrl>() << initialSelection);
#endif
#ifdef Q_OS_WIN
    qDebug() << "Initial filename:" << name;
    m_options->setInitiallySelectedFiles(QList<QUrl>() << QUrl::fromLocalFile(name));
#endif
#ifdef Q_OS_LINUX
    #if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 2))
    // Wohoo, big fix! https://codereview.qt-project.org/91501
    QUrl initialSelection = QUrl::fromLocalFile(QFileInfo(folder, name).absoluteFilePath());
    qDebug() << "Initial file:" << initialSelection;
    m_options->setInitiallySelectedFiles(QList<QUrl>() << initialSelection);
    #else
    qDebug() << "Initial directory:" << folder;
    m_dlgHelper->setDirectory(QUrl::fromLocalFile(folder));
    #endif
#endif

    m_dlgHelper->setOptions(m_options);
    m_dlgHelper->setFilter(); // applyOptions();

    Qt::WindowFlags flags = Qt::Dialog;
    if (!title().isEmpty()) flags |= Qt::WindowTitleHint;

    m_visible = m_dlgHelper->show(flags, m_modality, m_parentWindow);
}
예제 #13
0
void Background::computeCache_() const
{
    // Default values, such that image(f) returns "" for all frames
    filePathsWildcards_.clear();
    referenceFrames_.clear();
    filePathsPrefix_.clear();
    filePathsSuffix_.clear();

    // Get url relative to working dir
    QDir dir = global()->documentDir();
    QString url = dir.filePath(data_.imageUrl);

    // Case without wildcard
    if (!url.contains('*'))
    {
        filePathsPrefix_ = url;
    }

    // Case with wildcard
    //
    // Note: At this point, we are guaranteed that there is one and
    // only one '*', and that it is not followed by '/'
    else
    {
        // Get url relative to parent dir
        QFileInfo fileInfo(url);
        QDir parentDir = fileInfo.dir();
        url = fileInfo.fileName();

        // Store path of parent dir in cached prefix
        filePathsPrefix_ = parentDir.path() + "/";

        // Get matching files
        QStringList nameFilters(url);
        QDir::Filters filters = QDir::Files | QDir::Readable;
        QFileInfoList files = parentDir.entryInfoList(nameFilters, filters);

        // Get wildcard index
        int wildcardIndex = url.indexOf('*');

        // Cache prefix and suffix
        filePathsPrefix_ += url.left(wildcardIndex);
        filePathsSuffix_ = url.right(url.length() - wildcardIndex - 1);

        // Get wildcard values as string and int.
        // Example:
        //   files[i].fileName() = "image015.png"
        //   stringWildcards[i]  = "015"
        //   intWildcards[i]     = 15
        QStringList stringWildcards;
        QList<int> intWildcards;
        foreach(QFileInfo i, files)
        {
            // Get wildcard as string
            QString fileName = i.fileName();
            QString stringWildcard = fileName.mid(
                        wildcardIndex, fileName.length() - url.length() + 1);

            // Append to lists, if can convert to an int
            bool ok;
            int intWildcard = stringWildcard.toInt(&ok);
            if (ok)
            {
                stringWildcards << stringWildcard;
                intWildcards << intWildcard;
            }
        }
        int nWildcards = stringWildcards.size(); // == intWildcards.size();

        // If there is zero match, then it's trivial
        if (nWildcards > 0) // Nothing to do if there's zero match:
                            // image(f) will return prefix + suffix for all frames
        {
            // Find minimum, maximum, and their indices
            // Note: it's possible that min = max (e.g., only one entry)
            //       it's also possible that min or max are not unique (e.g., "background01.png" and "background1.png")
            minFrame_ = intWildcards[0];
            int maxFrame = intWildcards[0];
            for (int i=1; i<nWildcards; ++i)
            {
                if (intWildcards[i] > maxFrame) {
                    maxFrame = intWildcards[i];
                }
                if (intWildcards[i] < minFrame_) {
                    minFrame_ = intWildcards[i];
                }
            }

            // The remaining step is to create an array 'filePathsWildcards_' s.t.
            // for each f in [min, max], the value filePathsWildcards_[f-min]
            // represents the stringWildcard to use for frame f.
            //
            // example:
            //    stringWildcards = [ "03", "8", "005" ]
            //    intWildcards =    [ 3, 8, 5 ]
            //    min = 3 ; indexMin = 0
            //    max = 8 ; indexMax = 1
            //
            //    If hold == true:
            //    frameToString = [ "03", "03", "005", "005", "005", "8" ]
            //                f =    3     4       5     6      7     8
            //
            //    If hold == false:
            //    frameToString = [ "03", "",   "005",   "",    "",   "8" ]
            //                f =    3     4       5     6      7     8
            //

            // Initialization (non-empty vector of empty strings)
            filePathsWildcards_ = QVector<QString>(maxFrame-minFrame_+1);
            referenceFrames_ = QVector<int>(maxFrame-minFrame_+1, 0);

            // Fill with values of existing files
            for (int i=0; i<nWildcards; ++i) {
                filePathsWildcards_[intWildcards[i] - minFrame_] = stringWildcards[i];
                referenceFrames_[intWildcards[i] - minFrame_] = intWildcards[i];
            }

            // Fill the blanks between existing files if hold == true
            if (hold())
            {
                QString lastValidWildcard = filePathsWildcards_.first();
                int lastValidIntWildcard = referenceFrames_.first();
                for (int i=1; i<filePathsWildcards_.size()-1; ++i)
                {
                    if (filePathsWildcards_[i].isEmpty()) {
                        filePathsWildcards_[i] = lastValidWildcard;
                        referenceFrames_[i] = lastValidIntWildcard;
                    }
                    else {
                        lastValidWildcard = filePathsWildcards_[i];
                        lastValidIntWildcard = referenceFrames_[i];
                    }
                }
            }
            // Fill the blanks between existing files if hold == false
            // Nothing to do for filePathsWildcards_. The blank are
            // already an empty string, which is the correct result.
            // However, for now the blanks in referenceFrames_ are 0,
            // which is not good, 0 might be a provided frame. We want
            // to make sure each blank point to an unprovided frame, so
            // we choose minFrame - 1.
            else
            {
                for (int i=1; i<filePathsWildcards_.size()-1; ++i)
                {
                    if (filePathsWildcards_[i].isEmpty()) {
                        referenceFrames_[i] = minFrame_ - 1;
                    }
                }
            }
        }
    }
예제 #14
0
int QDeclarativeFolderListModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractListModel::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: folderChanged(); break;
        case 1: countChanged(); break;
        case 2: refresh(); break;
        case 3: inserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 4: removed((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 5: handleDataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break;
        case 6: { bool _r = isFolder((*reinterpret_cast< int(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        default: ;
        }
        _id -= 7;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QUrl*>(_v) = folder(); break;
        case 1: *reinterpret_cast< QUrl*>(_v) = parentFolder(); break;
        case 2: *reinterpret_cast< QStringList*>(_v) = nameFilters(); break;
        case 3: *reinterpret_cast< SortField*>(_v) = sortField(); break;
        case 4: *reinterpret_cast< bool*>(_v) = sortReversed(); break;
        case 5: *reinterpret_cast< bool*>(_v) = showDirs(); break;
        case 6: *reinterpret_cast< bool*>(_v) = showDotAndDotDot(); break;
        case 7: *reinterpret_cast< bool*>(_v) = showOnlyReadable(); break;
        case 8: *reinterpret_cast< int*>(_v) = count(); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setFolder(*reinterpret_cast< QUrl*>(_v)); break;
        case 2: setNameFilters(*reinterpret_cast< QStringList*>(_v)); break;
        case 3: setSortField(*reinterpret_cast< SortField*>(_v)); break;
        case 4: setSortReversed(*reinterpret_cast< bool*>(_v)); break;
        case 5: setShowDirs(*reinterpret_cast< bool*>(_v)); break;
        case 6: setShowDotAndDotDot(*reinterpret_cast< bool*>(_v)); break;
        case 7: setShowOnlyReadable(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 9;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}