kexi

kexirelationviewtable.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002, 2003 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 KEXIRELATIONVIEWTABLE_H
00022 #define KEXIRELATIONVIEWTABLE_H
00023 
00024 #include <qframe.h>
00025 #include <qstringlist.h>
00026 #include <qlabel.h>
00027 #include <klistview.h>
00028 
00029 #include <widget/kexifieldlistview.h>
00030 
00031 class KexiRelationView;
00032 class KexiRelationViewTable;
00033 class KexiRelationViewTableContainerHeader;
00034 
00035 namespace KexiDB
00036 {
00037     class TableOrQuerySchema;
00038 }
00039 
00040 class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTableContainer : public QFrame
00041 {
00042     Q_OBJECT
00043 
00044     public:
00045 //      KexiRelationViewTableContainer(KexiRelationView *parent, KexiDB::TableSchema *t);
00046         KexiRelationViewTableContainer(
00047             KexiRelationView *parent, KexiDB::TableOrQuerySchema *schema);
00048 
00049         virtual ~KexiRelationViewTableContainer();
00050 
00051         int globalY(const QString &field);
00052 //      KexiDB::TableSchema *table();
00053 
00054         KexiRelationViewTable* tableView() const { return m_tableView; }
00055         KexiDB::TableOrQuerySchema* schema() const;
00056         
00057         int right() { return x() + width() - 1; }
00058         int bottom() { return y() + height() - 1; }
00059 
00060     signals:
00061         void moved(KexiRelationViewTableContainer *);
00062         void endDrag();
00063         void gotFocus();
00064         void contextMenuRequest(const QPoint& pos);
00065 
00066     public slots:
00067         virtual void setFocus();
00068         virtual void unsetFocus();
00069 
00070     protected slots:
00071         void moved();
00072         void slotContextMenu(KListView *lv, QListViewItem *i, const QPoint& p);
00073 
00074     protected:
00075 //      KexiDB::TableSchema *m_table;
00076         KexiRelationViewTableContainerHeader *m_tableHeader;
00077         KexiRelationViewTable *m_tableView;
00078         KexiRelationView *m_parent;
00079 
00080         friend class KexiRelationViewTableContainerHeader;
00081 };
00082 
00083 /*
00084 class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTableItem : public KListViewItem
00085 {
00086     public:
00087         KexiRelationViewTableItem(QListView *parent, QListViewItem *after,
00088             QString key, QString field);
00089         virtual void paintFocus ( QPainter * p, const QColorGroup & cg, const QRect & r );
00090 };*/
00091 
00092 
00093 class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTable : public KexiFieldListView
00094 {
00095     Q_OBJECT
00096 
00097     public:
00098         KexiRelationViewTable(KexiDB::TableOrQuerySchema* tableOrQuerySchema, 
00099             KexiRelationView *view, QWidget *parent, const char *name = 0);
00100 //      KexiRelationViewTable(QWidget *parent, KexiRelationView *view, KexiDB::TableSchema *t, const char *name=0);
00101         virtual ~KexiRelationViewTable();
00102 
00103 //      KexiDB::TableSchema *table() const { return m_table; };
00104         int globalY(const QString &item);
00105 //      void setReadOnly(bool);
00106         virtual QSize sizeHint();
00107 
00108     signals:
00109         void tableScrolling();
00110 
00111     protected slots:
00112         void slotDropped(QDropEvent *e);
00113         void slotContentsMoving(int, int);
00114 //      void slotItemDoubleClicked( QListViewItem *i, const QPoint &, int );
00115 
00116     protected:
00117         virtual void contentsMousePressEvent( QMouseEvent * e );
00118         virtual bool acceptDrag(QDropEvent *e) const;
00119 //moved     virtual QDragObject *dragObject();
00120         virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); 
00121 
00122     private:
00123 //      QStringList m_fieldList;
00124 //      KexiDB::TableSchema *m_table;
00125         KexiRelationView *m_view;
00126 //      QPixmap m_keyIcon, m_noIcon;
00127 };
00128 
00129 class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTableContainerHeader : public QLabel
00130 {
00131     Q_OBJECT
00132     public:
00133         KexiRelationViewTableContainerHeader(const QString& text,QWidget *parent);
00134         virtual ~KexiRelationViewTableContainerHeader();
00135 
00136         virtual void setFocus();
00137         virtual void unsetFocus();
00138 
00139     signals:
00140         void moved();
00141         void endDrag();
00142 
00143     protected:
00144         bool eventFilter(QObject *obj, QEvent *ev);
00145         void mousePressEvent(QMouseEvent *ev);
00146         void mouseReleaseEvent(QMouseEvent *ev);
00147 
00148         bool m_dragging;
00149         int m_grabX;
00150         int m_grabY;
00151         int m_offsetX;
00152         int m_offsetY;
00153 
00154         QColor m_activeBG, m_activeFG, m_inactiveBG, m_inactiveFG;
00155 };
00156 
00157 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys