Changeset View
Changeset View
Standalone View
Standalone View
src/widget/relations/KexiRelationsScrollArea.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
45 | public: | 45 | public: | ||
46 | Private() | 46 | Private() | ||
47 | : readOnly(false) | 47 | : readOnly(false) | ||
48 | , selectedConnection(0) | 48 | , selectedConnection(0) | ||
49 | , focusedTableContainer(0) { | 49 | , focusedTableContainer(0) { | ||
50 | autoScrollTimer.setSingleShot(true); | 50 | autoScrollTimer.setSingleShot(true); | ||
51 | } | 51 | } | ||
52 | 52 | | |||
53 | KDbConnection *connection = nullptr; | ||||
53 | QWidget *areaWidget; | 54 | QWidget *areaWidget; | ||
54 | TablesHash tables; | 55 | TablesHash tables; | ||
55 | bool readOnly; | 56 | bool readOnly; | ||
56 | QSet<KexiRelationsConnection*> relationsConnections; | 57 | QSet<KexiRelationsConnection*> relationsConnections; | ||
57 | KexiRelationsConnection* selectedConnection; | 58 | KexiRelationsConnection* selectedConnection; | ||
58 | QPointer<KexiRelationsTableContainer> focusedTableContainer; | 59 | QPointer<KexiRelationsTableContainer> focusedTableContainer; | ||
59 | QPointer<KexiRelationsTableContainer> movedTableContainer; | 60 | QPointer<KexiRelationsTableContainer> movedTableContainer; | ||
60 | QTimer autoScrollTimer; | 61 | QTimer autoScrollTimer; | ||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | |||||
149 | KexiRelationsScrollArea::tableContainer(KDbTableSchema *t) const | 150 | KexiRelationsScrollArea::tableContainer(KDbTableSchema *t) const | ||
150 | { | 151 | { | ||
151 | return t ? d->tables.value(t->name()) : 0; | 152 | return t ? d->tables.value(t->name()) : 0; | ||
152 | } | 153 | } | ||
153 | 154 | | |||
154 | KexiRelationsTableContainer* | 155 | KexiRelationsTableContainer* | ||
155 | KexiRelationsScrollArea::addTableContainer(KDbTableSchema *t, const QRect &rect) | 156 | KexiRelationsScrollArea::addTableContainer(KDbTableSchema *t, const QRect &rect) | ||
156 | { | 157 | { | ||
157 | if (!t) | 158 | if (!t || !d->connection) | ||
158 | return 0; | 159 | return 0; | ||
159 | 160 | | |||
160 | qDebug() << t->name(); | 161 | qDebug() << t->name(); | ||
161 | 162 | | |||
162 | KexiRelationsTableContainer* c = tableContainer(t); | 163 | KexiRelationsTableContainer* c = tableContainer(t); | ||
163 | if (c) { | 164 | if (c) { | ||
164 | qWarning() << "table already added"; | 165 | qWarning() << "table already added"; | ||
165 | return c; | 166 | return c; | ||
166 | } | 167 | } | ||
167 | 168 | | |||
168 | c = new KexiRelationsTableContainer(d->areaWidget, this, | 169 | c = new KexiRelationsTableContainer(this, d->connection, | ||
169 | /*! @todo what about query? */ | 170 | /*! @todo what about query? */ | ||
170 | new KDbTableOrQuerySchema(t) | 171 | new KDbTableOrQuerySchema(t), d->areaWidget); | ||
171 | ); | | |||
172 | connect(c, SIGNAL(endDrag()), this, SLOT(slotTableViewEndDrag())); | 172 | connect(c, SIGNAL(endDrag()), this, SLOT(slotTableViewEndDrag())); | ||
173 | connect(c, SIGNAL(gotFocus()), this, SLOT(slotTableViewGotFocus())); | 173 | connect(c, SIGNAL(gotFocus()), this, SLOT(slotTableViewGotFocus())); | ||
174 | connect(c, SIGNAL(contextMenuRequest(QPoint)), | 174 | connect(c, SIGNAL(contextMenuRequest(QPoint)), | ||
175 | this, SIGNAL(tableContextMenuRequest(QPoint))); | 175 | this, SIGNAL(tableContextMenuRequest(QPoint))); | ||
176 | 176 | | |||
177 | if (rect.isValid()) {//predefined size | 177 | if (rect.isValid()) {//predefined size | ||
178 | QSize finalSize = c->size().expandedTo(c->sizeHint()); | 178 | QSize finalSize = c->size().expandedTo(c->sizeHint()); | ||
179 | QRect r = rect; | 179 | QRect r = rect; | ||
▲ Show 20 Lines • Show All 313 Lines • ▼ Show 20 Line(s) | 492 | #endif | |||
493 | } | 493 | } | ||
494 | else if (d->focusedTableContainer) { | 494 | else if (d->focusedTableContainer) { | ||
495 | KexiRelationsTableContainer *tmp = d->focusedTableContainer; | 495 | KexiRelationsTableContainer *tmp = d->focusedTableContainer; | ||
496 | d->focusedTableContainer = 0; | 496 | d->focusedTableContainer = 0; | ||
497 | hideTable(tmp); | 497 | hideTable(tmp); | ||
498 | } | 498 | } | ||
499 | } | 499 | } | ||
500 | 500 | | |||
501 | void KexiRelationsScrollArea::setConnection(KDbConnection *conn) | ||||
502 | { | ||||
503 | d->connection = conn; | ||||
504 | } | ||||
505 | | ||||
501 | void | 506 | void | ||
502 | KexiRelationsScrollArea::hideTable(KexiRelationsTableContainer* container) | 507 | KexiRelationsScrollArea::hideTable(KexiRelationsTableContainer* container) | ||
503 | { | 508 | { | ||
504 | Q_ASSERT(container); | 509 | Q_ASSERT(container); | ||
505 | /*! @todo what about query? */ | 510 | /*! @todo what about query? */ | ||
506 | TablesHashMutableIterator it(d->tables); | 511 | TablesHashMutableIterator it(d->tables); | ||
507 | if (!it.findNext(container)) | 512 | if (!it.findNext(container)) | ||
508 | return; | 513 | return; | ||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |