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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Kurtis Nusbaum (klnusbaum@gmail.com) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 #ifndef METAWINDOW_HPP_
00029 #define METAWINDOW_HPP_
00030 #include <QMainWindow>
00031 #include <QDialog>
00032 #include <QModelIndex>
00033 #include "Optika_treeview.hpp"
00034 
00041 class QAction;
00042 class QMenu;
00043 class QLabel;
00044 class QPushButton;
00045 class QLineEdit;
00046 namespace Optika{
00047 
00052 class SearchWidget : public QDialog{
00053   Q_OBJECT
00054 public:
00055 
00058 
00066   SearchWidget(TreeModel *treeModel, TreeView *treeView, QWidget *parent=0);
00067 
00069 
00070 private slots:
00071 
00074   
00079   void search();
00080 
00085   void next();
00086 
00091   void previous();
00092 
00094 
00095 private:
00096 
00099   
00110   QModelIndexList removeHiddenItems(QModelIndexList& items);
00111 
00113 
00116   
00120   QPushButton *searchButton, *closeButton, *nextButton, *previousButton;
00121   QLineEdit *searchTermsEdit;
00122   QLabel *matchesLabel;
00123   TreeModel *treeModel;
00124   TreeView *treeView;
00125 
00129   QList<QModelIndex> currentSearchResults;
00130 
00134   QList<QModelIndex>::const_iterator currentSearchIterator;
00135 
00137 
00138 };
00139 
00144 class MetaWindow : public QMainWindow{
00145   Q_OBJECT
00146 public:
00147 
00150 
00161   MetaWindow(RCP<ParameterList> validParameters, 
00162   RCP<DependencySheet> dependencySheet=null,
00163   void (*customFunc)(RCP<const ParameterList>)=NULL,
00164   QString fileName=QString(),
00165   const std::string actionButtonText="submit");
00166 
00170   ~MetaWindow();
00171 
00173 
00175 
00176   
00182    void setAboutInfo(QString aboutInfo);
00183 
00189    QString getAboutInfo();
00190 
00196    void setActionButtonText(QString newText);
00197 
00203    QString getActionButtonText();
00204 
00205 protected:
00206 
00209 
00215   void closeEvent(QCloseEvent *event);
00216 
00218 
00219 private:
00222   
00226   SearchWidget *searchWidget;
00227 
00229   QAction *resetAct, *loadAct, *saveAct, *saveAsAct, *quitAct, *aboutAct, *searchAct;
00231   QMenu *fileMenu, *recentMenu, *helpMenu;
00232 
00236   QPushButton *actionButton;
00237 
00241   QString aboutInfo;
00242 
00246   QString currentLoadDir, currentSaveDir;
00247 
00251   QStringList recentDocsList;
00252 
00256   TreeView *view;
00257 
00261   TreeModel *model;
00262 
00266   Delegate *delegate;
00267 
00269 
00272   
00276   void (*customFunc)(RCP<const ParameterList>);
00277 
00281   static QString getSettingsFileName(){
00282     static QString settingsFileName("OptikaSettings.xml");
00283     return settingsFileName;
00284   }
00285 
00293   void initilization(
00294     void (*customFunc)(RCP<const ParameterList>)=0, 
00295     const std::string actionButtonText="submit");
00296 
00300   void createMenus();
00301 
00305   void createActions();
00306 
00310   void load();
00311 
00315   void loadLastSettings();
00316 
00320   void saveSettings();
00321 
00325   void addRecentDocument(QString recentDocument);
00326 
00330   void updateRecentDocsMenu();
00331 
00335   static QString lastSaveDirSetting(){
00336     static const QString saveDirSetting("last_save_dir");
00337     return saveDirSetting;
00338   }
00339 
00343   static QString lastLoadDirSetting(){
00344     static const QString loadDirSetting("last_load_dir");
00345     return loadDirSetting;
00346   }
00347 
00351   static QString xresSetting(){
00352     static const QString xres("xres");
00353     return xres;
00354   }
00355 
00359   static QString yresSetting(){
00360     static const QString yres("yres");
00361     return yres;
00362   }
00363 
00367   static QString xposSetting(){
00368     static const QString xpos("xpos");
00369     return xpos;
00370   }
00371 
00375   static QString yposSetting(){
00376     static const QString ypos("ypos");
00377     return ypos;
00378   }
00379 
00380 private slots:
00383   
00387   void resetModel();
00388 
00392   bool saveFileAs();
00393 
00397   void saveFile();
00398 
00402   void loadFile();
00403 
00408   bool saveCurrentUnsavedFile();
00409 
00413   void loadRecentDoc();
00414 
00418   void showAbout();
00419 
00423   void initiateSearch();
00424   
00428   void doAction();
00429 
00431 };
00432 
00433 
00434 
00435 }
00436 #endif /* METAWINDOW_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines