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 
00183   ~MetaWindow();
00184 
00186 
00188 
00189   
00195    void setAboutInfo(QString aboutInfo);
00196 
00202    QString getAboutInfo();
00203 
00209    void setActionButtonText(QString newText);
00210 
00216    QString getActionButtonText();
00217 
00218 protected:
00219 
00222 
00228   void closeEvent(QCloseEvent *event);
00229 
00231 
00232 private:
00235   
00239   SearchWidget *searchWidget;
00240 
00242   QAction *resetAct, *loadAct, *saveAct, *saveAsAct, *quitAct, *aboutAct, *searchAct;
00244   QMenu *fileMenu, *recentMenu, *helpMenu;
00245 
00249   QPushButton *actionButton;
00250 
00254   QString aboutInfo;
00255 
00259   QString currentLoadDir, currentSaveDir;
00260 
00264   QStringList recentDocsList;
00265 
00269   TreeView *view;
00270 
00274   TreeModel *model;
00275 
00279   Delegate *delegate;
00280 
00282 
00285   
00289   void (*customFunc)(RCP<const ParameterList>);
00290 
00294   static QString getSettingsFileName(){
00295     static QString settingsFileName("OptikaSettings.xml");
00296     return settingsFileName;
00297   }
00298 
00306   void initilization(
00307     void (*customFunc)(RCP<const ParameterList>)=0, 
00308     const std::string actionButtonText="submit");
00309 
00313   void createMenus();
00314 
00318   void createActions();
00319 
00323   void load();
00324 
00328   void loadLastSettings();
00329 
00333   void saveSettings();
00334 
00338   void addRecentDocument(QString recentDocument);
00339 
00343   void updateRecentDocsMenu();
00344 
00348   static QString lastSaveDirSetting(){
00349     static const QString saveDirSetting("last_save_dir");
00350     return saveDirSetting;
00351   }
00352 
00356   static QString lastLoadDirSetting(){
00357     static const QString loadDirSetting("last_load_dir");
00358     return loadDirSetting;
00359   }
00360 
00364   static QString xresSetting(){
00365     static const QString xres("xres");
00366     return xres;
00367   }
00368 
00372   static QString yresSetting(){
00373     static const QString yres("yres");
00374     return yres;
00375   }
00376 
00380   static QString xposSetting(){
00381     static const QString xpos("xpos");
00382     return xpos;
00383   }
00384 
00388   static QString yposSetting(){
00389     static const QString ypos("ypos");
00390     return ypos;
00391   }
00392 
00393 private slots:
00396   
00400   void resetModel();
00401 
00405   bool saveFileAs();
00406 
00410   void saveFile();
00411 
00415   void loadFile();
00416 
00421   bool saveCurrentUnsavedFile();
00422 
00426   void loadRecentDoc();
00427 
00431   void showAbout();
00432 
00436   void initiateSearch();
00437   
00441   void doAction();
00442 
00444 };
00445 
00446 
00447 
00448 }
00449 #endif /* METAWINDOW_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines