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 <QObject>
25 #include <QMessageBox>
26 #include <QGLWidget>
27 #include <QHBoxLayout>
28 #include <QSplitter>
29 #include <QPalette>
30 #include <QPushButton>
31 #include <QFileDialog>
32 #include <QSpacerItem>
33 #include <QSizePolicy>
34
35 #include <iostream>
36 #include <fstream>
37
38 #include "ExprEditor.h"
39
40 class ExprGrapherWidget;
41 class ExprBrowser;
42 class QTabWidget;
43
44 class ExprDialog : public QDialog {
45 Q_OBJECT
46
47 public:
48 ExprEditor* editor;
49 ExprBrowser* browser;
50
51 private:
52 ExprGrapherWidget* grapher;
53 QLabel* previewCommentLabel;
54 QPushButton* acceptButton;
55 QPushButton* cancelButton;
56 ExprControlCollection* controls;
57
58 QPushButton* applyButton, *previewButton, *saveButton, *saveAsButton;
59 QPushButton* saveLocalButton, *clearButton;
60 QLineEdit* helpFindBox;
61 QTimer* showEditorTimer;
62 QTextBrowser* helpBrowser;
63 QTextCursor cursor;
64 QString prevFind;
65 int _currentEditorIdx;
66
67 public:
68 ExprDialog(QWidget* parent);
69
70 std::string getExpressionString() { return editor->getExpr(); }
71
72 void setExpressionString(const std::string& str) {
73 clearExpression();
74 editor->setExpr(str, /*apply*/ true);
75 }
76
77 void show();
78 int exec();
79
80 // Show the Nth editor dialog
81 void showEditor(int idx);
82
83 private:
84 void setupHelp(QTabWidget* tab);
85
86 protected:
87 void keyPressEvent(QKeyEvent* event);
88 void findHelper(QTextDocument::FindFlags flags);
89 void closeEvent(QCloseEvent* event);
90
91 signals:
92 void preview();
93 void expressionApplied();
94 void dialogClosed();
95 private
96 slots:
97 void previewExpression();
98 void verifiedApply();
99 void verifiedAccept();
100 void findNextInHelp();
101 void findPrevInHelp();
102 void _showEditor();
103 public
104 slots:
105
106 void applyExpression();
107
108 void clearExpression();
109
110 void reject();
111 };
112
113 #endif
ExprDialog::setupHelp
void setupHelp(QTabWidget *tab)
Definition: ExprDialog.cpp:215
ExprDialog::show
void show()
Definition: ExprDialog.cpp:148
ExprEditor
Definition: ExprEditor.h:94
ExprDialog::exec
int exec()
Definition: ExprDialog.cpp:155
ExprDialog::dialogClosed
void dialogClosed()
ExprBrowser
Definition: ExprBrowser.h:43
ExprDialog::saveAsButton
QPushButton * saveAsButton
Definition: ExprDialog.h:58
ExprGrapherWidget
Definition: ExprGrapher2d.h:69
ExprDialog::editor
ExprEditor * editor
Definition: ExprDialog.h:48
ExprDialog::grapher
ExprGrapherWidget * grapher
Definition: ExprDialog.h:52
ExprDialog::findHelper
void findHelper(QTextDocument::FindFlags flags)
Definition: ExprDialog.cpp:265
ExprDialog::ExprDialog
ExprDialog(QWidget *parent)
Definition: ExprDialog.cpp:35
ExprDialog::applyButton
QPushButton * applyButton
Definition: ExprDialog.h:58
ExprDialog::helpBrowser
QTextBrowser * helpBrowser
Definition: ExprDialog.h:62
ExprDialog::clearButton
QPushButton * clearButton
Definition: ExprDialog.h:59
ExprDialog::prevFind
QString prevFind
Definition: ExprDialog.h:64
ExprDialog::acceptButton
QPushButton * acceptButton
Definition: ExprDialog.h:54
ExprDialog::controls
ExprControlCollection * controls
Definition: ExprDialog.h:56
ExprControlCollection
Definition: ExprControlCollection.h:81
ExprDialog::clearExpression
void clearExpression()
Definition: ExprDialog.cpp:332
ExprDialog::previewExpression
void previewExpression()
Definition: ExprDialog.cpp:279
ExprDialog::closeEvent
void closeEvent(QCloseEvent *event)
Definition: ExprDialog.cpp:167
ExprDialog::verifiedApply
void verifiedApply()
Definition: ExprDialog.cpp:177
ExprDialog::getExpressionString
std::string getExpressionString()
Definition: ExprDialog.h:70
ExprDialog::previewCommentLabel
QLabel * previewCommentLabel
Definition: ExprDialog.h:53
ExprDialog::showEditor
void showEditor(int idx)
Definition: ExprDialog.cpp:140
ExprDialog::setExpressionString
void setExpressionString(const std::string &str)
Definition: ExprDialog.h:72
ExprDialog::findPrevInHelp
void findPrevInHelp()
Definition: ExprDialog.cpp:277
ExprEditor::getExpr
std::string getExpr()
Definition: ExprEditor.cpp:373
ExprDialog::cancelButton
QPushButton * cancelButton
Definition: ExprDialog.h:55
ExprDialog::findNextInHelp
void findNextInHelp()
Definition: ExprDialog.cpp:275
ExprDialog::cursor
QTextCursor cursor
Definition: ExprDialog.h:63
ExprDialog::previewButton
QPushButton * previewButton
Definition: ExprDialog.h:58
ExprDialog::preview
void preview()
ExprEditor::setExpr
void setExpr(const std::string &expression, const bool apply=false)
Definition: ExprEditor.cpp:375
ExprDialog::verifiedAccept
void verifiedAccept()
Definition: ExprDialog.cpp:193
ExprDialog
Definition: ExprDialog.h:44
ExprDialog::applyExpression
void applyExpression()
Definition: ExprDialog.cpp:284
ExprDialog::_currentEditorIdx
int _currentEditorIdx
Definition: ExprDialog.h:65
ExprDialog::showEditorTimer
QTimer * showEditorTimer
Definition: ExprDialog.h:61
ExprEditor.h
ExprDialog::_showEditor
void _showEditor()
Definition: ExprDialog.cpp:146
ExprDialog::helpFindBox
QLineEdit * helpFindBox
Definition: ExprDialog.h:60
ExprDialog::saveButton
QPushButton * saveButton
Definition: ExprDialog.h:58
ExprDialog::keyPressEvent
void keyPressEvent(QKeyEvent *event)
Definition: ExprDialog.cpp:162
ExprDialog::expressionApplied
void expressionApplied()
ExprDialog::browser
ExprBrowser * browser
Definition: ExprDialog.h:49
ExprDialog::reject
void reject()
Definition: ExprDialog.cpp:172
ExprDialog::saveLocalButton
QPushButton * saveLocalButton
Definition: ExprDialog.h:59