Exemplo n.º 1
0
void QueryModel::runQuery(QString const &query, QString const &attribute,
    bool yield)
{
    cancelQuery(); // just in case
    
    // clean results cache and notify the table of the loss of rows
    //int size = d_results.size();
    d_results.clear();
    d_hitsIndex.clear();
    emit layoutChanged();
    
    // clear cache and counter
    d_valueIndex.clear();
    d_totalHits = 0;
    
    d_query = query;
    d_attribute = attribute;
       
    // Do nothing if we where given a null-pointer
    if (!d_corpus)
        return;

    if (!query.isEmpty())
    {
        QTimer::singleShot(0, this, SLOT(startTimer()));

        if (yield)
          d_entriesFuture = QtConcurrent::run(this, &QueryModel::getEntriesWithQuery,
              query, attribute, yield);
        else
          d_entriesFuture = QtConcurrent::run(this, &QueryModel::getEntriesWithQuery,
              expandQuery(query, attribute), attribute, yield);
    }
    // If the query is empty, QueryModel is not supposed to do anything.
}
Exemplo n.º 2
0
void MainWindow::initialize(QString const &target)
{
    emit cancelQuery();

    if (target == NULL || target.isEmpty()) {
        QString *target = new QString();
        QString *argument = new QString();
        PersistenceHandler::loadLast(target, argument, this);
        ui->txtTarget->setText(*target);
        ui->txtArgument->setText(*argument);
        delete target;
        delete argument;

        checkTarget(ui->txtTarget->text());

        forceFocus();
        ui->txtTarget->setFocus(Qt::ActiveWindowFocusReason);
        ui->txtTarget->selectAll();

    } else {
        ui->txtTarget->setText(target);
//        ui->txtArgument->setText("");
        forceFocus();
        ui->txtArgument->setFocus(Qt::ActiveWindowFocusReason);
    }
}
Exemplo n.º 3
0
MainWindow::MainWindow(QList<Target *> *targetList, QString target) :
    QMainWindow(0),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
//    setAttribute(Qt::WA_TranslucentBackground);
    setAttribute(Qt::WA_DeleteOnClose);
    setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::CustomizeWindowHint);

    targetList_ = targetList;
    historyList = new QStringList();

    updateTargetCompleter();

    server = new QLocalServer(this);
    connect(server, SIGNAL(newConnection()), this, SLOT(newConnection()));
    server->listen(SERVER_MAIN);

    googleEnabled = true;
    editingCompleter = 0;

    forceFocus();
    initialize(target);

    workerThread = new QThread(this);
    worker = new QueryWorker();
    worker->moveToThread(workerThread);
    connect(this, SIGNAL(startQuery(QString, QString)), worker, SLOT(query(QString, QString)), Qt::QueuedConnection);
    connect(this, SIGNAL(cancelQuery()), worker, SLOT(abort()));
    connect(worker, SIGNAL(queryFinished(QStringList *)), this, SLOT(queryDone(QStringList *)));

    workerThread->start();
}
Exemplo n.º 4
0
			MMS_Simple_Browse::~MMS_Simple_Browse()
			{
				if( ongoingID_ )
				{
					debug(2) << "implicit abortion for browse ID" << ongoingID_;

					cancelQuery(ongoingID_);
					ongoingID_ = 0;
				}
				debug(2) << "destroyed";
			}
Exemplo n.º 5
0
void MainWindow::keyReleaseEvent(QKeyEvent *event)
{
    if (event->key() == Qt::Key_ScrollLock) {
        googleEnabled = !googleEnabled;
        emit cancelQuery();

        if (googleEnabled) {
            on_txtArgument_textEdited();
        } else {
            updateArgumentCompleter(historyList);
        }

    } else if (event->key() == Qt::Key_Escape) {
        qApp->exit(0);
    }
}
Exemplo n.º 6
0
void MainWindow::on_txtArgument_textEdited()
{
    emit cancelQuery();

    if (queryURL.isEmpty()) {
        return;
    }

    QString argument = ui->txtArgument->encodedText();

    if (argument.isEmpty()) {
        return;
    }

    if (googleEnabled) {
        emit startQuery(queryURL, argument);
    }
}
Exemplo n.º 7
0
void MainWindow::execute()
{
    emit cancelQuery();

    QString target = ui->txtTarget->text().trimmed();

    if (!target.isEmpty()) {
        for (QList<Target *>::const_iterator i = targetList_->cbegin(); i != targetList_->cend(); i++) {
            if (target.compare((*i)->getName(), Qt::CaseInsensitive) == 0) {

                //Saving history
                saveHistory(*(*i));

                QString command;

                if ((*i)->getCommand().isEmpty()) {
                    command = target;
                } else {
                    command = (*i)->getCommand();
                }

                if (command.startsWith("http://") || command.startsWith("https://")) {
                    command.append(ui->txtArgument->encodedText());
                    QDesktopServices::openUrl(QUrl(command));
                } else {
                    command.append(" ");
                    command.append(ui->txtArgument->text().trimmed());
                    QProcess *p = new QProcess(this);
                    p->startDetached(command);
                    connect(p, SIGNAL(finished(int)), p, SLOT(deleteLater())); //Clean UP!!
                }

                break;
            }
        }
    }

    PersistenceHandler::saveLast(ui->txtTarget->text(), ui->txtArgument->text(), this);
    qApp->exit(0);
}
Exemplo n.º 8
0
			bool MafwModelStrategy::alterStrategy_chain
					( RDFStrategyFlags flags, RDFStrategyFlags mask, QModelIndex const &index
					, InterfaceChain<ModelCommons> chain)
			{
				debug(2, model(), "MafwModelStrategy::alterStrategy") << model()->strategy();

				// diagnostics
				RDFStrategyFlags running_resp = mask & RDFStrategy::Running;

				if(running_resp & flags & ~model()->strategy(index))
				{
					warning(model(), "MafwModelStrategy::alterStrategy") << "re-enabling running not supported";
					return false;
				}

				// delegation
				if(!ContentModule_Simple::alterStrategy_chain
						(flags, mask & ~running_resp, index, chain))
					return false;

				// implementation
				if(running_resp & ~flags & model()->strategy(index))
				{
					debug(2, model(), "MafwModelStrategy::alterStrategy") << "turning off Running";

					model()->doDisableStrategyFlags(RDFStrategy::Running);

					if( ongoingID_ )
					{
						cancelQuery(ongoingID_);
						ongoingID_ = 0;
						model()->refreshModel(LiveNodeModel::Poll);
					}
				}
				return true;
			}
Exemplo n.º 9
0
QueryModel::~QueryModel()
{
    cancelQuery();
}
Exemplo n.º 10
0
FilterModel::~FilterModel()
{
    cancelQuery();
}
Exemplo n.º 11
0
static inline void newQueryCancellable(WlDictQuery * query)
{
    cancelQuery(query);
    query->cancel = g_cancellable_new();
}