1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
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
16 ** GNU Lesser General Public License Usage
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.
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.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef OUTPUTWINDOW_H
35 #define OUTPUTWINDOW_H
37 #include "outputformat.h"
38 #include <coreplugin/ioutputpane.h>
40 #include <QtGui/QPlainTextEdit>
41 #include <QtGui/QIcon>
53 namespace ProjectExplorer {
54 class OutputFormatter;
59 const char * const C_APP_OUTPUT = "Application Output";
66 struct OutputPanePrivate;
68 class OutputPane : public Core::IOutputPane
74 virtual ~OutputPane();
76 QWidget *outputWidget(QWidget *);
77 QList<QWidget*> toolBarWidgets() const;
78 QString displayName() const;
79 int priorityInStatusBar() const;
81 void visibilityChanged(bool);
92 void createNewOutputWindow(RunControl *rc);
93 void showTabFor(RunControl *rc);
95 bool aboutToClose() const;
96 bool closeTabs(bool prompt);
99 void allRunControlsFinished();
102 // ApplicationOutput specifics
103 void projectRemoved();
105 void appendMessage(ProjectExplorer::RunControl *rc, const QString &out,
106 ProjectExplorer::OutputFormat format);
109 void reRunRunControl();
110 void stopRunControl();
111 bool closeTab(int index);
112 void tabChanged(int);
113 void runControlStarted();
114 void runControlFinished();
116 void aboutToUnloadSession();
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
128 bool isRunning() const;
129 bool closeTab(int index, bool prompt);
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;
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;
147 class OutputWindow : public QPlainTextEdit
152 OutputWindow(QWidget *parent = 0);
155 OutputFormatter* formatter() const;
156 void setFormatter(OutputFormatter *formatter);
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);
162 void grayOutOldContent();
164 void showEvent(QShowEvent *);
167 void handleOldOutput();
169 void scrollToBottom();
172 bool isScrollbarAtBottom() const;
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);
181 void updateWordWrapMode();
184 void enableUndoRedo();
185 QString doNewlineEnfocement(const QString &out);
187 Core::BaseContext *m_outputWindowContext;
188 OutputFormatter *m_formatter;
190 bool m_enforceNewline;
191 bool m_scrollToBottom;
196 } // namespace Internal
197 } // namespace ProjectExplorer
199 #endif // OUTPUTWINDOW_H