summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukáš Lalinský <lalinsky@gmail.com>2008-12-10 22:55:28 +0100
committerLukáš Lalinský <lalinsky@gmail.com>2008-12-10 22:55:28 +0100
commitf4d9a3f2ad1896c5117ce1d3af3b8b3a433b3961 (patch)
treef05e68d3d7a39e1f4fbac2323cad7e1ed9158a38
parente23b78998b04bc91d022dd82880179118203efb9 (diff)
downloaddbmodel-f4d9a3f2ad1896c5117ce1d3af3b8b3a433b3961.tar.gz
dbmodel-f4d9a3f2ad1896c5117ce1d3af3b8b3a433b3961.tar.bz2
Highlight selected relationships
-rw-r--r--src/items/database/columnlistmodel.cpp12
-rw-r--r--src/items/database/columnlistview.cpp8
-rw-r--r--src/items/database/databaserelationship.cpp7
-rw-r--r--src/items/database/databasetable.cpp10
-rw-r--r--src/items/database/databasetable.h2
5 files changed, 19 insertions, 20 deletions
diff --git a/src/items/database/columnlistmodel.cpp b/src/items/database/columnlistmodel.cpp
index 5a282c8..7e9c664 100644
--- a/src/items/database/columnlistmodel.cpp
+++ b/src/items/database/columnlistmodel.cpp
@@ -100,17 +100,17 @@ ColumnListModel::setData(const QModelIndex &index, const QVariant &value, int ro
if (role == Qt::DisplayRole || role == Qt::EditRole) {
QString text = value.toString();
if (index.column() == 0) {
- m_columnList->table()->model()->undoStack()->push(
+ m_columnList->table()->document()->undoStack()->push(
new SetObjectPropertyCommand(column, "name", text));
goto OK;
}
if (index.column() == 1) {
- m_columnList->table()->model()->undoStack()->push(
+ m_columnList->table()->document()->undoStack()->push(
new SetObjectPropertyCommand(column, "dataType", text));
goto OK;
}
if (index.column() == 4) {
- m_columnList->table()->model()->undoStack()->push(
+ m_columnList->table()->document()->undoStack()->push(
new SetObjectPropertyCommand(column, "notes", text));
goto OK;
}
@@ -118,16 +118,16 @@ ColumnListModel::setData(const QModelIndex &index, const QVariant &value, int ro
if (role == Qt::CheckStateRole) {
bool checked = value.toInt() == Qt::Checked ? true : false;
if (index.column() == 2) {
- m_columnList->table()->model()->undoStack()->push(
+ m_columnList->table()->document()->undoStack()->push(
new SetObjectPropertyCommand(column, "required", checked));
goto OK;
}
if (index.column() == 3) {
- m_columnList->table()->model()->undoStack()->push(
+ m_columnList->table()->document()->undoStack()->push(
new SetObjectPropertyCommand(column, "primaryKey", checked));
if (!column->isRequired()) {
// TODO is there a simple way to group this with the previous command?
- m_columnList->table()->model()->undoStack()->push(
+ m_columnList->table()->document()->undoStack()->push(
new SetObjectPropertyCommand(column, "required", true));
}
goto OK;
diff --git a/src/items/database/columnlistview.cpp b/src/items/database/columnlistview.cpp
index c491467..4edb4ee 100644
--- a/src/items/database/columnlistview.cpp
+++ b/src/items/database/columnlistview.cpp
@@ -36,7 +36,7 @@ void
ColumnListView::addColumn()
{
AddColumnCommand *command = new AddColumnCommand(columnList());
- columnList()->table()->model()->undoStack()->push(command);
+ columnList()->table()->document()->undoStack()->push(command);
QModelIndex index = columnListModel()->indexFromRow(command->index());
setCurrentIndex(index);
edit(index);
@@ -47,7 +47,7 @@ ColumnListView::removeColumn()
{
QList<int> indexes = selectedColumns();
if (indexes.size() == 1) {
- columnList()->table()->model()->undoStack()->push(
+ columnList()->table()->document()->undoStack()->push(
new RemoveColumnCommand(columnList(), indexes[0]));
}
}
@@ -59,7 +59,7 @@ ColumnListView::moveColumnDown()
if (indexes.size() == 1) {
int i = indexes[0];
if (i + 1 < columnList()->columnCount()) {
- columnList()->table()->model()->undoStack()->push(
+ columnList()->table()->document()->undoStack()->push(
new SwapColumnsCommand(columnList(), i, i + 1));
setCurrentIndex(columnListModel()->indexFromRow(i + 1));
}
@@ -73,7 +73,7 @@ ColumnListView::moveColumnUp()
if (indexes.size() == 1) {
int i = indexes[0];
if (i > 0) {
- columnList()->table()->model()->undoStack()->push(
+ columnList()->table()->document()->undoStack()->push(
new SwapColumnsCommand(columnList(), i, i - 1));
setCurrentIndex(columnListModel()->indexFromRow(i - 1));
}
diff --git a/src/items/database/databaserelationship.cpp b/src/items/database/databaserelationship.cpp
index 02540c5..8eb0e2f 100644
--- a/src/items/database/databaserelationship.cpp
+++ b/src/items/database/databaserelationship.cpp
@@ -16,6 +16,7 @@
#include <QGraphicsScene>
#include <QDebug>
+#include "diagramdocument.h"
#include "databasetable.h"
#include "databaserelationship.h"
#include "range.h"
@@ -61,6 +62,12 @@ DatabaseRelationship::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
QPen pen(QPen(QColor(0, 0, 0), 1));
pen.setJoinStyle(Qt::MiterJoin);
+
+ if (!document()->isPrinting() && isSelected()) {
+ pen.setColor(QColor(0, 96, 255));
+// pen.setWidth(2);
+ }
+
painter->setPen(pen);
painter->drawPolyline(m_line);
painter->setBrush(pen.color());
diff --git a/src/items/database/databasetable.cpp b/src/items/database/databasetable.cpp
index 1460cd8..059284f 100644
--- a/src/items/database/databasetable.cpp
+++ b/src/items/database/databasetable.cpp
@@ -34,12 +34,6 @@ DatabaseTable::DatabaseTable(DiagramItem *parent)
connect(m_columnList, SIGNAL(columnChanged(int)), this, SLOT(updateLayout()));
}
-DiagramDocument *
-DatabaseTable::model() const
-{
- return qobject_cast<DiagramDocument *>(scene());
-}
-
QRectF
DatabaseTable::boundingRect() const
{
@@ -61,9 +55,9 @@ DatabaseTable::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QPen pen(QPen(QColor(0, 0, 0)));
pen.setJoinStyle(Qt::MiterJoin);
QPen borderPen(pen);
- if (!model()->isPrinting() && isSelected()) {
+ if (!document()->isPrinting() && isSelected()) {
borderPen.setColor(QColor(0, 96, 255));
- borderPen.setWidth(2);
+ //borderPen.setWidth(2);
}
painter->setPen(pen);
diff --git a/src/items/database/databasetable.h b/src/items/database/databasetable.h
index 8be1ee5..4402586 100644
--- a/src/items/database/databasetable.h
+++ b/src/items/database/databasetable.h
@@ -33,8 +33,6 @@ class DatabaseTable : public DiagramObject
public:
DatabaseTable(DiagramItem *parent = 0);
- DiagramDocument *model() const;
-
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);