//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QStringList RicFileHierarchyDialog::buildDirectoryListRecursive(const QString& currentDir, int level)
{
    QStringList allDirs;

    if (cancelPressed()) return allDirs;

    QString currPathFilter = pathFilter();
    bool subStringFilter = false;

    // Optimizing for speed by a refined match at first directory level
    if (level == 1)
    {
        QString pathFilter = this->pathFilter();
        if (!pathFilter.startsWith("*"))
        {
            int wildcardIndex = pathFilter.indexOf(QRegExp(QString("[*%1]").arg(SEPARATOR)));
            if (wildcardIndex >= 0)
            {
                currPathFilter = pathFilter.left(wildcardIndex + 1);
                subStringFilter = true;
            }
        }
    }

    QString currRelPath = RiaFilePathTools::relativePath(rootDir(), currentDir);
    if (pathFilterMatch(currPathFilter, currRelPath))
    {
        allDirs.push_back(currentDir);
    }
    else if(level == 1 && subStringFilter)
    {
        return QStringList();
    }

    QDir qdir(currentDir);
    QStringList subDirs = qdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
    for (QString subDir : subDirs)
    {
        QString subDirFullPath = qdir.absoluteFilePath(subDir);
        updateStatus(SEARCHING_FOR_DIRS, subDirFullPath);
        QApplication::processEvents();
        allDirs += buildDirectoryListRecursive(subDirFullPath, level + 1);
    }
    return cancelPressed() ? QStringList() : allDirs;
}
示例#2
0
QMessageFolderId QMessagePrivate::standardFolderId(QMessage::StandardFolder folder)
{
    StandardFolderMap::const_iterator it = standardFolderMap()->find(folder);
    if (it == standardFolderMap()->end()) {
        const char *path((folder == QMessage::InboxFolder ? "Inbox" : 
                         (folder == QMessage::OutboxFolder ? "Outbox" : 
                         (folder == QMessage::DraftsFolder ? "Drafts" : 
                         (folder == QMessage::SentFolder ? "Sent" : 
                         (folder == QMessage::TrashFolder ? "Trash" : ""))))));

        // Find the ID for this standard folder
        QMessageFolderFilter pathFilter(QMessageFolderFilter::byPath(path));
        QMessageFolderFilter accountFilter(QMessageFolderFilter::byParentAccountId(QMessageAccountId()));

        QMessageFolderId folderId(QMessageManager().queryFolders(pathFilter & accountFilter).first());
        it = standardFolderMap()->insert(folder, folderId);
    }

    return *it;
}