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 PROPERTIES_H 00011 #define PROPERTIES_H 00012 00013 #include <string> 00014 00015 class SessionItem; 00016 class QWidget; 00017 00018 /** 00019 * Interface for properties plug-ins. 00020 * 00021 * %Properties plug-ins will be displayed to the user when opening the 00022 * application properties dialog. This interface can be implemented by a 00023 * plug-in to get its custom properties widgets to appear in the application 00024 * properties dialog. The application properties dialog is modal and will 00025 * instantiate all properties plug-ins when shown and will destroy all 00026 * properties plug-ins when the dialog is closed. 00027 * 00028 * @see PropertiesShell, PropertiesQWidgetWrapper 00029 */ 00030 class Properties 00031 { 00032 public: 00033 /** 00034 * Returns the widget that will be displayed to the user. 00035 * 00036 * The widget will be displayed when the user selects the applicable tab in 00037 * the properties dialog. It is only instantiated once per instance of 00038 * this plug-in. The widget will be owned by the plug-in and should be 00039 * destroyed when the plug-in is destroyed. Please note, that the 00040 * properties dialog in which the widget will be displayed in is resizable, 00041 * so ensure that the Qt layout for the widget resizes properly. 00042 * 00043 * @warning The QWidget* returned by this method should never be 00044 * instantiated in the constructor of this plug-in. When the 00045 * application is run in batch mode, it will attempt to create 00046 * this plug-in and if this plug-in attempts to create a QWidget* 00047 * in its constructor, the application will crash. 00048 * 00049 * @return Returns the widget that will be displayed to the user. 00050 */ 00051 virtual QWidget* getWidget() = 0; 00052 00053 /** 00054 * Returns the name of the properties. 00055 * 00056 * This method is called by the properties dialog to get the name to 00057 * display on the tab containing the widget returned by getWidget(). 00058 * 00059 * @return Returns the properties name that is displayed to the user. 00060 */ 00061 virtual const std::string& getPropertiesName() const = 0; 00062 00063 /** 00064 * Initializes the widget to the properties of a given session item. 00065 * 00066 * This method is called by the properties dialog for the widget to 00067 * initialize its child widgets based on the current state of the given 00068 * session item. 00069 * 00070 * This method is guaranteed to only be called once per instance of the 00071 * class. 00072 * 00073 * @param pSessionItem 00074 * The session item for which to initialize the widget's values. 00075 * 00076 * @return Returns \c true if the widget was successfully initialized from 00077 * the given session item; otherwise returns \c false. If this 00078 * method returns \c false, the widget is not added to the 00079 * properties dialog. 00080 */ 00081 virtual bool initialize(SessionItem* pSessionItem) = 0; 00082 00083 /** 00084 * Applies the changes that the user made in the widget. 00085 * 00086 * This method is called when the user clicks the OK or Apply buttons in 00087 * the properties dialog. It applies the changes in the widget by calling 00088 * applyChanges() on the templated class. The applyChanges() method of the 00089 * templated class should return \c true if all changes were successfully 00090 * applied to the object. It should also return \c true if no updates need 00091 * to be made. 00092 * 00093 * The values modified by the user while the QWidget is displayed should be 00094 * applied to the session item for which the widget was initialized in the 00095 * initialize() method. 00096 * 00097 * @return This method returns \c true if the changes were successfully 00098 * applied to the session item or if no changes need to be made. 00099 * If \c false is returned, the widget will be activated in the 00100 * properties dialog if necessary and the dialog will not be 00101 * closed if the OK button was clicked. 00102 */ 00103 virtual bool applyChanges() = 0; 00104 00105 protected: 00106 /** 00107 * Since the Properties interface is usually used in conjunction with the 00108 * PlugIn interface, this should be destroyed by casting to the PlugIn 00109 * interface and calling PlugInManagerServices::destroyPlugIn(). 00110 */ 00111 virtual ~Properties() {} 00112 }; 00113 00114 #endif