Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 225 → Rev 226

/trunk/DBViewer/delegate.h
19,6 → 19,20
//! [0]
 
 
typedef struct field {
 
QString ID;
QString FieldName;
QString FieldAlias;
QString FieldType;
QString DefaultValue;
QString ClassIdentifer;
QString Comment;
 
} TField; // ýòà ñòðóêòóðà îïèñûâàåò ïîëå
 
 
 
class SpinBoxDelegate : public QItemDelegate
{
Q_OBJECT
97,6 → 111,12
{
Q_OBJECT
 
 
 
 
 
 
 
public:
FilterValueDelegate(QObject *parent = 0);
 
125,8 → 145,8
// QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID
mutable QStringList items; // ñïèñîê
static QString getClassInctanc(QString class_id);//îïðåäåëÿåì õðàíèëèùå îáúåêòîâ
static QString grtFieldType(QString class_id, QString fieldName);//îïðåäåëÿåì òèï äàííûõ ïîëÿ
 
static QString getFieldType(QString class_id, QString fieldName);//îïðåäåëÿåì òèï äàííûõ ïîëÿ
static TField getField(const QModelIndex &index); // ïî èíäåêñó (â òàáëèöå ôèëüòðîâ) ïîëó÷èì èíôîðìàöèþ î ïîëå
};
 
 
/trunk/DBViewer/database.cpp
879,6 → 879,8
 
}
filter_model->submitAll();
 
filter_model->sort(0,Qt::AscendingOrder);
// getDatabaseData();
model_is_build = false;
MainWindow::readModels();
890,6 → 892,7
void MainWindow::on_pushButton_11_clicked()// íàæàòèå êíîïêè "Ïðèìåíèòü" (íà âêëàäêå ôèëüòðîâ)
{
filter_model->submitAll();
filter_model->sort(0,Qt::AscendingOrder);
ui->pushButton_11->setEnabled(false);
ui->pushButton_12->setEnabled(false);
 
/trunk/DBViewer/delegate.cpp
641,12 → 641,17
 
 
 
QString grtFieldType(QString class_id, QString fieldName)//îïðåäåëÿåì òèï äàííûõ ïîëÿ
QString FilterValueDelegate::getFieldType(QString class_id, QString fieldName)//îïðåäåëÿåì òèï äàííûõ ïîëÿ
{
 
}
 
 
 
 
 
 
 
//! [1]
QWidget *FilterValueDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
682,12 → 687,65
 
 
 
TField FilterValueDelegate::getField(const QModelIndex &index) // ïî èíäåêñó (â òàáëèöå ôèëüòðîâ) ïîëó÷èì èíôîðìàöèþ î ïîëå
{
const QAbstractItemModel * model = index.model();
 
TField field_result;
QSqlQuery q;
QString sql_str;
bool ok;
 
 
// QString fieldName = index.model()->data(model->index(index.row(),4), Qt::EditRole).toString();
// QString class_id = index.model()->data(model->index(index.row(),2), Qt::EditRole).toString();
field_result.FieldName = index.model()->data(model->index(index.row(),4), Qt::EditRole).toString();
field_result.ClassIdentifer = index.model()->data(model->index(index.row(),2), Qt::EditRole).toString();
 
sql_str = tr("select * from `DescriptionOfClasses` where `ClassIdentifer` = '");
sql_str.append(field_result.ClassIdentifer);
sql_str.append(tr("' and `FieldName` = '"));
sql_str.append(field_result.FieldName);
sql_str.append(tr("'"));
 
ok = q.prepare(sql_str);
 
if(!ok) return field_result;
 
ok = q.exec();
 
if(!ok) return field_result;
 
int ID_index = q.record().indexOf(tr("ID"));
 
int FieldAlias_index = q.record().indexOf(tr("FieldAlias"));
 
int FieldType_index = q.record().indexOf(tr("FieldType"));
 
int DefaultValue_index = q.record().indexOf(tr("DefaultValue"));
 
int Comment_index = q.record().indexOf(tr("Comment"));
 
 
 
while(q.next()){
field_result.ID = q.value(ID_index).asString();
field_result.FieldAlias = q.value(FieldAlias_index).asString();
field_result.FieldType = q.value(FieldType_index).asString();
field_result.DefaultValue = q.value(DefaultValue_index).asString();
field_result.Comment = q.value(Comment_index).asString();
}
 
return field_result;
 
 
 
}
 
 
 
 
 
//! [2]
void FilterValueDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
710,9 → 768,15
QString sql_str;
QStringList itemsList;
bool ok;
TField Field;
 
Field = getField(index);
 
 
 
 
 
 
fieldName = index.model()->data(model->index(index.row(),4), Qt::EditRole).toString();
 
 
/trunk/DBViewer/mainwindow.cpp
914,7 → 914,13
connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
filter_model->setTable(tr("Filters"));
filter_model->setFilter(filtr_str);
 
 
 
filter_model->select();
 
filter_model->sort(0,Qt::AscendingOrder);
 
ui->tableView_3->setModel(filter_model);