BookmarkModel::BookmarkModel(QSqlDatabase database, QObject *parent) : QSqlTableModel(parent, database) { connect(this, SIGNAL(rowsInserted(const QModelIndex&, int, int)), SIGNAL(countChanged())); connect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SIGNAL(countChanged())); setEditStrategy(OnManualSubmit); }
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 ); }
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))); }
MovieTableModel::MovieTableModel(QObject *parent) : QSqlRelationalTableModel(parent) { setTable("movie"); setSort(1, Qt::AscendingOrder); setEditStrategy(QSqlTableModel::OnManualSubmit); setHeaderData(0, Qt::Horizontal, trUtf8("ID")); setHeaderData(1, Qt::Horizontal, trUtf8("Title")); setHeaderData(2, Qt::Horizontal, trUtf8("Main characters")); setHeaderData(3, Qt::Horizontal, trUtf8("Director")); setHeaderData(4, Qt::Horizontal, trUtf8("Distributor")); setHeaderData(5, Qt::Horizontal, trUtf8("Release date")); setHeaderData(6, Qt::Horizontal, trUtf8("Status")); setHeaderData(7, Qt::Horizontal, trUtf8("Availability")); }
FilmModel::FilmModel(QObject *parent) : QSqlTableModel(parent) { setTable("films"); setEditStrategy(QSqlTableModel::OnManualSubmit); setSort(0, Qt::AscendingOrder); setFilter(""); select(); setHeaderData(1, Qt::Horizontal, "Name"); setHeaderData(2, Qt::Horizontal, "Year"); setHeaderData(3, Qt::Horizontal, "Country"); setHeaderData(4, Qt::Horizontal, "Director"); setHeaderData(5, Qt::Horizontal, "Actors"); setHeaderData(6, Qt::Horizontal, "Type"); setHeaderData(7, Qt::Horizontal, "Genre"); setHeaderData(8, Qt::Horizontal, "Score"); }
SoundCloudAccountModel::SoundCloudAccountModel(QObject *parent) : QSqlTableModel(parent) { m_roles[UserIdRole] = "userId"; m_roles[UsernameRole] = "username"; m_roles[AccessTokenRole] = "accessToken"; m_roles[RefreshTokenRole] = "refreshToken"; m_roles[ScopesRole] = "scopes"; m_roles[ActiveRole] = "active"; #if QT_VERSION < 0x050000 setRoleNames(m_roles); #endif setTable("soundcloudAccounts"); setSort(1, Qt::AscendingOrder); setEditStrategy(QSqlTableModel::OnRowChange); select(); emit countChanged(rowCount()); }
RelationalCollection::RelationalCollection(QObject *parent): QSqlTableModel(parent), m_read_only(false), m_last_insert_row_id(-1), m_add_only_with_fitler(true), m_display_mode(CollectionDisplay::All) { // setEditStrategy(QSqlTableModel::OnManualSubmit); setEditStrategy(QSqlTableModel::OnFieldChange); // Works. setIdColumn(0); connect(this, SIGNAL(modelReset()), this, SIGNAL(modelChanged())); connect(this, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SIGNAL(modelChanged())); connect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SIGNAL(modelChanged())); connect(this, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, SIGNAL(modelChanged())); }
/** * @brief Creates a player model and set header data. * @param parent Parent obejct. */ PlayerModel::PlayerModel(QObject *parent) : QSqlRelationalTableModel(parent) { setTable("player"); setEditStrategy(QSqlTableModel::OnManualSubmit); select(); setHeaderData(0, Qt::Horizontal, QObject::tr("ID")); setHeaderData(1, Qt::Horizontal, QObject::tr("Firstname")); setHeaderData(2, Qt::Horizontal, QObject::tr("Surname")); setHeaderData(3, Qt::Horizontal, QObject::tr("Day of birth")); setHeaderData(4, Qt::Horizontal, QObject::tr("Address")); setHeaderData(5, Qt::Horizontal, QObject::tr("E-mail")); setHeaderData(6, Qt::Horizontal, QObject::tr("Phone")); setHeaderData(7, Qt::Horizontal, QObject::tr("Number")); setHeaderData(8, Qt::Horizontal, QObject::tr("Photo")); setHeaderData(9, Qt::Horizontal, QObject::tr("Post")); }
ProductsModel::ProductsModel(QObject *parent) : QSqlRelationalTableModel(parent) { // Language setup QString app_path; app_path = QApplication::applicationDirPath() + QDir::separator() + "settings.ini"; QSettings settings(app_path,QSettings::IniFormat); QString content = settings.value("s_language","").toString(); QString lanCode; QString lanName; if(content == "tamil_language"){ QTranslator translator; translator.load("tamilLanguage_la"); // QApplication::installTranslator(&translator); QApplication::instance()->installTranslator(&translator); lanCode = ProductForm::tr("Code"); lanName = ProductForm::tr("Name"); }else{ QTranslator translator; translator.load("englishLanguage_la"); // QApplication::installTranslator(&translator); QApplication::instance()->installTranslator(&translator); lanCode = ProductForm::tr("Code"); lanName = ProductForm::tr("Name"); } setTable("products"); setRelation(4, QSqlRelation("categories", "id", "name")); setEditStrategy(QSqlTableModel::OnManualSubmit); setHeaderData(fieldIndex("code"), Qt::Horizontal, lanCode); setHeaderData(fieldIndex("name"), Qt::Horizontal, lanName); setFilter("products.status = 'A'"); relationModel(4)->setFilter("status = 'A'"); setSort(fieldIndex("name"),Qt::AscendingOrder); select(); }
MusicUserModel::MusicUserModel(QObject *parent,QSqlDatabase db) : QSqlTableModel(parent,db) { setEditStrategy(QSqlTableModel::OnManualSubmit); }