Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 87 → Rev 86

/trunk/ClassEditor/classeditor.ui
231,7 → 231,7
</property>
<addaction name="action_removeAllPointer"/>
<addaction name="separator"/>
<addaction name="action_removeSelectedPointers"/>
<addaction name="action_5"/>
</widget>
<addaction name="action_newPointer"/>
<addaction name="separator"/>
330,7 → 330,7
<string>Удалить выделенные указатели</string>
</property>
</action>
<action name="action_removeSelectedPointers">
<action name="action_5">
<property name="text">
<string>Удалить выделенные указатели</string>
</property>
/trunk/ClassEditor/classeditor.cpp
191,10 → 191,7
 
/////model->setEditStrategy(QSqlTableModel::OnManualSubmit);
 
// modelForPointers->setEditStrategy(QSqlTableModel::OnManualSubmit);
 
modelForPointers->setEditStrategy(QSqlTableModel::OnFieldChange);
 
modelForPointers->setEditStrategy(QSqlTableModel::OnManualSubmit);
modelForPointers->setTable(tr("DescriptionOfClasses"));
 
 
322,13 → 319,10
connect(ui->action_newField, SIGNAL(triggered()), this, SLOT(on_pushButton_3_clicked())); // äîáàâèòü íîâîå ïîëå
connect(ui->action_newPointer, SIGNAL(triggered()), this, SLOT(on_action_newPointer())); // äîáàâèòü íîâîå ïîëå äëÿ óêàçàòåëåé íà êëàññû-êîíòåéíåðû
// connect(ui->action_newPointer, SIGNAL(triggered()), this, SLOT(on_pushButton_3_clicked())); // äîáàâèòü íîâîå ïîëå äëÿ óêàçàòåëåé íà êëàññû-êîíòåéíåðû
 
connect(ui->action_removeSelectedPointers, SIGNAL(triggered()), this, SLOT(on_action_removeSelectedPointers())); // óäàëèòü âûäåëåííûå êëàññû
connect(modelForDescription, SIGNAL(field_changed()), this, SLOT(on_field_changed())); // â òàáëèöå ïîëåé ïðîèçîøëè èçìåíåíèÿ
connect(ClassEditor::modelForPointers, SIGNAL(field_changed()), this, SLOT(on_field_changed())); // â òàáëèöå óêàçàòåëåé ïðîèçîøëè èçìåíåíèÿ
 
 
 
}
 
 
736,70 → 730,6
}
 
 
void ClassEditor::on_action_removeSelectedPointers(){ // óäàëèòü âûäåëåííûå óêàçàòåëè
QModelIndex model_index;
QItemSelectionModel *selectionModel = ui->tableView_3->selectionModel();
QModelIndexList indexes = selectionModel->selectedIndexes();
QList<int> selectedRows;
 
selectedRows.clear();
 
foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê
if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) {
selectedRows.append(model_index.row()); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå
}
}
 
qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // ñîðòèðóåì â îáðàòíîì ïîðÿäêå
 
QString Inctance_str; // èìÿ òàáëèöû-õðàíèëèùà
Inctance_str = mymodel->data(mymodel->index(ClassEditor::currIndexOfClassesTable.row(), 3)).toString();
for (int m =0; m < selectedRows.size(); ++m){
 
 
QString query_str;
QString field_name_str; // èìÿ óäàëÿåìîãî ïîëÿ
QSqlQuery q;
 
query_str.clear();
 
 
field_name_str = modelForPointers->data(modelForPointers->index(selectedRows.at(m), 1)).toString();
 
query_str.append(tr("ALTER TABLE "));
query_str.append(Inctance_str);
query_str.append(tr(" DROP COLUMN `"));
query_str.append(field_name_str);
query_str.append(tr("`"));
q.prepare(query_str);
bool ok = q.exec();
if (!ok) {
QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
this, // Ðîäèòåëüñêèé âèäæåò.
QObject::tr("Database Error"), // Çàãîëîâîê.
q.lastError().text()); // Òåêñò ñîîáùåíèÿ.
 
return; // âûõîäèì íå ïðèìåíÿÿ èçìåíåíèé
 
}
 
 
 
modelForPointers->removeRow(selectedRows.at(m));
 
}
 
 
refreshInctance();
 
 
 
}
 
 
 
 
 
void ClassEditor::on_pushButton_5_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü âñå ïîëÿ"
int row;
row = ClassEditor::modelForDescription->rowCount();
918,7 → 848,7
 
 
 
void ClassEditor::on_action_newPointer(){ // äîáàâëÿåì íîâîå ïîëå äëÿ óêàçàòåëåé íà îáúåêòû êëàññà-êîíòåéíåðà
void ClassEditor::on_action_newPointer(){
ClassEditor::addNewPointer();
ClassEditor::modelForPointers->select();
ui->tableView_3->resizeColumnsToContents();
/trunk/ClassEditor/classeditor.h
69,13 → 69,10
void on_action_ID_triggered(bool is_checked); // îáðàáàòûâàåì âûáîð â ìåíþ "Ïîêàçûâàòü ID"
void on_action_showAlias_triggered(bool is_checked); // îáðàáàòûâàåì âûáîð â ìåíþ "Ïîêàçûâàòü ïñåâäîíèì"
void on_action_showInstance_triggered(bool is_checked); // ... ïîêàçûâàòü õðàíèëèùà îáúåêòîâ
 
void on_tableView_clicked(const QModelIndex & index );
void on_myModel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
void on_modelForDescription_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
void on_action_removeAllClasses(); // óäàëèòü âñå êëàññû
void on_action_removeSelectedPointers(); // óäàëèòü âûäåëåííûå óêàçàòåëè
 
void removeClass(int class_row); // ôóíêöèÿ óäàëÿåò êëàññ, íàõîäÿùèéñÿ â ñòðîêå ñ íîìåðîì class_row
void on_field_changed(); // ïîìåíÿëîñü èìÿ ïîëÿ
void on_action_newPointer(); // äîáàâèòü íîâûé óêàçàòåëü íà êëàññ-êîíòåéíåð