File indexing completed on 2024-04-14 05:38:51

0001 /*
0002     KT main view header.
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 <QWidget>
0012 
0013 #include "tasksWidget.h"
0014 #include "variablesWidget.h"
0015 
0016 class QHBoxLayout;
0017 
0018 class CTHost;
0019 class CTCron;
0020 class QRadioButton;
0021 class QComboBox;
0022 
0023 /**
0024  * Main GUI view of the crontab entries.
0025  */
0026 class CrontabWidget : public QWidget
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     /**
0032      * Initializes view.
0033      */
0034     explicit CrontabWidget(QWidget *parent, CTHost *ctHost);
0035 
0036     /**
0037      * Destructor.
0038      */
0039     ~CrontabWidget() override;
0040 
0041     TasksWidget *tasksWidget() const;
0042 
0043     VariablesWidget *variablesWidget() const;
0044 
0045     CTHost *ctHost() const;
0046 
0047     CTCron *currentCron() const;
0048 
0049     QList<QAction *> cutCopyPasteActions();
0050 
0051 public Q_SLOTS:
0052 
0053     /**
0054      * Copies variables and/or tasks.
0055      */
0056     void copy();
0057 
0058     void cut();
0059 
0060     /**
0061      * Pastes variables and/or tasks from the clipboard.
0062      */
0063     void paste();
0064 
0065     /**
0066      * Print crontab.
0067      */
0068     void print();
0069 
0070 protected Q_SLOTS:
0071 
0072     void refreshCron();
0073 
0074     void checkOtherUsers();
0075 
0076 private:
0077     /**
0078      * Enables/disables paste button
0079      */
0080     void togglePasteAction(bool enabled);
0081 
0082     /**
0083      * Enables/disables modification buttons
0084      */
0085     void toggleModificationActions(bool enabled);
0086 
0087     /**
0088      * Enables/disables new entry actions
0089      */
0090     void toggleNewEntryActions(bool enabled);
0091 
0092     /**
0093      * Initialize actions.
0094      */
0095     void setupActions();
0096 
0097     /**
0098      * Initialize view from underlying objects.
0099      */
0100     void initialize();
0101 
0102     QHBoxLayout *createCronSelector();
0103 
0104     bool hasClipboardContent();
0105 
0106     /**
0107      * The application.
0108      */
0109     CTHost *mCtHost = nullptr;
0110 
0111     /**
0112      * Tree view of the crontab tasks.
0113      */
0114     TasksWidget *mTasksWidget = nullptr;
0115 
0116     /**
0117      * Tree view of the crontab tasks.
0118      */
0119     VariablesWidget *mVariablesWidget = nullptr;
0120 
0121     QAction *mCutAction = nullptr;
0122     QAction *mCopyAction = nullptr;
0123     QAction *mPasteAction = nullptr;
0124 
0125     /**
0126      * Clipboard tasks.
0127      */
0128     QList<CTTask *> mClipboardTasks;
0129 
0130     /**
0131      * Clipboard variable.
0132      */
0133     QList<CTVariable *> mClipboardVariables;
0134 
0135     QRadioButton *mCurrentUserCronRadio = nullptr;
0136     QRadioButton *mSystemCronRadio = nullptr;
0137     QRadioButton *mOtherUserCronRadio = nullptr;
0138 
0139     QComboBox *mOtherUsers = nullptr;
0140 
0141 };
0142