![]() |
rtVTK
0.6.0
|
00001 00002 /****************************************************************************** 00003 * Copyright (c) 2012, Grove City College 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are 00008 * met: 00009 * 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 00013 * * Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in 00015 * the documentation and/or other materials provided with the 00016 * distribution. 00017 * 00018 * * Neither the name of Grove City College nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00025 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00026 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 */ 00035 00036 00056 #ifndef StandAlone_TimerDialog_h 00057 #define StandAlone_TimerDialog_h 00058 00059 #include <map> 00060 using std::map; 00061 00062 #include <set> 00063 using std::set; 00064 00065 #include <string> 00066 using std::string; 00067 00068 #include <vector> 00069 using std::vector; 00070 00071 #include <QDialog> 00072 #include <QKeySequence> 00073 #include <QShortcut> 00074 #include <QTimer> 00075 00076 // Forward Declarations 00077 class QListWidget; 00078 class QKeySequence; 00079 class QShortcut; 00080 class QString; 00081 00082 namespace Ui 00083 { 00084 class TimerDialog; 00085 } // namespace Ui 00086 00087 namespace rtVTK 00088 { 00089 // Forward Declaration 00090 struct Plugin; 00091 00099 class Timer : public QTimer 00100 { 00101 Q_OBJECT 00102 public: 00103 Timer() : 00104 connection(""), 00105 shortcut(0), 00106 id(idCounter++), 00107 enabled(false) 00108 {/* no-op */} 00109 Timer(string c, QShortcut* s, bool a = false) : 00110 connection(c), 00111 shortcut(s), 00112 id(idCounter++), 00113 enabled(a) 00114 {/* no-op */} 00115 00116 ~Timer() 00117 { 00118 if (shortcut != 0) 00119 delete shortcut; 00120 } 00121 public slots: 00125 void slotToggle() 00126 { 00127 if (this->isActive()) 00128 { 00129 this->stop(); 00130 enabled = false; 00131 } 00132 else 00133 { 00134 enabled = true; 00135 this->start(); 00136 } 00137 } 00138 00139 public: 00140 string connection; 00144 QShortcut* shortcut; 00145 const uint id; 00146 static uint idCounter; 00152 bool enabled; 00153 }; // class Timer 00154 00156 class TimerDialog : public QDialog 00157 { 00158 Q_OBJECT 00159 00160 public: 00161 explicit TimerDialog(const vector<Plugin*>&, 00162 set<QKeySequence>&, QWidget* = 0); 00163 ~TimerDialog(); 00164 void populate(); 00165 00166 signals: 00167 void sgnlDisableIdle(); 00168 void sgnlRestoreIdle(); 00169 // For consistency with other dialog boxes and MainWindow's code, 00170 // TimerDialog never actually emits these signals, preferring to handle 00171 // timer pausing internally instead. tl;dr: Runtime warning suppression. 00172 void sgnlPauseTimers(); 00173 void sgnlUnpauseTimers(); 00174 00175 public slots: 00176 void slotPauseTimers(); 00177 void slotUnpauseTimers(); 00178 00179 private slots: 00180 void slotAddTimer(); 00181 void slotRemoveTimer(); 00182 void slotDifferentTimerHasRecievedFocus(); 00183 void slotTimerSettingsHaveBeenModifed(); 00184 void slotTimerSaveSettings(); 00185 void slotHideSuccessfulCreateTimer(); 00186 00187 private: 00188 void showEvent(QShowEvent*); 00189 void closeEvent(QCloseEvent*); 00190 void addSlotList(uint, Plugin*); 00191 void removeTabs(); 00192 void humanReadableFcn(string&); 00193 void machineReadableFcn(string&); 00194 void disableEditRemoveUI(); 00195 00196 Ui::TimerDialog *ui; 00197 00206 vector<QListWidget*> listWidgets; 00207 map<QListWidget*, uint> pluginIdx; 00208 00215 const vector<Plugin*>& plugins; 00216 00221 set<QKeySequence>& usedShortcutKeyCombos; 00222 00227 vector<Timer*> timers; 00228 00233 static const QString EmptyMessage; 00234 }; // class TimerDialog 00235 00236 } // namespace rtVTK 00237 00238 #endif // StandAlone_TimerDialog_h