1 /******************************************************************************
2 
3   This source file is part of the MoleQueue project.
4 
5   Copyright 2012 Kitware, Inc.
6 
7   This source code is released under the New BSD License, (the "License").
8 
9   Unless required by applicable law or agreed to in writing, software
10   distributed under the License is distributed on an "AS IS" BASIS,
11   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   See the License for the specific language governing permissions and
13   limitations under the License.
14 
15 ******************************************************************************/
16 
17 #ifndef MOLEQUEUE_QUEUESETTINGSDIALOG_H
18 #define MOLEQUEUE_QUEUESETTINGSDIALOG_H
19 
20 #include <QtWidgets/QDialog>
21 
22 #include <QtCore/QMap>
23 
24 class QAbstractButton;
25 class QItemSelection;
26 class QModelIndex;
27 
28 namespace Ui {
29     class QueueSettingsDialog;
30 }
31 
32 namespace MoleQueue
33 {
34 class AbstractQueueSettingsWidget;
35 class Program;
36 class ProgramConfigureDialog;
37 class Queue;
38 class QueueProgramItemModel;
39 
40 /// @brief Dialog for configuring queues and managing programs.
41 class QueueSettingsDialog : public QDialog
42 {
43   Q_OBJECT
44 
45 public:
46   explicit QueueSettingsDialog(Queue *queue, QWidget *parentObject = 0);
47   ~QueueSettingsDialog();
48 
currentQueue()49   Queue *currentQueue() const { return m_queue; }
50 
51 public slots:
52   void accept();
53 
54 protected slots:
55   void addProgramClicked();
56   void removeProgramClicked();
57   void configureProgramClicked();
58   void importProgramClicked();
59   void exportProgramClicked();
60   void doubleClicked(const QModelIndex &);
61   void enableProgramButtons(const QItemSelection &selected);
62   void showProgramConfigDialog(Program *prog);
63   void setEnabledProgramButtons(bool enabled);
64   void removeProgramDialog();
65   void buttonBoxButtonClicked(QAbstractButton*);
66   bool apply();
67   void reset();
68   void setDirty(bool dirty = true);
69   void tabChanged(int index);
70 
71 protected:
72   void closeEvent(QCloseEvent *);
73   void keyPressEvent(QKeyEvent *);
74 
75   /// Row indices, ascending order
76   QList<int> getSelectedRows();
77   QList<Program*> getSelectedPrograms();
78 
79   Ui::QueueSettingsDialog *ui;
80   Queue *m_queue;
81   QueueProgramItemModel *m_model;
82   QMap<Program *, ProgramConfigureDialog *> m_programConfigureDialogs;
83   AbstractQueueSettingsWidget *m_settingsWidget;
84   bool m_dirty;
85 };
86 
87 } // end MoleQueue namespace
88 
89 #endif // QUEUESETTINGSDIALOG_H
90