File indexing completed on 2024-04-21 05:45:50

0001 /*
0002     KT list view item cron tasks folder.
0003     --------------------------------------------------------------------
0004     SPDX-FileCopyrightText: 1999 Gary Meyer <gary@meyer.net>
0005     --------------------------------------------------------------------
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include <QTreeWidget>
0012 
0013 #include "cthost.h"
0014 
0015 class GenericListWidgetPrivate;
0016 class QKeyEvent;
0017 class QAction;
0018 class QVBoxLayout;
0019 
0020 class CrontabWidget;
0021 
0022 /**
0023  * GenericListWidget
0024  */
0025 class GenericListWidget : public QWidget
0026 {
0027     Q_OBJECT
0028 public:
0029     explicit GenericListWidget(CrontabWidget *crontabWidget, const QString &label, const QIcon &icon);
0030 
0031     ~GenericListWidget() override;
0032 
0033     QTreeWidget *treeWidget() const;
0034 
0035     CTHost *ctHost() const;
0036 
0037     CrontabWidget *crontabWidget() const;
0038 
0039     void resizeColumnContents();
0040 
0041     void keyPressEvent(QKeyEvent *e) override;
0042 
0043 protected Q_SLOTS:
0044     virtual void modifySelection(QTreeWidgetItem *item, int position) = 0;
0045 
0046     virtual void deleteSelection() = 0;
0047 
0048 protected:
0049     void removeAll();
0050 
0051     QTreeWidgetItem *firstSelected() const;
0052 
0053     QAction *createSeparator();
0054 
0055     void addRightAction(QAction *action, const QObject *receiver, const char *member);
0056     void addRightStretch();
0057 
0058     void setActionEnabled(QAction *action, bool enabled);
0059 
0060 private:
0061     QTreeWidget *mTreeWidget = nullptr;
0062 
0063     CrontabWidget *mCrontabWidget = nullptr;
0064 
0065     QVBoxLayout *mActionsLayout = nullptr;
0066 };
0067