Хранилища Subversion OpenInventory

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

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

/trunk/ClassEditor/mysql.cpp
273,7 → 273,7
fld = new TableField(tr("FieldAlias"), tbl); // ýòî òðåòüå ïîëå òàáëèöû áóäåò õðàíèòü ïñåâäîíèìû ïîëåé êëàññîâ
fld->setNotNull(true); // ïîëå íå ìîæåò áûòü ïóñòûì
fld->setType(tr("CHAR(30)")); // òèï ïîëÿ - ñòðîêà èç 30 ñèìâîëîâ
fld->setDefaultValue(tr("New class alias")); // çíà÷åíèå ïîëÿ ïî óìîë÷àíèþ
fld->setDefaultValue(tr("New field alias")); // çíà÷åíèå ïîëÿ ïî óìîë÷àíèþ
tbl->append(fld); // äîáàâëÿåì ïîëå â òàáëèöó
 
fld = new TableField(tr("FieldType"), tbl); // ýòî ÷åòâåðòîå ïîëå òàáëèöû áóäåò òèï ïîëÿ êëàññà
/trunk/ClassEditor/classeditor.cpp
230,8 → 230,31
ui->tableView->hideColumn(3);
ui->tableView->hideColumn(2);
 
ui->tableView_2->hideColumn(0);
ui->tableView_2->hideColumn(5);
ui->tableView_2->hideColumn(2);
 
currIndexOfClassesTable = modelForDescription->index(0, 1);
QModelIndex index_temp;
 
currClassID = mymodel->data(mymodel->index(0,0)).toString();
QItemSelectionModel *selectionModel = ui->tableView->selectionModel();
 
QModelIndex topLeft;
QModelIndex bottomRight;
 
topLeft = mymodel->index(0, 0, QModelIndex());
bottomRight = mymodel->index(0, 1, QModelIndex());
 
QItemSelection selection(topLeft, bottomRight);
selectionModel->select(selection, QItemSelectionModel::Select);
 
 
 
//connect(ui->tableView, SIGNAL(clicked(const QModelIndex)), this, SLOT(on_tableView_clicked(const QModelIndex)));
connect(mymodel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_myModel_dataChanged(QModelIndex,QModelIndex)));
connect(modelForDescription, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_modelForDescription_dataChanged(QModelIndex,QModelIndex)));
 
}
 
 
328,6 → 351,30
}
 
 
void ClassEditor::addNewField(){
// QSqlRecord rec = mymodel->record(1);
//bool ok;
//ok = rec.isEmpty();
//QString currientClassID;
//currientClassID = rec.value(1).toString();
int row = modelForDescription->rowCount();
modelForDescription->insertRows(row, 1);
modelForDescription->setData(modelForDescription->index(row, 5), QVariant(currClassID), Qt::EditRole);
modelForDescription->setData(modelForDescription->index(row, 4), QVariant(tr("NULL")), Qt::EditRole);
 
modelForDescription->submitAll();
}
 
 
 
 
 
 
 
 
 
 
 
void ClassEditor::on_pushButton_clicked(){
//int i;
//i++;
343,14 → 390,17
i++;
row = index.row();
column = index.column();
QModelIndex index_tmp;
currIndexOfClassesTable = index;
QModelIndex index_tmp;
QString tmp_str, filter_str;
index_tmp = ui->tableView->model()->index(row, 0);
tmp_str = ui->tableView->model()->data(index_tmp).toString();
//ui->label->setText(tmp_str);
currClassID = tmp_str;
// ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString());
filter_str = tr("ClassIdentifer = ");
filter_str.append(tmp_str);
modelForDescription->setFilter(filter_str);
ui->tableView_2->resizeColumnsToContents();
i++;
}
 
365,8 → 415,30
void ClassEditor::on_pushButton_3_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Íîâîå ïîëå"
int i;
i++;
ClassEditor::addNewField();
ClassEditor::modelForDescription->select();
}
void ClassEditor::on_pushButton_4_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü ïîëå"
int i;
i++;
QModelIndex model_index;
QItemSelectionModel *selectionModel = ui->tableView->selectionModel();
QModelIndexList indexes = selectionModel->selectedIndexes();
//model_index = mymodel->selec;
//modelList = ui->tableView->SelectItems;
i = indexes.size();
 
if (i > 0) model_index = indexes.at(0);
i++;
}
 
 
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();
}
/trunk/ClassEditor/classeditor.h
28,6 → 28,8
SettingsDialog settdialog;
TableField *field;
SqlTable *table;
QModelIndex currIndexOfClassesTable; // ïåðåìåííàÿ õðàíèò òåêóùèé èíäåêñ òàáëèöû êëàññîâ
QString currClassID; // òåêóùèé èäåíòèôèêàòîð êëàññà
 
QSqlTableModel* model;
// QSqlTableModel* modelForDescription;
38,6 → 40,7
 
void addNewClass(); // äîáàâèì íîâûé êëàññ
void addNewClass_new();
void addNewField(); // äîáàâëÿåì íîâîå ïîëå ê êëàññó
 
private slots:
 
46,9 → 49,9
void on_pushButton_3_clicked(); // îáðàáîò÷èê íàæàòèÿ êíîïêè "Íîâîå ïîëå"
void on_pushButton_4_clicked(); // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü ïîëå"
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 );
 
 
 
};
 
#endif // CLASSEDITOR_H
/trunk/ClassEditor/modelfordescriptiontable.cpp
9,13 → 9,13
Qt::ItemFlags ModelForDescriptionTable::flags(
const QModelIndex &index) const {
Qt::ItemFlags flags = QSqlTableModel::flags(index);
if ((index.column() != 3) && (index.column() != 0))
if ((index.column() != 5) && (index.column() != 0))
flags |= Qt::ItemIsEditable;
//if (index.column() == 4)
// flags |= Qt::ItemIsUserCheckable;
else
{
if (index.column() == 0) flags &= ~Qt::ItemIsEditable; // çàïðåùàåì ðåäàêòèðîâàíèå òðåòüåãî ñòîëáöà
if ((index.column() == 0) || (index.column() == 5)) flags &= ~Qt::ItemIsEditable; // çàïðåùàåì ðåäàêòèðîâàíèå òðåòüåãî ñòîëáöà
}
return flags;
}
98,7 → 98,7
int a = (index.row() % 2) ? 14 : 0;
if(index.column() == 2)
return qVariantFromValue(QColor(220,240-a,230-a));
else if(index.column() == 4)
else if(index.column() == 6)
return qVariantFromValue(QColor(200,220-a,255-a));
else
return value;