kexi

kexiquerydesignersqlhistory.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
3 Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KEXIQUERYDESIGNERSQLHISTORY_H
22#define KEXIQUERYDESIGNERSQLHISTORY_H
23
24#include <tqscrollview.h>
25#include <tqdatetime.h>
26#include <tqptrlist.h>
27#include <tqmap.h>
28#include <tqsimplerichtext.h>
29
30class TQSimpleRichText;
31class TDEPopupMenu;
32
33class HistoryEntry
34{
35 public:
36 HistoryEntry(bool success, const TQTime &time, const TQString &statement, /*int y,*/ const TQString &error = TQString());
37 ~HistoryEntry();
38
39 TQRect geometry(int y, int width, TQFontMetrics f);
40 void drawItem(TQPainter *p, int width, const TQColorGroup &cg);
41
42 void setSelected(bool selected, const TQColorGroup &cg);
43 bool isSelected() const { return m_selected; }
44 void highlight(const TQColorGroup &selected);
45
46 TQString statement() { return m_statement; }
47 void updateTime(const TQTime &execTime);
48
49 private:
50 bool m_succeed;
51 TQTime m_execTime;
52 TQString m_statement;
53 TQString m_error;
54 TQSimpleRichText *m_formated;
55
56 int m_y;
57 bool m_selected;
58};
59
60typedef TQPtrList<HistoryEntry> History;
61
62class KexiQueryDesignerSQLHistory : public TQScrollView
63{
64 TQ_OBJECT
65
66
67 public:
68 KexiQueryDesignerSQLHistory(TQWidget *parent, const char *name=0);
69 virtual ~KexiQueryDesignerSQLHistory();
70
71 TDEPopupMenu* popupMenu() const;
72
73// void contextMenu(const TQPoint &pos, HistoryEntry *e);
74
75 void setHistory(History *h);
76
77 TQString selectedStatement() const;
78
79 public slots:
80 void addEvent(const TQString& q, bool s, const TQString &error);
81
82 void slotToClipboard();
83 void slotEdit();
84
85 void clear();
86
87// HistoryItem itemAt(int y);
88
89 protected:
90 void addEntry(HistoryEntry *e);
91 virtual void drawContents(TQPainter *p, int cx, int cy, int cw, int ch);
92 virtual void contentsMousePressEvent(TQMouseEvent * e);
93 virtual void contentsMouseDoubleClickEvent(TQMouseEvent * e);
94
95 signals:
96 void editRequested(const TQString &text);
97 void currentItemDoubleClicked();
98
99 private:
100 History *m_history;
101 HistoryEntry *m_selected;
102 TDEPopupMenu *m_popup;
103};
104
105#endif