kexirelationview.h
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 Copyright (C) 2002 Lucijan Busch <lucijan@gmx.at> 00003 Copyright (C) 2003-2004, 2006 Jaroslaw Staniek <js@iidea.pl> 00004 00005 This program is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this program; see the file COPYING. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KEXIRELATIONVIEW_H 00022 #define KEXIRELATIONVIEW_H 00023 00024 #include <qguardedptr.h> 00025 #include <qscrollview.h> 00026 #include <qptrlist.h> 00027 #include <qdict.h> 00028 00029 #include <kexidb/tableschema.h> 00030 00031 #include "kexirelationviewconnection.h" 00032 00033 class QFrame; 00034 00035 class KexiRelationViewTable; 00036 class KexiRelationViewTableContainer; 00037 class KAction; 00038 class KPopupMenu; 00039 00040 namespace KexiDB 00041 { 00042 class Reference; 00043 class Connection; 00044 } 00045 00046 typedef QDict<KexiRelationViewTableContainer> TablesDict; 00047 typedef QDictIterator<KexiRelationViewTableContainer> TablesDictIterator; 00048 typedef QPtrList<KexiRelationViewConnection> ConnectionList; 00049 typedef QPtrListIterator<KexiRelationViewConnection> ConnectionListIterator; 00050 00051 struct SourceConnection 00052 { 00053 QString masterTable; 00054 QString detailsTable; 00055 QString masterField; 00056 QString detailsField; 00057 }; 00058 00068 class KEXIRELATIONSVIEW_EXPORT KexiRelationView : public QScrollView 00069 { 00070 Q_OBJECT 00071 00072 public: 00073 KexiRelationView(QWidget *parent, const char *name=0); 00074 virtual ~KexiRelationView(); 00075 00077 TablesDict* tables() { return &m_tables; } 00078 00083 KexiRelationViewTableContainer* addTableContainer(KexiDB::TableSchema *t, 00084 const QRect &rect = QRect()); 00085 00087 KexiRelationViewTableContainer * tableContainer(KexiDB::TableSchema *t) const; 00088 00090 void addConnection(const SourceConnection& _conn /*, bool interactive=true*/); 00091 00092 void setReadOnly(bool); 00093 00094 inline KexiRelationViewConnection* selectedConnection() const { return m_selectedConnection; } 00095 00096 inline KexiRelationViewTableContainer* focusedTableView() const { return m_focusedTableView; } 00097 00098 virtual QSize sizeHint() const; 00099 00100 const ConnectionList* connections() const { return &m_connectionViews; } 00101 00102 // KexiRelationViewTableContainer* containerForTable(KexiDB::TableSchema* tableSchema); 00103 00104 signals: 00105 void tableContextMenuRequest( const QPoint& pos ); 00106 void connectionContextMenuRequest( const QPoint& pos ); 00107 void emptyAreaContextMenuRequest( const QPoint& pos ); 00108 void tableViewGotFocus(); 00109 void connectionViewGotFocus(); 00110 void emptyAreaGotFocus(); 00111 void tableHidden(KexiDB::TableSchema& t); 00112 void tablePositionChanged(KexiRelationViewTableContainer*); 00113 void aboutConnectionRemove(KexiRelationViewConnection*); 00114 00115 public slots: 00117 void clearSelection(); 00118 00121 void clear(); 00122 00124 void removeAllConnections(); 00125 00127 void hideAllTablesExcept( KexiDB::TableSchema::List* tables ); 00128 00129 void slotTableScrolling(const QString&); 00130 00132 void removeSelectedObject(); 00133 00134 00135 protected slots: 00136 void containerMoved(KexiRelationViewTableContainer *c); 00137 void slotListUpdate(QObject *s); 00138 void slotTableViewEndDrag(); 00139 void slotTableViewGotFocus(); 00140 00141 protected: 00142 // /*! executes popup menu at \a pos, or, 00143 // if \a pos not specified: at center of selected table view (if any selected), 00144 // or at center point of the relations view. */ 00145 // void executePopup( QPoint pos = QPoint(-1,-1) ); 00146 00147 void drawContents(QPainter *p, int cx, int cy, int cw, int ch); 00148 void contentsMousePressEvent(QMouseEvent *ev); 00149 virtual void keyPressEvent(QKeyEvent *ev); 00150 00151 void recalculateSize(int width, int height); 00152 void stretchExpandSize(); 00153 // void invalidateActions(); 00154 // void clearTableSelection(); 00155 // void clearConnSelection(); 00156 00157 void hideTable(KexiRelationViewTableContainer* tableView); 00158 void removeConnection(KexiRelationViewConnection *conn); 00159 00160 TablesDict m_tables; 00161 bool m_readOnly; 00162 ConnectionList m_connectionViews; 00163 KexiRelationViewConnection* m_selectedConnection; 00164 QGuardedPtr<KexiRelationViewTableContainer> m_focusedTableView; 00165 }; 00166 00167 #endif
