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 __indexWindow 0008 #define __indexWindow 0009 0010 #include <QWidget> 0011 0012 class QListWidget; 0013 0014 /** 0015 Post a toplevel listbox synchronously. 0016 0017 When the user presses the Idx button in the @ref KMultiFormListBox, then a 0018 listbox with the elements from the KMultiFormListBox must be shown. From this 0019 listbox the user should chose the element he wants to scroll to. 0020 This widget takes care of posting this listbox, and ensuring that the 0021 user can not do anything else before he has chosen an element. 0022 0023 This widget resembles the behavior of @ref QPopupMenu, the difference 0024 is, however, that the QPopupMenu can not handle that the elements in the 0025 menu exceed the size of the screen. This widget can. 0026 0027 In the future this widget may be replaced with the QPopupMenu if the 0028 QPopupMenu can handle this situation. But for now - it works! 0029 0030 @internal 0031 **/ 0032 class indexWindow : public QWidget 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 indexWindow(); 0038 0039 /** 0040 This method inserts an element into the listbox which is shown when 0041 the @ref exec method is invoked. 0042 **/ 0043 void insertItem(const QString &txt); 0044 0045 /** 0046 This function shows the index window with the elements inserted using 0047 the @ref insertItem function. The function will not return before the 0048 user has chosen an element in the listbox, or have pressed the right 0049 mouse button outside the window. As a result of returning from this 0050 function, the listbox is hidden. 0051 0052 @param start The upper left corner of the pop-up window. 0053 @param width The width of the window 0054 @return The index of the element chosen, or -1 if no element has been 0055 chosen. 0056 **/ 0057 int exec(const QPoint &start, int width); 0058 0059 protected: 0060 void finish(int retVal); 0061 void hideEvent(QHideEvent *h) override; 0062 0063 protected Q_SLOTS: 0064 void lbSelected(int); 0065 0066 private: 0067 QListWidget *lb = nullptr; 0068 bool lbFinish; 0069 int itemSelected; 0070 }; 0071 0072 #endif /* indexWindow */