| 1 | /********************************************************************** |
|---|
| 2 | AbstractEditTab - Generic tab for editing templates |
|---|
| 3 | |
|---|
| 4 | Copyright (C) 2009-2011 by David Lonie |
|---|
| 5 | |
|---|
| 6 | This library is free software; you can redistribute it and/or modify |
|---|
| 7 | it under the terms of the GNU Library General Public License as |
|---|
| 8 | published by the Free Software Foundation; either version 2.1 of the |
|---|
| 9 | License, or (at your option) any later version. |
|---|
| 10 | |
|---|
| 11 | This program is distributed in the hope that it will be useful, |
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | GNU General Public icense for more details. |
|---|
| 15 | ***********************************************************************/ |
|---|
| 16 | |
|---|
| 17 | #ifndef ABSTRACTEDITTAB_H |
|---|
| 18 | #define ABSTRACTEDITTAB_H |
|---|
| 19 | |
|---|
| 20 | #include <globalsearch/ui/abstracttab.h> |
|---|
| 21 | |
|---|
| 22 | #include <QtCore/QList> |
|---|
| 23 | #include <QtCore/QString> |
|---|
| 24 | #include <QtCore/QStringList> |
|---|
| 25 | |
|---|
| 26 | class QComboBox; |
|---|
| 27 | class QLineEdit; |
|---|
| 28 | class QListWidget; |
|---|
| 29 | class QPushButton; |
|---|
| 30 | class QTextEdit; |
|---|
| 31 | |
|---|
| 32 | namespace GlobalSearch { |
|---|
| 33 | class AbstractDialog; |
|---|
| 34 | class OptBase; |
|---|
| 35 | class Optimizer; |
|---|
| 36 | class QueueInterface; |
|---|
| 37 | |
|---|
| 38 | /** |
|---|
| 39 | * @class AbstractEditTab abstractedittab.h <globalsearch/abstractedittab.h> |
|---|
| 40 | * |
|---|
| 41 | * @brief Abstract class implementing a template editor |
|---|
| 42 | * |
|---|
| 43 | * @author David C. Lonie |
|---|
| 44 | */ |
|---|
| 45 | class AbstractEditTab : public GlobalSearch::AbstractTab |
|---|
| 46 | { |
|---|
| 47 | Q_OBJECT; |
|---|
| 48 | |
|---|
| 49 | public: |
|---|
| 50 | /** |
|---|
| 51 | * Constructor |
|---|
| 52 | * |
|---|
| 53 | * @param parent AbstractDialog that will use this tab |
|---|
| 54 | * @param p Associated OptBase |
|---|
| 55 | */ |
|---|
| 56 | explicit AbstractEditTab( AbstractDialog *parent, OptBase *p ); |
|---|
| 57 | |
|---|
| 58 | /** |
|---|
| 59 | * Destructor |
|---|
| 60 | */ |
|---|
| 61 | virtual ~AbstractEditTab(); |
|---|
| 62 | |
|---|
| 63 | public slots: |
|---|
| 64 | /** |
|---|
| 65 | * Lock GUI elements that shouldn't change once the search begins. |
|---|
| 66 | */ |
|---|
| 67 | virtual void lockGUI(); |
|---|
| 68 | |
|---|
| 69 | /** |
|---|
| 70 | * Force a refresh of the GUI elements using the internal state. |
|---|
| 71 | */ |
|---|
| 72 | virtual void updateGUI(); |
|---|
| 73 | |
|---|
| 74 | /** |
|---|
| 75 | * Display the currently selected template in the text editor. |
|---|
| 76 | */ |
|---|
| 77 | virtual void updateEditWidget(); |
|---|
| 78 | |
|---|
| 79 | /** |
|---|
| 80 | * Popup a message box displaying the keyword documentation. |
|---|
| 81 | */ |
|---|
| 82 | virtual void showHelp(); |
|---|
| 83 | |
|---|
| 84 | /** |
|---|
| 85 | * Save the text in the template editor to the appropriate |
|---|
| 86 | * template list. |
|---|
| 87 | */ |
|---|
| 88 | virtual void saveCurrentTemplate(); |
|---|
| 89 | |
|---|
| 90 | /** |
|---|
| 91 | * Generate the list of optsteps. |
|---|
| 92 | */ |
|---|
| 93 | virtual void populateOptStepList(); |
|---|
| 94 | |
|---|
| 95 | /** |
|---|
| 96 | * Fill the template selection combo using the template names for |
|---|
| 97 | * the current QueueInterface and Optimizer. |
|---|
| 98 | */ |
|---|
| 99 | virtual void populateTemplates(); |
|---|
| 100 | |
|---|
| 101 | /** |
|---|
| 102 | * Create a new optstep at the end of the optstep list. It will |
|---|
| 103 | * initialize using the currently selected optstep's templates. |
|---|
| 104 | */ |
|---|
| 105 | virtual void appendOptStep(); |
|---|
| 106 | |
|---|
| 107 | /** |
|---|
| 108 | * Delete the currently selected optstep. |
|---|
| 109 | */ |
|---|
| 110 | virtual void removeCurrentOptStep(); |
|---|
| 111 | |
|---|
| 112 | /** |
|---|
| 113 | * Save the current optimization scheme. This will prompt for the |
|---|
| 114 | * user to specify the filename. |
|---|
| 115 | */ |
|---|
| 116 | virtual void saveScheme(); |
|---|
| 117 | |
|---|
| 118 | /** |
|---|
| 119 | * Load an optimization scheme from a file. This will prompt the |
|---|
| 120 | * user for the filename. |
|---|
| 121 | */ |
|---|
| 122 | virtual void loadScheme(); |
|---|
| 123 | |
|---|
| 124 | /** |
|---|
| 125 | * @return A list of the available template names for the current |
|---|
| 126 | * QueueInterface and Optimizer. |
|---|
| 127 | */ |
|---|
| 128 | virtual QStringList getTemplateNames(); |
|---|
| 129 | |
|---|
| 130 | signals: |
|---|
| 131 | /** |
|---|
| 132 | * Emitted when the Optimizer changes. |
|---|
| 133 | */ |
|---|
| 134 | void optimizerChanged(Optimizer*); |
|---|
| 135 | |
|---|
| 136 | /** |
|---|
| 137 | * Emitted when the QueueInterface changes. |
|---|
| 138 | */ |
|---|
| 139 | void queueInterfaceChanged(QueueInterface*); |
|---|
| 140 | |
|---|
| 141 | protected slots: |
|---|
| 142 | /** |
|---|
| 143 | * Create connections and initialize GUI. |
|---|
| 144 | */ |
|---|
| 145 | virtual void initialize(); |
|---|
| 146 | |
|---|
| 147 | /** |
|---|
| 148 | * Refresh the "userX" line edits. |
|---|
| 149 | */ |
|---|
| 150 | virtual void updateUserValues(); |
|---|
| 151 | |
|---|
| 152 | /** |
|---|
| 153 | * Determine the currently selected QueueInterface and emit |
|---|
| 154 | * queueInterfaceChanged if it differs from the current one. |
|---|
| 155 | */ |
|---|
| 156 | virtual void updateQueueInterface(); |
|---|
| 157 | |
|---|
| 158 | /** |
|---|
| 159 | * Determine the currently selected Optimizer and emit |
|---|
| 160 | * optimizerChanged if it differs from the current one. |
|---|
| 161 | */ |
|---|
| 162 | virtual void updateOptimizer();\ |
|---|
| 163 | |
|---|
| 164 | /** |
|---|
| 165 | * Launch the QueueInterface configuration dialog. |
|---|
| 166 | */ |
|---|
| 167 | virtual void configureQueueInterface(); |
|---|
| 168 | |
|---|
| 169 | /** |
|---|
| 170 | * Launch the Optimizer configuration dialog. |
|---|
| 171 | */ |
|---|
| 172 | virtual void configureOptimizer(); |
|---|
| 173 | |
|---|
| 174 | protected: |
|---|
| 175 | /// List of all optimizers. This must be filled in derived classes |
|---|
| 176 | /// prior to calling initialize() |
|---|
| 177 | QList<Optimizer*> m_optimizers; |
|---|
| 178 | |
|---|
| 179 | /// List of all QueueInterfaces. This must be filled in derived classes |
|---|
| 180 | /// prior to calling initialize() |
|---|
| 181 | QList<QueueInterface*> m_queueInterfaces; |
|---|
| 182 | |
|---|
| 183 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 184 | QComboBox *ui_combo_queueInterfaces; |
|---|
| 185 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 186 | QComboBox *ui_combo_optimizers; |
|---|
| 187 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 188 | QComboBox *ui_combo_templates; |
|---|
| 189 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 190 | QLineEdit *ui_edit_user1; |
|---|
| 191 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 192 | QLineEdit *ui_edit_user2; |
|---|
| 193 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 194 | QLineEdit *ui_edit_user3; |
|---|
| 195 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 196 | QLineEdit *ui_edit_user4; |
|---|
| 197 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 198 | QListWidget *ui_list_edit; |
|---|
| 199 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 200 | QListWidget *ui_list_optStep; |
|---|
| 201 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 202 | QPushButton *ui_push_add; |
|---|
| 203 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 204 | QPushButton *ui_push_help; |
|---|
| 205 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 206 | QPushButton *ui_push_loadScheme; |
|---|
| 207 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 208 | QPushButton *ui_push_optimizerConfig; |
|---|
| 209 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 210 | QPushButton *ui_push_queueInterfaceConfig; |
|---|
| 211 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 212 | QPushButton *ui_push_remove; |
|---|
| 213 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 214 | QPushButton *ui_push_saveScheme; |
|---|
| 215 | /// Cached GUI pointer. This is set in DefaultEditTab |
|---|
| 216 | QTextEdit *ui_edit_edit; |
|---|
| 217 | }; |
|---|
| 218 | } |
|---|
| 219 | |
|---|
| 220 | #endif |
|---|