1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
/* This file is part of the KDE project
Copyright (C) 2004 Lucijan Busch <[email protected]>
Copyright (C) 2003-2004 Jaroslaw Staniek <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KEXIRECORDNAVIGATOR_H
#define KEXIRECORDNAVIGATOR_H
#include <qframe.h>
#include <kexi_export.h>
class QToolButton;
class QIntValidator;
class QScrollView;
class QScrollBar;
class QLabel;
class KLineEdit;
class KGuiItem;
class KexiRecordNavigatorPrivate;
//! \brief KexiRecordNavigatorHandler interface handles requests generated by KexiRecordNavigator
class KEXIGUIUTILS_EXPORT KexiRecordNavigatorHandler
{
public:
KexiRecordNavigatorHandler();
virtual ~KexiRecordNavigatorHandler();
//! Moving to record \a r is requested. Records are counted from 0.
virtual void moveToRecordRequested(uint r) = 0;
virtual void moveToLastRecordRequested() = 0;
virtual void moveToPreviousRecordRequested() = 0;
virtual void moveToNextRecordRequested() = 0;
virtual void moveToFirstRecordRequested() = 0;
virtual void addNewRecordRequested() = 0;
};
//! \brief KexiRecordNavigator class provides a record navigator.
/*! Record navigator is usually used for data tables (e.g. KexiTableView)
or data-aware forms.
You can plug KexiRecordNavigator object to your data-aware object in two ways:
1) By connectiong to slots prevButtonClicked(), etc.
2) A bit cleaner way: by inheriting from KexiRecordNavigatorHandler interface
in your data-aware class and implementing all it's prototype methods like
moveToRecordRequested(), and then caling setRecordHandler() on navigator's object.
Note that using this way, you can allow to exist more than one navigator widget
connected with your data-aware object (don't matter if this is sane).
*/
class KEXIGUIUTILS_EXPORT KexiRecordNavigator : public QFrame
{
Q_OBJECT
public:
KexiRecordNavigator(QWidget *parent, int leftMargin = 0, const char *name=0);
virtual ~KexiRecordNavigator();
void setParentView(QScrollView *view);
/*! Sets record navigator handler. This allows to react
on actions performed within navigator and vice versa. */
void setRecordHandler(KexiRecordNavigatorHandler *handler);
/*! \return true if data inserting is enabled (the default). */
inline bool isInsertingEnabled() const { return m_isInsertingEnabled; }
/*! \return current record number displayed for this navigator.
can return 0, if the 'text box's content is cleared. */
uint currentRecordNumber() const;
/*! \return record count displayed for this navigator. */
uint recordCount() const;
/*! Sets horizontal bar's \a hbar (at the bottom) geometry so this record navigator
is properly positioned together with horizontal scroll bar. This method is used
in QScrollView::setHBarGeometry() implementations:
see KexiTableView::setHBarGeometry() and KexiFormScrollView::setHBarGeometry()
for usage examples. */
void setHBarGeometry( QScrollBar & hbar, int x, int y, int w, int h );
/*! @internal used for keyboard handling. */
virtual bool eventFilter( QObject *o, QEvent *e );
/*! \return true if "editing" indicator is visible for this navigator.
@see showEditingIndicator() */
bool editingIndicatorVisible() const;
/*! \return true if "editing" indicator is enabled for this navigator.
Only meaningful if setEditingIndicatorEnabled(true) is called. */
bool editingIndicatorEnabled() const;
//! @short A set of GUI items usable for displaying related actions.
/*! For instance, the items are used by Kexi main window to create shared actions. */
class KEXIGUIUTILS_EXPORT Actions {
public:
static const KGuiItem& moveToFirstRecord();
static const KGuiItem& moveToPreviousRecord();
static const KGuiItem& moveToNextRecord();
static const KGuiItem& moveToLastRecord();
static const KGuiItem& moveToNewRecord();
};
public slots:
/*! Sets insertingEnabled flag. If true, "+" button will be enabled. */
void setInsertingEnabled(bool set);
/*! Sets visibility of "inserting" button. */
void setInsertingButtonVisible(bool set);
/*! Sets visibility of the place where "editing" indicator will be displayed.
"editing" indicator will display KexiRecordMarker::penImage() image when
setEditingIndicatorVisible() is called.
This method is currently used e.g. within standard kexi forms
(see KexiFormScrollView class). */
void setEditingIndicatorEnabled(bool set);
/*! Shows or hides "editing" indicator. */
void showEditingIndicator(bool show);
virtual void setEnabled(bool set);
/*! Sets current record number for this navigator,
i.e. a value that will be displayed in the 'record number' text box.
This can also affect button's enabling and disabling.
If @p r is 0, 'record number' text box's content is cleared. */
void setCurrentRecordNumber(uint r);
/*! Sets record count for this navigator.
This can also affect button's enabling and disabling.
By default count is 0. */
void setRecordCount(uint count);
void updateGeometry(int leftMargin);
/*! Sets label text at the left of the for record navigator's button.
By default this label contains translated "Row:" text. */
void setLabelText(const QString& text);
signals:
void prevButtonClicked();
void nextButtonClicked();
void lastButtonClicked();
void firstButtonClicked();
void newButtonClicked();
void recordNumberEntered( uint r );
protected slots:
void slotPrevButtonClicked();
void slotNextButtonClicked();
void slotLastButtonClicked();
void slotFirstButtonClicked();
void slotNewButtonClicked();
//void slotRecordNumberReturnPressed(const QString& text);
protected:
void updateButtons(uint recCnt);
QLabel *m_textLabel;
QToolButton *m_navBtnFirst;
QToolButton *m_navBtnPrev;
QToolButton *m_navBtnNext;
QToolButton *m_navBtnLast;
QToolButton *m_navBtnNew;
KLineEdit *m_navRecordNumber;
QIntValidator *m_navRecordNumberValidator;
KLineEdit *m_navRecordCount; //!< readonly counter
uint m_nav1DigitWidth;
// uint m_recordCount;
QScrollView *m_view;
bool m_isInsertingEnabled : 1;
KexiRecordNavigatorPrivate *d;
};
#endif
|