OSDN Git Service

Integrate merge-request #541 into branch '1.2'
[qt-creator-jp/qt-creator-jp.git] / src / plugins / find / findplugin.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact:  Qt Software Information (qt-info@nokia.com)
8 **
9 ** Commercial Usage
10 **
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at qt-sales@nokia.com.
27 **
28 **************************************************************************/
29
30 #ifndef FINDPLUGIN_H
31 #define FINDPLUGIN_H
32
33 #include "ifindfilter.h"
34 #include "findtoolbar.h"
35
36 #include <extensionsystem/iplugin.h>
37
38 #include <QtCore/QHash>
39 #include <QtCore/QStringList>
40 #include <QtGui/QAction>
41 #include <QtGui/QTextDocument>
42
43 namespace Find {
44 namespace Internal {
45
46 class FindToolWindow;
47
48 class FindPlugin : public ExtensionSystem::IPlugin
49 {
50     Q_OBJECT
51
52 public:
53     FindPlugin();
54     virtual ~FindPlugin();
55
56     // IPlugin
57     bool initialize(const QStringList &arguments, QString *error_message);
58     void extensionsInitialized();
59     void shutdown();
60
61     QTextDocument::FindFlags findFlags() const;
62     void updateFindCompletion(const QString &text);
63     void updateReplaceCompletion(const QString &text);
64     QStringListModel *findCompletionModel() { return m_findCompletionModel; }
65     QStringListModel *replaceCompletionModel() { return m_replaceCompletionModel; }
66
67 public slots:
68     void setCaseSensitive(bool sensitive);
69     void setWholeWord(bool wholeOnly);
70     void setBackward(bool backward);
71
72 signals:
73     void findFlagsChanged();
74
75 private slots:
76     void filterChanged();
77     void openFindFilter();
78
79 private:
80     void setFindFlag(QTextDocument::FindFlag flag, bool enabled);
81     bool hasFindFlag(QTextDocument::FindFlag flag);
82     void updateCompletion(const QString &text, QStringList &completions, QStringListModel *model);
83     void setupMenu();
84     void setupFilterMenuItems();
85     void writeSettings();
86     void readSettings();
87
88     //variables
89     QHash<IFindFilter *, QAction *> m_filterActions;
90
91     CurrentDocumentFind *m_currentDocumentFind;
92     FindToolBar *m_findToolBar;
93     FindToolWindow *m_findDialog;
94     QTextDocument::FindFlags m_findFlags;
95     QStringListModel *m_findCompletionModel;
96     QStringListModel *m_replaceCompletionModel;
97     QStringList m_findCompletions;
98     QStringList m_replaceCompletions;
99     QAction *m_openFindDialog;
100 };
101
102 } // namespace Internal
103 } // namespace Find
104
105 #endif // FINDPLUGIN_H