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

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 __USERDEFINEDREGEXPS_H
0008 #define __USERDEFINEDREGEXPS_H
0009 
0010 #include <QDockWidget>
0011 #include <QList>
0012 #include <QTreeWidgetItem>
0013 
0014 class CompoundRegExp;
0015 class QPoint;
0016 class RegExp;
0017 
0018 class UserDefinedRegExps : public QDockWidget
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     explicit UserDefinedRegExps(QWidget *parent, const QString &title);
0024     const QList<CompoundRegExp *> regExps() const;
0025 
0026 public Q_SLOTS:
0027     void slotSelectNewAction();
0028 
0029 protected Q_SLOTS:
0030     void slotLoad(QTreeWidgetItem *item);
0031     void slotContextMenuTriggered(const QPoint &pos);
0032     void slotPopulateUserRegexps();
0033     void slotUnSelect();
0034     void slotRenameUserRegexp();
0035     void slotDeleteUserRegexp();
0036 
0037 protected:
0038     void createItems(const QString &title, const QString &dir, bool usersRegExp);
0039 
0040 Q_SIGNALS:
0041     void load(RegExp *);
0042 
0043 private:
0044     QTreeWidget *_userDefined = nullptr;
0045     QList<CompoundRegExp *> _regExps;
0046 };
0047 
0048 class WidgetWinItem : public QTreeWidgetItem
0049 {
0050 public:
0051     WidgetWinItem(const QString &name, RegExp *regexp, bool users, QTreeWidgetItem *parent);
0052     ~WidgetWinItem();
0053     static QString path();
0054 
0055     QString fileName() const;
0056     RegExp *regExp() const;
0057     QString name() const;
0058     void setName(const QString &);
0059     bool isUsersRegExp() const
0060     {
0061         return _usersRegExp;
0062     }
0063 
0064 private:
0065     QString _name;
0066     RegExp *_regexp = nullptr;
0067     bool _usersRegExp;
0068 };
0069 
0070 #endif // __USERDEFINEDREGEXPS_H