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); } }
void toResultLock::query(const QString &sql, const toQueryParams ¶m) { 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
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 }
void toResultLong::query(const QString &sql, const toQueryParams ¶m) { 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(); }
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 }
void toResultLine::query(const QString &sql, const toQueryParams ¶m, 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 }
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; }