summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--databasemodel.cpp3
-rw-r--r--databaserelation.cpp2
-rw-r--r--databasetable.cpp20
3 files changed, 14 insertions, 11 deletions
diff --git a/databasemodel.cpp b/databasemodel.cpp
index fba80ca..b93bd1d 100644
--- a/databasemodel.cpp
+++ b/databasemodel.cpp
@@ -26,9 +26,6 @@
DatabaseModel::DatabaseModel(QObject *parent)
: QGraphicsScene(parent), m_line(NULL)
{
- QFont font("Sans");
- font.setPointSize(9);
- setFont(font);
connect(this, SIGNAL(tableMoved(DatabaseTable *)), SLOT(updatePositions(DatabaseTable *)));
}
diff --git a/databaserelation.cpp b/databaserelation.cpp
index 6f7eab0..4345691 100644
--- a/databaserelation.cpp
+++ b/databaserelation.cpp
@@ -40,6 +40,7 @@ DatabaseRelation::shape() const
path.lineTo(m_line.p2());
path.addPolygon(m_arrowHead);
QPen pen(QPen(QColor(0, 0, 0), 1));
+ pen.setJoinStyle(Qt::MiterJoin);
QPainterPathStroker ps;
ps.setCapStyle(pen.capStyle());
ps.setWidth(pen.widthF() + 0.3);
@@ -55,6 +56,7 @@ DatabaseRelation::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
Q_UNUSED(widget);
QPen pen(QPen(QColor(0, 0, 0), 1));
+ pen.setJoinStyle(Qt::MiterJoin);
painter->setPen(pen);
painter->drawLine(m_line);
painter->setBrush(pen.color());
diff --git a/databasetable.cpp b/databasetable.cpp
index d30b87e..71e2ba1 100644
--- a/databasetable.cpp
+++ b/databasetable.cpp
@@ -41,10 +41,10 @@ DatabaseTable::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
Q_UNUSED(widget);
QFont font = scene()->font();
- QFontMetricsF fontMetrics(font);
-
QFont boldFont = font;
boldFont.setBold(true);
+ QFont boldFontWithUnderline = boldFont;
+ boldFontWithUnderline.setUnderline(true);
QPen pen(QPen(QColor(0, 0, 0)));
pen.setJoinStyle(Qt::MiterJoin);
@@ -72,12 +72,15 @@ DatabaseTable::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QPointF colPos = m_firstColPos;
QPointF leftSizePos = colPos - QPointF(m_leftSideWidth, 0);
foreach (Column *column, m_columns) {
- painter->setFont(column->isRequired() ? boldFont : font);
+ painter->setFont(column->isRequired()
+ ? (column->isPrimaryKey() ? boldFontWithUnderline : boldFont)
+ : font);
painter->drawText(colPos, column->name());
- colPos += m_colPosIncrement;
if (column->isPrimaryKey()) {
+ painter->setFont(column->isRequired() ? boldFont : font);
painter->drawText(leftSizePos, "PK");
}
+ colPos += m_colPosIncrement;
leftSizePos += m_colPosIncrement;
}
@@ -180,12 +183,13 @@ DatabaseTable::updateLayout()
m_leftSideWidth += spaceWidth * 2;
width = qMax(nameWidth + spaceWidth * 4, m_leftSideWidth + maxColumnWidth + spaceWidth * 2);
- m_outerRect = QRectF(0, 0, width, height + qMax(0.66, qreal(m_columns.size())) * height);
+ qreal nameHeight = height + spaceWidth;
+ m_outerRect = QRectF(0, 0, width, nameHeight + qMax(0.66, qreal(m_columns.size())) * height);
- m_nameBgRect = QRectF(0, 0, width, height);
- m_namePos = QPointF((width - nameWidth) / 2, fontMetrics.ascent());
+ m_nameBgRect = QRectF(0, 0, width, nameHeight);
+ m_namePos = QPointF((width - nameWidth) / 2, fontMetrics.ascent() + spaceWidth / 2);
- m_firstColPos = QPointF(m_leftSideWidth + spaceWidth * 1 - 1, height + fontMetrics.ascent() + 2);
+ m_firstColPos = QPointF(m_leftSideWidth + spaceWidth * 1 - 1, nameHeight + fontMetrics.ascent() + 2);
m_colPosIncrement = QPointF(0, fontMetrics.lineSpacing());
update();