Optika GUI Toolik  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Optika_metawindow.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Optika: A Tool For Developing Parameter Obtaining GUIs
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the
8 // U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Kurtis Nusbaum (klnusbaum@gmail.com)
38 //
39 // ***********************************************************************
40 // @HEADER
41 #ifndef METAWINDOW_HPP_
42 #define METAWINDOW_HPP_
43 #include <QMainWindow>
44 #include <QDialog>
45 #include <QModelIndex>
46 #include "Optika_treeview.hpp"
47 
54 class QAction;
55 class QMenu;
56 class QLabel;
57 class QPushButton;
58 class QLineEdit;
59 namespace Optika{
60 
65 class SearchWidget : public QDialog{
66  Q_OBJECT
67 public:
68 
71 
79  SearchWidget(TreeModel *treeModel, TreeView *treeView, QWidget *parent=0);
80 
82 
83 private slots:
84 
87 
92  void search();
93 
98  void next();
99 
104  void previous();
105 
107 
108 private:
109 
112 
123  QModelIndexList removeHiddenItems(QModelIndexList& items);
124 
126 
129 
134  QLineEdit *searchTermsEdit;
135  QLabel *matchesLabel;
138 
142  QList<QModelIndex> currentSearchResults;
143 
147  QList<QModelIndex>::const_iterator currentSearchIterator;
148 
150 
151 };
152 
157 class MetaWindow : public QMainWindow{
158  Q_OBJECT
159 public:
160 
163 
174  MetaWindow(RCP<ParameterList> validParameters,
175  RCP<DependencySheet> dependencySheet=null,
176  void (*customFunc)(RCP<const ParameterList>)=NULL,
177  QString fileName=QString(),
178  const std::string actionButtonText="submit",
179  const std::string actionNoSaveButtonText="");
180 
184  ~MetaWindow();
185 
187 
189 
190 
196  void setAboutInfo(QString aboutInfo);
197 
203  QString getAboutInfo();
204 
210  void setActionButtonText(QString newText);
211 
217  QString getActionButtonText();
218 
219 protected:
220 
223 
229  void closeEvent(QCloseEvent *event);
230 
232 
233 private:
236 
241 
246 
250  QPushButton *actionButton;
251 
254  QPushButton *actionNoSaveButton;
255 
259  QString aboutInfo;
260 
265 
269  QStringList recentDocsList;
270 
275 
280 
285 
287 
290 
295 
299  static QString getSettingsFileName(){
300  static QString settingsFileName("OptikaSettings.xml");
301  return settingsFileName;
302  }
303 
311  void initilization(
313  const std::string actionButtonText="submit",
314  const std::string actionNoSaveButtonText="");
315 
319  void createMenus();
320 
324  void createActions();
325 
329  void load();
330 
334  void loadLastSettings();
335 
339  void saveSettings();
340 
344  void addRecentDocument(QString recentDocument);
345 
349  void updateRecentDocsMenu();
350 
354  static QString lastSaveDirSetting(){
355  static const QString saveDirSetting("last_save_dir");
356  return saveDirSetting;
357  }
358 
362  static QString lastLoadDirSetting(){
363  static const QString loadDirSetting("last_load_dir");
364  return loadDirSetting;
365  }
366 
370  static QString xresSetting(){
371  static const QString xres("xres");
372  return xres;
373  }
374 
378  static QString yresSetting(){
379  static const QString yres("yres");
380  return yres;
381  }
382 
386  static QString xposSetting(){
387  static const QString xpos("xpos");
388  return xpos;
389  }
390 
394  static QString yposSetting(){
395  static const QString ypos("ypos");
396  return ypos;
397  }
398 
399 private slots:
402 
406  void resetModel();
407 
411  bool saveFileAs();
412 
416  void saveFile();
417 
421  void loadFile();
422 
427  bool saveCurrentUnsavedFile();
428 
432  void loadRecentDoc();
433 
437  void showAbout();
438 
442  void initiateSearch();
443 
447  void doAction();
448 
452  void doActionNoSave();
453 
455 };
456 
457 
458 
459 }
460 #endif /* METAWINDOW_HPP_ */
void initiateSearch()
Starts a search for a parituclar Parameter or ParameterList.
bool saveCurrentUnsavedFile()
Asks the user whether or not they would like to currently save the file they are working on...
void loadRecentDoc()
Loads a document from the set of recent documents.
QString getActionButtonText()
Gets the text being displayed int he action button.
QAction * resetAct
Various actions.
static QString xresSetting()
Gets the name of the xres setting.
SearchWidget(TreeModel *treeModel, TreeView *treeView, QWidget *parent=0)
Constructs a SearchWidget.
void resetModel()
Resets the treemodel to its default state.
QString getAboutInfo()
Gets the information to be added to the about dialog of the GUI.
~MetaWindow()
Deconstructer for the metawindow.
void createActions()
Creates all necessary actions used in the menut items.
QPushButton * actionButton
The button the user pushes that either closes the MetaWindow or runs the custom function.
void initilization(void(*customFunc)(RCP< const ParameterList >)=0, const std::string actionButtonText="submit", const std::string actionNoSaveButtonText="")
Common initialization shared by all constructors.
A small widget that searchs through a parameter list for a particular name of either a parameter or a...
void doAction()
What should happen when the user clicks the action button.
void doActionNoSave()
What should happen when the user clicks the actionNoSave button.
static QString lastLoadDirSetting()
Gets the name of the last load directory setting.
QModelIndexList removeHiddenItems(QModelIndexList &items)
Removes any indicies in a QModelIndexList that correspond to a hidden item.
MetaWindow(RCP< ParameterList > validParameters, RCP< DependencySheet > dependencySheet=null, void(*customFunc)(RCP< const ParameterList >)=NULL, QString fileName=QString(), const std::string actionButtonText="submit", const std::string actionNoSaveButtonText="")
Constructs a MainWindow object.
void updateRecentDocsMenu()
Currently under developement.
QPushButton * searchButton
Widgets comprising a search widget.
void saveFile()
Saves the current solver to the file the user has already specified.
static QString yresSetting()
Gets the name of the yres setting.
void addRecentDocument(QString recentDocument)
Currently under developement.
void createMenus()
Creates all the menus for the metawindow.
void setActionButtonText(QString newText)
Sets the action button text.
void loadLastSettings()
Loads the last state of the MetaWindow (things like window size and screen position).
QString aboutInfo
Any additional about information that should be displayed in the about dialog.
static QString xposSetting()
Gets the name of the xpos setting.
bool saveFileAs()
Saves the parameter list settings to a user specified file.
QList< QModelIndex > currentSearchResults
The results of the search last performed.
SearchWidget * searchWidget
Widgets comprising the MetaWindow.
void previous()
Highlights the previous result in the list of results that are set by the search function.
QMenu * fileMenu
Various menus.
Class used to view TreeModels.
TreeView * view
The TreeView being used in the metawindow.
void load()
Loads previous parameter settings.
static QString getSettingsFileName()
Returns the name used to store refernce the settings file.
QStringList recentDocsList
A list of recently used documents.
QString currentLoadDir
Load and save directory paths.
QPushButton * actionNoSaveButton
The button the user pushes that does the does not save.
void next()
Highlights the next result in the list of results that are set by the search function.
Delegate * delegate
The deleages being used to modify any input values.
void setAboutInfo(QString aboutInfo)
Adds the information specified to the about dialog of the GUI.
The Main Window that contains all other widgets in the Optika GUI. For all undocumented functions ple...
static QString yposSetting()
Gets the name of the ypos setting.
void closeEvent(QCloseEvent *event)
Handles any QCloseEvents for the metawindow.
void(* customFunc)(RCP< const ParameterList >)
The custom function to run when the user clicks the action button.
TreeModel * model
The TreeModel being used to display the inputs.
void showAbout()
Shows information about the program.
void search()
Searches the for a parameter or parameter list containing the string enterd in the search terms box...
void saveSettings()
Saves the state of the MetaWindow (things like window size and screen position).
TreeModel is a type of QAbstractItemModel that has a Tree like structure.
static QString lastSaveDirSetting()
Gets the name of the last saved directory setting.
The delegate used for the Optika package. For non-documented functions please refer to the Qt API...
void loadFile()
Loads a solver the user was previously working on and had saved.
The view used in Optikas implementation of the MVC framework.
QList< QModelIndex >::const_iterator currentSearchIterator
An iterator over the results of the last search performed.