Esempio n. 1
0
void SociContainer::handleNotification(Dispatcher<SQLPreview::ActionEvent, QVariant, int> *oSource, SQLPreview::ActionEvent nEvent, QVariant oData, int nRows)
{
	UNUSED(oSource);

	Progress prg("Fetch columns...");
	StdString query;

	if(nEvent == SQLPreview::ActionEvent::EVENT_SQL_EXECUTE)
	{
		setTablename("");
		query = oData.value<StdString>();
		mPreviewLimit = nRows;
		setQuery(query);
		refreshPreview(query, mPreviewLimit);
	}
	else if(nEvent == SQLPreview::ActionEvent::EVENT_SQL_TOGGLE)
	{
		bool enabled = oData.value<bool>();
		if(enabled)
		{
			setTablename("");
			mPreviewLimit = mPreviewPanel->getPreviewLimit();
			query = mPreviewPanel->getQuery();
			setQuery(query);
			refreshPreview(query, mPreviewLimit);
		}
	}
}
BOOL CInventoryRequest::initInventory()
{
	CString csStateFile;

	if (m_bNotify)
		// Notify IP information changes
		setQuery( _T( "NOTIFY"), _T( "IP"));
	else
	{
		setQuery( _T( "INVENTORY"));

		/****	
		*
		* Package history inventory section
		*
		****/
		m_pLogger->log( LOG_PRIORITY_DEBUG, _T( "INVENTORY => Loading Download history"));
		if (!loadDownloadHistory())
		{
			m_pLogger->log( LOG_PRIORITY_DEBUG, _T("INVENTORY => Failed opening Download Package history file <%s>"), LookupError( GetLastError()));
		}
	}
	/******************/

	if( m_pDeviceid->getOldDeviceID() != _T("") )
		m_cmXml.AddChildElem( _T("OLD_DEVICEID"),m_pDeviceid->getOldDeviceID());
			
	/****	
	*
	* Get the Device netbios Name
	*
	****/

	m_pTheDB	= new CXMLInteract(&m_cmXml);
	m_pState	= new COCSInventoryState;
	m_pPluginState	= new COCSInventoryState;
	m_pSysInfo	= new CSysInfo( getAgentConfig()->isDebugRequired() >= OCS_DEBUG_MODE_TRACE, getDataFolder());

	m_Device.SetDeviceName( m_pDeviceid->getComputerName());
	// Get DeviceId from ocsinventoryFront
	m_Device.SetDeviceID( m_pDeviceid->getDeviceID() );

	/*****
	 *
	 *	Main inventory function
	 *
	 ****/
	// Get Device info
	if (!runInventory())
		return FALSE;

	// Read last inventory state from XML file
	m_pLogger->log( LOG_PRIORITY_DEBUG, _T( "INVENTORY => Reading last inventory state"));
	csStateFile.Format( _T("%s\\%s"), getDataFolder(), OCS_LAST_STATE_FILE);
	if (!m_pState->ReadFromFile( csStateFile, OCS_STATE_STANDARD_SECTION))
		m_pLogger->log( LOG_PRIORITY_WARNING, _T( "INVENTORY => Failed to load/parse inventory state from file <%s>"), csStateFile);
	if (!m_pPluginState->ReadFromFile( csStateFile, OCS_STATE_PLUGIN_SECTION))
		m_pLogger->log( LOG_PRIORITY_WARNING, _T( "INVENTORY => Failed to load/parse plugin state from file <%s>"), csStateFile);
	return TRUE;
}
int PointSqlQueryModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QSqlQueryModel::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: setQuery((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QSqlDatabase(*)>(_a[2]))); break;
        case 1: setQuery((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 2: setQuery((*reinterpret_cast< const QSqlQuery(*)>(_a[1]))); break;
        case 3: { QVariant _r = data((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< QVariant*>(_a[0]) = _r; }  break;
        case 4: refresh((*reinterpret_cast< double(*)>(_a[1])),(*reinterpret_cast< double(*)>(_a[2])),(*reinterpret_cast< double(*)>(_a[3]))); break;
        case 5: refreshSearch((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 6: { QVariant _r = datasingle((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QVariant*>(_a[0]) = _r; }  break;
        case 7: { bool _r = openDB();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 8: initDB(); break;
        case 9: closeDB(); break;
        case 10: { double _r = distance((*reinterpret_cast< double(*)>(_a[1])),(*reinterpret_cast< double(*)>(_a[2])),(*reinterpret_cast< double(*)>(_a[3])),(*reinterpret_cast< double(*)>(_a[4])));
            if (_a[0]) *reinterpret_cast< double*>(_a[0]) = _r; }  break;
        default: ;
        }
        _id -= 11;
    }
    return _id;
}
Esempio n. 4
0
void TableModel::DelRecord(const QString &aTblName, const QString &aCondition)
{
    QString str = query().executedQuery();
    emit BeforeRefresh();
    setQuery("DELETE FROM " + aTblName + " WHERE " + aCondition);
    setQuery(str);
    emit Refresh();
}
void Katapult::completeQuery()
{
    if(!bestMatch.isNull()) {
        QString newQuery = bestMatch.item()->text();
        setQuery("");
        setQuery(newQuery);
    }
}
void StopsQueryModel::showStops(int type) {
    qDebug() << "Showstops with type" << type;
    setQuery("SELECT * FROM stopstable WHERE type = 1 ORDER BY rank");
    if (type) {
//        QString query = QString("SELECT * FROM stopstable WHERE type = ") + QString::number(type) + QString(" OR favorite = 1 ORDER BY rank");
//        qDebug() << query;
//        setQuery(query);
    }
    else {
        setQuery("SELECT * FROM stopstable ORDER BY rank");
    }

}
Esempio n. 7
0
bool GameLibraryModel::select()
{
    const QString query = selectStatement();
    if (query.isEmpty())
        return false;

    beginResetModel();

//    d->clearCache();

    QSqlQuery qu(database());
    qu.prepare(query);
    for (auto &val : params) {
        qu.addBindValue(val);
    }
    qu.exec();
    setQuery(qu);

    if (!qu.isActive() || lastError().isValid()) {
        setTable(tableName()); // resets the record & index
        endResetModel();
        return false;
    }
    endResetModel();
    return true;
}
Esempio n. 8
0
 FactListModel(const Q& query, Wt::WObject *parent=0) :
     BaseQM(parent) {
     setQuery(query);
     addColumn("id", tr("facts.fact.id"));
     addColumn("text", tr("facts.fact.text"), Wt::ItemIsEditable);
     addColumn("when_added", tr("facts.common.when_added"));
 }
Esempio n. 9
0
void SmlAllModel::refresh(int orderColumn, int orderMode)
{
    QString orderString("");
    switch (orderColumn) {
    case 0: {
        if(orderMode) orderString = "ORDER by sml.smlid DESC";
        else orderString = "ORDER by sml.smlid ASC";
    }
    break;
    case 1: {
        if(orderMode) orderString = "ORDER by smla.author DESC";
        else orderString = "ORDER by smla.author ASC";
    }
    break;
    case 2: {
        if(orderMode) orderString = "ORDER by sml.title DESC";
        else orderString = "ORDER by sml.title ASC";
    }
    break;
    case 3: {
        if(orderMode) orderString = "ORDER by smlp.publisher DESC";
        else orderString = "ORDER by smlp.publisher ASC";
    }
    break;
    }

    QSqlQuery query("SELECT sml.smlid, smla.author, sml.title, smlp.publisher FROM sheetmusiclibrary sml, smlauthor smla, smlpublisher smlp WHERE smla.smlauthorid=sml.author AND smlp.smlpublisherid=sml.publisher "+orderString, *myW->getMyDb()->getMyPupilDb());
    setQuery(query);
    if (query.lastError().isValid()) qDebug() << "DB Error: 148 - " << query.lastError();

    setHeaderData(0, Qt::Horizontal, QObject::tr("Index"));
    setHeaderData(1, Qt::Horizontal, QObject::tr("Komponist / Author"));
    setHeaderData(2, Qt::Horizontal, QObject::tr("Titel"));
    setHeaderData(3, Qt::Horizontal, QObject::tr("Verlag"));
}
void SoundCloudSearchDialog::showHistoryDialog() {
    SearchHistoryDialog dialog(this);
    
    if (dialog.exec() == QDialog::Accepted) {
        setQuery(dialog.query());
    }
}
CProcessListTable::CProcessListTable (QWidget * parent, CMySQLServer *m)
: CQueryTable(parent, 0, m, "CProcessListTable")
{
  bool notnew = m->mysql()->version().major <= 3 && m->mysql()->version().minor <= 22;

  sql = "SHOW ";
  if (!notnew)
    sql += "FULL ";
  sql += "PROCESSLIST";

  setKeepColumnWidth(true);
  qry = new CMySQLQuery(m->mysql());
  qry->setEmitMessages(false);
  setQuery(qry);

  columnsWindow = new CTableFieldChooser(0, this, "CProcessListTableColumnsWindow");
  setCaption(tr("Process List"));
  columnsWindow->setCaption("[" + m->connectionName() + "] " + tr("Process List Columns"));
  verticalHeader()->hide();
  setFocusStyle(QTable::FollowStyle);
  setSelectionMode(QTable::MultiRow);
  setLeftMargin(0);
  is_first = true;
  setReadOnly(false);
  refresh();
}
Esempio n. 12
0
//! [0]
void DeviceModel::refresh()
{
    setQuery("SELECT * FROM tab_devices ORDER BY d_typeID, d_producer, d_name");
    setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
    setHeaderData(1, Qt::Horizontal, QObject::tr("First name"));
    setHeaderData(2, Qt::Horizontal, QObject::tr("Last name"));
}/*
Esempio n. 13
0
void QgsSpatialQuery::runQuery( QgsFeatureIds &qsetIndexResult,
                                QgsFeatureIds &qsetIndexInvalidTarget,
                                QgsFeatureIds &qsetIndexInvalidReference,
                                int relation, QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
{
    setQuery( lyrTarget, lyrReference );

    // Create Spatial index for Reference - Set mIndexReference
    mPb->setFormat( QObject::tr( "Processing 1/2 - %p%" ) );
    int totalStep = mUseReferenceSelection
                    ? mLayerReference->selectedFeatureCount()
                    : ( int )( mLayerReference->featureCount() );
    mPb->init( 1, totalStep );
    setSpatialIndexReference( qsetIndexInvalidReference ); // Need set mLayerReference before

    // Make Query
    mPb->setFormat( QObject::tr( "Processing 2/2 - %p%" ) );
    totalStep = mUseTargetSelection
                ? mLayerTarget->selectedFeatureCount()
                : ( int )( mLayerTarget->featureCount() );
    mPb->init( 1, totalStep );

    execQuery( qsetIndexResult, qsetIndexInvalidTarget, relation );

} // QSet<int> QgsSpatialQuery::runQuery( int relation)
Esempio n. 14
0
 void set_query() {
     dbo::Transaction t(tApp->session());
     ULP::Q q;
     if (only_blocked_) {
         q = tApp->session().query<UserPtr>(
                 "select U from thechess_message_filter F "
                 "left join thechess_user U on F.bad_id = U.id");
         q.where("F.good_id = ?").bind(tApp->user());
     } else {
         q = tApp->session().find<User>();
     }
     if (not_removed_) {
         q.where("rights != ?").bind(NONE);
         q.where("vacation_until is null");
         q.where("last_online > ?").bind(now() - 10 * WEEK);
     }
     if (only_online_) {
         q.where("last_online >= ?");
         q.bind(now() - Options::instance()->away_timeout());
     }
     if (!name_like_.empty()) {
         q.where("(username like ? or id = ?)");
         q.bind("%" + name_like_ + "%");
         q.bind(Wt::Wc::str2int(name_like_.toUTF8()));
     }
     q.orderBy("games_stat_elo desc");
     setQuery(q, /* keep_columns */ true);
 }
Esempio n. 15
0
/*!
  Sets this QXmlQuery to the XQuery read from the \a queryURI.  Use
  isValid() after calling this function. If an error occurred reading
  \a queryURI, e.g., the query does not exist, cannot be read, or is
  invalid, isValid() will return \e false.

  The supported URI schemes are the same as those in the XQuery
  function \c{fn:doc}, except that queryURI can be the object of
  a variable binding.

  \a baseURI is the Base URI of the static context, as defined in the
  \l {http://www.w3.org/TR/xquery/}{XQuery language}. It is used
  internally to resolve relative URIs that appear in the query, and
  for message reporting. If \a baseURI is empty, \a queryURI is used.
  Otherwise, \a baseURI is used, and it is resolved against the \l
  {QCoreApplication::applicationFilePath()} {application file path} if
  it is relative.

  If \a queryURI is empty or invalid, or if \a baseURI is invalid,
  the behavior of this function is undefined.
 */
void QXmlQuery::setQuery(const QUrl &queryURI, const QUrl &baseURI)
{
    Q_ASSERT_X(queryURI.isValid(), Q_FUNC_INFO, "The passed URI must be valid.");

    const QUrl canonicalURI(QPatternist::XPathHelper::normalizeQueryURI(queryURI));
    Q_ASSERT(canonicalURI.isValid());
    Q_ASSERT(!canonicalURI.isRelative());
    Q_ASSERT(baseURI.isValid() || baseURI.isEmpty());

    d->queryURI = QPatternist::XPathHelper::normalizeQueryURI(baseURI.isEmpty() ? queryURI : baseURI);

    QPatternist::AutoPtr<QIODevice> result;

    try
    {
        result.reset(QPatternist::AccelTreeResourceLoader::load(canonicalURI, d->m_networkAccessDelegator,
                                                                d->staticContext()));
    }
    catch(const QPatternist::Exception)
    {
        /* We do nothing, result will be 0. */
    }

    if(result)
    {
        setQuery(result.data(), d->queryURI);
        result->close();
    }
    else
        d->recompileRequired();
}
void Katapult::keyReleased(QKeyEvent *e)
{
    if(e->key() == Key_BackSpace) {
        if(hideTimer->isActive())
            hideTimer->stop();
        if(clearTimer->isActive())
            clearTimer->stop();
        QString newQuery = _query.left(_query.length()-1);
        setQuery("");
        setQuery(newQuery);
    } else {
        char c;
        if((c = e->ascii()) >= 32)
            setQuery(_query + c);
    }
}
Esempio n. 17
0
void AlarmsLogQueryModel::refresh(const QDate& date1, const QDate& date2)
{
  QSqlQuery query;
  query.prepare("SELECT l.id, l.date_, l.act, l.q, e.text, l.gg, l.zzz "
	   ",l.isRead,e.type,e.isAlert "
	   "FROM tb_logs l "
	   ",tb_events e "
	   "WHERE l.eee=e.id "
	   "AND DATE(l.date_)>=:date1 "
	   "AND DATE(l.date_)<=:date2 "
	   "ORDER BY l.date_ DESC");
  query.bindValue(":date1", date1);
  query.bindValue(":date2", date2);
  query.exec();

  setQuery(query);
  setHeaderData(Date,
  		Qt::Horizontal, trUtf8("Дата"));
  setHeaderData(Act, Qt::Horizontal, trUtf8("ACT"));
  setHeaderData(Q, Qt::Horizontal, trUtf8("Q"));
  setHeaderData(Eee, Qt::Horizontal, trUtf8("EEE"));
  setHeaderData(Gg, Qt::Horizontal, trUtf8("GG"));
  setHeaderData(Zzz, Qt::Horizontal, trUtf8("ZZZ"));
  setHeaderData(Type, Qt::Horizontal, trUtf8("Type"));
}
Esempio n. 18
0
bool SalesModel::setProperty(int rowIndex, const QString &property, const QVariant &value)
{

    QVariantMap rowValues = getProperty(rowIndex);
    const char * UPDATE_STAMENT="UPDATE items_sales set price = :price WHERE prov = :prov and ref = :ref "
            "and size = :size and color = :color and sales_date = :sales_date;";
    m_updateQuery.prepare(UPDATE_STAMENT);
    m_updateQuery.bindValue(":ref",rowValues["ref"]);
    m_updateQuery.bindValue(":size",rowValues["size"]);
    m_updateQuery.bindValue(":color",rowValues["color"]);
    m_updateQuery.bindValue(":prov",rowValues["prov"]);
    m_updateQuery.bindValue(":sales_date",rowValues["date"]);
    m_updateQuery.bindValue(":price", value);
    if(!m_updateQuery.exec()){
        qWarning()<<"could no update sales "<<m_updateQuery.lastQuery();
        return false;

    }
    qDebug()<<"price updated "<<value;
    QHash<int, QByteArray> roles = roleNames();
    QModelIndex ind = index(rowIndex,roles.key("price"));
    QSqlQuery q = query();
    q.exec();
    setQuery(q);

    emit dataChanged(ind,ind);
    return true;

}
Esempio n. 19
0
void EditableSqlModel::refresh()
{
    setQuery("select * from person");
    setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
    setHeaderData(1, Qt::Horizontal, QObject::tr("First name"));
    setHeaderData(2, Qt::Horizontal, QObject::tr("Last name"));
}
Esempio n. 20
0
MetaSQLQuery::MetaSQLQuery(const QString & query) {
    _data = new MetaSQLQueryPrivate();
    _source = QString::null;

    if(!query.isEmpty()) {
        setQuery(query);
    }
}
void SqlQueryModel::reload()
{
    if (query().exec()) {
        setQuery(query());
    } else {
        qCritical() << tr("Echec de ré-execution de la requète %1 : %2").arg(query().lastQuery()).arg(lastError().text());
    }
}
Esempio n. 22
0
void SeasonListModel::select()
{
	QSqlQuery query;
	query.prepare("SELECT * FROM season WHERE show_id=:show_id");
	query.bindValue(":show_id", _show);
	query.exec();
	setQuery(query);
}
void EmployeeTableModel::refresh()
{
    clear();
    setQuery(selectQ, QSqlDatabase::database("KarbowyDb"));
    setHeaderData(EMPLOYEE_COLUMN_LOGIN, Qt::Horizontal, "Login");
    setHeaderData(EMPLOYEE_COLUMN_PASSWORD, Qt::Horizontal, "Hasło");
    setHeaderData(EMPLOYEE_COLUMN_NAME, Qt::Horizontal, "Imię i nazwisko");
}
Esempio n. 24
0
void EpisodeListModel::select()
{
	QSqlQuery query;
	query.prepare("SELECT * FROM episode WHERE show_id=:show_id AND season=:season");
	query.bindValue(":show_id", _show);
	query.bindValue(":season", _season);
	query.exec();
	setQuery(query);
}
Esempio n. 25
0
void OrderLineModel::setToEmptyModel()
{
	//! TODO : verify
    setQuery("");

    setHeaderData(OrderLineField_id, Qt::Horizontal, tr("EMPTY"));
    setHeaderData(OrderLineField_name, Qt::Horizontal, tr("EMPTY"));
    setHeaderData(OrderLineField_price, Qt::Horizontal, tr("EMPTY"));
}
void ZipCountryModel::filterCity(const QString &name)
{
    if (m_City==name)
        return;
    m_City=name;
    QString req = QString("SELECT ZIP, CITY FROM ZIPS WHERE `COUNTRY`='%1' AND `CITY` like '%2%' ORDER BY CITY ASC LIMIT 0, 20")
            .arg(m_Country).arg(name);
    setQuery(req, db);
}
void ZipCountryModel::filterZipCode(const QString &zipCode)
{
    if (m_Zip==zipCode)
        return;
    m_Zip=zipCode;
    QString req = QString("SELECT ZIP, CITY FROM ZIPS WHERE `COUNTRY`='%1' AND `ZIP` like '%2%' ORDER BY ZIP LIMIT 0, 20")
            .arg(m_Country).arg(zipCode);
    setQuery(req, db);
}
Esempio n. 28
0
TableModel::TableModel(DbConnection &db, QString table, QObject *parent) :
    SqlModel(db, parent),
    tableName(table),
    where(Filter{})
{
    rowsLimit = 100;
    setQuery("SELECT * FROM \"" + table + "\"");
     //todo move all row limiting into this class?
}
void SearchSuggester::setSearchEngine(const QString &searchEngine)
{
	const QString query(m_query);

	m_searchEngine = searchEngine;
	m_query.clear();

	setQuery(query);
}
Esempio n. 30
0
ApplyMarkQuery::ApplyMarkQuery(QString auth_token, QString channel, QString title,
QString link, QString description, qreal latitude,
qreal longitude, QString time, QObject *parent)
: QObject(parent)
{
  manager = new QNetworkAccessManager(this);
  setQuery(auth_token, channel, title, link, description, latitude, longitude, time);
  qDebug() << "ApplyMarkQuery created:\n"
    << httpQuery << jsonQuery;
}