OSDN Git Service

It's 2011 now.
[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 (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
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 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef OUTPUTWINDOW_H
35 #define OUTPUTWINDOW_H
36
37 #include "outputformat.h"
38 #include <coreplugin/ioutputpane.h>
39
40 #include <QtGui/QPlainTextEdit>
41 #include <QtGui/QIcon>
42
43 QT_BEGIN_NAMESPACE
44 class QTabWidget;
45 class QToolButton;
46 class QAction;
47 QT_END_NAMESPACE
48
49 namespace Core {
50     class BaseContext;
51 }
52
53 namespace ProjectExplorer {
54 class OutputFormatter;
55 class RunControl;
56 class Project;
57
58 namespace Constants {
59     const char * const C_APP_OUTPUT = "Application Output";
60 }
61
62 namespace Internal {
63
64 class OutputWindow;
65
66 struct OutputPanePrivate;
67
68 class OutputPane : public Core::IOutputPane
69 {
70     Q_OBJECT
71
72 public:
73     OutputPane();
74     virtual ~OutputPane();
75
76     QWidget *outputWidget(QWidget *);
77     QList<QWidget*> toolBarWidgets() const;
78     QString displayName() const;
79     int priorityInStatusBar() const;
80     void clearContents();
81     void visibilityChanged(bool);
82     bool canFocus();
83     bool hasFocus();
84     void setFocus();
85
86     bool canNext();
87     bool canPrevious();
88     void goToNext();
89     void goToPrev();
90     bool canNavigate();
91
92     void createNewOutputWindow(RunControl *rc);
93     void showTabFor(RunControl *rc);
94
95     bool aboutToClose() const;
96     bool closeTabs(bool prompt);
97
98 signals:
99      void allRunControlsFinished();
100
101 public slots:
102     // ApplicationOutput specifics
103     void projectRemoved();
104
105     void appendMessage(ProjectExplorer::RunControl *rc, const QString &out,
106                        ProjectExplorer::OutputFormat format);
107
108 private slots:
109     void reRunRunControl();
110     void stopRunControl();
111     bool closeTab(int index);
112     void tabChanged(int);
113     void runControlStarted();
114     void runControlFinished();
115
116     void aboutToUnloadSession();
117
118 private:
119     struct RunControlTab {
120         explicit RunControlTab(RunControl *runControl = 0,
121                                OutputWindow *window = 0);
122         RunControl* runControl;
123         OutputWindow *window;
124         // Is the run control stopping asynchronously, close the tab once it finishes
125         bool asyncClosing;
126     };
127
128     bool isRunning() const;
129     bool closeTab(int index, bool prompt);
130
131     int indexOf(const RunControl *) const;
132     int indexOf(const QWidget *outputWindow) const;
133     int currentIndex() const;
134     RunControl *currentRunControl() const;
135     int tabWidgetIndexOf(int runControlIndex) const;
136
137     QWidget *m_mainWidget;
138     QTabWidget *m_tabWidget;
139     QList<RunControlTab> m_runControlTabs;
140     QAction *m_stopAction;
141     QToolButton *m_reRunButton;
142     QToolButton *m_stopButton;
143     QIcon m_runIcon;
144 };
145
146
147 class OutputWindow : public QPlainTextEdit
148 {
149     Q_OBJECT
150
151 public:
152     OutputWindow(QWidget *parent = 0);
153     ~OutputWindow();
154
155     OutputFormatter* formatter() const;
156     void setFormatter(OutputFormatter *formatter);
157
158     void appendMessage(const QString &out, OutputFormat format);
159     /// appends a \p text using \p format without using formater
160     void appendText(const QString &text, const QTextCharFormat &format, int maxLineCount);
161
162     void grayOutOldContent();
163
164     void showEvent(QShowEvent *);
165
166     void clear();
167     void handleOldOutput();
168
169     void scrollToBottom();
170
171 protected:
172     bool isScrollbarAtBottom() const;
173
174     virtual void mousePressEvent(QMouseEvent *e);
175     virtual void mouseReleaseEvent(QMouseEvent *e);
176     virtual void mouseMoveEvent(QMouseEvent *e);
177     virtual void resizeEvent(QResizeEvent *e);
178     virtual void keyPressEvent(QKeyEvent *ev);
179
180 private slots:
181     void updateWordWrapMode();
182
183 private:
184     void enableUndoRedo();
185     QString doNewlineEnfocement(const QString &out);
186
187     Core::BaseContext *m_outputWindowContext;
188     OutputFormatter *m_formatter;
189
190     bool m_enforceNewline;
191     bool m_scrollToBottom;
192     bool m_linksActive;
193     bool m_mousePressed;
194 };
195
196 } // namespace Internal
197 } // namespace ProjectExplorer
198
199 #endif // OUTPUTWINDOW_H