OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / projectexplorer / outputwindow.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef OUTPUTWINDOW_H
34 #define OUTPUTWINDOW_H
35
36 #include "outputformat.h"
37 #include <coreplugin/ioutputpane.h>
38
39 #include <QtGui/QPlainTextEdit>
40 #include <QtGui/QIcon>
41
42 QT_BEGIN_NAMESPACE
43 class QTabWidget;
44 class QToolButton;
45 class QAction;
46 QT_END_NAMESPACE
47
48 namespace Core {
49     class BaseContext;
50 }
51
52 namespace ProjectExplorer {
53 class OutputFormatter;
54 class RunControl;
55 class Project;
56
57 namespace Constants {
58     const char * const C_APP_OUTPUT = "Application Output";
59 }
60
61 namespace Internal {
62
63 class OutputWindow;
64
65 struct OutputPanePrivate;
66
67 class OutputPane : public Core::IOutputPane
68 {
69     Q_OBJECT
70
71 public:
72     enum CloseTabMode {
73         CloseTabNoPrompt,
74         CloseTabWithPrompt
75     };
76
77     OutputPane();
78     virtual ~OutputPane();
79
80     QWidget *outputWidget(QWidget *);
81     QList<QWidget*> toolBarWidgets() const;
82     QString displayName() const;
83     int priorityInStatusBar() const;
84     void clearContents();
85     void visibilityChanged(bool);
86     bool canFocus();
87     bool hasFocus();
88     void setFocus();
89
90     bool canNext();
91     bool canPrevious();
92     void goToNext();
93     void goToPrev();
94     bool canNavigate();
95
96     void createNewOutputWindow(RunControl *rc);
97     void showTabFor(RunControl *rc);
98
99     bool aboutToClose() const;
100     bool closeTabs(CloseTabMode mode);
101
102 signals:
103      void allRunControlsFinished();
104
105 public slots:
106     // ApplicationOutput specifics
107     void projectRemoved();
108
109     void appendMessage(ProjectExplorer::RunControl *rc, const QString &out,
110                        ProjectExplorer::OutputFormat format);
111
112 private slots:
113     void reRunRunControl();
114     void stopRunControl();
115     bool closeTab(int index);
116     void tabChanged(int);
117     void runControlStarted();
118     void runControlFinished();
119
120     void aboutToUnloadSession();
121
122 private:
123     struct RunControlTab {
124         explicit RunControlTab(RunControl *runControl = 0,
125                                OutputWindow *window = 0);
126         RunControl* runControl;
127         OutputWindow *window;
128         // Is the run control stopping asynchronously, close the tab once it finishes
129         bool asyncClosing;
130     };
131
132     bool isRunning() const;
133     bool closeTab(int index, CloseTabMode cm);
134     bool optionallyPromptToStop(RunControl *runControl);
135
136     int indexOf(const RunControl *) const;
137     int indexOf(const QWidget *outputWindow) const;
138     int currentIndex() const;
139     RunControl *currentRunControl() const;
140     int tabWidgetIndexOf(int runControlIndex) const;
141
142     QWidget *m_mainWidget;
143     QTabWidget *m_tabWidget;
144     QList<RunControlTab> m_runControlTabs;
145     QAction *m_stopAction;
146     QToolButton *m_reRunButton;
147     QToolButton *m_stopButton;
148     QIcon m_runIcon;
149 };
150
151
152 class OutputWindow : public QPlainTextEdit
153 {
154     Q_OBJECT
155
156 public:
157     OutputWindow(QWidget *parent = 0);
158     ~OutputWindow();
159
160     OutputFormatter* formatter() const;
161     void setFormatter(OutputFormatter *formatter);
162
163     void appendMessage(const QString &out, OutputFormat format);
164     /// appends a \p text using \p format without using formater
165     void appendText(const QString &text, const QTextCharFormat &format, int maxLineCount);
166
167     void grayOutOldContent();
168
169     void showEvent(QShowEvent *);
170
171     void clear();
172     void handleOldOutput();
173
174     void scrollToBottom();
175
176 protected:
177     bool isScrollbarAtBottom() const;
178
179     virtual void mousePressEvent(QMouseEvent *e);
180     virtual void mouseReleaseEvent(QMouseEvent *e);
181     virtual void mouseMoveEvent(QMouseEvent *e);
182     virtual void resizeEvent(QResizeEvent *e);
183     virtual void keyPressEvent(QKeyEvent *ev);
184
185 private slots:
186     void updateWordWrapMode();
187
188 private:
189     void enableUndoRedo();
190     QString doNewlineEnfocement(const QString &out);
191
192     Core::BaseContext *m_outputWindowContext;
193     OutputFormatter *m_formatter;
194
195     bool m_enforceNewline;
196     bool m_scrollToBottom;
197     bool m_linksActive;
198     bool m_mousePressed;
199 };
200
201 } // namespace Internal
202 } // namespace ProjectExplorer
203
204 #endif // OUTPUTWINDOW_H