ClassificationWidget.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2010 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 CLASSIFICATIONWIDGET_H
00011 #define CLASSIFICATIONWIDGET_H
00012 
00013 #include "Classification.h"
00014 #include "ConfigurationSettings.h"
00015 #include "DynamicObject.h"
00016 #include "SafePtr.h"
00017 
00018 #include <QtGui/QWidget>
00019 
00020 #include <boost/any.hpp>
00021 #include <string>
00022 #include <vector>
00023 
00024 class DateTime;
00025 class QComboBox;
00026 class QDate;
00027 class QDateEdit;
00028 class QListWidget;
00029 class QPushButton;
00030 class QSpinBox;
00031 class QStackedWidget;
00032 class QTabWidget;
00033 class QTextEdit;
00034 class Subject;
00035 
00036 /**
00037  *  A widget to display classification markings.
00038  *
00039  *  The classification widget provides the means by which users can view and/or
00040  *  edit classification markings.  The widget contains two tabs: one tab for the
00041  *  markings that are displayed at the top and bottom of an object or product,
00042  *  and another tab for ancillary information with the classification.
00043  *
00044  *  The first tab allows users to choose the overall classification level and
00045  *  the values of the various classification fields that also comprise the
00046  *  overall markings string.  A preview of the final classification string is
00047  *  provided.
00048  *
00049  *  The second tab contains the following information that is included in the
00050  *  classification object:
00051  *  - %Classification reason
00052  *  - Declassification type
00053  *  - Declassification date
00054  *  - File downgrade
00055  *  - Downgrade date
00056  *  - File control
00057  *  - Description
00058  *  - Copy number
00059  *  - Number of copies
00060  *
00061  *  At the bottom of the widget outside of the tab widget is the favorites list.
00062  *  This list allows users to store commonly used classification markings for
00063  *  the purpose of easily updating the markings for multiple objects.  The
00064  *  favorites list is stored in the user's configuration file as the user adds
00065  *  or removes items from the list.
00066  *
00067  *  @see        Classification
00068  */
00069 class ClassificationWidget : public QWidget
00070 {
00071    Q_OBJECT
00072 
00073 public:
00074    SETTING_PTR(Favorites, SecurityMarkings, DynamicObject)
00075 
00076    /**
00077     *  Creates the classification widget.
00078     *
00079     *  @param   pParent
00080     *           The parent widget.
00081     */
00082    ClassificationWidget(QWidget* pParent = NULL);
00083 
00084    /**
00085     *  Destroys the classification widget.
00086     */
00087    virtual ~ClassificationWidget();
00088 
00089    /**
00090     *  Sets the widget to view and edit the markings of a given Classification
00091     *  object.
00092     *
00093     *  This method sets the internal Classification object that is being edited
00094     *  to the given classification.  All changes to the widgets are applied
00095     *  immediately to the Classification object.
00096     *
00097     *  @param   pClassification
00098     *           The Classification object to display and edit.
00099     *  @param   initializeWidgets
00100     *           If set to \c true, the widgets are initialized to the values
00101     *           contained in the given Classification object.  If set to
00102     *           \c false the widgets are initialized to empty values.
00103     */
00104    void setClassification(Classification* pClassification, bool initializeWidgets = true);
00105 
00106 protected:
00107    /**
00108     *  Initializes the widgets if the Classification object has been modified
00109     *  since the widget was last displayed.
00110     *
00111     *  This method is used internally and should not be called directly.
00112     *
00113     *  @param   pEvent
00114     *           The show event causing the update.
00115     */
00116    virtual void showEvent(QShowEvent* pEvent);
00117 
00118    /**
00119     *  Attaches to the Classification object to determine whether the widgets
00120     *  should be initialized when the widget is shown.
00121     *
00122     *  This method is used internally and should not be called directly.
00123     *
00124     *  @param   pEvent
00125     *           The hide event causing the update.
00126     */
00127    virtual void hideEvent(QHideEvent* pEvent);
00128 
00129    /**
00130     *  Writes the favorites list to the user configuration settings and
00131     *  serializes the configuration settings to the configuration file.
00132     *
00133     *  This method is called automatically when the user adds or removes items
00134     *  from the favorites list.
00135     *
00136     *  @return  Returns \c true if the favorites list was successfully
00137     *           written to the user configuration settings; otherwise
00138     *           returns \c false.
00139     */
00140    bool serializeFavorites();
00141 
00142    /**
00143     *  Reads the favorites list from the user configuration settings and
00144     *  populates the favorites combo box.
00145     *
00146     *  This method is called automatically when the widget is created.
00147     *
00148     *  @return  Returns \c true if the favorites list was successfully
00149     *           populated from the user configuration settings; otherwise
00150     *           returns \c false.
00151     */
00152    bool deserializeFavorites();
00153 
00154    /**
00155     *  Populates the favorites combo box from the current list of favorites.
00156     */
00157    void updateFavoritesCombo();
00158 
00159    /**
00160     *  Clears the favorites list.
00161     *
00162     *  This method clears the favorites list but does not change the contents
00163     *  of the favorites combo box.  To update the favorites combo box, call
00164     *  updateFavoritesCombo().
00165     */
00166    void clearFavorites();
00167 
00168 protected slots:
00169    /**
00170     *  Updates the markings preview widget.
00171     *
00172     *  This method updates the markings string in the preview widget to reflect
00173     *  the current widget values.  This method is called automatically when the
00174     *  user changes widget values and should not need to be called directly.
00175     */
00176    void updateMarkings();
00177 
00178 private:
00179    ClassificationWidget(const ClassificationWidget& rhs);
00180    ClassificationWidget& operator=(const ClassificationWidget& rhs);
00181 
00182    QComboBox* mpClassLevelCombo;
00183    QTabWidget* mpTabWidget;
00184    QStackedWidget* mpValueStack;
00185    QListWidget* mpCodewordList;
00186    QListWidget* mpSystemList;
00187    QListWidget* mpFileReleasingList;
00188    QListWidget* mpCountryCodeList;
00189    QListWidget* mpExemptionList;
00190    QPushButton* mpAddButton;
00191    QComboBox* mpClassReasonCombo;
00192    QComboBox* mpDeclassTypeCombo;
00193    QDateEdit* mpDeclassDateEdit;
00194    QPushButton* mpResetDeclassDateButton;
00195    QComboBox* mpFileDowngradeCombo;
00196    QDateEdit* mpDowngradeDateEdit;
00197    QPushButton* mpResetDowngradeDateButton;
00198    QComboBox* mpFileControlCombo;
00199    QTextEdit* mpDescriptionEdit;
00200    QSpinBox* mpCopyNumberSpinBox;
00201    QSpinBox* mpNumberOfCopiesSpinBox;
00202    QTextEdit* mpMarkingsEdit;
00203    QComboBox* mpFavoritesCombo;
00204 
00205    SafePtr<Classification> mpClass;
00206    std::vector<Classification*> mlstFavorites;
00207    bool mNeedsInitialization;
00208 
00209 private:
00210    void resetToDefault(QWidget* pWidget = NULL);
00211    void initialize();
00212 
00213    QString getListString(QListWidget* pListWidget);
00214    void selectListFromString(QListWidget* pListWidget, const QString& strText);
00215    void selectComboFromString(QComboBox* pComboBox, const QString& strText);
00216    void setDateEdit(QDateEdit* pDateEdit, const DateTime* pDateTime);
00217 
00218    void classificationModified(Subject& subject, const std::string& signal, const boost::any& value);
00219 
00220 private slots:
00221    void setLevel(const QString& level);
00222    void updateSize();
00223    void checkAddButton(int iIndex);
00224    void setCodewords();
00225    void setSystem();
00226    void setFileReleasing();
00227    void setCountryCode();
00228    void setDeclassificationExemption();
00229    void addListItem();
00230    void resetList();
00231    void setClassificationReason(const QString& reason);
00232    void setDeclassificationType(const QString& declassType);
00233    void setDeclassificationDate(const QDate& declassDate);
00234    void resetDeclassificationDate();
00235    void setFileDowngrade(const QString& fileDowngrade);
00236    void setDowngradeDate(const QDate& downgradeDate);
00237    void resetDowngradeDate();
00238    void setFileControl(const QString& fileControl);
00239    void setDescription();
00240    void setFileCopyNumber(const QString& copyNumber);
00241    void setFileNumberOfCopies(const QString& numberOfCopies);
00242    void favoriteSelected();
00243    void addFavoriteItem();
00244    void removeFavoriteItem();
00245 };
00246 
00247 #endif

Software Development Kit - Opticks 4.9.0 Build 16218