File indexing completed on 2024-04-28 05:51:09

0001 /*
0002  *  SPDX-FileCopyrightText: 2002-2003 Jesper K. Pedersen <blackie@kde.org>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-only
0005  **/
0006 
0007 #ifndef __kmultiformlistboxentry
0008 #define __kmultiformlistboxentry
0009 
0010 #include <QWidget>
0011 
0012 class QPushButton;
0013 
0014 /**
0015    This widget must be the base class for an entry widget used in the @ref
0016    KMultiFormListBox class. It is necessary for you to inherit this class to get any
0017    information attached to the elements in the KMultiFormListBox.
0018 
0019    The KMultiFormListBox widget features a fast scrolling mechanism through the Idx
0020    button. If you want to use this in you KMultiFormListBox, then you must do the
0021    following:
0022    @li Create a @ref QPushButton as a sub-widget to your KMultiFormListBoxEntry.
0023    @li Override the @ref indexButton method to return your QPushButton
0024    @li Override the @ref idxString to return a @ref QString
0025    with a textual representation of the content in this KMultiFormListBoxEntry. This
0026    string will be used in the drop-down box which the user gets when he
0027    presses the Idx button.
0028    @li The drop down window must be aligned horizontal to some widget
0029    (which should be next to the Idx button, to ensure a good looking GUI. The
0030    position of the drop down widget may be specified in two ways: (1)
0031    override the @ref valueWidget method to return a widget, to align with
0032    (that is the upper right corner of the drop down  window will be the
0033    same as the lower right corner of this widget) or (2) override the @ref
0034    indexWindowPos method to return a start point for the drop down window and
0035    a width.
0036  **/
0037 class KMultiFormListBoxEntry : public QWidget
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042     KMultiFormListBoxEntry(QWidget *parent)
0043         : QWidget(parent)
0044     {
0045     }
0046 
0047     virtual QPushButton *indexButton()
0048     {
0049         return nullptr;
0050     }
0051 
0052     virtual QWidget *valueWidget()
0053     {
0054         return nullptr;
0055     }
0056 
0057     virtual void indexWindowPos(QPoint *start, int *width); // both variables are return values.
0058 
0059     // This function must return a string representing the KMultiFormListBox. This is
0060     // used when showing the fast-search menu available from the `Idx' button.
0061     virtual QString idxString()
0062     {
0063         return QString();
0064     }
0065 
0066 public Q_SLOTS:
0067     void acceptIndexButton();
0068 
0069 Q_SIGNALS:
0070     void gotoIndex(KMultiFormListBoxEntry *);
0071 };
0072 
0073 #endif /* kmultiformlistboxentry */