Хранилища Subversion OpenInventory

Сравнить редакции

Не учитывать пробелы Редакция 74 → Редакция 75

/trunk/ClassEditor/classeditor.cpp
243,6 → 243,8
currIndexOfClassesTable = mymodel->index(0, 1);
QModelIndex index_temp;
 
 
 
currClassID = mymodel->data(mymodel->index(0,0)).toString();
QItemSelectionModel *selectionModel = ui->tableView->selectionModel();
 
260,6 → 262,9
QString str_fltr = tr("ClassIdentifer = ");
class_indx = mymodel->data(mymodel->index(0,0)).toString();
class_instance = mymodel->data(mymodel->index(0,3)).toString();
 
currInctanceTable = class_instance; //
modelForDescription->setInctance(class_instance); // ïåðåäàåì â ìîäåëü ïîëåé èìÿ òåêóùåé òàáëèöû-õðàíèëèùà
//class_instance.append(tr("_inctance"));
str_fltr.append(class_indx);
 
490,6 → 495,11
index_instance = ui->tableView->model()->index(row, 3);
tmp_str = ui->tableView->model()->data(index_tmp).toString();
instance_str = ui->tableView->model()->data(index_instance).toString();
modelForDescription->setInctance(instance_str); // ïåðåäàåì â ìîäåëü ïîëåé èìÿ òåêóùåé òàáëèöû-õðàíèëèùà
 
 
 
 
// instance_str.append(tr("_inctance"));
/*
Inctance_model.clear();
646,13 → 656,36
}
 
void ClassEditor::on_myModel_dataChanged( const QModelIndex & topLeft, const QModelIndex & bottomRight ){
 
int i;
i++;
ui->tableView->resizeColumnsToContents();
 
 
 
 
 
}
 
void ClassEditor::on_modelForDescription_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ){
ui->tableView_2->resizeColumnsToContents();
 
/*
QString instance_str;
instance_str = mymodel->data(mymodel->index(ClassEditor::currIndexOfClassesTable.row(), 3)).toString();
tableForInstance->close();
delete model;
delete tableForInstance;
model = new QSqlTableModel();
tableForInstance = new QTableView();
model->setTable(instance_str);
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
tableForInstance->setModel(model);
 
model->select();
tableForInstance->setWindowTitle(instance_str);
tableForInstance->show();
*/
}
 
void ClassEditor::on_action_ID_triggered(bool is_checked){ // îáðàáàòûâàåì âûáîð â ìåíþ "Ïîêàçûâàòü ID"
/trunk/ClassEditor/modelfordescriptiontable.cpp
24,7 → 24,10
bool ModelForDescriptionTable::setData(const QModelIndex &index, const QVariant &value, int role) {
//// if (index.column()==3) return false; // â òðåòüåé êîëîíêå íå äàåì ïîìåíÿòü çíà÷åíèå
bool lResult = false;
QVariant old_value; // ñîõðàíèì ñòàðîå çíà÷åíèå
old_value = data(index);
 
 
/*
QString str_tmp;
if (index.column()==1) { // åñëè ìåíÿåì èìÿ êëàññà
47,14 → 50,52
rec.setValue(index.column(), value);
rec.setGenerated(index.column(), true);
 
/*
if (index.column()==1){
rec.setValue(index.column()+2, QVariant(str_tmp));
rec.setGenerated(index.column()+2, true);
newindex = MyModel::index(index.row(), index.column()+2);
QSqlTableModel::setData(newindex, QVariant(str_tmp), Qt::EditRole);
 
if (index.column()==1){ // åñëè ïîìåíÿëîñü èìÿ ïîëÿ
QSqlQuery qu;
QString old_field_name; // ñòàðîå èìÿ ïîëÿ
QString new_field_name; // íîâîå èìÿ ïîëÿ
QString query_str;
QString type_str; // òèï äàííûõ ïîëÿ
old_field_name = old_value.toString(); // îïðåäåëèì òåêóùåå (êîòîðîå íóæíî ïîìåíÿòü) èìÿ ïîëÿ
new_field_name = value.toString();
type_str = data(ModelForDescriptionTable::index(index.row(), 3)).toString(); // òèï ïîëÿ õðàíèòüñÿ â 3 ñòîëáöå, ñ÷èòûâàåì åãî çíà÷åíèå
query_str = tr("ALTER TABLE ");
query_str.append(ModelForDescriptionTable::Inctance);
query_str.append(tr(" CHANGE COLUMN `"));
query_str.append(old_field_name);
query_str.append(tr("` `"));
query_str.append(new_field_name);
query_str.append(tr("` "));
query_str.append(type_str);
query_str.append(tr(" CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL"));
qu.prepare(query_str);
bool ok;
ok = qu.exec();
if (!ok) return false;
 
/*
if (!ok) {
 
QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
this, // Ðîäèòåëüñêèé âèäæåò.
QObject::tr("Database Error"), // Çàãîëîâîê.
qu.lastError().text() ); // Òåêñò ñîîáùåíèÿ.
 
return ok; // âûõîäèì íå ïðèìåíÿÿ èçìåíåíèé
 
}
 
*/
 
 
// rec.setValue(index.column()+2, QVariant(str_tmp));
// rec.setGenerated(index.column()+2, true);
// newindex = MyModel::index(index.row(), index.column()+2);
// QSqlTableModel::setData(newindex, QVariant(str_tmp), Qt::EditRole);
}
*/
 
 
/*
 
if (index.column()==0){
113,3 → 154,8
}
return value;
}
 
 
void ModelForDescriptionTable::setInctance(QString currInctatce){ // ïåðåäàåì èìÿ òåêóùåé òàáëèöû-õðàíèëèùà
ModelForDescriptionTable::Inctance = currInctatce;
}
/trunk/ClassEditor/modelfordescriptiontable.h
1,10 → 1,12
#ifndef MODELFORDESCRIPTIONTABLE_H
#define MODELFORDESCRIPTIONTABLE_H
 
#include <QMainWindow>
#include <QObject>
#include <QtGui>
#include <QSqlQueryModel>
#include <QSqlTableModel>
#include <QSqlQuery>
 
class ModelForDescriptionTable : public QSqlTableModel
{
14,11 → 16,14
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &, const QVariant &, int);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
void setInctance(QString currInctatce); // ïåðåäàåì èìÿ òåêóùåé òàáëèöû-õðàíèëèùà
signals:
 
public slots:
 
private:
QString Inctance; // èìÿ òàáëèöû-õðàíèëèùà îáúåêòîâ âûäåëåííîãî (â òàáëèöå êëàññîâ) êëàññà
 
};
 
#endif // MODELFORDESCRIPTIONTABLE_H