git-svn-id: svn://db.shs.com.ru/libs@155 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -73,6 +73,7 @@ bool SQLQueryModel::setData(const QModelIndex& index, const QVariant & value, in
|
||||
//qDebug() << "[UPDATE]" << q.lastQuery();
|
||||
dataChanged(index, index);
|
||||
updateTable(true);
|
||||
emit tableChanged();
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < w_.size(); ++i)
|
||||
if (*w_[i]) (*w_[i])->setHidden(false);
|
||||
resizeEvent(0);
|
||||
}
|
||||
|
||||
@@ -348,7 +351,9 @@ SQLTableWidget::SQLTableWidget(QWidget * parent): QWidget(parent), filters_group
|
||||
|
||||
//act_add.setText(trUtf8("Add ..."));
|
||||
//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);
|
||||
filters_group.addAction(ui->actionFilter_AND);
|
||||
filters_group.addAction(ui->actionFilter_OR);
|
||||
@@ -380,13 +385,13 @@ bool SQLTableWidget::eventFilter(QObject * o, QEvent * e) {
|
||||
if (o == ui->view->viewport()) {
|
||||
if (e->type() == QEvent::MouseButtonPress) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (o == ui->view->horizontalHeader()->viewport()) {
|
||||
static QPoint pp;
|
||||
QMouseEvent * me = (QMouseEvent * )e;
|
||||
if (e->type() == QEvent::MouseButtonPress)
|
||||
pp = me->pos();
|
||||
@@ -425,7 +430,7 @@ bool SQLTableWidget::eventFilter(QObject * o, QEvent * e) {
|
||||
} 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);
|
||||
connect(model, SIGNAL(updateTable(bool)), this, SLOT(updateTable(bool)));
|
||||
connect(model, SIGNAL(tableChanged()), this, SIGNAL(tableChanged()));
|
||||
//model->setTable(table_);
|
||||
cquery = "SELECT * FROM " + table_ + ";";
|
||||
model->setQuery(cquery, QSqlDatabase::database(connection_name));
|
||||
@@ -667,8 +673,7 @@ void SQLTableWidget::setConnectionName(const QString & conn_name) {
|
||||
|
||||
QString SQLTableWidget::tableNames() {
|
||||
QString ret = table_;
|
||||
static QSet<QString> rtables;
|
||||
rtables.clear();
|
||||
QSet<QString> rtables;
|
||||
for (int i = 0; i < column_props.size(); ++i) {
|
||||
ColumnProperties & cp(column_props[i]);
|
||||
if (!cp.visible || cp.relation_key.isEmpty() || cp.relation_column.isEmpty())
|
||||
@@ -765,9 +770,10 @@ void SQLTableWidget::on_buttonAdd_clicked() {
|
||||
}
|
||||
qs.append(");");
|
||||
QSqlQuery q(QSqlDatabase::database(connection_name));
|
||||
if (q.exec(qs))
|
||||
if (q.exec(qs)) {
|
||||
updateTable();
|
||||
else
|
||||
emit tableChanged();
|
||||
} else
|
||||
qDebug() << q.lastError();
|
||||
//qDebug() << q.lastQuery();
|
||||
}
|
||||
@@ -804,9 +810,10 @@ void SQLTableWidget::del_triggered() {
|
||||
qs.append(");");
|
||||
//qDebug() << qs; return;
|
||||
QSqlQuery q(QSqlDatabase::database(connection_name));
|
||||
if (q.exec(qs))
|
||||
if (q.exec(qs)) {
|
||||
updateTable();
|
||||
else
|
||||
emit tableChanged();
|
||||
} else
|
||||
qDebug() << q.lastError();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user