File indexing completed on 2024-04-21 05:51:36

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 __concwidget
0008 #define __concwidget
0009 
0010 #include "multicontainerwidget.h"
0011 
0012 class ConcRegExp;
0013 
0014 /**
0015    RegExp widget which can have several sub widget inside it.
0016    This widget is invisible to the user, but act as a container around
0017    other RegExp widgets
0018    @internal
0019 */
0020 class ConcWidget : public MultiContainerWidget
0021 {
0022 public:
0023     ConcWidget(RegExpEditorWindow *editorWindow, QWidget *parent);
0024     ConcWidget(RegExpEditorWindow *editorWindow, RegExpWidget *child, QWidget *parent);
0025     ConcWidget(RegExpEditorWindow *editorWindow, ConcWidget *origConc, unsigned int start, unsigned int end);
0026     ConcWidget(ConcRegExp *regexp, RegExpEditorWindow *editorWindow, QWidget *parent);
0027     void init();
0028 
0029     QSize sizeHint() const override;
0030     RegExp *regExp() const override;
0031     bool updateSelection(bool parentSelected) override;
0032     bool isSelected() const override;
0033 
0034     void applyRegExpToSelection(RegExpType type) override;
0035     RegExpType type() const override
0036     {
0037         return CONC;
0038     }
0039 
0040     RegExp *selection() const override;
0041     void addNewConcChild(DragAccepter *accepter, ConcWidget *child) override;
0042     bool validateSelection() const override;
0043     bool acceptWidgetInsert(RegExpType) const override
0044     {
0045         return false;
0046     }
0047 
0048     bool acceptWidgetPaste() const override
0049     {
0050         return false;
0051     }
0052 
0053     bool hasAnyChildren()
0054     {
0055         return _children.count() > 1;
0056     }
0057 
0058 protected:
0059     void paintEvent(QPaintEvent *e) override;
0060     void mousePressEvent(QMouseEvent *event) override;
0061     void sizeAccepter(DragAccepter *accepter, int height, int totHeight);
0062     void getSelectionIndexes(int *start, int *end);
0063     // virtual void dragEnterEvent(QDragEnterEvent* event) { event->setAccepted( false ); }
0064 
0065 private:
0066     int _maxSelectedHeight;
0067 };
0068 
0069 #endif // __concwidget