File indexing completed on 2024-04-14 05:44:23
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 compoundwidget 0008 #define compoundwidget 0009 0010 #include <QWidget> 0011 0012 #include "singlecontainerwidget.h" 0013 0014 class QLineEdit; 0015 class KTextEdit; 0016 class QDialog; 0017 class QCheckBox; 0018 class QPaintEvent; 0019 class CompoundRegExp; 0020 0021 /** 0022 Widget containing configuration details for @ref CompoundWidget 0023 @internal 0024 */ 0025 class CompoundDetailWindow : public QWidget 0026 { 0027 public: 0028 explicit CompoundDetailWindow(QWidget *parent); 0029 QString title() const; 0030 QString description() const; 0031 bool allowReplace() const; 0032 void setTitle(const QString &); 0033 void setDescription(const QString &); 0034 void setAllowReplace(bool); 0035 0036 private: 0037 QLineEdit *_title = nullptr; 0038 KTextEdit *_description = nullptr; 0039 QCheckBox *_allowReplace = nullptr; 0040 }; 0041 0042 /** 0043 Comopund RegExp widget. 0044 0045 This widget has two purposes: 0046 @li To make it possible for a user to collapse a huge regular expression 0047 to take up less screen space. 0048 @li To act as back references for later use. 0049 0050 @internal 0051 */ 0052 class CompoundWidget : public SingleContainerWidget 0053 { 0054 Q_OBJECT 0055 0056 public: 0057 CompoundWidget(RegExpEditorWindow *editorWindow, QWidget *parent); 0058 CompoundWidget(CompoundRegExp *regexp, RegExpEditorWindow *editorWindow, QWidget *parent); 0059 0060 bool updateSelection(bool parentSelected) override; 0061 QSize sizeHint() const override; 0062 RegExp *regExp() const override; 0063 RegExpType type() const override 0064 { 0065 return COMPOUND; 0066 } 0067 0068 int edit() override; 0069 0070 protected: 0071 void paintEvent(QPaintEvent *e) override; 0072 void mousePressEvent(QMouseEvent *e) override; 0073 void mouseReleaseEvent(QMouseEvent *e) override; 0074 void init(); 0075 QPixmap getIcon(const QString &name); 0076 0077 protected Q_SLOTS: 0078 void slotConfigCanceled(); 0079 void slotConfigWindowClosed(); 0080 0081 private: 0082 bool _hidden; 0083 QPixmap _up, _down; 0084 mutable QSize _pixmapSize; 0085 mutable QPoint _pixmapPos; 0086 0087 QDialog *_configWindow = nullptr; 0088 CompoundDetailWindow *_content = nullptr; 0089 0090 mutable QSize _textSize; 0091 mutable QSize _childSize; 0092 QByteArray _backup; 0093 0094 int _backRefId; 0095 }; 0096 0097 #endif // compoundwidget