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 SESSIONITEM_H 00011 #define SESSIONITEM_H 00012 00013 #include <list> 00014 #include <string> 00015 #include <vector> 00016 00017 #include "ContextMenuAction.h" 00018 00019 class QIcon; 00020 class SessionItemSerializer; 00021 class SessionItemDeserializer; 00022 00023 /** 00024 * The base class for all objects in a session. 00025 * 00026 * The SessionItem class is a base class for all objects that are included in 00027 * a session. 00028 */ 00029 class SessionItem 00030 { 00031 public: 00032 /** 00033 * Returns a unique ID for the session item. 00034 * 00035 * The session item ID is automatically assigned when the item is created. 00036 * It is unique for all session items in the current session. 00037 * 00038 * @return The unique ID for the session item as a text string. The 00039 * string has the format {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} 00040 * where 'x' is a hexidecimal digit. 00041 */ 00042 virtual const std::string& getId() const = 0; 00043 00044 /** 00045 * Returns the icon associated with the session item. 00046 * 00047 * @return The item icon. 00048 */ 00049 virtual const QIcon& getIcon() const = 0; 00050 00051 /** 00052 * Returns the session item name. 00053 * 00054 * The session item name is the full name of the session item. This can be 00055 * a longer name that is used to help uniquely identify the item. To get 00056 * the name that is displayed to the user, call getDisplayName() instead. 00057 * 00058 * @return The session item name. 00059 */ 00060 virtual const std::string& getName() const = 0; 00061 00062 /** 00063 * Returns the session item name that should be displayed to the user. 00064 * 00065 * The display name can be used to present a shorter name to the user such 00066 * as a filename that does not include the full path. To get the full name 00067 * of the session item, call getName() instead. 00068 * 00069 * @param fullName 00070 * If set to \c true and no display name has been set, then the 00071 * full session item name is returned instead. 00072 * 00073 * @return The session item display name. If no display name has been set 00074 * and the \em fullName parameter is set to \c true, then the full 00075 * item name is returned, which is equivalent to calling getName(). 00076 */ 00077 virtual const std::string& getDisplayName(bool fullName = false) const = 0; 00078 00079 /** 00080 * Returns the additional text about the session item that can be displayed 00081 * to the user. 00082 * 00083 * @return The text string containing additional information about this 00084 * session item that can be displayed to the user. 00085 */ 00086 virtual const std::string& getDisplayText() const = 0; 00087 00088 /** 00089 * Returns the context menu actions available for this session item. 00090 * 00091 * @return The list of context menu actions that should be displayed when 00092 * the user right-clicks on a widget displaying or containing the 00093 * session item. 00094 * 00095 * @see ContextMenuAction 00096 */ 00097 virtual std::list<ContextMenuAction> getContextMenuActions() const = 0; 00098 00099 /** 00100 * Returns whether the display name and display text are automatically 00101 * updated when a filename is set as the item name. 00102 * 00103 * If this method returns \c true and the item name is updated to a 00104 * filename, the display name is automatically set to the base filename and 00105 * extension without the full path. The display text is automatically set 00106 * to the full path and filename, which is the same value as the item name 00107 * returned by getName(). 00108 * 00109 * If this method returns \c true and the item name is updated to a name 00110 * that is not a filename, the display name and display text are set to 00111 * empty text. 00112 * 00113 * If this method returns \c false, the display name and display text are 00114 * not affected when the item name is updated. 00115 * 00116 * @return Returns \c true if the display name and display text are 00117 * automatically updated when a filename is set as the item name; 00118 * otherwise returns \c false. By default, this method returns 00119 * \c true when a SessionItem is first created. 00120 * 00121 * @see getDisplayName(), getDisplayText() 00122 */ 00123 virtual bool hasFilenameDisplay() const = 0; 00124 00125 /** 00126 * Returns the Properties plug-in names whose widgets should comprise the 00127 * available tabs of the properties dialog for this session item. 00128 * 00129 * @return Returns the Properties plug-in names for this session item. 00130 */ 00131 virtual std::vector<std::string> getPropertiesPages() const = 0; 00132 00133 /** 00134 * Retrieves session save validity. 00135 * 00136 * Method returns whether or not the item will be included when saving a 00137 * session. 00138 * 00139 * @return Returns \c true if the item will be saved in a session, or 00140 * \c false otherwise. 00141 */ 00142 virtual bool isValidSessionSaveItem() const = 0; 00143 00144 /** 00145 * Saves the SessionItem as part of a full session save. 00146 * 00147 * This method will normally only be called by the SessionManager during a 00148 * session save. Every concrete type that inherits from SessionItem should 00149 * provide its own implementation for this method. If a SessionItem needs 00150 * to be recreated on session load, but does not have any state information 00151 * that it needs to save, it should call serialize(NULL,0) on the serializer. 00152 * If a SessionItem does not need to be created on session load, it should 00153 * simply return true from this method. This method will only be called on 00154 * session items that exist at the time of session serialization. 00155 * 00156 * @param serializer 00157 * The object to use to save the item as part of the current 00158 * session. 00159 * 00160 * @return True if the item was successfully saved and false otherwise. 00161 */ 00162 virtual bool serialize(SessionItemSerializer& serializer) const = 0; 00163 00164 /** 00165 * Restores the SessionItem from a saved session. 00166 * 00167 * This method will normally only be called by the SessionManager during a 00168 * session restore operation. Every concrete type that inherits from SessionItem 00169 * should provide its own implementation for this method. 00170 * 00171 * @param deserializer 00172 * The object to use to restore the item from a saved session 00173 * 00174 * @return True if the item was successfully restored and false otherwise. 00175 */ 00176 virtual bool deserialize(SessionItemDeserializer& deserializer) = 0; 00177 00178 protected: 00179 /** 00180 * The session item should be destroyed by calling one of the destruction 00181 * methods to destroy the specific subclass instance. 00182 */ 00183 virtual ~SessionItem() {} 00184 }; 00185 00186 #endif