git-svn-id: svn://db.shs.com.ru/libs@155 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -17,7 +17,7 @@ if(DEBUG)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
||||||
endif()
|
endif()
|
||||||
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${PIP_LIBRARY} qad_widgets qad_utils qad_blockview)
|
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${PIP_LIBRARY} qad_widgets qad_utils qad_blockview)
|
||||||
pip_code_model(CCM "../pip/src/io/piiodevice.h" OPTIONS "-DPIP_EXPORT" "-Es")
|
pip_code_model(CCM "../pip/src/io/piiodevice.h" "../pip/src/io/pipacketextractor.h" OPTIONS "-DPIP_EXPORT" "-Es")
|
||||||
#message(STATUS "pip_code_model for iodevice = ${CCM}")
|
#message(STATUS "pip_code_model for iodevice = ${CCM}")
|
||||||
#message(STATUS "pip_INCLUDES = ${PIP_INCLUDES}")
|
#message(STATUS "pip_INCLUDES = ${PIP_INCLUDES}")
|
||||||
file(GLOB CPPS_UTILS "piqt_*.cpp")
|
file(GLOB CPPS_UTILS "piqt_*.cpp")
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ bool SQLQueryModel::setData(const QModelIndex& index, const QVariant & value, in
|
|||||||
//qDebug() << "[UPDATE]" << q.lastQuery();
|
//qDebug() << "[UPDATE]" << q.lastQuery();
|
||||||
dataChanged(index, index);
|
dataChanged(index, index);
|
||||||
updateTable(true);
|
updateTable(true);
|
||||||
|
emit tableChanged();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -112,6 +113,8 @@ void SQLUniEdit::setProp(const ColumnProperties & p) {
|
|||||||
default: wtext = new QLineEdit(this); connect(wtext, SIGNAL(textChanged(QString)), this, SLOT(value_text(QString))); break;
|
default: wtext = new QLineEdit(this); connect(wtext, SIGNAL(textChanged(QString)), this, SLOT(value_text(QString))); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < w_.size(); ++i)
|
||||||
|
if (*w_[i]) (*w_[i])->setHidden(false);
|
||||||
resizeEvent(0);
|
resizeEvent(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +351,9 @@ SQLTableWidget::SQLTableWidget(QWidget * parent): QWidget(parent), filters_group
|
|||||||
|
|
||||||
//act_add.setText(trUtf8("Add ..."));
|
//act_add.setText(trUtf8("Add ..."));
|
||||||
//act_del.setText(trUtf8("Remove selected"));
|
//act_del.setText(trUtf8("Remove selected"));
|
||||||
popup_menu.addAction(QIcon(":/icons/edit-delete.png"), trUtf8("Remove selected"), this, SLOT(del_triggered()));
|
action_del = new QAction(QIcon(":/icons/edit-delete.png"), trUtf8("Remove selected"), this);
|
||||||
|
connect(action_del, SIGNAL(triggered(bool)), this, SLOT(del_triggered()));
|
||||||
|
popup_menu.addAction(action_del);
|
||||||
ui->actionFilter_AND->setChecked(true);
|
ui->actionFilter_AND->setChecked(true);
|
||||||
filters_group.addAction(ui->actionFilter_AND);
|
filters_group.addAction(ui->actionFilter_AND);
|
||||||
filters_group.addAction(ui->actionFilter_OR);
|
filters_group.addAction(ui->actionFilter_OR);
|
||||||
@@ -380,13 +385,13 @@ bool SQLTableWidget::eventFilter(QObject * o, QEvent * e) {
|
|||||||
if (o == ui->view->viewport()) {
|
if (o == ui->view->viewport()) {
|
||||||
if (e->type() == QEvent::MouseButtonPress) {
|
if (e->type() == QEvent::MouseButtonPress) {
|
||||||
QMouseEvent * me = (QMouseEvent * )e;
|
QMouseEvent * me = (QMouseEvent * )e;
|
||||||
if (me->button() == Qt::RightButton && !read_only) {
|
if (me->button() == Qt::RightButton) {
|
||||||
|
action_del->setVisible(!read_only);
|
||||||
popup_menu.popup(me->globalPos());
|
popup_menu.popup(me->globalPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (o == ui->view->horizontalHeader()->viewport()) {
|
if (o == ui->view->horizontalHeader()->viewport()) {
|
||||||
static QPoint pp;
|
|
||||||
QMouseEvent * me = (QMouseEvent * )e;
|
QMouseEvent * me = (QMouseEvent * )e;
|
||||||
if (e->type() == QEvent::MouseButtonPress)
|
if (e->type() == QEvent::MouseButtonPress)
|
||||||
pp = me->pos();
|
pp = me->pos();
|
||||||
@@ -425,7 +430,7 @@ bool SQLTableWidget::eventFilter(QObject * o, QEvent * e) {
|
|||||||
} else return true;
|
} else return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QObject::eventFilter(o, e);
|
return QWidget::eventFilter(o, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -448,6 +453,7 @@ void SQLTableWidget::setTableName(const QString & t) {
|
|||||||
}
|
}
|
||||||
model = new SQLQueryModel(table_, connection_name, column_props, column_indexes, this);
|
model = new SQLQueryModel(table_, connection_name, column_props, column_indexes, this);
|
||||||
connect(model, SIGNAL(updateTable(bool)), this, SLOT(updateTable(bool)));
|
connect(model, SIGNAL(updateTable(bool)), this, SLOT(updateTable(bool)));
|
||||||
|
connect(model, SIGNAL(tableChanged()), this, SIGNAL(tableChanged()));
|
||||||
//model->setTable(table_);
|
//model->setTable(table_);
|
||||||
cquery = "SELECT * FROM " + table_ + ";";
|
cquery = "SELECT * FROM " + table_ + ";";
|
||||||
model->setQuery(cquery, QSqlDatabase::database(connection_name));
|
model->setQuery(cquery, QSqlDatabase::database(connection_name));
|
||||||
@@ -667,8 +673,7 @@ void SQLTableWidget::setConnectionName(const QString & conn_name) {
|
|||||||
|
|
||||||
QString SQLTableWidget::tableNames() {
|
QString SQLTableWidget::tableNames() {
|
||||||
QString ret = table_;
|
QString ret = table_;
|
||||||
static QSet<QString> rtables;
|
QSet<QString> rtables;
|
||||||
rtables.clear();
|
|
||||||
for (int i = 0; i < column_props.size(); ++i) {
|
for (int i = 0; i < column_props.size(); ++i) {
|
||||||
ColumnProperties & cp(column_props[i]);
|
ColumnProperties & cp(column_props[i]);
|
||||||
if (!cp.visible || cp.relation_key.isEmpty() || cp.relation_column.isEmpty())
|
if (!cp.visible || cp.relation_key.isEmpty() || cp.relation_column.isEmpty())
|
||||||
@@ -765,9 +770,10 @@ void SQLTableWidget::on_buttonAdd_clicked() {
|
|||||||
}
|
}
|
||||||
qs.append(");");
|
qs.append(");");
|
||||||
QSqlQuery q(QSqlDatabase::database(connection_name));
|
QSqlQuery q(QSqlDatabase::database(connection_name));
|
||||||
if (q.exec(qs))
|
if (q.exec(qs)) {
|
||||||
updateTable();
|
updateTable();
|
||||||
else
|
emit tableChanged();
|
||||||
|
} else
|
||||||
qDebug() << q.lastError();
|
qDebug() << q.lastError();
|
||||||
//qDebug() << q.lastQuery();
|
//qDebug() << q.lastQuery();
|
||||||
}
|
}
|
||||||
@@ -804,9 +810,10 @@ void SQLTableWidget::del_triggered() {
|
|||||||
qs.append(");");
|
qs.append(");");
|
||||||
//qDebug() << qs; return;
|
//qDebug() << qs; return;
|
||||||
QSqlQuery q(QSqlDatabase::database(connection_name));
|
QSqlQuery q(QSqlDatabase::database(connection_name));
|
||||||
if (q.exec(qs))
|
if (q.exec(qs)) {
|
||||||
updateTable();
|
updateTable();
|
||||||
else
|
emit tableChanged();
|
||||||
|
} else
|
||||||
qDebug() << q.lastError();
|
qDebug() << q.lastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ protected:
|
|||||||
QString & conn_name;
|
QString & conn_name;
|
||||||
signals:
|
signals:
|
||||||
void updateTable(bool save_selection);
|
void updateTable(bool save_selection);
|
||||||
|
void tableChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -129,6 +130,7 @@ signals:
|
|||||||
|
|
||||||
class SQLNewEdit: public QWidget {
|
class SQLNewEdit: public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
friend class SQLTableWidget;
|
||||||
public:
|
public:
|
||||||
explicit SQLNewEdit(const ColumnProperties & prop, const QString & conn_name, QWidget * parent = 0);
|
explicit SQLNewEdit(const ColumnProperties & prop, const QString & conn_name, QWidget * parent = 0);
|
||||||
~SQLNewEdit() {delete line; delete check;}
|
~SQLNewEdit() {delete line; delete check;}
|
||||||
@@ -147,6 +149,7 @@ private:
|
|||||||
|
|
||||||
class SQLFilterEdit: public QWidget {
|
class SQLFilterEdit: public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
friend class SQLTableWidget;
|
||||||
public:
|
public:
|
||||||
explicit SQLFilterEdit(const ColumnProperties & prop, const QString & conn_name, QWidget * parent = 0);
|
explicit SQLFilterEdit(const ColumnProperties & prop, const QString & conn_name, QWidget * parent = 0);
|
||||||
~SQLFilterEdit() {delete line; delete combo;}
|
~SQLFilterEdit() {delete line; delete combo;}
|
||||||
@@ -290,12 +293,14 @@ private:
|
|||||||
QMenu popup_menu, popup_col, popup_filter;
|
QMenu popup_menu, popup_col, popup_filter;
|
||||||
QTime tm;
|
QTime tm;
|
||||||
QActionGroup filters_group;
|
QActionGroup filters_group;
|
||||||
|
QAction * action_del;
|
||||||
QList<QAction*> add_actions;
|
QList<QAction*> add_actions;
|
||||||
QMap<QString, QPair<QString, QString> > translates, fixed_translates;
|
QMap<QString, QPair<QString, QString> > translates, fixed_translates;
|
||||||
QMap<QString, bool> col_vis;
|
QMap<QString, bool> col_vis;
|
||||||
int timer;
|
int timer;
|
||||||
bool filters_active, table_opened, read_only, first_update;
|
bool filters_active, table_opened, read_only, first_update;
|
||||||
static QString _dir;
|
static QString _dir;
|
||||||
|
QPoint pp;
|
||||||
QString connection_name;
|
QString connection_name;
|
||||||
|
|
||||||
|
|
||||||
@@ -321,6 +326,7 @@ signals:
|
|||||||
void rowClicked(int row);
|
void rowClicked(int row);
|
||||||
void recordClicked(QSqlRecord rec);
|
void recordClicked(QSqlRecord rec);
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
|
void tableChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user