Fixes: rename OutputPane into OutputPaneManager

RevBy:    dt
    Details:  also clean up the class interface a bit
This commit is contained in:
hjk
2009-01-26 14:13:15 +01:00
parent a0a4cec8a8
commit f68d6cf0a0
4 changed files with 75 additions and 69 deletions

View File

@@ -131,7 +131,6 @@ MainWindow::MainWindow() :
m_versionDialog(0), m_versionDialog(0),
m_activeContext(0), m_activeContext(0),
m_pluginManager(0), m_pluginManager(0),
m_outputPane(new OutputPane(m_globalContext)),
m_outputMode(0), m_outputMode(0),
m_generalSettings(new GeneralSettings), m_generalSettings(new GeneralSettings),
m_shortcutSettings(new ShortcutSettings), m_shortcutSettings(new ShortcutSettings),
@@ -150,6 +149,8 @@ MainWindow::MainWindow() :
#endif #endif
m_toggleSideBarButton(new QToolButton) m_toggleSideBarButton(new QToolButton)
{ {
OutputPaneManager::create();
setWindowTitle(tr("Qt Creator")); setWindowTitle(tr("Qt Creator"));
qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png")); qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png"));
setDockNestingEnabled(true); setDockNestingEnabled(true);
@@ -247,9 +248,9 @@ MainWindow::~MainWindow()
//because they might trigger stuff that tries to access data from editorwindow, like removeContextWidget //because they might trigger stuff that tries to access data from editorwindow, like removeContextWidget
// All modes are now gone // All modes are now gone
delete OutputPane::instance(); OutputPaneManager::destroy();
// Now that the OutputPane is gone, is a good time to delete the view // Now that the OutputPaneManager is gone, is a good time to delete the view
m_pluginManager->removeObject(m_outputView); m_pluginManager->removeObject(m_outputView);
delete m_outputView; delete m_outputView;
@@ -299,14 +300,15 @@ bool MainWindow::init(ExtensionSystem::PluginManager *pm, QString *)
outputModeWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(m_outputMode)); outputModeWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(m_outputMode));
outputModeWidget->setFocusProxy(oph); outputModeWidget->setFocusProxy(oph);
m_outputMode->setContext(m_outputPane->context()); m_outputMode->setContext(m_globalContext);
m_pluginManager->addObject(m_outputMode); m_pluginManager->addObject(m_outputMode);
m_pluginManager->addObject(m_generalSettings); m_pluginManager->addObject(m_generalSettings);
m_pluginManager->addObject(m_shortcutSettings); m_pluginManager->addObject(m_shortcutSettings);
// Add widget to the bottom, we create the view here instead of inside the OutputPane, since // Add widget to the bottom, we create the view here instead of inside the
// the ViewManager needs to be initilized before // OutputPaneManager, since the ViewManager needs to be initilized before
m_outputView = new Core::BaseView("OutputWindow.Buttons", m_outputPane->buttonsWidget(), QList<int>(), Core::IView::Second); m_outputView = new Core::BaseView("OutputWindow.Buttons",
OutputPaneManager::instance()->buttonsWidget(), QList<int>(), Core::IView::Second);
m_pluginManager->addObject(m_outputView); m_pluginManager->addObject(m_outputView);
return true; return true;
} }
@@ -318,7 +320,7 @@ void MainWindow::extensionsInitialized()
m_viewManager->extensionsInitalized(); m_viewManager->extensionsInitalized();
m_messageManager->init(m_pluginManager); m_messageManager->init(m_pluginManager);
m_outputPane->init(m_pluginManager); OutputPaneManager::instance()->init();
m_actionManager->initialize(); m_actionManager->initialize();
readSettings(); readSettings();
@@ -756,7 +758,7 @@ void MainWindow::setFocusToEditor()
if (focusWidget && focusWidget == qApp->focusWidget()) { if (focusWidget && focusWidget == qApp->focusWidget()) {
if (FindToolBarPlaceHolder::getCurrent()) if (FindToolBarPlaceHolder::getCurrent())
FindToolBarPlaceHolder::getCurrent()->hide(); FindToolBarPlaceHolder::getCurrent()->hide();
m_outputPane->slotHide(); OutputPaneManager::instance()->slotHide();
RightPaneWidget::instance()->setShown(false); RightPaneWidget::instance()->setShown(false);
} }
} }

View File

@@ -80,13 +80,12 @@ class CoreImpl;
class FancyTabWidget; class FancyTabWidget;
class GeneralSettings; class GeneralSettings;
class NavigationWidget; class NavigationWidget;
class OutputPane;
class ProgressManagerPrivate; class ProgressManagerPrivate;
class ShortcutSettings; class ShortcutSettings;
class ViewManager; class ViewManager;
class VersionDialog; class VersionDialog;
class CORE_EXPORT MainWindow : public QMainWindow class CORE_EXPORT MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@@ -198,7 +197,6 @@ private:
ExtensionSystem::PluginManager *m_pluginManager; ExtensionSystem::PluginManager *m_pluginManager;
OutputPane *m_outputPane;
BaseMode *m_outputMode; BaseMode *m_outputMode;
GeneralSettings *m_generalSettings; GeneralSettings *m_generalSettings;
ShortcutSettings *m_shortcutSettings; ShortcutSettings *m_shortcutSettings;

View File

@@ -81,7 +81,7 @@ private:
OutputPanePlaceHolder *OutputPanePlaceHolder::m_current = 0; OutputPanePlaceHolder *OutputPanePlaceHolder::m_current = 0;
OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent) OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent)
:QWidget(parent), m_mode(mode), m_closeable(true) : QWidget(parent), m_mode(mode), m_closeable(true)
{ {
setVisible(false); setVisible(false);
setLayout(new QVBoxLayout); setLayout(new QVBoxLayout);
@@ -98,8 +98,8 @@ OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent)
OutputPanePlaceHolder::~OutputPanePlaceHolder() OutputPanePlaceHolder::~OutputPanePlaceHolder()
{ {
if (m_current == this) { if (m_current == this) {
OutputPane::instance()->setParent(0); OutputPaneManager::instance()->setParent(0);
OutputPane::instance()->hide(); OutputPaneManager::instance()->hide();
} }
} }
@@ -117,45 +117,54 @@ void OutputPanePlaceHolder::currentModeChanged(Core::IMode *mode)
{ {
if (m_current == this) { if (m_current == this) {
m_current = 0; m_current = 0;
OutputPane::instance()->setParent(0); OutputPaneManager::instance()->setParent(0);
OutputPane::instance()->hide(); OutputPaneManager::instance()->hide();
OutputPane::instance()->updateStatusButtons(false); OutputPaneManager::instance()->updateStatusButtons(false);
} }
if (m_mode == mode) { if (m_mode == mode) {
m_current = this; m_current = this;
layout()->addWidget(OutputPane::instance()); layout()->addWidget(OutputPaneManager::instance());
OutputPane::instance()->show(); OutputPaneManager::instance()->show();
OutputPane::instance()->updateStatusButtons(isVisible()); OutputPaneManager::instance()->updateStatusButtons(isVisible());
OutputPane::instance()->setCloseable(m_closeable); OutputPaneManager::instance()->setCloseable(m_closeable);
} }
} }
//// ////
// OutputPane // OutputPaneManager
//// ////
OutputPane *OutputPane::m_instance = 0; static OutputPaneManager *m_instance = 0;
OutputPane *OutputPane::instance() void OutputPaneManager::create()
{
m_instance = new OutputPaneManager;
}
void OutputPaneManager::destroy()
{
delete m_instance;
m_instance = 0;
}
OutputPaneManager *OutputPaneManager::instance()
{ {
return m_instance; return m_instance;
} }
void OutputPane::updateStatusButtons(bool visible) void OutputPaneManager::updateStatusButtons(bool visible)
{ {
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt(); int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
if (m_buttons.value(idx)) if (m_buttons.value(idx))
m_buttons.value(idx)->setChecked(visible); m_buttons.value(idx)->setChecked(visible);
} }
OutputPane::OutputPane(const QList<int> &context, QWidget *parent) : OutputPaneManager::OutputPaneManager(QWidget *parent) :
QWidget(parent), QWidget(parent),
m_context(context),
m_widgetComboBox(new QComboBox), m_widgetComboBox(new QComboBox),
m_clearButton(new QToolButton), m_clearButton(new QToolButton),
m_closeButton(new QToolButton), m_closeButton(new QToolButton),
m_closeAction(0), m_closeAction(0),
m_pluginManager(0),
m_lastIndex(-1), m_lastIndex(-1),
m_outputWidgetPane(new QStackedWidget), m_outputWidgetPane(new QStackedWidget),
m_opToolBarWidgets(new QStackedWidget) m_opToolBarWidgets(new QStackedWidget)
@@ -191,24 +200,19 @@ OutputPane::OutputPane(const QList<int> &context, QWidget *parent) :
#else #else
m_buttonsWidget->layout()->setSpacing(4); m_buttonsWidget->layout()->setSpacing(4);
#endif #endif
m_instance = this;
} }
OutputPane::~OutputPane() OutputPaneManager::~OutputPaneManager()
{ {
m_instance = 0;
} }
QWidget *OutputPane::buttonsWidget() QWidget *OutputPaneManager::buttonsWidget()
{ {
return m_buttonsWidget; return m_buttonsWidget;
} }
void OutputPane::init(ExtensionSystem::PluginManager *pm) void OutputPaneManager::init()
{ {
m_pluginManager = pm;
ActionManager *am = Core::ICore::instance()->actionManager(); ActionManager *am = Core::ICore::instance()->actionManager();
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW); ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
@@ -217,7 +221,8 @@ void OutputPane::init(ExtensionSystem::PluginManager *pm)
mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES); mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
mpanes->menu()->setTitle(tr("Output &Panes")); mpanes->menu()->setTitle(tr("Output &Panes"));
QList<IOutputPane*> panes = m_pluginManager->getObjects<IOutputPane>(); QList<IOutputPane*> panes = ExtensionSystem::PluginManager::instance()
->getObjects<IOutputPane>();
QMultiMap<int, IOutputPane*> sorted; QMultiMap<int, IOutputPane*> sorted;
foreach (IOutputPane* outPane, panes) foreach (IOutputPane* outPane, panes)
sorted.insertMulti(outPane->priorityInStatusBar(), outPane); sorted.insertMulti(outPane->priorityInStatusBar(), outPane);
@@ -251,7 +256,7 @@ void OutputPane::init(ExtensionSystem::PluginManager *pm)
actionId.remove(QLatin1Char(' ')); actionId.remove(QLatin1Char(' '));
QAction *action = new QAction(outPane->name(), this); QAction *action = new QAction(outPane->name(), this);
Command *cmd = am->registerAction(action, actionId, m_context); Command *cmd = am->registerAction(action, actionId, QList<int>() << Constants::C_GLOBAL_ID);
if (outPane->priorityInStatusBar() != -1) { if (outPane->priorityInStatusBar() != -1) {
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
cmd->setDefaultKeySequence(QKeySequence("Ctrl+" + QString::number(shortcutNumber))); cmd->setDefaultKeySequence(QKeySequence("Ctrl+" + QString::number(shortcutNumber)));
@@ -281,7 +286,7 @@ void OutputPane::init(ExtensionSystem::PluginManager *pm)
changePage(); changePage();
} }
void OutputPane::shortcutTriggered() void OutputPaneManager::shortcutTriggered()
{ {
QAction *action = qobject_cast<QAction*>(sender()); QAction *action = qobject_cast<QAction*>(sender());
if (action && m_actions.contains(action)) { if (action && m_actions.contains(action)) {
@@ -305,7 +310,7 @@ void OutputPane::shortcutTriggered()
} }
} }
void OutputPane::buttonTriggered() void OutputPaneManager::buttonTriggered()
{ {
QPushButton *button = qobject_cast<QPushButton *>(sender()); QPushButton *button = qobject_cast<QPushButton *>(sender());
QMap<int, QPushButton *>::const_iterator it, end; QMap<int, QPushButton *>::const_iterator it, end;
@@ -327,7 +332,7 @@ void OutputPane::buttonTriggered()
} }
} }
void OutputPane::updateToolTip() void OutputPaneManager::updateToolTip()
{ {
QAction *action = qobject_cast<QAction*>(sender()); QAction *action = qobject_cast<QAction*>(sender());
if (action) { if (action) {
@@ -337,7 +342,7 @@ void OutputPane::updateToolTip()
} }
} }
void OutputPane::slotHide() void OutputPaneManager::slotHide()
{ {
if (OutputPanePlaceHolder::m_current) { if (OutputPanePlaceHolder::m_current) {
OutputPanePlaceHolder::m_current->setVisible(false); OutputPanePlaceHolder::m_current->setVisible(false);
@@ -350,7 +355,7 @@ void OutputPane::slotHide()
} }
} }
int OutputPane::findIndexForPage(IOutputPane *out) int OutputPaneManager::findIndexForPage(IOutputPane *out)
{ {
if (!out) if (!out)
return -1; return -1;
@@ -370,7 +375,7 @@ int OutputPane::findIndexForPage(IOutputPane *out)
return -1; return -1;
} }
void OutputPane::ensurePageVisible(int idx) void OutputPaneManager::ensurePageVisible(int idx)
{ {
if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() != idx) { if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() != idx) {
m_widgetComboBox->setCurrentIndex(m_widgetComboBox->findData(idx)); m_widgetComboBox->setCurrentIndex(m_widgetComboBox->findData(idx));
@@ -380,13 +385,13 @@ void OutputPane::ensurePageVisible(int idx)
} }
void OutputPane::showPage(bool focus) void OutputPaneManager::showPage(bool focus)
{ {
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender())); int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
showPage(idx, focus); showPage(idx, focus);
} }
void OutputPane::showPage(int idx, bool focus) void OutputPaneManager::showPage(int idx, bool focus)
{ {
IOutputPane *out = m_pageMap.value(idx); IOutputPane *out = m_pageMap.value(idx);
if (idx > -1) { if (idx > -1) {
@@ -405,7 +410,7 @@ void OutputPane::showPage(int idx, bool focus)
} }
} }
void OutputPane::togglePage(bool focus) void OutputPaneManager::togglePage(bool focus)
{ {
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender())); int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
if (OutputPanePlaceHolder::m_current if (OutputPanePlaceHolder::m_current
@@ -417,23 +422,23 @@ void OutputPane::togglePage(bool focus)
} }
} }
void OutputPane::setCloseable(bool b) void OutputPaneManager::setCloseable(bool b)
{ {
m_closeAction->setVisible(b); m_closeAction->setVisible(b);
} }
bool OutputPane::closeable() bool OutputPaneManager::closeable()
{ {
return m_closeButton->isVisibleTo(m_closeButton->parentWidget()); return m_closeButton->isVisibleTo(m_closeButton->parentWidget());
} }
void OutputPane::focusInEvent(QFocusEvent *e) void OutputPaneManager::focusInEvent(QFocusEvent *e)
{ {
if (m_outputWidgetPane->currentWidget()) if (m_outputWidgetPane->currentWidget())
m_outputWidgetPane->currentWidget()->setFocus(e->reason()); m_outputWidgetPane->currentWidget()->setFocus(e->reason());
} }
void OutputPane::changePage() void OutputPaneManager::changePage()
{ {
if (m_outputWidgetPane->count() <= 0) if (m_outputWidgetPane->count() <= 0)
return; return;
@@ -470,7 +475,7 @@ void OutputPane::changePage()
m_lastIndex = idx; m_lastIndex = idx;
} }
void OutputPane::clearPage() void OutputPaneManager::clearPage()
{ {
if (m_pageMap.contains(m_outputWidgetPane->currentIndex())) if (m_pageMap.contains(m_outputWidgetPane->currentIndex()))
m_pageMap.value(m_outputWidgetPane->currentIndex())->clearContents(); m_pageMap.value(m_outputWidgetPane->currentIndex())->clearContents();

View File

@@ -47,21 +47,20 @@ class QStackedWidget;
class QPushButton; class QPushButton;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace ExtensionSystem { class PluginManager; }
namespace Core { namespace Core {
class IMode; class IMode;
class IOutputPane; class IOutputPane;
namespace Internal { namespace Internal {
class OutputPane; class OutputPaneManager;
class MainWindow;
} }
class CORE_EXPORT OutputPanePlaceHolder : public QWidget class CORE_EXPORT OutputPanePlaceHolder : public QWidget
{ {
friend class Core::Internal::OutputPane; // needs to set m_visible and thus access m_current friend class Core::Internal::OutputPaneManager; // needs to set m_visible and thus access m_current
Q_OBJECT Q_OBJECT
public: public:
OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0); OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0);
@@ -80,17 +79,13 @@ private:
namespace Internal { namespace Internal {
class OutputPane class OutputPaneManager : public QWidget
: public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
OutputPane(const QList<int> &context, QWidget *parent = 0); void init();
~OutputPane(); static OutputPaneManager *instance();
void init(ExtensionSystem::PluginManager *pm);
static OutputPane *instance();
const QList<int> &context() const { return m_context; }
void setCloseable(bool b); void setCloseable(bool b);
bool closeable(); bool closeable();
QWidget *buttonsWidget(); QWidget *buttonsWidget();
@@ -103,7 +98,7 @@ public slots:
protected: protected:
void focusInEvent(QFocusEvent *e); void focusInEvent(QFocusEvent *e);
private slots:; private slots:
void changePage(); void changePage();
void showPage(bool focus); void showPage(bool focus);
void togglePage(bool focus); void togglePage(bool focus);
@@ -112,17 +107,23 @@ private slots:;
void buttonTriggered(); void buttonTriggered();
private: private:
// the only class that is allowed to create and destroy
friend class MainWindow;
static void create();
static void destroy();
OutputPaneManager(QWidget *parent = 0);
~OutputPaneManager();
void showPage(int idx, bool focus); void showPage(int idx, bool focus);
void ensurePageVisible(int idx); void ensurePageVisible(int idx);
int findIndexForPage(IOutputPane *out); int findIndexForPage(IOutputPane *out);
const QList<int> m_context;
QComboBox *m_widgetComboBox; QComboBox *m_widgetComboBox;
QToolButton *m_clearButton; QToolButton *m_clearButton;
QToolButton *m_closeButton; QToolButton *m_closeButton;
QAction *m_closeAction; QAction *m_closeAction;
ExtensionSystem::PluginManager *m_pluginManager;
QMap<int, Core::IOutputPane*> m_pageMap; QMap<int, Core::IOutputPane*> m_pageMap;
int m_lastIndex; int m_lastIndex;
@@ -132,7 +133,7 @@ private:
QMap<int, QPushButton *> m_buttons; QMap<int, QPushButton *> m_buttons;
QMap<QAction *, int> m_actions; QMap<QAction *, int> m_actions;
static OutputPane *m_instance; static OutputPaneManager *m_instance;
}; };
} // namespace Internal } // namespace Internal