Example #1
0
// run async, because query() starts searching immediately
void QueryModel::getEntriesWithQuery(QString const &query,
    QString const &attribute, bool yield)
{
    try {
        if (d_entryCache->contains(CacheKey(query, attribute, yield)))
        {
            {
              QMutexLocker locker(&d_resultsMutex);
              CacheItem *cachedResult = d_entryCache->object(
                  CacheKey(query, attribute, yield));
              d_totalHits = cachedResult->hits;
              d_hitsIndex = cachedResult->index;
              d_results   = cachedResult->entries;
            }

            emit queryFinished(d_results.size(), d_results.size(), query,
                attribute, true, yield);
            return;
        }

        QueryModel::getEntries(
            d_corpus->query(alpinocorpus::CorpusReader::XPATH, query.toUtf8().constData()),
            query.toUtf8().constData(), attribute.toUtf8().constData(), yield);
    } catch (std::exception const &e) {
        qDebug() << "Error in QueryModel::getEntries: " << e.what();
        emit queryFailed(e.what());
    }
}
Example #2
0
void BracketedWindow::setModel(FilterModel *model)
{
    d_model.reset(model);
    d_ui->resultsTable->setModel(d_model.data());

    d_ui->hitsLabel->clear();
    d_ui->entriesLabel->clear();

    emit saveStateChanged();

    //d_ui->resultsTable->setColumnHidden(1, true);

    //d_ui->resultsTable->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
    //d_ui->resultsTable->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
    //d_ui->resultsTable->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);

    d_ui->resultsTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    d_ui->resultsTable->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    d_ui->resultsTable->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);

    // disables horizontal jumping when a sentence is selected
    d_ui->resultsTable->setAutoScroll(false);

    /*
    connect(d_model.data(), SIGNAL(queryEntryFound(QString)),
        this, SLOT(updateResultsTotalCount()));
    */

    connect(d_model.data(), SIGNAL(nEntriesFound(int, int)),
        SLOT(updateCounts(int, int)));

    connect(d_model.data(), SIGNAL(queryFailed(QString)),
        SLOT(queryFailed(QString)));

    connect(d_model.data(), SIGNAL(queryStarted(int)),
        SLOT(progressStarted(int)));

    connect(d_model.data(), SIGNAL(queryStopped(int, int)),
        SLOT(progressStopped(int, int)));

    connect(d_model.data(), SIGNAL(queryFinished(int, int, bool)),
            SLOT(progressFinished(int, int, bool)));

    connect(d_model.data(), SIGNAL(progressChanged(int)),
        SLOT(progressChanged(int)));
}
void DroneshareAPIBroker::httpFinished()
{
    QLOG_DEBUG() << "DroneshareUpload::httpFinished()";
    if (!m_httpRequestAborted) {
        // Finished uploading the log
        if (m_networkReply->error()) {
            // upload failed
            emit queryFailed(m_networkReply->errorString());
        } else {
            // Upload success
            QString reply = QString(m_networkReply->readAll());
            QLOG_DEBUG() << "Droneshare: JSON reply: " << reply;
            emit queryComplete(reply);
        }
    }
    if(m_networkReply) {
        m_networkReply->deleteLater();
        m_networkReply = NULL;
    }
}
Example #4
0
QueryModel::QueryModel(CorpusPtr corpus, QObject *parent)
:
    QAbstractTableModel(parent),
    d_corpus(corpus),
    d_entryCache(new EntryCache()),
    d_timer(new QTimer)
{
    connect(this, SIGNAL(queryEntryFound(QString)),
        SLOT(mapperEntryFound(QString)));
    connect(this, SIGNAL(queryFinished(int, int, QString, QString, bool, bool)),
        SLOT(finalizeQuery(int, int, QString, QString, bool, bool)));

    // Timer for progress updates.
    connect(d_timer.data(), SIGNAL(timeout()),
        SLOT(updateProgress()));
    connect(this, SIGNAL(queryStopped(int, int)),
        SLOT(stopProgress()));
    connect(this, SIGNAL(queryFinished(int, int, QString, QString, bool, bool)),
        SLOT(stopProgress()));
    connect(this, SIGNAL(queryFailed(QString)),
        SLOT(stopProgress()));
}
void DroneshareUploadDialog::acceptUserLogin(QString& username, QString& password, int indexNumber)
{
    QLOG_DEBUG() << "Droneshare: " << username << " pass: XXXXXXX" << "index: " << indexNumber;
    m_username = username;
    m_password = password;

    QSettings settings;
    settings.beginGroup("Droneshare");
    settings.setValue("username", m_username);
    settings.endGroup();
    settings.sync();

    m_droneshareQuery = new DroneshareAPIBroker();
    connect(m_droneshareQuery, SIGNAL(queryComplete(QString)),
            this, SLOT(vehicleQueryComplete(QString)));
    connect(m_droneshareQuery, SIGNAL(queryFailed(QString)),
            this, SLOT(vehicleQueryFailed(QString)));

    m_droneshareQuery->addBaseUrl(DroneshareBaseUrl);
    m_droneshareQuery->addQuery("/user/" + m_username);
    m_droneshareQuery->addQueryItem("api_key", DroneshareAPIKey);
    m_droneshareQuery->sendQueryRequest();
    QLOG_DEBUG() << "droneshare: user request: " << m_droneshareQuery->getUrl();
}