Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 72 → Rev 73

/trunk/ClassEditor/mysql.cpp
320,3 → 320,11
 
 
}
 
 
QSqlError MySql::dbLastError(){ // ôóíêöèÿ ôîçâðàùàåò ïîñëåäíþþ îøèáêó áàçû äàííûõ
QString error;
error = db.lastError().text();
 
return db.lastError();
}
/trunk/ClassEditor/classeditor.ui
155,22 → 155,6
<height>27</height>
</rect>
</property>
<widget class="QMenu" name="menu_2">
<property name="title">
<string>Поле</string>
</property>
<widget class="QMenu" name="menu_4">
<property name="title">
<string>Удалить поля</string>
</property>
<addaction name="action_removeAllFields"/>
<addaction name="separator"/>
<addaction name="action_removeSelectedFields"/>
</widget>
<addaction name="action_8"/>
<addaction name="separator"/>
<addaction name="menu_4"/>
</widget>
<widget class="QMenu" name="menu">
<property name="title">
<string>Класс</string>
191,6 → 175,22
<addaction name="action_showAlias"/>
<addaction name="action_showInstance"/>
</widget>
<widget class="QMenu" name="menu_2">
<property name="title">
<string>Поле</string>
</property>
<widget class="QMenu" name="menu_4">
<property name="title">
<string>Удалить поля</string>
</property>
<addaction name="action_removeAllFields"/>
<addaction name="separator"/>
<addaction name="action_removeSelectedFields"/>
</widget>
<addaction name="action_newField"/>
<addaction name="separator"/>
<addaction name="menu_4"/>
</widget>
<addaction name="menu"/>
<addaction name="menu_2"/>
</widget>
218,7 → 218,7
<string>Удалить выбранные классы</string>
</property>
</action>
<action name="action_8">
<action name="action_newField">
<property name="text">
<string>Новое поле</string>
</property>
/trunk/ClassEditor/mysql.h
29,6 → 29,7
#include <QVariant>
#include <QProcess>
#include <QByteArray>
#include <QSqlQuery>
 
 
class MySql : public QObject
63,6 → 64,7
bool createTable(SqlTable* table); // ñîçäàåò â áàçå äàííûõ òàáëèöó
 
QString lasError();
QSqlError dbLastError(); // ôóíêöèÿ ôîçâðàùàåò ïîñëåäíþþ îøèáêó áàçû äàííûõ
 
 
};
/trunk/ClassEditor/classeditor.cpp
288,8 → 288,9
connect(ui->action_removeSelectedFields, SIGNAL(triggered()), this, SLOT(on_pushButton_4_clicked())); // óäàëèòü âûäåëåííûå ïîëÿ
connect(ui->action_removeAllFields, SIGNAL(triggered()), this, SLOT(on_pushButton_5_clicked())); // óäàëèòü âñå ïîëÿ
connect(ui->action_removeSelectedClasses, SIGNAL(triggered()), this, SLOT(on_pushButton_2_clicked())); // óäàëèòü âûäåëåííûå êëàññû
connect(ui->action_removeAllClasses, SIGNAL(triggered()), this, SLOT(on_action_removeAllClasses())); // óäàëèòü âûäåëåííûå êëàññû
connect(ui->action_newClass, SIGNAL(triggered()), this, SLOT(on_pushButton_clicked())); // óäàëèòü âûäåëåííûå êëàññû
connect(ui->action_removeAllClasses, SIGNAL(triggered()), this, SLOT(on_action_removeAllClasses())); // óäàëèòü âñå êëàññû
connect(ui->action_newClass, SIGNAL(triggered()), this, SLOT(on_pushButton_clicked())); // äîáàâèòü íîâûé êëàññ
connect(ui->action_newField, SIGNAL(triggered()), this, SLOT(on_pushButton_3_clicked())); // äîáàâèòü íîâîå ïîëå
}
 
 
418,10 → 419,27
//ok = rec.isEmpty();
//QString currientClassID;
//currientClassID = rec.value(1).toString();
QString Inctance_str;
QString Inctance_str; // èìÿ òàáëèöû-õðàíèëèùà îáúåêòîâ äëÿ âûáðàííîãî êëàññà
QString query_str = tr("ALTER TABLE ");
QString db_error;
QSqlQuery q;
int currRow = ClassEditor::currIndexOfClassesTable.row(); //
Inctance_str = mymodel->data(mymodel->index(currRow, 3)).toString();
query_str.append( Inctance_str);
query_str.append(tr(" ADD COLUMN `New field` CHAR(10)"));
bool ok = q.prepare(query_str);
 
ok = q.exec();
if (!ok) {
QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
this, // Ðîäèòåëüñêèé âèäæåò.
QObject::tr("Database Error"), // Çàãîëîâîê.
q.lastError().text()); // Òåêñò ñîîáùåíèÿ.
 
return; // âûõîäèì íå ïðèìåíÿÿ èçìåíåíèé
 
}
 
int row = modelForDescription->rowCount();
modelForDescription->insertRows(row, 1);
modelForDescription->setData(modelForDescription->index(row, 5), QVariant(currClassID), Qt::EditRole);
428,6 → 446,16
modelForDescription->setData(modelForDescription->index(row, 4), QVariant(tr("NULL")), Qt::EditRole);
 
modelForDescription->submitAll();
 
delete model;
delete tableForInstance;
model = new QSqlTableModel();
tableForInstance = new QTableView();
model->setTable(Inctance_str);
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
tableForInstance->setModel(model);
tableForInstance->setWindowTitle(Inctance_str);
tableForInstance->show();
}
 
 
552,8 → 580,9
*/
selectedRows.clear();
foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê
if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå
 
if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) {
selectedRows.append(model_index.row()); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå
}
}
 
qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // ñîðòèðóåì â îáðàòíîì ïîðÿäêå