You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
koffice/kexi/widget/utils/kexirecordnavigator.h

192 lines
6.8 KiB

/* This file is part of the KDE project
Copyright (C) 2004 Lucijan Busch <lucijan@kde.org>
Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
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 <tqframe.h>
#include <kexi_export.h>
class TQToolButton;
class TQIntValidator;
class TQScrollView;
class TQScrollBar;
class TQLabel;
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 TQFrame
{
Q_OBJECT
TQ_OBJECT
public:
KexiRecordNavigator(TQWidget *tqparent, int leftMargin = 0, const char *name=0);
virtual ~KexiRecordNavigator();
void setParentView(TQScrollView *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) tqgeometry so this record navigator
is properly positioned together with horizontal scroll bar. This method is used
in TQScrollView::setHBarGeometry() implementations:
see KexiTableView::setHBarGeometry() and KexiFormScrollView::setHBarGeometry()
for usage examples. */
void setHBarGeometry( TQScrollBar & hbar, int x, int y, int w, int h );
/*! @internal used for keyboard handling. */
virtual bool eventFilter( TQObject *o, TQEvent *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 TQString& 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 TQString& text);
protected:
void updateButtons(uint recCnt);
TQLabel *m_textLabel;
TQToolButton *m_navBtnFirst;
TQToolButton *m_navBtnPrev;
TQToolButton *m_navBtnNext;
TQToolButton *m_navBtnLast;
TQToolButton *m_navBtnNew;
KLineEdit *m_navRecordNumber;
TQIntValidator *m_navRecordNumberValidator;
KLineEdit *m_navRecordCount; //!< readonly counter
uint m_nav1DigitWidth;
// uint m_recordCount;
TQScrollView *m_view;
bool m_isInsertingEnabled : 1;
KexiRecordNavigatorPrivate *d;
};
#endif