コード例 #1
0
ファイル: partialarchive.cpp プロジェクト: Iktwo/evopedia
void PartialArchive::changeToLocalArchive()
{
    QString localArchiveDir;
    if (QDir(dir).exists("metadata.txt")) {
        localArchiveDir = dir;
    } else {
        QStringList subdirs = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
        if (subdirs.isEmpty()) {
            localArchiveDir = dir; /* will fail */
        } else {
            /* there should only be one */
            localArchiveDir = dir + "/" + subdirs[0];
        }
    }

    LocalArchive *a = new LocalArchive(localArchiveDir);
    if (!a->isReadable()) {
        QString err(a->getErrorMessage());
        QMessageBox::critical(0, "Error", tr("Archive downloaded completely but it "
                                                  "is not valid and cannot be used (%1).").arg(err));
        delete a;
    } else {
        ArchiveManager *am((static_cast<EvopediaApplication *>(qApp))->evopedia()->getArchiveManager());
        am->exchangeArchives(this, a);
    }
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: evopedia/evopedia_qt
void MainWindow::refreshSearchResults()
{
    Evopedia *evopedia = (static_cast<EvopediaApplication *>(qApp))->evopedia();
    LocalArchive *backend = evopedia->getArchiveManager()->getLocalArchive(ui->languageChooser->currentText());
    TitleIterator it;
    if (backend != 0)
        it = backend->getTitlesWithPrefix(ui->searchField->text());
    titleListModel->setTitleIterator(it);
}
コード例 #3
0
void HarmattanEvopediaApplication::refreshSearchResults()
{
    if (settings->getLanguageIndex() == -1) {
        titleListModel->setTitleIterator(TitleIterator());
        return;
    }

    QString lang = settings->getLanguageList()[settings->getLanguageIndex()];

    LocalArchive *backend = evopedia->getArchiveManager()->getLocalArchive(lang);

    if (backend == NULL) {
        titleListModel->setTitleIterator(TitleIterator());
        return;
    }

    TitleIterator it = backend->getTitlesWithPrefix(searchPrefix);
    titleListModel->setTitleIterator(it);
}