Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 223 → Rev 224

/trunk/DBViewer/database.cpp
576,7 → 576,7
 
 
}
else if(!class_filter.isEmpty()) // åñëè ôèëüòð äëÿ êëàññà íå ïóñòîé)
else if(!class_filter.isEmpty()) // åñëè ôèëüòð äëÿ êëàññà íå ïóñòîé, à ôèëüòð ïóñòîé
{
filtr_tmp.append(class_filter); // äîáàâèì è ôèëüòð äëÿ êëàññà (êîòîðûé óêàçûâàëè â äåðåâå ìîäåëåé)
}
/trunk/DBViewer/delegate.cpp
575,7 → 575,146
 
 
 
FilterValueDelegate::FilterValueDelegate(QObject *parent)
: QItemDelegate(parent)
{
}
//! [0]
 
void FilterValueDelegate::setClassID(QString newClassID){
class_id = newClassID;
}
 
 
 
//! [1]
QWidget *FilterValueDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex &/* index */) const
{
QStringList Name_list;
 
Name_list = items;
 
QComboBox *editor = new QComboBox(parent);
 
/*
editor->addItem("0");
editor->addItem("1");
editor->addItem("2");
editor->addItem("3");
editor->addItem("4");
editor->addItem("5");
editor->addItem("6");
editor->addItem("7");
editor->addItem("8");
editor->addItem("9");
*/
 
// editor->addItem("0");
 
// // // editor->addItems(Name_list);
// editor->setEditable(false);
return editor;
}
//! [1]
 
//! [2]
void FilterValueDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
// int value = index.model()->data(index, Qt::EditRole).toInt();
 
// QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
// spinBox->setValue(value);
 
 
const QAbstractItemModel * model = index.model();
 
 
QString value = index.model()->data(index, Qt::EditRole).toString();
QString class_id = index.model()->data(model->index(index.row(),2), Qt::EditRole).toString();
QComboBox *comboBox = static_cast<QComboBox*>(editor);
 
//QStringList ID_list;
//QStringList Name_list;
int curr_index;
 
//ID_list = items.keys();
//Name_list = items.values();
 
curr_index = items.indexOf(value);
if (curr_index==-1) return;
comboBox->setCurrentIndex(curr_index);
/****************************************************
if (value == "0") comboBox->setCurrentIndex(0);
if (value == "1") comboBox->setCurrentIndex(1);
if (value == "2") comboBox->setCurrentIndex(2);
if (value == "3") comboBox->setCurrentIndex(3);
if (value == "4") comboBox->setCurrentIndex(4);
if (value == "5") comboBox->setCurrentIndex(5);
if (value == "6") comboBox->setCurrentIndex(6);
if (value == "7") comboBox->setCurrentIndex(7);
if (value == "8") comboBox->setCurrentIndex(8);
if (value == "9") comboBox->setCurrentIndex(9);
******************************************************/
comboBox->setEditable(false);
 
 
//comboBox->setItemText(0, value);
 
}
//! [2]
 
//! [3]
void FilterValueDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
// QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
// spinBox->interpretText();
// int value = spinBox->value();
 
// model->setData(index, value, Qt::EditRole);
QStringList ID_list;
QStringList Name_list;
 
QComboBox *comboBox = static_cast<QComboBox*>(editor);
int currIndex;
currIndex = comboBox->currentIndex();
if (currIndex==-1) return;
// QString value = comboBox->itemText(currIndex);
 
// ID_list = items.keys();
// Name_list = items.values();
 
// QString value = ID_list.at(currIndex);
QString value = items.at(currIndex);
model->setData(index, value, Qt::EditRole);
}
//! [3]
 
//! [4]
void FilterValueDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
{
editor->setGeometry(option.rect);
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
//! [4]
MyDEDelegate::MyDEDelegate(
bool calpopup,
QObject *parent)
/trunk/DBViewer/mainwindow.cpp
927,7 → 927,7
filterSpinDelegate.getItems();
ui->tableView_3->setItemDelegateForColumn(4, &filterSpinDelegate);
 
 
// ui->tableView_3->setItemDelegate();
conditionList <<"" << "and" << "or" << "(" << "and (" << "or (";
filterConditionDelegate.setItems(conditionList);
ui->tableView_3->setItemDelegateForColumn(3, &filterConditionDelegate);
938,7 → 938,11
ui->tableView_3->setItemDelegateForColumn(5, &filterConditionDelegate_1);
 
 
ui->tableView_3->setItemDelegateForColumn(6, &filterValueDelegate);
 
 
 
 
ui->pushButton_9->setEnabled(true);
ui->pushButton_10->setEnabled(true);
 
/trunk/DBViewer/delegate.h
17,6 → 17,8
 
//#include <QMainWindow>
//! [0]
 
 
class SpinBoxDelegate : public QItemDelegate
{
Q_OBJECT
54,6 → 56,8
 
 
 
 
 
class FilterConditionDelegate : public QItemDelegate
{
Q_OBJECT
89,7 → 93,42
 
 
 
class FilterValueDelegate : public QItemDelegate
{
Q_OBJECT
 
public:
FilterValueDelegate(QObject *parent = 0);
 
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
 
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
 
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &index) const;
 
 
 
void setClassID(QString newClassID);
// void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê
 
void setItems(QStringList new_items){items = new_items;}
 
 
private:
 
 
QString class_id; // òàáëèöà-õðàíèëèùå, îòêóäà áóäåì áðàòü ñïèñîê
// QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID
QStringList items; // ñïèñîê
};
 
 
 
 
//! [0]
class FilterSpinBoxDelegate : public QItemDelegate
{
/trunk/DBViewer/mainwindow.h
165,9 → 165,11
QItemDelegate standart_delegate;
CPictureDelegate * picture_delegate;
IconDelegate * iconDelegate;
FileDelegate * fileDelegate; // äåëåãàò äëÿ òàáëèöû ñ ôèëüòðàìè, áóäêò îòîáðàæàòü ñïèñîê ïîëåé êëàññà
FileDelegate * fileDelegate; // äåëåãàò äëÿ òàáëèöû ñ ôèëüòðàìè, áóäåò îòîáðàæàòü ñïèñîê ïîëåé êëàññà
FilterSpinBoxDelegate filterSpinDelegate;
FilterConditionDelegate filterConditionDelegate, filterConditionDelegate_1, filterConditionDelegate_2;
FilterValueDelegate filterValueDelegate; // äåëåãàò äëÿ òàáëèöû ñ ôèëüòðàìè, áóäåò îòîáðàæàòü ñïèñîê çíà÷åíèé îáúåêòîâ êëàññà
 
bool comboBox_slot_enable; // äëÿ áëîêèðîâêè ñëîòà, êîãäà ìåíÿåì item_index èç ïðîãðàììû, à íå âðó÷íóþ
QList <int> boolFieldsIndexes_global; // ñïèñîê íîìåðîâ ñòîëáöîâ ñ òèïîì "BOOL"