kexi

kexirelationview.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002   Lucijan Busch <lucijan@gmx.at>
00003    Copyright (C) 2003-2004 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 
00082         KexiRelationViewTableContainer* addTable(KexiDB::TableSchema *t, const QRect &rect = QRect());
00083 
00085         void addConnection(const SourceConnection& _conn /*, bool interactive=true*/);
00086 
00087         void setReadOnly(bool);
00088 
00089         inline KexiRelationViewConnection* selectedConnection() const { return m_selectedConnection; }
00090 
00091         inline KexiRelationViewTableContainer* focusedTableView() const { return m_focusedTableView; }
00092 
00093         virtual QSize sizeHint() const;
00094 
00095         const ConnectionList* connections() const { return &m_connectionViews; }
00096 
00097 //      KexiRelationViewTableContainer* containerForTable(KexiDB::TableSchema* tableSchema);
00098 
00099     signals:
00100         void tableContextMenuRequest( const QPoint& pos );
00101         void connectionContextMenuRequest( const QPoint& pos );
00102         void emptyAreaContextMenuRequest( const QPoint& pos );
00103         void tableViewGotFocus();
00104         void connectionViewGotFocus();
00105         void emptyAreaGotFocus();
00106         void tableHidden(KexiDB::TableSchema& t);
00107         void tablePositionChanged(KexiRelationViewTableContainer*);
00108         void aboutConnectionRemove(KexiRelationViewConnection*);
00109 
00110     public slots:
00112         void clearSelection();
00113 
00116         void clear();
00117 
00119         void removeAllConnections();
00120 
00122         void hideAllTablesExcept( KexiDB::TableSchema::List* tables );
00123 
00124         void slotTableScrolling(QString);
00125 
00127         void removeSelectedObject();
00128 
00129 
00130     protected slots:
00131         void containerMoved(KexiRelationViewTableContainer *c);
00132         void slotListUpdate(QObject *s);
00133         void slotTableViewEndDrag();
00134         void slotTableViewGotFocus();
00135 
00136     protected:
00137 //      /*! executes popup menu at \a pos, or, 
00138 //       if \a pos not specified: at center of selected table view (if any selected),
00139 //       or at center point of the relations view. */
00140 //      void executePopup( QPoint pos = QPoint(-1,-1) );
00141 
00142         void drawContents(QPainter *p, int cx, int cy, int cw, int ch);
00143         void contentsMousePressEvent(QMouseEvent *ev);
00144         virtual void keyPressEvent(QKeyEvent *ev);
00145 
00146         void recalculateSize(int width, int height);
00147         void stretchExpandSize();
00148 //      void        invalidateActions();
00149 //      void clearTableSelection();
00150 //      void clearConnSelection();
00151 
00152         void hideTable(KexiRelationViewTableContainer* tableView);
00153         void removeConnection(KexiRelationViewConnection *conn);
00154 
00155         TablesDict m_tables;
00156         bool m_readOnly;
00157         ConnectionList m_connectionViews;
00158         KexiRelationViewConnection* m_selectedConnection;
00159         QGuardedPtr<KexiRelationViewTableContainer> m_focusedTableView;
00160 };
00161 
00162 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys