1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
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.
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef OUTPUTWINDOW_H
34 #define OUTPUTWINDOW_H
36 #include "outputformat.h"
37 #include <coreplugin/ioutputpane.h>
39 #include <QtGui/QPlainTextEdit>
40 #include <QtGui/QIcon>
52 namespace ProjectExplorer {
53 class OutputFormatter;
58 const char * const C_APP_OUTPUT = "Application Output";
65 struct OutputPanePrivate;
67 class OutputPane : public Core::IOutputPane
78 virtual ~OutputPane();
80 QWidget *outputWidget(QWidget *);
81 QList<QWidget*> toolBarWidgets() const;
82 QString displayName() const;
83 int priorityInStatusBar() const;
85 void visibilityChanged(bool);
96 void createNewOutputWindow(RunControl *rc);
97 void showTabFor(RunControl *rc);
99 bool aboutToClose() const;
100 bool closeTabs(CloseTabMode mode);
103 void allRunControlsFinished();
106 // ApplicationOutput specifics
107 void projectRemoved();
109 void appendMessage(ProjectExplorer::RunControl *rc, const QString &out,
110 ProjectExplorer::OutputFormat format);
113 void reRunRunControl();
114 void stopRunControl();
115 bool closeTab(int index);
116 void tabChanged(int);
117 void runControlStarted();
118 void runControlFinished();
120 void aboutToUnloadSession();
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
132 bool isRunning() const;
133 bool closeTab(int index, CloseTabMode cm);
134 bool optionallyPromptToStop(RunControl *runControl);
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;
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;
152 class OutputWindow : public QPlainTextEdit
157 OutputWindow(QWidget *parent = 0);
160 OutputFormatter* formatter() const;
161 void setFormatter(OutputFormatter *formatter);
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);
167 void grayOutOldContent();
169 void showEvent(QShowEvent *);
172 void handleOldOutput();
174 void scrollToBottom();
177 bool isScrollbarAtBottom() const;
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);
186 void updateWordWrapMode();
189 void enableUndoRedo();
190 QString doNewlineEnfocement(const QString &out);
192 Core::BaseContext *m_outputWindowContext;
193 OutputFormatter *m_formatter;
195 bool m_enforceNewline;
196 bool m_scrollToBottom;
201 } // namespace Internal
202 } // namespace ProjectExplorer
204 #endif // OUTPUTWINDOW_H