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 OPTION_H 00011 #define OPTION_H 00012 00013 class QWidget; 00014 00015 #include <string> 00016 00017 /** 00018 * Interface for option plug-ins. 00019 * 00020 * All option plug-ins will be displayed to the user when opening the 00021 * application options dialog, ie. "Tools\Options". This interface can be 00022 * implemented by a plug-in to get their custom option widgets to appear 00023 * in the application options dialog. The application options dialog 00024 * is modal and will instantiate all option plug-ins when shown and will 00025 * destroy all option plug-ins when the dialog is closed. 00026 * 00027 * @see OptionShell, OptionQWidgetWrapper 00028 */ 00029 class Option 00030 { 00031 public: 00032 /** 00033 * Returns the name of the option. 00034 * 00035 * This will be displayed to the 00036 * user in a tree view, allowing them to show the widget returned 00037 * by getWidget() for this option. This string can include '/', 00038 * which will then create a group in the tree view. For instance, 00039 * a returned string of "Windows/Workspace/Cube" would create a tree 00040 * heirarchy like the following: 00041 * <ul><li>Windows</li> 00042 * <ul><li>Workspace</li> 00043 * <ul><li>Cube</li></ul> 00044 * </ul> 00045 * </ul> 00046 * 00047 * If the string needs to actually include a '/', it can be escaped by 00048 * using '//'. When placing option plug-ins into a heirarchy please 00049 * attempt to put them into the already provided application heirarchy 00050 * where possible. If not possible, please create a top-level node 00051 * with the name of the plug-in suite and place option plug-ins 00052 * under that node. 00053 * 00054 * @return Returns the name of the option. 00055 */ 00056 virtual const std::string& getOptionName() = 0; 00057 00058 /** 00059 * Returns the widget that will be displayed to the user. 00060 * 00061 * The widget will only be displayed when the user 00062 * selects the option in the options dialog. 00063 * This widget should only be instantiated 00064 * once per instance of this plug-in. This 00065 * widget will be owned by this plug-in and should 00066 * be destroyed when the plug-in is destroyed. 00067 * Please note, that the option dialog that this widget will 00068 * be displayed in is resizable, so ensure the Qt layout for 00069 * this widget resizes properly. 00070 * 00071 * @warning The QWidget* returned by this method should NEVER be 00072 * instantiated in the constructor of this plug-in. When the 00073 * application is run in batch mode, it will attempt to 00074 * create this plug-in and if this plug-in attempts to create 00075 * a QWidget* in it's constructor, the application will crash. 00076 * 00077 * @return Returns the widget that will be displayed to the user. 00078 */ 00079 virtual QWidget* getWidget() = 0; 00080 00081 /** 00082 * Apply the changes that the user made in the QWidget. 00083 * 00084 * The values modified by the user while the QWidget 00085 * was displayed should be stored permanently. 00086 * This usually means storing the values in ConfigurationSettings, 00087 * but can include any method that will store the values such 00088 * that the values will be retained through a stop and start 00089 * of the application and the values should generally be associated 00090 * with the user running the application only. 00091 * The values modified by the user should NEVER be permanently 00092 * stored until this method is called. This method is guaranteed 00093 * to only be called once per instance of the class. 00094 */ 00095 virtual void applyChanges() = 0; 00096 00097 protected: 00098 /** 00099 * Since the Option interface is usually used in conjunction with the 00100 * PlugIn interface, this should be destroyed by casting to 00101 * the PlugIn interface and calling PlugInManagerServices::destroyPlugIn(). 00102 */ 00103 virtual ~Option() {} 00104 }; 00105 00106 #endif