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
26 #include <QStandardItemModel>
27 #include <QTreeWidget>
29 #include "../core/sc_process.hpp"
33 class LookupDialogTreeView
: public QTreeView
38 LookupDialogTreeView(QWidget
* parent
): QTreeView(parent
) {}
41 bool openDocumentation();
44 class GenericLookupDialog
: public QDialog
49 static const int PathRole
= Qt::UserRole
+ 1;
50 static const int CharPosRole
= Qt::UserRole
+ 2;
51 static const int IsClassRole
= Qt::UserRole
+ 3;
52 static const int ClassNameRole
= Qt::UserRole
+ 4;
53 static const int MethodNameRole
= Qt::UserRole
+ 5;
55 explicit GenericLookupDialog(QWidget
*parent
= 0);
56 void query( const QString
& query
) { mQueryEdit
->setText(query
); this->performQuery(); }
57 void clearQuery() { mQueryEdit
->clear(); }
60 void openDocumentation();
63 virtual void onAccepted(QModelIndex
);
66 virtual void performQuery() = 0;
69 QStandardItem
* firstItemInLine(QModelIndex
);
70 bool eventFilter( QObject
*, QEvent
* );
71 void paintEvent( QPaintEvent
* );
74 static QList
<QStandardItem
*> makeDialogItem(QString
const & displayString
, QString
const & displayPath
,
75 QString
const & path
, int position
,
76 QString
const & className
, QString
const & methodName
,
79 LookupDialogTreeView
*mResult
;
80 QLineEdit
*mQueryEdit
;
83 class LookupDialog
: public GenericLookupDialog
88 explicit LookupDialog(QWidget
*parent
= 0);
92 void onAccepted(QModelIndex
);
95 QStandardItemModel
* modelForClass(const QString
& className
);
96 QStandardItemModel
* modelForMethod(const QString
& methodName
);
97 QStandardItemModel
* modelForPartialQuery(const QString
& queryString
);
98 bool performClassQuery(const QString
& className
);
99 bool performMethodQuery(const QString
& methodName
);
100 bool performPartialQuery(const QString
& queryString
);
102 bool mIsPartialQuery
;
105 // LATER: cache symbol references to avoid duplicate lookup
106 class SymbolReferenceRequest
:
112 SymbolReferenceRequest(SCProcess
* process
, QObject
* parent
= NULL
):
113 ScRequest(process
, parent
)
116 void sendRequest(QString
const & symbol
)
118 send("findReferencesToSymbol", symbol
);
122 class ReferencesDialog
:
128 explicit ReferencesDialog(QWidget
* parent
= NULL
);
131 void requestCanceled();
133 void onResposeFromLanguage(const QString
&command
, const QString
&responseData
);
134 QStandardItemModel
* parse(QString
const & responseData
);
139 #endif // SCIDE_WIDGETS_LOOKUP_DIALOG_HPP_INCLUDED