summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--databasemodel.cpp2
-rw-r--r--databasetable.cpp1
-rw-r--r--databasetable.h7
-rw-r--r--tableproperties.cpp16
-rw-r--r--tableproperties.h1
5 files changed, 24 insertions, 3 deletions
diff --git a/databasemodel.cpp b/databasemodel.cpp
index f38a385..9e6f635 100644
--- a/databasemodel.cpp
+++ b/databasemodel.cpp
@@ -96,7 +96,7 @@ DatabaseModel::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
DatabaseTable *source = qgraphicsitem_cast<DatabaseTable *>(itemAt(m_line->line().p1()));
DatabaseTable *target = qgraphicsitem_cast<DatabaseTable *>(itemAt(m_line->line().p2()));
if (source && target && source != target) {
- qDebug() << "Add relation between " << source << " and " << target;
+ //qDebug() << "Add relation between " << source << " and " << target;
DatabaseRelation *relation = new DatabaseRelation();
relation->setSource(source);
relation->setTarget(target);
diff --git a/databasetable.cpp b/databasetable.cpp
index 50e7e9e..663bfdc 100644
--- a/databasetable.cpp
+++ b/databasetable.cpp
@@ -100,6 +100,7 @@ DatabaseTable::setName(const QString &name)
{
m_name = name;
updateLayout();
+ emit propertyChanged("name", name);
}
Column *
diff --git a/databasetable.h b/databasetable.h
index 48517ae..1d2ebcc 100644
--- a/databasetable.h
+++ b/databasetable.h
@@ -24,8 +24,10 @@
class Column;
class DatabaseModel;
-class DatabaseTable : public DatabaseModelItem
+class DatabaseTable : public QObject, public DatabaseModelItem
{
+ Q_OBJECT
+
public:
DatabaseTable(QGraphicsItem *parent = 0);
@@ -49,6 +51,9 @@ public:
enum { Type = DatabaseModelItem::Table };
virtual int type() const { return Type; }
+signals:
+ void propertyChanged(const QString &name, const QVariant &value);
+
protected slots:
void updateLayout();
diff --git a/tableproperties.cpp b/tableproperties.cpp
index 52890a9..e319c04 100644
--- a/tableproperties.cpp
+++ b/tableproperties.cpp
@@ -23,7 +23,7 @@
#include <QDebug>
TableProperties::TableProperties(MainWindow *window, QWidget *parent)
- : QWidget(parent), m_window(window)
+ : QWidget(parent), m_window(window), m_table(0)
{
ui.setupUi(this);
connect(ui.nameEdit,
@@ -49,6 +49,11 @@ TableProperties::setSelectedTableName(const QString &name)
void
TableProperties::setTable(DatabaseTable *table)
{
+ // Disconnect all connections from the previous table
+ if (m_table) {
+ disconnect(m_table, 0, this, 0);
+ }
+
m_table = NULL;
if (table == NULL) {
setEnabled(false);
@@ -59,12 +64,21 @@ TableProperties::setTable(DatabaseTable *table)
setEnabled(true);
ui.nameEdit->setText(table->name());
ui.columnsWidget->setTable(table);
+ connect(table, SIGNAL(propertyChanged(const QString &, const QVariant &)), SLOT(updateProperty(const QString &, const QVariant &)));
}
m_table = table;
updateColumnSelection();
}
void
+TableProperties::updateProperty(const QString &name, const QVariant &value)
+{
+ if (name == "name") {
+ ui.nameEdit->setText(value.toString());
+ }
+}
+
+void
TableProperties::updateColumnSelection()
{
QList<int> columns = ui.columnsWidget->selectedColumns();
diff --git a/tableproperties.h b/tableproperties.h
index 4b13d1d..6ad51a5 100644
--- a/tableproperties.h
+++ b/tableproperties.h
@@ -37,6 +37,7 @@ public:
protected slots:
void setSelectedTableName(const QString &name);
void updateColumnSelection();
+ void updateProperty(const QString &name, const QVariant &value);
private:
MainWindow *m_window;