scide: LookupDialog - store information if dialog item is a class item
[supercollider.git] / editors / sc-ide / widgets / lookup_dialog.hpp
blob634b484c92f060c7213afefdb3046b07ef958bf4
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 private slots:
47 void onAccepted(QModelIndex);
48 virtual void performQuery() = 0;
50 protected:
51 bool eventFilter( QObject *, QEvent * );
52 void paintEvent( QPaintEvent * );
53 void focusResults();
55 static QList<QStandardItem *> makeDialogItem(QString const & name, QString const & displayPath,
56 QString const & path, int position, bool isClassItem);
58 QTreeView *mResult;
59 QLineEdit *mQueryEdit;
62 class LookupDialog : public GenericLookupDialog
64 Q_OBJECT
66 public:
67 explicit LookupDialog(QWidget *parent = 0);
69 private slots:
70 void performQuery();
72 private:
73 QStandardItemModel * modelForClass(const QString & className);
74 QStandardItemModel * modelForMethod(const QString & methodName);
75 QStandardItemModel * modelForCaseInsensitiveQuery(const QString & queryString);
76 bool performClassQuery(const QString & className);
77 bool performMethodQuery(const QString & methodName);
78 bool performPartialQuery(const QString & queryString);
81 // LATER: cache symbol references to avoid duplicate lookup
82 class SymbolReferenceRequest:
83 public ScRequest
85 Q_OBJECT
87 public:
88 SymbolReferenceRequest(SCProcess * process, QObject * parent = NULL):
89 ScRequest(process, parent)
92 void sendRequest(QString const & symbol)
94 send("findReferencesToSymbol", symbol);
98 class ReferencesDialog:
99 public LookupDialog
101 Q_OBJECT
103 public:
104 explicit ReferencesDialog(QWidget * parent = NULL);
106 private slots:
107 void requestCanceled();
108 void performQuery();
109 void onResposeFromLanguage(const QString &command, const QString &responseData);
110 QStandardItemModel * parse(QString const & responseData);
113 } // namespace ScIDE
115 #endif // SCIDE_WIDGETS_LOOKUP_DIALOG_HPP_INCLUDED