void ColumnEditorModel::deleteRow(int nRow) { DatabaseColumn *col = columnItem(nRow); removeRow(nRow); if(col) delete col; }
void ImportCsvDialogue::loadTableColumns(int index) { trw_columns->clear(); ImportDialogueTable *table = tables.at(index); current_table = table; if (!table) return; int n = 1; for (int i = 0; i < table->count(); ++i) { trw_columns->addTopLevelItem(columnItem(table->at(i)->name(), table->at(i)->id(), n)); } for (int i = 0; i < table->childTablesCount(); ++i) { for (int k = 0; k < table->childTableAt(i)->count(); ++k) { trw_columns->addTopLevelItem(columnItem(table->childTableAt(i)->at(k)->name(), table->childTableAt(i)->at(k)->id(), n)); } } QMenu *menu = btn_add_linked_table->menu(); if (menu) { menu->clear(); } else { menu = new QMenu(btn_add_linked_table); btn_add_linked_table->setMenu(menu); btn_add_linked_table->setPopupMode(QToolButton::InstantPopup); QObject::connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(addLinkedTable(QAction*))); } for (int i = 0; i < table->childTemplatesCount(); ++i) { QAction *action = new QAction(table->childTemplateAt(i)->name(), menu); action->setData(i); menu->addAction(action); } updateHeader(); }
void ColumnEditorModel::updateType(int nRow, StdString const &oType) { QStandardItem *it = item(nRow, 0); if(it == NULL) return; it->setText(spt::string::toQt(oType)); DatabaseColumn *col = columnItem(nRow); if(col == NULL) return; col->setType(TypeStringProvider.toType(oType)); QVariant v; v.setValue(col); it->setData(v); setItem(nRow, 0, it); }
void ColumnEditorModel::updateName(int nRow, StdString const &oName) { QStandardItem *it = item(nRow, 0); if(it == NULL) it = new QStandardItem(); it->setText(spt::string::toQt(oName)); DatabaseColumn *col = columnItem(nRow); if(col == NULL) col = new DatabaseColumn(); col->setName(oName); QVariant v; v.setValue(col); it->setData(v); setItem(nRow, 0, it); }