scide: DocManager - report warnings via the status bar
[supercollider.git] / editors / sc-ide / widgets / lookup_dialog.hpp
blobf8020190952228df9fa0f43a3e47e6370a62cd33
1 /*
2 SuperCollider Qt IDE
3 Copyright (c) 2012 Jakob Leben & Tim Blechmann
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef SCIDE_WIDGETS_LOOKUP_DIALOG_HPP_INCLUDED
22 #define SCIDE_WIDGETS_LOOKUP_DIALOG_HPP_INCLUDED
24 #include <QDialog>
25 #include <QLineEdit>
26 #include <QStandardItemModel>
27 #include <QTreeWidget>
29 #include "../core/sc_process.hpp"
31 namespace ScIDE {
33 class GenericLookupDialog: public QDialog
35 Q_OBJECT
37 public:
38 static const int PathRole = Qt::UserRole + 1;
39 static const int CharPosRole = Qt::UserRole + 2;
40 static const int IsClassRole = Qt::UserRole + 3;
42 explicit GenericLookupDialog(QWidget *parent = 0);
43 void query( const QString & query ) { mQueryEdit->setText(query); this->performQuery(); }
44 void clearQuery() { mQueryEdit->clear(); }
46 protected Q_SLOTS:
47 virtual void onAccepted(QModelIndex);
49 private Q_SLOTS:
50 virtual void performQuery() = 0;
52 protected:
53 QStandardItem * currentItem();
54 bool eventFilter( QObject *, QEvent * );
55 void paintEvent( QPaintEvent * );
56 void focusResults();
58 static QList<QStandardItem *> makeDialogItem(QString const & name, QString const & displayPath,
59 QString const & path, int position, bool isClassItem);
61 QTreeView *mResult;
62 QLineEdit *mQueryEdit;
65 class LookupDialog : public GenericLookupDialog
67 Q_OBJECT
69 public:
70 explicit LookupDialog(QWidget *parent = 0);
72 private slots:
73 void performQuery();
74 void onAccepted(QModelIndex);
76 private:
77 QStandardItemModel * modelForClass(const QString & className);
78 QStandardItemModel * modelForMethod(const QString & methodName);
79 QStandardItemModel * modelForPartialQuery(const QString & queryString);
80 bool performClassQuery(const QString & className);
81 bool performMethodQuery(const QString & methodName);
82 bool performPartialQuery(const QString & queryString);
84 bool mIsPartialQuery;
87 // LATER: cache symbol references to avoid duplicate lookup
88 class SymbolReferenceRequest:
89 public ScRequest
91 Q_OBJECT
93 public:
94 SymbolReferenceRequest(SCProcess * process, QObject * parent = NULL):
95 ScRequest(process, parent)
98 void sendRequest(QString const & symbol)
100 send("findReferencesToSymbol", symbol);
104 class ReferencesDialog:
105 public LookupDialog
107 Q_OBJECT
109 public:
110 explicit ReferencesDialog(QWidget * parent = NULL);
112 private slots:
113 void requestCanceled();
114 void performQuery();
115 void onResposeFromLanguage(const QString &command, const QString &responseData);
116 QStandardItemModel * parse(QString const & responseData);
119 } // namespace ScIDE
121 #endif // SCIDE_WIDGETS_LOOKUP_DIALOG_HPP_INCLUDED