KSeExpr  4.0.4.0
ExprBrowser.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2011-2019 Disney Enterprises, Inc.
2 // SPDX-License-Identifier: LicenseRef-Apache-2.0
3 // SPDX-FileCopyrightText: 2020 L. E. Segovia <amy@amyspark.me>
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 /*
6  * @file ExprBrowser.h
7  * @brief Browser for a library of expressions from a tree of files
8  * @author aselle
9  */
10 
11 #pragma once
12 
13 #include <QAbstractItemModel>
14 #include <QWidget>
15 
16 #include <fstream>
17 #include <iostream>
18 #include <sstream>
19 
20 class QLineEdit;
21 class QTreeWidget;
22 class QTreeView;
23 class QTreeWidgetItem;
24 class QTextBrowser;
25 class ExprEditor;
26 class QSortFilterProxyModel;
27 class QDir;
28 
29 class ExprTreeModel;
31 
32 class ExprBrowser : public QWidget
33 {
34  Q_OBJECT
35 
37  QList<QString> labels;
38  QList<QString> paths;
41  QTreeView *treeNew;
42  QLineEdit *exprFilter;
43  std::string _userExprDir;
44  std::string _localExprDir;
45  QString _context;
46  QString _searchPath;
48 
49 public:
50  ExprBrowser(QWidget *parent, ExprEditor *editor);
51  ~ExprBrowser() override;
52  void addPath(const std::string &name, const std::string &path);
53  std::string getSelectedPath();
54  void selectPath(const char *path);
55  void addUserExpressionPath(const std::string &context);
56  bool getExpressionDirs();
57  bool getExpressionDirs(const std::string &context);
58  void setSearchPath(const QString &context, const QString &path);
59  void expandAll();
60  void expandToDepth(int depth);
61  void setApplyOnSelect(bool on)
62  {
63  _applyOnSelect = on;
64  }
65 
66 public Q_SLOTS:
67  void handleSelection(const QModelIndex &current, const QModelIndex &previous);
68  void update();
69  void clear();
70  void clearSelection();
71  void saveExpression();
72  void saveLocalExpressionAs();
73  void saveExpressionAs();
74 
75 private Q_SLOTS:
76  void clearFilter();
77  void filterChanged(const QString &str);
78 };
ExprEditor * editor
Definition: ExprBrowser.h:36
~ExprBrowser() override
QTreeView * treeNew
Definition: ExprBrowser.h:41
void expandToDepth(int depth)
void setSearchPath(const QString &context, const QString &path)
void saveExpression()
void expandAll()
void handleSelection(const QModelIndex &current, const QModelIndex &previous)
void saveLocalExpressionAs()
bool _applyOnSelect
Definition: ExprBrowser.h:47
QString _searchPath
Definition: ExprBrowser.h:46
void filterChanged(const QString &str)
std::string _userExprDir
Definition: ExprBrowser.h:43
bool getExpressionDirs(const std::string &context)
ExprBrowser(QWidget *parent, ExprEditor *editor)
bool getExpressionDirs()
QList< QString > paths
Definition: ExprBrowser.h:38
void clearSelection()
QLineEdit * exprFilter
Definition: ExprBrowser.h:42
QList< QString > labels
Definition: ExprBrowser.h:37
void addUserExpressionPath(const std::string &context)
void setApplyOnSelect(bool on)
Definition: ExprBrowser.h:61
void addPath(const std::string &name, const std::string &path)
std::string getSelectedPath()
ExprTreeFilterModel * proxyModel
Definition: ExprBrowser.h:40
void selectPath(const char *path)
void clearFilter()
void saveExpressionAs()
std::string _localExprDir
Definition: ExprBrowser.h:44
ExprTreeModel * treeModel
Definition: ExprBrowser.h:39
QString _context
Definition: ExprBrowser.h:45