00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef ALGORITHMDIALOG_H 00011 #define ALGORITHMDIALOG_H 00012 00013 #include <QtCore/QEventLoop> 00014 #include <QtGui/QDialog> 00015 00016 /** 00017 * Modeless dialog support for a plug-in. 00018 * 00019 * The algorithm dialog provides a means for plug-ins to display modeless dialogs where 00020 * an event loop can be executed to prevent control from returning to the caller until 00021 * the dialog is accepted or rejected. 00022 * 00023 * After calling show(), call enterLoop() to begin the event loop. The enterLoop() 00024 * method will not return until the dialog is accepted or rejected. 00025 * 00026 * WARNING: If another instance of an algorithm dialog is instantiated while the event 00027 * loop of this instance is running, accepting or rejecting this dialog will not cause 00028 * enterLoop() to return until control has returned from the other dialog instance. 00029 */ 00030 class AlgorithmDialog : public QDialog 00031 { 00032 Q_OBJECT 00033 00034 public: 00035 /** 00036 * Creates the algorithm dialog. 00037 * 00038 * By default, the dialog is created as a modeless dialog. 00039 * 00040 * @param pParent 00041 * The parent widget. 00042 */ 00043 AlgorithmDialog(QWidget* pParent = 0); 00044 00045 /** 00046 * Destroys the algorithm dialog. 00047 * 00048 * If the event loop is running and the dialog has not been accepted or rejected, 00049 * the event loop is exited with a QDialog::Rejected value. 00050 */ 00051 ~AlgorithmDialog(); 00052 00053 /** 00054 * Begins the local event loop. 00055 * 00056 * This method begins the local event loop, and the method will not return until 00057 * the dialog is accepted or rejected. 00058 * 00059 * @return QDialog::Accepted is returned if the dialog is accepted either by the 00060 * user or programmatically. QDialog::Rejected is returned if the dialog 00061 * is rejected or if the dialog is destroyed without being accepted or 00062 * rejected. 00063 */ 00064 int enterLoop(); 00065 00066 public slots: 00067 /** 00068 * Closes the dialog, accepting the changes. 00069 * 00070 * This method accepts the dialog and exits the local event loop, thereby returning 00071 * control to the caller of eventLoop(). 00072 * 00073 * WARNING: If overriding this method, the base class must be called to ensure 00074 * proper execution of the application. 00075 */ 00076 void accept(); 00077 00078 /** 00079 * Closes the dialog, rejecting the changes. 00080 * 00081 * This method rejects the dialog and exits the local event loop, thereby returning 00082 * control to the caller of eventLoop(). 00083 * 00084 * WARNING: If overriding this method, the base class must be called to ensure 00085 * proper execution of the application. 00086 */ 00087 void reject(); 00088 00089 private: 00090 AlgorithmDialog(const AlgorithmDialog& rhs); 00091 AlgorithmDialog& operator=(const AlgorithmDialog& rhs); 00092 QEventLoop* mpEventLoop; 00093 }; 00094 00095 #endif