Subversion Repositories OpenInventory

Rev

Rev 86 | Rev 134 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 86 Rev 87
Line 189... Line 189...
189
modelForDescription->setTable(tr("DescriptionOfClasses"));
189
modelForDescription->setTable(tr("DescriptionOfClasses"));
190
modelForDescription->setEditStrategy(QSqlTableModel::OnFieldChange);
190
modelForDescription->setEditStrategy(QSqlTableModel::OnFieldChange);
191
191
192
/////model->setEditStrategy(QSqlTableModel::OnManualSubmit);
192
/////model->setEditStrategy(QSqlTableModel::OnManualSubmit);
193
193
194
modelForPointers->setEditStrategy(QSqlTableModel::OnManualSubmit);
194
// modelForPointers->setEditStrategy(QSqlTableModel::OnManualSubmit);
-
 
195
-
 
196
modelForPointers->setEditStrategy(QSqlTableModel::OnFieldChange);
-
 
197
195
modelForPointers->setTable(tr("DescriptionOfClasses"));
198
modelForPointers->setTable(tr("DescriptionOfClasses"));
196
199
197
200
198
201
199
202
Line 317... Line 320...
317
connect(ui->action_removeAllClasses, SIGNAL(triggered()), this, SLOT(on_action_removeAllClasses())); // óäàëèòü âñå êëàññû
320
connect(ui->action_removeAllClasses, SIGNAL(triggered()), this, SLOT(on_action_removeAllClasses())); // óäàëèòü âñå êëàññû
318
connect(ui->action_newClass, SIGNAL(triggered()), this, SLOT(on_pushButton_clicked())); // äîáàâèòü íîâûé êëàññ
321
connect(ui->action_newClass, SIGNAL(triggered()), this, SLOT(on_pushButton_clicked())); // äîáàâèòü íîâûé êëàññ
319
connect(ui->action_newField, SIGNAL(triggered()), this, SLOT(on_pushButton_3_clicked())); // äîáàâèòü íîâîå ïîëå
322
connect(ui->action_newField, SIGNAL(triggered()), this, SLOT(on_pushButton_3_clicked())); // äîáàâèòü íîâîå ïîëå
320
connect(ui->action_newPointer, SIGNAL(triggered()), this, SLOT(on_action_newPointer())); // äîáàâèòü íîâîå ïîëå äëÿ óêàçàòåëåé íà êëàññû-êîíòåéíåðû
323
connect(ui->action_newPointer, SIGNAL(triggered()), this, SLOT(on_action_newPointer())); // äîáàâèòü íîâîå ïîëå äëÿ óêàçàòåëåé íà êëàññû-êîíòåéíåðû
321
// connect(ui->action_newPointer, SIGNAL(triggered()), this, SLOT(on_pushButton_3_clicked())); // äîáàâèòü íîâîå ïîëå äëÿ óêàçàòåëåé íà êëàññû-êîíòåéíåðû
324
// connect(ui->action_newPointer, SIGNAL(triggered()), this, SLOT(on_pushButton_3_clicked())); // äîáàâèòü íîâîå ïîëå äëÿ óêàçàòåëåé íà êëàññû-êîíòåéíåðû
-
 
325
-
 
326
connect(ui->action_removeSelectedPointers, SIGNAL(triggered()), this, SLOT(on_action_removeSelectedPointers())); // óäàëèòü âûäåëåííûå êëàññû
322
connect(modelForDescription, SIGNAL(field_changed()), this, SLOT(on_field_changed())); // â òàáëèöå ïîëåé ïðîèçîøëè èçìåíåíèÿ
327
connect(modelForDescription, SIGNAL(field_changed()), this, SLOT(on_field_changed())); // â òàáëèöå ïîëåé ïðîèçîøëè èçìåíåíèÿ
323
connect(ClassEditor::modelForPointers, SIGNAL(field_changed()), this, SLOT(on_field_changed())); // â òàáëèöå óêàçàòåëåé ïðîèçîøëè èçìåíåíèÿ
328
connect(ClassEditor::modelForPointers, SIGNAL(field_changed()), this, SLOT(on_field_changed())); // â òàáëèöå óêàçàòåëåé ïðîèçîøëè èçìåíåíèÿ
324
329
325
330
-
 
331
326
}
332
}
327
333
328
334
329
335
330
336
Line 728... Line 734...
728
734
729
    //if (i > 0) model_index = indexes.at(0);
735
    //if (i > 0) model_index = indexes.at(0);
730
}
736
}
731
737
732
738
-
 
739
void ClassEditor::on_action_removeSelectedPointers(){ // óäàëèòü âûäåëåííûå óêàçàòåëè
-
 
740
    QModelIndex model_index;
-
 
741
    QItemSelectionModel *selectionModel = ui->tableView_3->selectionModel();
-
 
742
    QModelIndexList indexes = selectionModel->selectedIndexes();
-
 
743
    QList<int> selectedRows;
-
 
744
-
 
745
    selectedRows.clear();
-
 
746
-
 
747
    foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê
-
 
748
        if (!selectedRows.contains(model_index.row()) && (model_index.column()==1))  {
-
 
749
            selectedRows.append(model_index.row()); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå
-
 
750
        }
-
 
751
    }
-
 
752
-
 
753
    qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // ñîðòèðóåì â îáðàòíîì ïîðÿäêå
-
 
754
-
 
755
    QString Inctance_str; // èìÿ òàáëèöû-õðàíèëèùà
-
 
756
    Inctance_str = mymodel->data(mymodel->index(ClassEditor::currIndexOfClassesTable.row(), 3)).toString();
-
 
757
    for (int m =0; m < selectedRows.size(); ++m){
-
 
758
-
 
759
-
 
760
        QString query_str;
-
 
761
        QString field_name_str; // èìÿ óäàëÿåìîãî ïîëÿ
-
 
762
        QSqlQuery q;
-
 
763
-
 
764
        query_str.clear();
-
 
765
-
 
766
-
 
767
        field_name_str = modelForPointers->data(modelForPointers->index(selectedRows.at(m), 1)).toString();
-
 
768
-
 
769
        query_str.append(tr("ALTER TABLE "));
-
 
770
        query_str.append(Inctance_str);
-
 
771
        query_str.append(tr(" DROP COLUMN `"));
-
 
772
        query_str.append(field_name_str);
-
 
773
        query_str.append(tr("`"));
-
 
774
        q.prepare(query_str);
-
 
775
        bool ok = q.exec();
-
 
776
        if (!ok) {
-
 
777
                                    QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
-
 
778
                                                                                    this,                      // Ðîäèòåëüñêèé âèäæåò.
-
 
779
                                                                                    QObject::tr("Database Error"),   // Çàãîëîâîê.
-
 
780
                                                                                    q.lastError().text()); // Òåêñò ñîîáùåíèÿ.
-
 
781
-
 
782
                                                                    return; // âûõîäèì íå ïðèìåíÿÿ èçìåíåíèé
-
 
783
-
 
784
                             }
-
 
785
-
 
786
-
 
787
-
 
788
        modelForPointers->removeRow(selectedRows.at(m));
-
 
789
-
 
790
    }
-
 
791
-
 
792
-
 
793
    refreshInctance();
-
 
794
-
 
795
-
 
796
-
 
797
}
-
 
798
-
 
799
-
 
800
-
 
801
-
 
802
733
void ClassEditor::on_pushButton_5_clicked(){         // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü âñå ïîëÿ"
803
void ClassEditor::on_pushButton_5_clicked(){         // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü âñå ïîëÿ"
734
int row;
804
int row;
735
row = ClassEditor::modelForDescription->rowCount();
805
row = ClassEditor::modelForDescription->rowCount();
736
ClassEditor::modelForDescription->removeRows(0, row);
806
ClassEditor::modelForDescription->removeRows(0, row);
737
ClassEditor::modelForDescription->submitAll();
807
ClassEditor::modelForDescription->submitAll();
Line 846... Line 916...
846
}
916
}
847
917
848
918
849
919
850
920
851
void ClassEditor::on_action_newPointer(){
921
void ClassEditor::on_action_newPointer(){ // äîáàâëÿåì íîâîå ïîëå äëÿ óêàçàòåëåé íà îáúåêòû êëàññà-êîíòåéíåðà
852
    ClassEditor::addNewPointer();
922
    ClassEditor::addNewPointer();
853
    ClassEditor::modelForPointers->select();
923
    ClassEditor::modelForPointers->select();
854
    ui->tableView_3->resizeColumnsToContents();
924
    ui->tableView_3->resizeColumnsToContents();
855
925
856
}
926
}