Example #1
0
void toResultItem::query(const QString &sql, toQueryParams const& param)
{
    if (!setSqlAndParams(sql, param))
        return ;

    start();
    if (!handled() || Query)
    {
        if (!Query)
            done();
        return ;
    }

    try
    {
        if (Query)
        {
            delete Query;
            Query = NULL;
        }
        Query = new toEventQuery(this
                                 , connection()
                                 , sql
                                 , param
                                 , toEventQuery::READ_ALL);
        connect(Query, SIGNAL(dataAvailable(toEventQuery*)), this, SLOT(slotPoll()));
        connect(Query, SIGNAL(done(toEventQuery*)), this, SLOT(slotQueryDone()));
        Query->start();
    }
    catch (const QString &str)
    {
        done();
        Utils::toStatusMessage(str);
    }
}
Example #2
0
void toResultLock::query(const QString &sql,
                         const toQueryParams &param)
{
    if (!handled())
        return ;

    if (!setSqlAndParams(sql, param))
        return ;

    if (Query)
    {
        delete Query;
        Query = NULL;
    }
    clear();
    Checked.clear();

    try
    {
        LastItem = NULL;
        if (!sql.isEmpty())
        {
            Query = new toEventQuery(this, connection(), toSQL::string(SQLLock, connection()), toQueryParams() << sql, toEventQuery::READ_ALL);
        }
        else
        {
            Query = new toEventQuery(this, connection(), toSQL::string(SQLBlockingLock, connection()), toQueryParams(), toEventQuery::READ_ALL);
        }
        startQuery();
    }
    TOCATCH
} // query
Example #3
0
void toResultCombo::query(const QString &sql, toQueryParams const& param)
{
    if (!setSqlAndParams(sql, param))
        return ;

    try
    {
        SelectedFound = false;
        blockSignals(true); // Do not emit currentIndexChanged when 1st field is inserted
        clear();
        addItems(Additional);
        for (int i = 0; i < Additional.count(); i++)
            if (Additional[i] == Selected)
                setCurrentIndex(i);
        {
            //Q_ASSERT_X(Query == NULL , qPrintable(__QHERE__), "toResultCombo query while BG is running");
            if (Query)
            {
                Query->disconnect(this);
                delete Query;
                Query = NULL;
            }
            Query = new toEventQuery(this, connection(), sql, param, toEventQuery::READ_ALL);
            connect(Query, SIGNAL(dataAvailable(toEventQuery*)), this, SLOT(slotPoll()));
            connect(Query, SIGNAL(done(toEventQuery*)), this, SLOT(slotQueryDone()));
            Query->start();
        }
    }
    TOCATCH
}
Example #4
0
void toResultLong::query(const QString &sql, const toQueryParams &param)
{
    setSqlAndParams(sql, param);
    slotStop();
    Query = NULL;
    LastItem = NULL;
    RowNumber = 0;
    First = true;

    clear();

    setSorting( -1);

    if (NumberColumn)
    {
        addColumn(QString::fromLatin1("#"));
        setColumnAlignment(0, Qt::AlignRight);
    }

    if (Filter)
        Filter->startingQuery();

    try
    {
        Query = new toEventQuery(this
                                 , connection()
                                 , sql
                                 , param
                                 //, Statistics
                                 , toEventQuery::READ_ALL
                                );
        connect(Query, SIGNAL(dataAvailable(toEventQuery*)), this, SLOT(slotAddItem()));
        connect(Query, SIGNAL(done(toEventQuery*)), this, SLOT(slotQueryDone()));
        if (ReadAll)
        {
            MaxNumber = -1;
            //// Query->slotReadAll(); // indicate that all records should be fetched
        }
        else
            MaxNumber = toConfigurationNewSingle::Instance().option(ToConfiguration::Database::InitialFetchInt).toInt();
        Query->start();
    }
    catch (const toConnection::exception &str)
    {
        First = false;
        emit firstResult(toResult::sql(), str, true);
        emit done();
        //// if (Mode != toQuery::Long)
        Utils::toStatusMessage(str);
    }
    catch (const QString &str)
    {
        First = false;
        emit firstResult(toResult::sql(), str, true);
        emit done();
        //// if (Mode != toQuery::Long)
        Utils::toStatusMessage(str);
    }
    updateContents();
}
Example #5
0
void toResultField::query(const QString &sql, toQueryParams const& param)
{
    if (!setSqlAndParams(sql, param))
        return ;

    setFilename(QString::null);

    try
    {
        clear();
        Unapplied = QString::null;
        if (Query)
        {
            delete Query;
            Query = NULL;
        }

        Query = new toEventQuery(this
                                 , connection()
                                 , sql
                                 , param
                                 , toEventQuery::READ_ALL);
        connect(Query, SIGNAL(dataAvailable(toEventQuery*)), this, SLOT(slotPoll()));
        connect(Query, SIGNAL(done(toEventQuery*, unsigned long)), this, SLOT(slotQueryDone()));
        Query->start();
    }
    TOCATCH
}
Example #6
0
void toResultLine::query(const QString &sql, const toQueryParams &param, bool first)
{
    if (!handled() || Query)
        return ;
#if 0
    start();
#endif
    setSqlAndParams(sql, param);

    try
    {
        First = first;
        Query = new toEventQuery(this, connection(), sql, param, toEventQuery::READ_ALL);
        connect(Query, SIGNAL(dataAvailable()), this, SLOT(poll()));
        connect(Query, SIGNAL(done()), this, SLOT(queryDone()));
        Query->start();
    }
    TOCATCH
}
Example #7
0
void toResultTableView::querySub(QSharedPointer<toConnectionSubLoan> &con, const QString &sql, toQueryParams const& param)
{
    setSqlAndParams(sql, param);

    TLOG(7, toDecorator, __HERE__) << "Query from toResultTableView::querySub :" << sql << std::endl;
    try
    {
        if (Model && running())
            Model->stop();
        freeModel();

        readAllAct->setEnabled(true);
        Ready = false;
        Finished = false;
        Working->setText(tr("Please wait..."));
        Working->hide();

        // sets visible true but won't show if parent is hidden
        QTimer t(this);
        t.singleShot(300, Working, SLOT(forceShow()));

        toEventQuery *query = new toEventQuery(this
                                               , con
                                               , sql
                                               , param
                                               , toEventQuery::READ_FIRST
                                               //, Statistics
                                              );

        toResultModel *model = allocModel(query);
        setModel(model);

        connect(Model, SIGNAL(done()), this, SLOT(slotHandleDone()));
        connect(Model, SIGNAL(modelReset()), this, SLOT(slotHandleReset()));
        connect(Model,
                SIGNAL(firstResult(const toConnection::exception &, bool)),
                this,
                SLOT(slotHandleFirst(const toConnection::exception &, bool)));
        setSortingEnabled(true);
        query->start();
    }
    catch (const toConnection::exception &str)
    {
        emit firstResult(toResult::sql(), str, true);
        emit done();
        slotHandleDone();
        Utils::toStatusMessage(str);
    }
    catch (const QString &str)
    {
        emit firstResult(toResult::sql(), str, true);
        emit done();
        slotHandleDone();
        Utils::toStatusMessage(str);
    }

    verticalHeader()->setVisible(false);
    verticalHeader()->setDefaultSectionSize(QFontMetrics(QFont()).height() + 4);

    horizontalHeader()->setHighlightSections(false);

    // when a new model is created the column sizes are lost
    ColumnsResized = false;
}