kexi

kexiquerydesignersqlhistory.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
00003    Copyright (C) 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 KEXIQUERYDESIGNERSQLHISTORY_H
00022 #define KEXIQUERYDESIGNERSQLHISTORY_H
00023 
00024 #include <qscrollview.h>
00025 #include <qdatetime.h>
00026 #include <qptrlist.h>
00027 #include <qmap.h>
00028 #include <qsimplerichtext.h>
00029 
00030 class QSimpleRichText;
00031 class KPopupMenu;
00032 
00033 class HistoryEntry
00034 {
00035     public:
00036         HistoryEntry(bool success, const QTime &time, const QString &statement, /*int y,*/ const QString &error = QString::null);
00037         ~HistoryEntry();
00038 
00039         QRect   geometry(int y, int width, QFontMetrics f);
00040         void    drawItem(QPainter *p, int width, const QColorGroup &cg);
00041 
00042         void    setSelected(bool selected, const QColorGroup &cg);
00043         bool    isSelected() const { return m_selected; }
00044         void    highlight(const QColorGroup &selected);
00045 
00046         QString statement() { return m_statement; }
00047         void updateTime(const QTime &execTime);
00048 
00049     private:
00050         bool    m_succeed;
00051         QTime   m_execTime;
00052         QString m_statement;
00053         QString m_error;
00054         QSimpleRichText *m_formated;
00055 
00056         int m_y;
00057         bool    m_selected;
00058 };
00059 
00060 typedef QPtrList<HistoryEntry> History;
00061 
00062 class KexiQueryDesignerSQLHistory : public QScrollView
00063 {
00064     Q_OBJECT
00065 
00066     public:
00067         KexiQueryDesignerSQLHistory(QWidget *parent, const char *name=0);
00068         virtual ~KexiQueryDesignerSQLHistory();
00069 
00070         KPopupMenu* popupMenu() const;
00071 
00072 //      void        contextMenu(const QPoint &pos, HistoryEntry *e);
00073 
00074         void setHistory(History *h);
00075 
00076         QString selectedStatement() const;
00077 
00078     public slots:
00079         void addEvent(const QString& q, bool s, const QString &error);
00080 
00081         void slotToClipboard();
00082         void slotEdit();
00083 
00084         void clear();
00085 
00086 //      HistoryItem itemAt(int y);
00087 
00088     protected:
00089         void addEntry(HistoryEntry *e);
00090         virtual void drawContents(QPainter *p, int cx, int cy, int cw, int ch);
00091         virtual void contentsMousePressEvent(QMouseEvent * e);
00092         virtual void contentsMouseDoubleClickEvent(QMouseEvent * e);
00093 
00094     signals:
00095         void editRequested(const QString &text);
00096         void currentItemDoubleClicked();
00097 
00098     private:
00099         History *m_history;
00100         HistoryEntry *m_selected;
00101         KPopupMenu *m_popup;
00102 };
00103 
00104 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys