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 PROPERTIESSHELL_H 00011 #define PROPERTIESSHELL_H 00012 00013 #include "PlugInShell.h" 00014 #include "Properties.h" 00015 00016 /** 00017 * \ingroup ShellModule 00018 * A base class for plug-in shells or plug-in instances. 00019 * 00020 * This class provides a default implementation of the Properties plug-in 00021 * interface. If a properties plug-in needs to implement a QWidget, try 00022 * subclassing PropertiesQWidgetWrapper instead of PropertiesShell. However, 00023 * if the properties plug-in should simply wrap an existing QWidget, subclass 00024 * PropertiesShell. 00025 * 00026 * @see Properties, PropertiesQWidgetWrapper 00027 */ 00028 class PropertiesShell : public Properties, public PlugInShell 00029 { 00030 public: 00031 /** 00032 * Creates the properties plug-in. 00033 * 00034 * The constructor sets the plug-in type to 00035 * PlugInManagerServices::PropertiesType(). 00036 * 00037 * @see getType() 00038 */ 00039 PropertiesShell(); 00040 00041 /** 00042 * Destroys the properties plug-in. 00043 */ 00044 virtual ~PropertiesShell(); 00045 00046 /** 00047 * @copydoc Properties::getWidget() 00048 * 00049 * @default The default implementation calls createWidget() and stores and 00050 * returns the returned widget pointer. Successive calls to this 00051 * method will simply return the stored widget pointer. 00052 */ 00053 QWidget* getWidget(); 00054 00055 /** 00056 * @copydoc Properties::getPropertiesName() 00057 * 00058 * @default The default implementation returns the value provided to 00059 * setPropertiesName(). If setPropertiesName() has not been 00060 * called, this method returns an empty string. 00061 */ 00062 const std::string& getPropertiesName() const; 00063 00064 /** 00065 * @copydoc Properties::initialize() 00066 * 00067 * @default The default implementation sets the member pointer that can be 00068 * retrieved by calling getSessionItem() and returns \c true. 00069 */ 00070 bool initialize(SessionItem* pSessionItem); 00071 00072 protected: 00073 /** 00074 * Creates the properties widget. 00075 * 00076 * This method must be implemented in subclasses to create the QWidget. 00077 * Upon creation, the widget should be populated with default values. 00078 * Initialization of the widget will occur in initialize(), which is called 00079 * after this method. 00080 * 00081 * This method is guaranteed to be called only once per instance of this 00082 * plug-in. 00083 * 00084 * @return The created properties widget. 00085 */ 00086 virtual QWidget* createWidget() = 0; 00087 00088 /** 00089 * Sets the properties name that will be returned from getPropertiesName(). 00090 * 00091 * @param name 00092 * The properties name that will appear on a tab in the properties 00093 * dialog. 00094 */ 00095 void setPropertiesName(const std::string& name); 00096 00097 /** 00098 * Returns the session item for which the widget is initialized. 00099 * 00100 * This method provides a means to retrieve the session item to which the 00101 * widget is initialized. The returned pointer can be used when appying 00102 * changes back to the session item. 00103 * 00104 * @return The session item to which changes should be applied. 00105 * 00106 * @see initialize() 00107 */ 00108 SessionItem* getSessionItem() const; 00109 00110 private: 00111 QWidget* mpWidget; 00112 std::string mName; 00113 SessionItem* mpSessionItem; 00114 }; 00115 00116 #endif