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 KMULTIFORMLISTBOX_MULTIVISIBLE_H 0008 #define KMULTIFORMLISTBOX_MULTIVISIBLE_H 0009 0010 // ------------------------------- Description ---------------------------- 0011 // This is the KMultiFormListBox Widget. You do not need to inherit from this class, 0012 // your interface to it will be through the methods `append` and `elements'. 0013 // 0014 // To make an instance of the widget, you need to inherit the classes 0015 // `KMultiFormListBoxFactory' and `KMultiFormListBoxEntry'. 0016 // ------------------------------------------------------------------------ 0017 0018 // -------------------------------- includes ------------------------------ 0019 #include "kmultiformlistbox-shower.h" 0020 #include "kmultiformlistbox.h" 0021 #include <QScrollArea> 0022 //------------------------------------------------------------------------- 0023 class QVBoxLayout; 0024 class KMultiFormListBoxFactory; 0025 0026 /** 0027 @internal 0028 */ 0029 class KMultiFormListBoxMultiVisible : public QScrollArea, KMultiFormListBoxShower 0030 { 0031 Q_OBJECT 0032 0033 friend class KMultiFormListBox; 0034 0035 private: 0036 /** 0037 @param factory A factory used to generate the instances of KMultiFormListBoxEntry 0038 class which is repeated in the KMultiFormListBox 0039 @param parent A pointer to the parent widget 0040 */ 0041 explicit KMultiFormListBoxMultiVisible(KMultiFormListBoxFactory *factory, QWidget *parent = nullptr); 0042 0043 /** 0044 @return The elements in the KMultiFormListBox 0045 */ 0046 KMultiFormListBoxEntryList elements() override; 0047 void append(KMultiFormListBoxEntry *) override; 0048 0049 QWidget *qWidget() override 0050 { 0051 return this; 0052 } 0053 0054 public Q_SLOTS: 0055 0056 /** 0057 This slot should be connected to a button which lets the user know that 0058 he may get more elements in this KMultiFormListBox by pressing it. 0059 The button should be labeled ``More Entries'' or something similar. 0060 */ 0061 void addElement() override; // Adds an empty element to the KMultiFormListBox 0062 0063 protected Q_SLOTS: 0064 0065 /** 0066 When this slot is invoked then the Idx menu will be shown. 0067 @param elm The KMultiFormListBoxEntry element where the Idx button was 0068 pressed. This information is necessary to be able to calculate the 0069 location where the drop down menu should be shown 0070 */ 0071 void showIndexList(KMultiFormListBoxEntry *elm); 0072 0073 protected: 0074 /** 0075 Copies the element pointed to by which to the clipboard and removes it 0076 from the interface. 0077 This function is accessed from the class @ref CCP. 0078 @param which A pointer to the element to cut. 0079 */ 0080 void cut(KMultiFormListBoxEntry *which); 0081 0082 /** 0083 Copies the element pointed to by which to the clipboard. 0084 This function is accessed from the class @ref CCP. 0085 @param which A pointer to the element to copied. 0086 */ 0087 void copy(KMultiFormListBoxEntry *which); 0088 0089 /** 0090 Paste the element from the clipboard to the KMultiFormListBox 0091 This function is accessed from the class @ref CCP. 0092 @param which A pointer to the KMultiFormListBoxEntry element which the 0093 clipboard element should be inserted before,. 0094 */ 0095 void paste(KMultiFormListBoxEntry *which); 0096 0097 /** 0098 Inserts an empty KMultiFormListBoxEntry into the widget. 0099 @param which A pointer to the element which the new empty widget 0100 should be inserted before. 0101 */ 0102 0103 void addElement(KMultiFormListBoxEntry *); 0104 0105 friend class CCP; 0106 0107 void resizeEvent(QResizeEvent *) override; 0108 void addElemBefore(KMultiFormListBoxEntry *newElm, QWidget *existing); 0109 void insertElmIntoWidget(KMultiFormListBoxEntry *elm, KMultiFormListBoxEntry *after); 0110 void showWidget(KMultiFormListBoxEntry *elm); 0111 void delElement(QWidget *) override; 0112 void delAnElement() override; 0113 void addElemBefore(KMultiFormListBoxEntry *newElm, KMultiFormListBoxEntry *existing); 0114 void updateClipperContent(); 0115 int countElements(WidgetList *); 0116 0117 private: 0118 // Instance variables 0119 0120 KMultiFormListBoxFactory *factory; 0121 WidgetList *elms; 0122 QPushButton *addBut; 0123 QByteArray clipboard; 0124 QVBoxLayout *layout; 0125 }; 0126 0127 #endif // KMULTIFORMLISTBOX_MULTIVISIBLE_H