SeExpr
ExprDialog.h
Go to the documentation of this file.
1 /*
2 * Copyright Disney Enterprises, Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License
6 * and the following modification to it: Section 6 Trademarks.
7 * deleted and replaced with:
8 *
9 * 6. Trademarks. This License does not grant permission to use the
10 * trade names, trademarks, service marks, or product names of the
11 * Licensor and its affiliates, except as required for reproducing
12 * the content of the NOTICE file.
13 *
14 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * @file ExprDialog.h
18 * @brief A basic editor/browser/previewer for expression editing
19 * @author jlacewel
20 */
21 #ifndef _MY_EXPR_EDITOR_H
22 #define _MY_EXPR_EDITOR_H
23 
24 #include <QtCore/QObject>
25 #include <QtGui/QMessageBox>
26 #include <QtOpenGL/QGLWidget>
27 #include <QtGui/QHBoxLayout>
28 #include <QtGui/QSplitter>
29 #include <QtGui/QPalette>
30 #include <QtGui/QPushButton>
31 #include <QtGui/QFileDialog>
32 #include <QtGui/QSpacerItem>
33 #include <QtGui/QSizePolicy>
34 
35 
36 #include <iostream>
37 #include <fstream>
38 
39 #include "ExprEditor.h"
40 
41 class ExprGrapherWidget;
42 class ExprBrowser;
43 class QTabWidget;
44 
45 class ExprDialog:public QDialog
46 {
47  Q_OBJECT
48 
49 public:
52 private:
55  QPushButton* acceptButton;
56  QPushButton* cancelButton;
58 
61  QLineEdit* helpFindBox;
62  QTimer* showEditorTimer;
63  QTextBrowser* helpBrowser;
64  QTextCursor cursor;
65  QString prevFind;
67 public:
68  ExprDialog(QWidget* parent);
69 
70  std::string getExpressionString()
71  {
72  return editor->getExpr();
73  }
74 
75  void setExpressionString(const std::string& str)
76  {
78  editor->setExpr(str, /*apply*/ true);
79  }
80 
81  void show();
82  int exec();
83 
84  // Show the Nth editor dialog
85  void showEditor(int idx);
86 
87 private:
88  void setupHelp(QTabWidget* tab);
89 
90 protected:
91  void keyPressEvent(QKeyEvent* event);
92  void findHelper(QTextDocument::FindFlags flags);
93  void closeEvent(QCloseEvent* event);
94 
95 signals:
96  void preview();
97  void expressionApplied();
98  void dialogClosed();
99 private slots:
100  void previewExpression();
101  void verifiedApply();
102  void verifiedAccept();
103  void findNextInHelp();
104  void findPrevInHelp();
105  void _showEditor();
106 public slots:
107 
108  void applyExpression();
109 
110  void clearExpression();
111 
112  void reject();
113 };
114 
115 #endif
void setupHelp(QTabWidget *tab)
Definition: ExprDialog.cpp:234
void applyExpression()
Definition: ExprDialog.cpp:311
QTimer * showEditorTimer
Definition: ExprDialog.h:62
QLineEdit * helpFindBox
Definition: ExprDialog.h:61
QTextBrowser * helpBrowser
Definition: ExprDialog.h:63
ExprGrapherWidget * grapher
Definition: ExprDialog.h:53
void keyPressEvent(QKeyEvent *event)
Definition: ExprDialog.cpp:172
QPushButton * saveAsButton
Definition: ExprDialog.h:59
ExprControlCollection * controls
Definition: ExprDialog.h:57
void findHelper(QTextDocument::FindFlags flags)
Definition: ExprDialog.cpp:286
QPushButton * applyButton
Definition: ExprDialog.h:59
void clearExpression()
Definition: ExprDialog.cpp:360
void previewExpression()
Definition: ExprDialog.cpp:305
void setExpressionString(const std::string &str)
Definition: ExprDialog.h:75
QString prevFind
Definition: ExprDialog.h:65
QPushButton * clearButton
Definition: ExprDialog.h:60
QPushButton * cancelButton
Definition: ExprDialog.h:56
std::string getExpressionString()
Definition: ExprDialog.h:70
QPushButton * acceptButton
Definition: ExprDialog.h:55
void dialogClosed()
ExprDialog(QWidget *parent)
Definition: ExprDialog.cpp:36
void showEditor(int idx)
Definition: ExprDialog.cpp:144
void _showEditor()
Definition: ExprDialog.cpp:151
void verifiedApply()
Definition: ExprDialog.cpp:190
ExprEditor * editor
Definition: ExprDialog.h:50
QPushButton * previewButton
Definition: ExprDialog.h:59
QLabel * previewCommentLabel
Definition: ExprDialog.h:54
void findNextInHelp()
Definition: ExprDialog.cpp:296
void show()
Definition: ExprDialog.cpp:156
void preview()
void closeEvent(QCloseEvent *event)
Definition: ExprDialog.cpp:178
QTextCursor cursor
Definition: ExprDialog.h:64
void findPrevInHelp()
Definition: ExprDialog.cpp:301
ExprBrowser * browser
Definition: ExprDialog.h:51
std::string getExpr()
Definition: ExprEditor.cpp:400
int _currentEditorIdx
Definition: ExprDialog.h:66
void reject()
Definition: ExprDialog.cpp:184
QPushButton * saveButton
Definition: ExprDialog.h:59
QPushButton * saveLocalButton
Definition: ExprDialog.h:60
void expressionApplied()
void setExpr(const std::string &expression, const bool apply=false)
Definition: ExprEditor.cpp:405
void verifiedAccept()
Definition: ExprDialog.cpp:211