示例#1
0
/* When the widget is first shown, set up table mappings if they exist*/
void ScreenControl::showEvent(QShowEvent *event)
{
  if (DEBUG)
    qDebug("ScreenControl::showEvent() entered with mode = %d and shown %d",
           _mode, _shown);
  if(!_shown)
  {
    _shown = true;
    setTable(_schemaName, _tableName);

    // now set the sort order
    for (int i = 0; i < _model->columnCount(); i++)
    { 
      if (_model->headerData(i,Qt::Horizontal,Qt::DisplayRole).toString() == _sortColumn)
      {
        _model->setSort(i, Qt::AscendingOrder);
        break;
      }
    }

    if (_mode != New)
      search();
  }
  QWidget::showEvent(event);
  if (DEBUG)
    qDebug("ScreenControl::showEvent() returning");
}
示例#2
0
void HiddenTableModel::setTableModel(int id) {
    Q_UNUSED(id);
    QSqlQuery query;
    const QString tableName("hidden_songs");

    QStringList columns;
    columns << "library." + LIBRARYTABLE_ID;
    QString filter("mixxx_deleted=1");
    query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS " + tableName + " AS "
                  "SELECT "
                  + columns.join(",") +
                  " FROM library "
                  "INNER JOIN track_locations "
                  "ON library.location=track_locations.id "
                  "WHERE " + filter);
    if (!query.exec()) {
        qDebug() << query.executedQuery() << query.lastError();
    }

    //Print out any SQL error, if there was one.
    if (query.lastError().isValid()) {
        qDebug() << __FILE__ << __LINE__ << query.lastError();
    }

    QStringList tableColumns;
    tableColumns << LIBRARYTABLE_ID;
    setTable(tableName, LIBRARYTABLE_ID, tableColumns,
             m_pTrackCollection->getTrackSource());
    setDefaultSort(fieldIndex("artist"), Qt::AscendingOrder);
    setSearch("");
}
示例#3
0
void cNPC::save()
{
	if ( changed_ )
	{
		initSave;
		setTable( "npcs" );

		addField( "serial", serial() );
		addField( "summontime", summonTime_ ? summonTime_ - Server::instance()->time() : 0 );
		addField( "additionalflags", additionalFlags_ );
		addField( "owner", owner_ ? owner_->serial() : INVALID_SERIAL );
		addField( "stablemaster", stablemasterSerial_ );
		addStrField( "ai", aiid_ );
		addField( "wandertype", ( Q_UINT8 ) wanderType() );
		addField( "wanderx1", wanderX1() );
		addField( "wanderx2", wanderX2() );
		addField( "wandery1", wanderY1() );
		addField( "wandery2", wanderY2() );
		addField( "wanderradius", wanderRadius() );

		addCondition( "serial", serial() );
		saveFields;
	}

	cBaseChar::save();
}
示例#4
0
void cNPC::save()
{
	if ( changed_ )
	{
		initSave;
		setTable( "npcs" );

		addField( "serial", serial() );
		addField( "mindamage", minDamage_);
		addField( "maxdamage", maxDamage_);
		addField( "tamingminskill", tamingMinSkill_);
		addField( "summontime", summonTime_ ? summonTime_ - uiCurrentTime : 0 );
		addField( "additionalflags", additionalFlags_ );
		addField( "owner", owner_ ? owner_->serial() : INVALID_SERIAL );
		addStrField( "carve", carve_);
		addStrField( "spawnregion", spawnregion_);
		addField( "stablemaster", stablemasterSerial_ );
		addStrField( "lootlist", lootList_);
		addStrField( "ai", aiid_ );
		addField( "wandertype", (UINT8)wanderType() );
		addField( "wanderx1", wanderX1() );
		addField( "wanderx2", wanderX2() );
		addField( "wandery1", wanderY1() );
		addField( "wandery2", wanderY2() );
		addField( "wanderradius", wanderRadius() );
		addField( "fleeat", criticalHealth() );
		addField( "spellslow", spellsLow_ );
		addField( "spellshigh", spellsHigh_ );
		addField( "controlslots", controlSlots_ );

		addCondition( "serial", serial() );
		saveFields;
	}
	cBaseChar::save();
}
示例#5
0
MEstablecimiento::MEstablecimiento( QObject *parent )
 : QSqlTableModel( parent )
{
 setTable( "car_establecimientos" );
 setHeaderData( 0, Qt::Horizontal, "#ID" );
 setHeaderData( 1, Qt::Horizontal, "Nombre" );
 setHeaderData( 2, Qt::Horizontal, "#RESMPA" );
}
示例#6
0
MDescuentos::MDescuentos(QObject *parent) :
QSqlTableModel(parent)
{
    setTable( "descuentos" );
    _seleccionado = false;
    _id_comprobante = -1;
    _tipo = Invalido;
}
示例#7
0
void XTreeView::select()
{
  setTable();
  _model->select();
  
  emit valid(FALSE);

}
示例#8
0
/*!
	Performs persistency layer saves.
*/
void cUObject::save()
{
	bool havetags_ = ( tags_.size() > 0 );
	// uobjectmap fields

	// If the type is changed somewhere in the code
	// That part needs to take care of delete/recreate
	// So we never update the type EVER here..
	if( !isPersistent )
	{
		initSave;
		setTable( "uobjectmap" );
		addField( "serial", serial_ );
		addStrField( "type", QString( objectID() ) );
		addCondition( "serial", serial_ );
		saveFields;
		clearFields;
	}

	// uobject fields
	if ( changed_ )
	{
		initSave;
		setTable( "uobject" );
		addStrField( "name", name_ );
		addField( "serial", serial_ );
		addField( "multis", multis_ );
		addField( "direction", dir_);
		addField( "pos_x", pos_.x );
		addField( "pos_y", pos_.y );
		addField( "pos_z", pos_.z );
		addField( "pos_map", pos_.map );
		addStrField( "events", eventList_ == QString::null ? QString( "" ) : eventList_ );
		addStrField( "bindmenu", bindmenu_ );
		addCondition( "serial", serial_ );
		addField( "havetags", havetags_ );
		saveFields;
	}
	if( havetags_ )
	{
		tags_.save( serial_ );
	}

	PersistentObject::save();
	flagUnchanged(); // This is the botton of the chain, now go up and flag everyone unchanged.
}
示例#9
0
ContextModel::ContextModel(QObject *parent) :
    QSqlTableModel(parent)
{
    setTable("context");
    setSort(fieldIndex("shortdescr"), Qt::AscendingOrder);

    select();
}
示例#10
0
/*!
	Performs persistency layer saves.
*/
void cUObject::save()
{
	bool havetags_ = ( tags_.size() > 0 );
	// uobjectmap fields
	initSave;

	// If the type is changed somewhere in the code
	// That part needs to take care of delete/recreate
	// So we never update the type EVER here..
	if( !isPersistent )
	{
		setTable( "uobjectmap" );
		addField( "serial", serial_ );
		addStrField( "type", objectID() );
		addCondition( "serial", serial_ );
		saveFields;
		clearFields;
	}
	
	// uobject fields
	if ( changed_ )
	{
		setTable( "uobject" );	
		addStrField( "name", name_ );
		addField( "serial", serial_ );
		addField( "multis", multis_ );
		addField( "pos_x", pos_.x );
		addField( "pos_y", pos_.y );
		addField( "pos_z", pos_.z );
		addField( "pos_map", pos_.map );
		addStrField( "events", eventList_.join( "," ) );
		addStrField( "bindmenu", bindmenu_ );
		addCondition( "serial", serial_ );
		addField( "havetags", havetags_ );
		saveFields;
	}
	if( havetags_ )
	{
		tags_.save( serial_ );
	}


	PersistentObject::save();
	changed_ = false;

}
示例#11
0
ContentTypesModel::ContentTypesModel(int id, QObject *parent, QSqlDatabase db) :
	QSqlRelationalTableModel(parent, db) {
	_id = id;
	_f = "";
	_begin = 0;
	_limit = 25;
	setTable("app_content_type");
}
示例#12
0
/* When the widget is first shown, set up table mappings if they exist*/
void formControl::showEvent(QShowEvent *event)
{
  if(!_shown)
  {
    _shown = true;
    setTable(_schemaName, _tableName);
  }
  QWidget::showEvent(event);
}
示例#13
0
DTScheduleModel::DTScheduleModel(QObject *parent, QSqlDatabase db) :
    QSqlTableModel(parent, db),
    mStartDate(QDate()),
    mEndDate(QDate()),
    mStartColIndex(-1),
    mDurationColIndex(-1)
{
    setTable("RECEPTION");
}
示例#14
0
MPrefCategorias::MPrefCategorias(QObject *parent)
 : QSqlTableModel(parent)
{
 setTable( "car_categorias" );
 setHeaderData( 0, Qt::Horizontal, "#id_db" );
 setHeaderData( 1, Qt::Horizontal, "Categoria" );
 setHeaderData( 2, Qt::Horizontal, "Especial" );
 setEditStrategy( QSqlTableModel::OnManualSubmit );
}
示例#15
0
MCajas::MCajas(QObject *parent ) :
QSqlTableModel(parent)
{
    setTable( "caja" );
    this->setHeaderData( 0, Qt::Horizontal, "#ID" );
    this->setHeaderData( 1, Qt::Horizontal, "Nombre" );
    this->setHeaderData( 2, Qt::Horizontal, "Fecha de Alta"  );
    this->setHeaderData( 3, Qt::Horizontal, "Saldo Actual" );
}
示例#16
0
MealModel::MealModel(int meal, QObject *parent) : QSqlRelationalTableModel(parent), meal(meal)
{
    setTable("menu");
    setRelation(2, QSqlRelation("recipes", "id", "name"));
    setFilter(QString("meal='%1'").arg(meal));
    sort(2, Qt::AscendingOrder);
    select();

    setSupportedDragActions(Qt::MoveAction);
}
ReferTableModel::ReferTableModel(QObject *parent)
{
    setTable("referNode");
    setSort(1, Qt::AscendingOrder);
    setHeaderData(1, Qt::Horizontal, tr("NetID"));
    setHeaderData(2, Qt::Horizontal, tr("Floor"));
    setHeaderData(3, Qt::Horizontal, tr("Number"));
    setHeaderData(4, Qt::Horizontal, tr("TMP_Period"));
    select();
}
示例#18
0
MVPresupuestos::MVPresupuestos(QObject *parent) :
    QSqlRelationalTableModel(parent)
{
    setTable( "v_presupuestos" );
    setHeaderData( 0, Qt::Horizontal, "#ID" );
    setHeaderData( 1, Qt::Horizontal, "#Presupuesto" );
    setHeaderData( 2, Qt::Horizontal, "Destinatario" );
    setHeaderData( 3, Qt::Horizontal, "Fecha" );
    setHeaderData( 4, Qt::Horizontal, "Total" );
}
示例#19
0
void BaseExternalTrackModel::setTableModel(int id) {
    Q_UNUSED(id);
    QStringList columns;
    columns << "id";
    // TODO(XXX) preview column, needs a temporary view
    setTable(m_trackTable, columns[0], columns,
             m_pTrackCollection->getTrackSource(m_trackSource));
    setDefaultSort(fieldIndex("artist"), Qt::AscendingOrder);
    initHeaderData();
}
示例#20
0
MCompraProducto::MCompraProducto(QObject *parent)
 : QSqlRelationalTableModel(parent)
{
 setTable( "compras_productos" );
 setHeaderData( 0, Qt::Horizontal, "#item" );
 setHeaderData( 1, Qt::Horizontal, "#Compra" );
 setHeaderData( 2, Qt::Horizontal, "#Producto" );
 setHeaderData( 3, Qt::Horizontal, "Precio Compra" );
 setHeaderData( 4, Qt::Horizontal, "Cantidad" );
}
PoitemTableModel::PoitemTableModel(QObject * parent, QSqlDatabase db) :
  QSqlRelationalTableModel(parent, db)
{
  setTable("poitem");

  // select statement on which everything else is based
  _selectStatement =
      QString("SELECT pohead_number, "
	     "       item_id, item_number,"
	     "       warehous_id, warehous_code,"
	     "       poitem_unitprice * poitem_qty_ordered AS extprice,"
	     "       prj_number,"
	     "       expcat_code,"
	     "       0 AS itemsrc_minordqty, 0 AS itemsrc_multordqty, "
	     "       1 AS itemsrc_invvendoruomratio,"
	     "       CURRENT_DATE AS earliestdate, "
	     "       poitem.* "
	     "FROM pohead"
	     "     JOIN poitem ON (poitem_pohead_id=pohead_id)"
	     "     LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)"
	     "     LEFT OUTER JOIN item ON (itemsite_item_id=item_id)"
	     "     LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id)"
	     "     LEFT OUTER JOIN prj ON (poitem_prj_id=prj_id)"
	     "     LEFT OUTER JOIN expcat ON (poitem_expcat_id=expcat_id)"
	     );

  setEditStrategy(QSqlTableModel::OnManualSubmit); // OnRow?
  setSort(POITEM_LINENUMBER_COL, Qt::AscendingOrder);

  // insert only those columns not directly part of the poitem table
  insertColumns(0, 7);

  setHeaderData(POITEM_LINENUMBER_COL,	Qt::Horizontal, tr("#"));
  setHeaderData(ITEM_NUMBER_COL,	Qt::Horizontal, tr("Item"));
  setHeaderData(WAREHOUS_CODE_COL,	Qt::Horizontal, tr("Supplying Site"));
  setHeaderData(POITEM_VEND_ITEM_NUMBER_COL, Qt::Horizontal, tr("Vend Item #"));
  setHeaderData(POITEM_VEND_ITEM_DESCRIP_COL,Qt::Horizontal, tr("Vend Description"));
  setHeaderData(POITEM_VEND_UOM_COL,	Qt::Horizontal, tr("Vend UOM"));
  setHeaderData(POITEM_QTY_ORDERED_COL,	Qt::Horizontal, tr("Qty."));
  setHeaderData(POITEM_UNITPRICE_COL,	Qt::Horizontal, tr("Unit Price"));
  setHeaderData(EXTPRICE_COL,		Qt::Horizontal, tr("Ext. Price"));
  setHeaderData(POITEM_FREIGHT_COL,	Qt::Horizontal, tr("Freight"));
  setHeaderData(POITEM_DUEDATE_COL,	Qt::Horizontal, tr("Due Date"));
  setHeaderData(PRJ_NUMBER_COL,		Qt::Horizontal, tr("Project #"));
  setHeaderData(EXPCAT_CODE_COL,	Qt::Horizontal, tr("Expense Cat."));

  _poheadid	= -1;
  _poitemid	= -1;
  findHeadData();
  _dirty = false;

  select();

  connect(this, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(markDirty(QModelIndex, QModelIndex)));
}
示例#22
0
QueueModel::QueueModel(QObject *parent, QSqlDatabase db) :
    QSqlRelationalTableModel(parent, db)
{
    setTable("queuesongs");
    setSinger(-1);
    setRelation(3, QSqlRelation("dbsongs", "songid", "artist"));
    setRelation(4, QSqlRelation("dbsongs", "songid", "title"));
    setRelation(5, QSqlRelation("dbsongs", "songid", "discid"));
    setRelation(6, QSqlRelation("dbsongs", "songid", "path"));
    setSort(9, Qt::AscendingOrder);
}
示例#23
0
MMascota::MMascota( QObject *parent )
 : QSqlRelationalTableModel( parent )
{
 setTable( "mascota" );
 setHeaderData( 0, Qt::Horizontal, "#ID" );
 setHeaderData( 1, Qt::Horizontal, "Dueño" );
   setRelation( 1, QSqlRelation( "dueno", "id", "apellido" ) );
 setHeaderData( 2, Qt::Horizontal, "Nombre" );
 setHeaderData( 3, Qt::Horizontal, "Raza" );
 setHeaderData( 4, Qt::Horizontal, "Genero" );
}
示例#24
0
void StreamTableModel2::setFrom(int startTime, int duration )
{
//    setFilter(QString("(streamid=%1) AND (startime > %2)").arg(m_StreamId).arg(startTime) );
    setTable("event");
    generateRoleNames();
    setFilter(QString("(streamid=%1) AND (startime BETWEEN %2 AND %3)").arg(m_StreamId).arg(startTime).arg(startTime + duration) );
    bool ret = select();
    if(!ret){
        qDebug() << "select failed";
    }
}
MobileTableModel::MobileTableModel(QObject *parent)
{
    setTable("mobileConfig");
    setSort(1, Qt::AscendingOrder);
    setHeaderData(1, Qt::Horizontal, tr("FixID"));
    setHeaderData(2, Qt::Horizontal, tr("Mode"));
    setHeaderData(3, Qt::Horizontal, tr("DST Address"));
    setHeaderData(4, Qt::Horizontal, tr("Period"));
    setHeaderData(5, Qt::Horizontal, tr("Self Address"));
    select();
}
	HStringTable StringTableManager::getTable(UINT32 id)
	{
		auto iterFind = mTables.find(id);
		if (iterFind != mTables.end())
			return iterFind->second;

		HStringTable newTable = StringTable::create();
		setTable(id, newTable);

		return newTable;
	}
示例#27
0
AboCommentsModel::AboCommentsModel(const QString &telA, QObject *parent)
  : QSqlTableModel(parent)
{
  setTable("tb_abonentNotes");
  setFilter(QString("telA=%1").arg(telA));
  select();
  
  setHeaderData(TelA, Qt::Horizontal, trUtf8("Телефон"));
  setHeaderData(Date, Qt::Horizontal, trUtf8("Дата"));
  setHeaderData(Text, Qt::Horizontal, trUtf8("Примечание"));
}
void BaseExternalPlaylistModel::setPlaylist(QString playlist_path) {
    QSqlQuery finder_query(m_database);
    finder_query.prepare(QString("SELECT id from %1 where name=:name").arg(m_playlistsTable));
    finder_query.bindValue(":name", playlist_path);

    if (!finder_query.exec()) {
        LOG_FAILED_QUERY(finder_query) << "Error getting id for playlist:" << playlist_path;
        return;
    }

    // TODO(XXX): Why not last-insert id?
    int playlistId = -1;
    QSqlRecord finder_query_record = finder_query.record();
    while (finder_query.next()) {
        playlistId = finder_query.value(
                finder_query_record.indexOf("id")).toInt();
    }

    if (playlistId == -1) {
        qDebug() << "ERROR: Could not get the playlist ID for playlist:" << playlist_path;
        return;
    }

    QString playlistViewTable = QString("%1_%2").arg(m_playlistTracksTable,
                                                     QString::number(playlistId));

    QStringList columns;
    columns << "track_id";
    columns << "position";
    columns << "'' AS " + LIBRARYTABLE_PREVIEW;


    QSqlQuery query(m_database);
    FieldEscaper f(m_database);
    QString queryString = QString(
        "CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS "
        "SELECT %2 FROM %3 WHERE playlist_id = %4")
            .arg(f.escapeString(playlistViewTable),
                 columns.join(","),
                 m_playlistTracksTable,
                 QString::number(playlistId));
    query.prepare(queryString);

    if (!query.exec()) {
        LOG_FAILED_QUERY(query) << "Error creating temporary view for playlist.";
        return;
    }

    columns[2] = LIBRARYTABLE_PREVIEW;
    setTable(playlistViewTable, columns[0], columns, m_trackSource);
    setDefaultSort(fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION),
                   Qt::AscendingOrder);
    setSearch("");
}
示例#29
0
void PlaylistTableModel::setTableModel(int playlistId) {
    //qDebug() << "PlaylistTableModel::setTableModel" << playlistId;
    if (m_iPlaylistId == playlistId) {
        qDebug() << "Already focused on playlist " << playlistId;
        return;
    }

    m_iPlaylistId = playlistId;
    QString playlistTableName = "playlist_" + QString::number(m_iPlaylistId);
    QSqlQuery query(m_database);
    FieldEscaper escaper(m_database);

    QStringList columns;
    columns << PLAYLISTTRACKSTABLE_TRACKID + " AS " + LIBRARYTABLE_ID
            << PLAYLISTTRACKSTABLE_POSITION
            << PLAYLISTTRACKSTABLE_DATETIMEADDED
            << "'' AS " + LIBRARYTABLE_PREVIEW
            // For sorting the cover art column we give LIBRARYTABLE_COVERART
            // the same value as the cover hash.
            << LIBRARYTABLE_COVERART_HASH + " AS " + LIBRARYTABLE_COVERART;

    // We drop files that have been explicitly deleted from mixxx
    // (mixxx_deleted=0) from the view. There was a bug in <= 1.9.0 where
    // removed files were not removed from playlists, so some users will have
    // libraries where this is the case.
    QString queryString = QString("CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS "
                                  "SELECT %2 FROM PlaylistTracks "
                                  "INNER JOIN library ON library.id = PlaylistTracks.track_id "
                                  "WHERE PlaylistTracks.playlist_id = %3")
                          .arg(escaper.escapeString(playlistTableName),
                               columns.join(","),
                               QString::number(playlistId));
    if (!m_showAll) {
        queryString.append(" AND library.mixxx_deleted = 0");
    }
    query.prepare(queryString);
    if (!query.exec()) {
        LOG_FAILED_QUERY(query);
    }

    columns[0] = LIBRARYTABLE_ID;
    // columns[1] = PLAYLISTTRACKSTABLE_POSITION from above
    // columns[2] = PLAYLISTTRACKSTABLE_DATETIMEADDED from above
    columns[3] = LIBRARYTABLE_PREVIEW;
    columns[4] = LIBRARYTABLE_COVERART;
    setTable(playlistTableName, LIBRARYTABLE_ID, columns,
            m_pTrackCollection->getTrackSource());
    setSearch("");
    setDefaultSort(fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION), Qt::AscendingOrder);
    setSort(defaultSortColumn(), defaultSortOrder());

    connect(&m_playlistDao, SIGNAL(changed(int)),
            this, SLOT(playlistChanged(int)));
}
示例#30
0
MItemPlanCuota::MItemPlanCuota(QObject *parent) :
QSqlRelationalTableModel(parent)
{
    setTable( "item_cuota" );
    setHeaderData( 0, Qt::Horizontal, "#ID Item" );
    setHeaderData( 1, Qt::Horizontal, "#ID Plan" );
    setHeaderData( 2, Qt::Horizontal, "#Cuota" );
    setHeaderData( 3, Qt::Horizontal, "Importe" );
    setHeaderData( 4, Qt::Horizontal, "Fecha Vencimiento" );
    setHeaderData( 5, Qt::Horizontal, "Fecha de Pago" );
    setHeaderData( 6, Qt::Horizontal, "#ID Recibo" );
}