Some code reorganization

Changing nothing, just preventing next patch to be scrambled by it.
This commit is contained in:
Thorbjørn Lindeijer
2009-01-09 11:06:36 +01:00
parent 816b83feed
commit ce1d728b9a
2 changed files with 119 additions and 120 deletions

View File

@@ -52,68 +52,6 @@
using namespace ProjectExplorer::Internal; using namespace ProjectExplorer::Internal;
using namespace ProjectExplorer; using namespace ProjectExplorer;
bool OutputPane::hasFocus()
{
return m_tabWidget->currentWidget() && m_tabWidget->currentWidget()->hasFocus();
}
bool OutputPane::canFocus()
{
return m_tabWidget->currentWidget();
}
void OutputPane::setFocus()
{
if (m_tabWidget->currentWidget())
m_tabWidget->currentWidget()->setFocus();
}
void OutputPane::appendOutput(const QString &/*out*/)
{
// This function is in the interface, since we can't do anything sensible here, we don't do anything here.
}
void OutputPane::appendOutput(RunControl *rc, const QString &out)
{
OutputWindow *ow = m_outputWindows.value(rc);
ow->appendOutput(out);
}
void OutputPane::showTabFor(RunControl *rc)
{
OutputWindow *ow = m_outputWindows.value(rc);
m_tabWidget->setCurrentWidget(ow);
}
void OutputPane::stopRunControl()
{
RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
rc->stop();
}
void OutputPane::reRunRunControl()
{
RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
if (rc->runConfiguration()->project() != 0)
rc->start();
}
void OutputPane::closeTab(int index)
{
OutputWindow *ow = static_cast<OutputWindow *>(m_tabWidget->widget(index));
RunControl *rc = m_outputWindows.key(ow);
if (rc->isRunning()) {
QString msg = tr("The application is still running. Close it first.");
QMessageBox::critical(0, tr("Unable to close"), msg);
return;
}
m_tabWidget->removeTab(index);
delete ow;
delete rc;
}
OutputPane::OutputPane() OutputPane::OutputPane()
: m_mainWidget(new QWidget) : m_mainWidget(new QWidget)
{ {
@@ -173,21 +111,57 @@ OutputPane::~OutputPane()
delete m_mainWidget; delete m_mainWidget;
} }
void OutputPane::projectRemoved() QWidget *OutputPane::outputWidget(QWidget *)
{ {
tabChanged(m_tabWidget->currentIndex()); return m_mainWidget;
} }
void OutputPane::tabChanged(int i) QList<QWidget*> OutputPane::toolBarWidgets(void) const
{ {
if (i == -1) { return QList<QWidget*>() << m_reRunButton << m_stopButton
m_stopButton->setEnabled(false); ; // << m_insertLineButton;
m_reRunButton->setEnabled(false); }
} else {
RunControl *rc = runControlForTab(i); QString OutputPane::name() const
m_stopButton->setEnabled(rc->isRunning()); {
m_reRunButton->setEnabled(!rc->isRunning() && rc->runConfiguration()->project()); return tr("Application Output");
} }
int OutputPane::priorityInStatusBar() const
{
return 60;
}
void OutputPane::clearContents()
{
OutputWindow *currentWindow = qobject_cast<OutputWindow *>(m_tabWidget->currentWidget());
if (currentWindow)
currentWindow->clear();
}
void OutputPane::visibilityChanged(bool /* b */)
{
}
bool OutputPane::hasFocus()
{
return m_tabWidget->currentWidget() && m_tabWidget->currentWidget()->hasFocus();
}
bool OutputPane::canFocus()
{
return m_tabWidget->currentWidget();
}
void OutputPane::setFocus()
{
if (m_tabWidget->currentWidget())
m_tabWidget->currentWidget()->setFocus();
}
void OutputPane::appendOutput(const QString &/*out*/)
{
// This function is in the interface, since we can't do anything sensible here, we don't do anything here.
} }
void OutputPane::createNewOutputWindow(RunControl *rc) void OutputPane::createNewOutputWindow(RunControl *rc)
@@ -195,11 +169,11 @@ void OutputPane::createNewOutputWindow(RunControl *rc)
connect(rc, SIGNAL(started()), connect(rc, SIGNAL(started()),
this, SLOT(runControlStarted())); this, SLOT(runControlStarted()));
connect(rc, SIGNAL(finished()), connect(rc, SIGNAL(finished()),
this, SLOT(runControlFinished())); this, SLOT(runControlFinished()));
// First look if we can reuse a tab // First look if we can reuse a tab
bool found = false; bool found = false;
for (int i=0; i<m_tabWidget->count(); ++i) { for (int i = 0; i < m_tabWidget->count(); ++i) {
RunControl *old = runControlForTab(i); RunControl *old = runControlForTab(i);
if (old->runConfiguration() == rc->runConfiguration() && !old->isRunning()) { if (old->runConfiguration() == rc->runConfiguration() && !old->isRunning()) {
// Reuse this tab // Reuse this tab
@@ -222,6 +196,71 @@ void OutputPane::createNewOutputWindow(RunControl *rc)
} }
} }
void OutputPane::appendOutput(RunControl *rc, const QString &out)
{
OutputWindow *ow = m_outputWindows.value(rc);
ow->appendOutput(out);
}
void OutputPane::showTabFor(RunControl *rc)
{
OutputWindow *ow = m_outputWindows.value(rc);
m_tabWidget->setCurrentWidget(ow);
}
void OutputPane::insertLine()
{
OutputWindow *currentWindow = qobject_cast<OutputWindow *>(m_tabWidget->currentWidget());
if (currentWindow)
currentWindow->clear();
}
void OutputPane::reRunRunControl()
{
RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
if (rc->runConfiguration()->project() != 0)
rc->start();
}
void OutputPane::stopRunControl()
{
RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
rc->stop();
}
void OutputPane::closeTab(int index)
{
OutputWindow *ow = static_cast<OutputWindow *>(m_tabWidget->widget(index));
RunControl *rc = m_outputWindows.key(ow);
if (rc->isRunning()) {
QString msg = tr("The application is still running. Close it first.");
QMessageBox::critical(0, tr("Unable to close"), msg);
return;
}
m_tabWidget->removeTab(index);
delete ow;
delete rc;
}
void OutputPane::projectRemoved()
{
tabChanged(m_tabWidget->currentIndex());
}
void OutputPane::tabChanged(int i)
{
if (i == -1) {
m_stopButton->setEnabled(false);
m_reRunButton->setEnabled(false);
} else {
RunControl *rc = runControlForTab(i);
m_stopButton->setEnabled(rc->isRunning());
m_reRunButton->setEnabled(!rc->isRunning() && rc->runConfiguration()->project());
}
}
void OutputPane::runControlStarted() void OutputPane::runControlStarted()
{ {
RunControl *rc = runControlForTab(m_tabWidget->currentIndex()); RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
@@ -240,51 +279,11 @@ void OutputPane::runControlFinished()
} }
} }
QWidget *OutputPane::outputWidget(QWidget *)
{
return m_mainWidget;
}
QList<QWidget*> OutputPane::toolBarWidgets(void) const
{
return QList<QWidget*>() << m_reRunButton << m_stopButton
; // << m_insertLineButton;
}
QString OutputPane::name() const
{
return tr("Application Output");
}
void OutputPane::clearContents()
{
OutputWindow *currentWindow = qobject_cast<OutputWindow *>(m_tabWidget->currentWidget());
if (currentWindow)
currentWindow->clear();
}
void OutputPane::visibilityChanged(bool /* b */)
{
}
void OutputPane::insertLine()
{
OutputWindow *currentWindow = qobject_cast<OutputWindow *>(m_tabWidget->currentWidget());
if (currentWindow)
currentWindow->clear();
}
RunControl* OutputPane::runControlForTab(int index) const RunControl* OutputPane::runControlForTab(int index) const
{ {
return m_outputWindows.key(qobject_cast<OutputWindow *>(m_tabWidget->widget(index))); return m_outputWindows.key(qobject_cast<OutputWindow *>(m_tabWidget->widget(index)));
} }
int OutputPane::priorityInStatusBar() const
{
return 60;
}
/*******************/ /*******************/

View File

@@ -77,9 +77,9 @@ public:
void appendOutput(const QString &out); void appendOutput(const QString &out);
// ApplicationOutputspecifics // ApplicationOutputspecifics
void createNewOutputWindow(RunControl *); void createNewOutputWindow(RunControl *rc);
void appendOutput(RunControl *, const QString &out); void appendOutput(RunControl *rc, const QString &out);
void showTabFor(RunControl *); void showTabFor(RunControl *rc);
public slots: public slots:
void projectRemoved(); void projectRemoved();
@@ -105,10 +105,10 @@ private:
}; };
class OutputWindow : public QPlainTextEdit class OutputWindow : public QPlainTextEdit
{ {
Q_OBJECT Q_OBJECT
public: public:
OutputWindow(QWidget *parent = 0); OutputWindow(QWidget *parent = 0);
~OutputWindow(); ~OutputWindow();