Optika GUI Toolik Version of the Day
Optika_metawindow.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //         Optika: A Tool For Developing Parameter Obtaining GUIs
00005 //                Copyright (2009) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the 
00008 // U.S. Government retains certain rights in this software.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kurtis Nusbaum (klnusbaum@gmail.com) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 #ifndef METAWINDOW_HPP_
00042 #define METAWINDOW_HPP_
00043 #include <QMainWindow>
00044 #include <QDialog>
00045 #include <QModelIndex>
00046 #include "Optika_treeview.hpp"
00047 
00054 class QAction;
00055 class QMenu;
00056 class QLabel;
00057 class QPushButton;
00058 class QLineEdit;
00059 namespace Optika{
00060 
00065 class SearchWidget : public QDialog{
00066   Q_OBJECT
00067 public:
00068 
00071 
00079   SearchWidget(TreeModel *treeModel, TreeView *treeView, QWidget *parent=0);
00080 
00082 
00083 private slots:
00084 
00087   
00092   void search();
00093 
00098   void next();
00099 
00104   void previous();
00105 
00107 
00108 private:
00109 
00112   
00123   QModelIndexList removeHiddenItems(QModelIndexList& items);
00124 
00126 
00129   
00133   QPushButton *searchButton, *closeButton, *nextButton, *previousButton;
00134   QLineEdit *searchTermsEdit;
00135   QLabel *matchesLabel;
00136   TreeModel *treeModel;
00137   TreeView *treeView;
00138 
00142   QList<QModelIndex> currentSearchResults;
00143 
00147   QList<QModelIndex>::const_iterator currentSearchIterator;
00148 
00150 
00151 };
00152 
00157 class MetaWindow : public QMainWindow{
00158   Q_OBJECT
00159 public:
00160 
00163 
00174   MetaWindow(RCP<ParameterList> validParameters, 
00175   RCP<DependencySheet> dependencySheet=null,
00176   void (*customFunc)(RCP<const ParameterList>)=NULL,
00177   QString fileName=QString(),
00178   const std::string actionButtonText="submit",
00179   const std::string actionNoSaveButtonText="");
00180 
00184   ~MetaWindow();
00185 
00187 
00189 
00190   
00196    void setAboutInfo(QString aboutInfo);
00197 
00203    QString getAboutInfo();
00204 
00210    void setActionButtonText(QString newText);
00211 
00217    QString getActionButtonText();
00218 
00219 protected:
00220 
00223 
00229   void closeEvent(QCloseEvent *event);
00230 
00232 
00233 private:
00236   
00240   SearchWidget *searchWidget;
00241 
00243   QAction *resetAct, *loadAct, *saveAct, *saveAsAct, *quitAct, *aboutAct, *searchAct;
00245   QMenu *fileMenu, *recentMenu, *helpMenu;
00246 
00250   QPushButton *actionButton;
00251 
00254   QPushButton *actionNoSaveButton;
00255 
00259   QString aboutInfo;
00260 
00264   QString currentLoadDir, currentSaveDir;
00265 
00269   QStringList recentDocsList;
00270 
00274   TreeView *view;
00275 
00279   TreeModel *model;
00280 
00284   Delegate *delegate;
00285 
00287 
00290   
00294   void (*customFunc)(RCP<const ParameterList>);
00295 
00299   static QString getSettingsFileName(){
00300     static QString settingsFileName("OptikaSettings.xml");
00301     return settingsFileName;
00302   }
00303 
00311   void initilization(
00312     void (*customFunc)(RCP<const ParameterList>)=0, 
00313     const std::string actionButtonText="submit",
00314     const std::string actionNoSaveButtonText="");
00315 
00319   void createMenus();
00320 
00324   void createActions();
00325 
00329   void load();
00330 
00334   void loadLastSettings();
00335 
00339   void saveSettings();
00340 
00344   void addRecentDocument(QString recentDocument);
00345 
00349   void updateRecentDocsMenu();
00350 
00354   static QString lastSaveDirSetting(){
00355     static const QString saveDirSetting("last_save_dir");
00356     return saveDirSetting;
00357   }
00358 
00362   static QString lastLoadDirSetting(){
00363     static const QString loadDirSetting("last_load_dir");
00364     return loadDirSetting;
00365   }
00366 
00370   static QString xresSetting(){
00371     static const QString xres("xres");
00372     return xres;
00373   }
00374 
00378   static QString yresSetting(){
00379     static const QString yres("yres");
00380     return yres;
00381   }
00382 
00386   static QString xposSetting(){
00387     static const QString xpos("xpos");
00388     return xpos;
00389   }
00390 
00394   static QString yposSetting(){
00395     static const QString ypos("ypos");
00396     return ypos;
00397   }
00398 
00399 private slots:
00402   
00406   void resetModel();
00407 
00411   bool saveFileAs();
00412 
00416   void saveFile();
00417 
00421   void loadFile();
00422 
00427   bool saveCurrentUnsavedFile();
00428 
00432   void loadRecentDoc();
00433 
00437   void showAbout();
00438 
00442   void initiateSearch();
00443   
00447   void doAction();
00448 
00452   void doActionNoSave();
00453 
00455 };
00456 
00457 
00458 
00459 }
00460 #endif /* METAWINDOW_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines