diff --git a/src/plugins/coreplugin/ioutputpane.h b/src/plugins/coreplugin/ioutputpane.h index e38e9fbe8b36269d1757d8d7041f5f14bea718e0..5a841011c9c00d96d9def197af1a44be890e394f 100644 --- a/src/plugins/coreplugin/ioutputpane.h +++ b/src/plugins/coreplugin/ioutputpane.h @@ -64,6 +64,12 @@ public: // Wheter the outputpane can be focused at the moment. // (E.g. the search result window doesn't want to be focussed if the are no results.) virtual bool canFocus() = 0; + + virtual bool canNavigate() = 0; + virtual bool canNext() = 0; + virtual bool canPrevious() = 0; + virtual void goToNext() = 0; + virtual void goToPrev() = 0; public slots: void popup() { @@ -89,10 +95,16 @@ public slots: emit togglePage(withFocusIfShown); } + void navigateStateChanged() + { + emit navigateStateUpdate(); + } + signals: void showPage(bool withFocus); void hidePage(); void togglePage(bool withFocusIfShown); + void navigateStateUpdate(); }; } // namespace Core diff --git a/src/plugins/coreplugin/messageoutputwindow.cpp b/src/plugins/coreplugin/messageoutputwindow.cpp index 3fb450344506b7ed0590e051fff1197cfa8930e3..7fc733744b5cd112be67057641f5c8acad11d905 100644 --- a/src/plugins/coreplugin/messageoutputwindow.cpp +++ b/src/plugins/coreplugin/messageoutputwindow.cpp @@ -89,3 +89,28 @@ int MessageOutputWindow::priorityInStatusBar() const { return -1; } + +bool MessageOutputWindow::canNext() +{ + return false; +} + +bool MessageOutputWindow::canPrevious() +{ + return false; +} + +void MessageOutputWindow::goToNext() +{ + +} + +void MessageOutputWindow::goToPrev() +{ + +} + +bool MessageOutputWindow::canNavigate() +{ + return false; +} diff --git a/src/plugins/coreplugin/messageoutputwindow.h b/src/plugins/coreplugin/messageoutputwindow.h index 70e1308e0dd577003f60dc6b08e768c690cfe6bf..821aa671420deb227323e3277dcf02c0a7f4df64 100644 --- a/src/plugins/coreplugin/messageoutputwindow.h +++ b/src/plugins/coreplugin/messageoutputwindow.h @@ -60,6 +60,12 @@ public: bool hasFocus(); void setFocus(); + virtual bool canNext(); + virtual bool canPrevious(); + virtual void goToNext(); + virtual void goToPrev(); + bool canNavigate(); + private: QTextEdit *m_widget; }; diff --git a/src/plugins/coreplugin/outputpane.cpp b/src/plugins/coreplugin/outputpane.cpp index e141473162d12ad1ae0d9b88e2594617e5239ed4..92adb63e89d0915e85721cd799bc059178360c91 100644 --- a/src/plugins/coreplugin/outputpane.cpp +++ b/src/plugins/coreplugin/outputpane.cpp @@ -40,6 +40,8 @@ #include <extensionsystem/pluginmanager.h> +#include <QtCore/QDebug> + #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QComboBox> @@ -159,6 +161,8 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : m_widgetComboBox(new QComboBox), m_clearButton(new QToolButton), m_closeButton(new QToolButton), + m_nextAction(0), + m_prevAction(0), m_closeAction(0), m_lastIndex(-1), m_outputWidgetPane(new QStackedWidget), @@ -171,6 +175,18 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : m_clearButton->setToolTip(tr("Clear")); connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clearPage())); + m_nextAction = new QAction(this); + m_nextAction->setIcon(QIcon(":/core/images/next.png")); + m_nextAction->setProperty("type", QLatin1String("dockbutton")); + m_nextAction->setText(tr("Next Item")); + connect(m_nextAction, SIGNAL(triggered()), this, SLOT(slotNext())); + + m_prevAction = new QAction(this); + m_prevAction->setIcon(QIcon(":/core/images/prev.png")); + m_prevAction->setProperty("type", QLatin1String("dockbutton")); + m_prevAction->setText(tr("Previous Item")); + connect(m_prevAction, SIGNAL(triggered()), this, SLOT(slotPrev())); + m_closeButton->setIcon(QIcon(":/core/images/closebutton.png")); m_closeButton->setProperty("type", QLatin1String("dockbutton")); connect(m_closeButton, SIGNAL(clicked()), this, SLOT(slotHide())); @@ -178,12 +194,13 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : QVBoxLayout *mainlayout = new QVBoxLayout; mainlayout->setSpacing(0); mainlayout->setMargin(0); - QToolBar *toolBar = new QToolBar; - toolBar->addWidget(m_widgetComboBox); - toolBar->addWidget(m_clearButton); - toolBar->addWidget(m_opToolBarWidgets); - m_closeAction = toolBar->addWidget(m_closeButton); - mainlayout->addWidget(toolBar); + m_toolBar = new QToolBar; + m_toolBar->addWidget(m_widgetComboBox); + m_toolBar->addWidget(m_clearButton); + + m_opToolBarAction = m_toolBar->addWidget(m_opToolBarWidgets); + m_closeAction = m_toolBar->addWidget(m_closeButton); + mainlayout->addWidget(m_toolBar); mainlayout->addWidget(m_outputWidgetPane, 10); setLayout(mainlayout); @@ -195,6 +212,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : #else m_buttonsWidget->layout()->setSpacing(4); #endif + } OutputPaneManager::~OutputPaneManager() @@ -216,11 +234,32 @@ void OutputPaneManager::init() { ActionManager *am = Core::ICore::instance()->actionManager(); ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW); + QList<int> globalcontext; + globalcontext.append(Core::Constants::C_GLOBAL_ID); // Window->Output Panes ActionContainer *mpanes = am->createMenu(Constants::M_WINDOW_PANES); mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES); mpanes->menu()->setTitle(tr("Output &Panes")); + mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup"); + mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup"); + + Core::Command *cmd; + + cmd = am->registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalcontext); + cmd->setDefaultKeySequence(QKeySequence("Shift+F6")); + m_toolBar->insertAction(m_opToolBarAction ,cmd->action()); + mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); + + cmd = am->registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalcontext); + m_toolBar->insertAction(m_opToolBarAction, cmd->action()); + cmd->setDefaultKeySequence(QKeySequence("F6")); + mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); + + QAction *sep = new QAction(this); + sep->setSeparator(true); + cmd = am->registerAction(sep, QLatin1String("Coreplugin.OutputPane.Sep"), globalcontext); + mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); QList<IOutputPane*> panes = ExtensionSystem::PluginManager::instance() ->getObjects<IOutputPane>(); @@ -241,6 +280,7 @@ void OutputPaneManager::init() connect(outPane, SIGNAL(showPage(bool)), this, SLOT(showPage(bool))); connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide())); connect(outPane, SIGNAL(togglePage(bool)), this, SLOT(togglePage(bool))); + connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState())); QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets); QHBoxLayout *toolButtonsLayout = new QHBoxLayout; @@ -265,7 +305,7 @@ void OutputPaneManager::init() cmd->setDefaultKeySequence(QKeySequence(paneShortCut(Qt::ALT, shortcutNumber))); #endif } - mpanes->addAction(cmd); + mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup"); m_actions.insert(cmd->action(), idx); // TODO priority -1 @@ -343,6 +383,24 @@ void OutputPaneManager::updateToolTip() } } +void OutputPaneManager::slotNext() +{ + int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt(); + ensurePageVisible(idx); + IOutputPane *out = m_pageMap.value(idx); + if (out->canNext()) + out->goToNext(); +} + +void OutputPaneManager::slotPrev() +{ + int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt(); + ensurePageVisible(idx); + IOutputPane *out = m_pageMap.value(idx); + if (out->canPrevious()) + out->goToPrev(); +} + void OutputPaneManager::slotHide() { if (OutputPanePlaceHolder::m_current) { @@ -384,6 +442,16 @@ void OutputPaneManager::ensurePageVisible(int idx) } } +void OutputPaneManager::updateNavigateState() +{ + IOutputPane* pane = qobject_cast<IOutputPane*>(sender()); + int idx = findIndexForPage(pane); + if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx) { + m_prevAction->setEnabled(pane->canNavigate() && pane->canPrevious()); + m_nextAction->setEnabled(pane->canNavigate() && pane->canNext()); + } +} + // Slot connected to showPage signal of each page void OutputPaneManager::showPage(bool focus) { @@ -457,11 +525,17 @@ void OutputPaneManager::changePage() } int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt(); + if (m_lastIndex == idx) + return; m_outputWidgetPane->setCurrentIndex(idx); m_opToolBarWidgets->setCurrentIndex(idx); m_pageMap.value(idx)->visibilityChanged(true); m_pageMap.value(m_lastIndex)->visibilityChanged(false); + bool canNavigate = m_pageMap.value(idx)->canNavigate(); + m_prevAction->setEnabled(canNavigate && m_pageMap.value(idx)->canPrevious()); + m_nextAction->setEnabled(canNavigate && m_pageMap.value(idx)->canNext()); + if (m_buttons.value(m_lastIndex)) m_buttons.value(m_lastIndex)->setChecked(false); diff --git a/src/plugins/coreplugin/outputpane.h b/src/plugins/coreplugin/outputpane.h index 86dccdcdb5a402fa765ddd8c66a99ae4ad7777b6..9fbbf780c6b1c60dc6a549262c620655f990e942 100644 --- a/src/plugins/coreplugin/outputpane.h +++ b/src/plugins/coreplugin/outputpane.h @@ -39,6 +39,7 @@ QT_BEGIN_NAMESPACE class QAction; class QComboBox; class QToolButton; +class QToolBar; class QStackedWidget; class QPushButton; QT_END_NAMESPACE @@ -89,6 +90,8 @@ public: public slots: void slotHide(); + void slotNext(); + void slotPrev(); void shortcutTriggered(); protected: @@ -101,6 +104,7 @@ private slots: void clearPage(); void updateToolTip(); void buttonTriggered(); + void updateNavigateState(); private: // the only class that is allowed to create and destroy @@ -118,13 +122,18 @@ private: QComboBox *m_widgetComboBox; QToolButton *m_clearButton; QToolButton *m_closeButton; + + QAction *m_nextAction; + QAction *m_prevAction; QAction *m_closeAction; + QToolBar *m_toolBar; QMap<int, Core::IOutputPane*> m_pageMap; int m_lastIndex; QStackedWidget *m_outputWidgetPane; QStackedWidget *m_opToolBarWidgets; + QAction *m_opToolBarAction; QWidget *m_buttonsWidget; QMap<int, QPushButton *> m_buttons; QMap<QAction *, int> m_actions; diff --git a/src/plugins/debugger/cdb/cdbcom.h b/src/plugins/debugger/cdb/cdbcom.h index 8a631e3f1fc1da4b510ba008f7ec0fa23b9a3f42..19208710a9f4c687a3a8f63d2644199ef2635ff1 100644 --- a/src/plugins/debugger/cdb/cdbcom.h +++ b/src/plugins/debugger/cdb/cdbcom.h @@ -43,4 +43,5 @@ typedef IDebugDataSpaces4 CIDebugDataSpaces; typedef IDebugSymbolGroup2 CIDebugSymbolGroup; typedef IDebugBreakpoint2 CIDebugBreakpoint; + #endif // CDBCOM_H diff --git a/src/plugins/debugger/cdb/cdbdumperhelper.h b/src/plugins/debugger/cdb/cdbdumperhelper.h index b9ec2bccccbbf8248a94e833bc5a30b3b9e8cf18..9500d4d4e01c10e046535badfec348d73aed717b 100644 --- a/src/plugins/debugger/cdb/cdbdumperhelper.h +++ b/src/plugins/debugger/cdb/cdbdumperhelper.h @@ -32,6 +32,7 @@ #include "watchutils.h" #include "cdbcom.h" + #include <QtCore/QStringList> #include <QtCore/QMap> @@ -42,8 +43,7 @@ struct CdbComInterfaces; class IDebuggerManagerAccessForEngines; class DebuggerManager; -/* For code clarity, all the stuff related to custom dumpers - * goes here. +/* For code clarity, all the stuff related to custom dumpers goes here. * "Custom dumper" is a library compiled against the current * Qt containing functions to evaluate values of Qt classes * (such as QString, taking pointers to their addresses). diff --git a/src/plugins/debugger/cdb/cdboptions.cpp b/src/plugins/debugger/cdb/cdboptions.cpp index b26053beee85e7bee742752fb79a10d36a1a5aaa..1740c3a6d7b91ef077d4eed83713e95c63a062e0 100644 --- a/src/plugins/debugger/cdb/cdboptions.cpp +++ b/src/plugins/debugger/cdb/cdboptions.cpp @@ -28,6 +28,7 @@ **************************************************************************/ #include "cdboptions.h" + #include <QtCore/QSettings> #include <QtCore/QDir> #include <QtCore/QFileInfo> diff --git a/src/plugins/debugger/cdb/cdbstacktracecontext.h b/src/plugins/debugger/cdb/cdbstacktracecontext.h index 98e509ad982e99c500342f7ee9332b8add8936ac..b5e041d2c2f1f2b0fa21806aa3d41738148bd1b4 100644 --- a/src/plugins/debugger/cdb/cdbstacktracecontext.h +++ b/src/plugins/debugger/cdb/cdbstacktracecontext.h @@ -73,7 +73,7 @@ public: // Top-Level instruction offset for disassembler ULONG64 instructionOffset() const { return m_instructionOffset; } - CdbStackFrameContext*frameContextAt(int index, QString *errorMessage); + CdbStackFrameContext *frameContextAt(int index, QString *errorMessage); // Format for logging void format(QTextStream &str) const; diff --git a/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp b/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp index 7daba56a587ca91624b298569e391fb6ba727360..47035c5ec4df3d6d2d6834d854017b6ce8f80bdd 100644 --- a/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp +++ b/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp @@ -31,6 +31,7 @@ #include "cdbdebugengine_p.h" #include "watchhandler.h" #include "watchutils.h" + #include <QtCore/QTextStream> enum { debug = 0 }; @@ -40,7 +41,10 @@ static inline QString msgSymbolNotFound(const QString &s) return QString::fromLatin1("The symbol '%1' could not be found.").arg(s); } -static inline bool isTopLevelSymbol(const DEBUG_SYMBOL_PARAMETERS &p) { return p.ParentSymbol == DEBUG_ANY_ID; } +static inline bool isTopLevelSymbol(const DEBUG_SYMBOL_PARAMETERS &p) +{ + return p.ParentSymbol == DEBUG_ANY_ID; +} static inline void debugSymbolFlags(unsigned long f, QTextStream &str) { diff --git a/src/plugins/debugger/cdb/cdbsymbolgroupcontext.h b/src/plugins/debugger/cdb/cdbsymbolgroupcontext.h index 033252e387c989ac561d01073c95a1a38575d26c..ea992e546cfa898093eec84bd3563f0cd5f1d27f 100644 --- a/src/plugins/debugger/cdb/cdbsymbolgroupcontext.h +++ b/src/plugins/debugger/cdb/cdbsymbolgroupcontext.h @@ -130,7 +130,8 @@ private: }; // Helper to a sequence of WatchData into a list. -class WatchDataBackInserter { +class WatchDataBackInserter +{ public: explicit WatchDataBackInserter(QList<WatchData> &wh) : m_wh(wh) {} diff --git a/src/plugins/debugger/win/dbgwinutils.cpp b/src/plugins/debugger/win/dbgwinutils.cpp index 2145f001ad22eb2fb6964c872744168d7530f574..9ef66aa1ad9fac437159631b655002d90fc6a501 100644 --- a/src/plugins/debugger/win/dbgwinutils.cpp +++ b/src/plugins/debugger/win/dbgwinutils.cpp @@ -34,6 +34,7 @@ #ifdef USE_PSAPI # include <psapi.h> #endif + namespace Debugger { namespace Internal { @@ -75,5 +76,5 @@ QList<ProcData> winProcessList() return rc; } -} -} +} // namespace Internal +} // namespace Debugger diff --git a/src/plugins/debugger/win/dbgwinutils.h b/src/plugins/debugger/win/dbgwinutils.h index 1045e822b420396458ea1d3747f6b716421c1378..af16913a8ed33a87468c34a3971b1af543fb172a 100644 --- a/src/plugins/debugger/win/dbgwinutils.h +++ b/src/plugins/debugger/win/dbgwinutils.h @@ -27,8 +27,8 @@ ** **************************************************************************/ -#ifndef _DBG_WINDUTILS_H -#define _DBG_WINDUTILS_H +#ifndef DEBUGGER_DBG_WINUTILS_H +#define DEBUGGER_DBG_WINUTILS_H #include <QtCore/QList> @@ -39,6 +39,7 @@ struct ProcData; // debuggerdialogs, used by the process listing dialogs QList<ProcData> winProcessList(); -} -} -#endif +} // namespace Internal +} // namespace Debugger + +#endif // DEBUGGER_DBG_WINUTILS_H diff --git a/src/plugins/debugger/win/peutils.cpp b/src/plugins/debugger/win/peutils.cpp index 23cabb8bc3bf0a3b04032ee4742e96ebe058a94b..084e511f4688a19878af5a470d53cde01885f157 100644 --- a/src/plugins/debugger/win/peutils.cpp +++ b/src/plugins/debugger/win/peutils.cpp @@ -40,7 +40,7 @@ using Core::Utils::winErrorMessage; // a memory mapped file template <class Ptr> - inline Ptr *makePtr(void *base, ptrdiff_t offset) +inline Ptr *makePtr(void *base, ptrdiff_t offset) { return reinterpret_cast<Ptr*>(static_cast<char*>(base) + offset); } @@ -275,5 +275,5 @@ bool getPDBFiles(const QString &peExecutableFileName, QStringList *rc, QString * return success; } -} -} +} // namespace Internal +} // namespace Debugger diff --git a/src/plugins/debugger/win/peutils.h b/src/plugins/debugger/win/peutils.h index c9885991be903527b0052dfd07fa4c3304dae017..7b4b0061fc9008da733298eb0073390a5c53e8af 100644 --- a/src/plugins/debugger/win/peutils.h +++ b/src/plugins/debugger/win/peutils.h @@ -27,8 +27,8 @@ ** **************************************************************************/ -#ifndef PEUTILS_H -#define PEUTILS_H +#ifndef DEBUGGER_PEUTILS_H +#define DEBUGGER_PEUTILS_H #include <QtCore/qnamespace.h> @@ -45,7 +45,7 @@ namespace Internal { // Return a list of Program-Database (*.pdb) files a PE executable refers to. */ bool getPDBFiles(const QString &peExecutableFileName, QStringList *rc, QString *errorMessage); -} -} +} // namespace Internal +} // namespace Debugger -#endif // PEUTILS_H +#endif // DEBUGGER_PEUTILS_H diff --git a/src/plugins/find/searchresulttreemodel.cpp b/src/plugins/find/searchresulttreemodel.cpp index 68beb2afb8f3ace34b4a9fa0fbd5f25ae9d03962..0afd1fa459ee7a9914eccf1458c8ff810f48d5c0 100644 --- a/src/plugins/find/searchresulttreemodel.cpp +++ b/src/plugins/find/searchresulttreemodel.cpp @@ -255,3 +255,61 @@ void SearchResultTreeModel::clear() m_rootItem->clearChildren(); reset(); } + +QModelIndex SearchResultTreeModel::next(const QModelIndex &idx) const +{ + QModelIndex parent = idx.parent(); + if (parent.isValid()) { + int row = idx.row(); + if (row + 1 < rowCount(parent)) { + // Same parent + return index(row + 1, 0, parent); + } else { + // Next parent + int parentRow = parent.row(); + QModelIndex nextParent; + if (parentRow + 1 < rowCount()) { + nextParent = index(parentRow + 1, 0); + } else { + // Wrap around + nextParent = index(0,0); + } + return nextParent.child(0, 0); + } + } else { + // We are on a top level item + return idx.child(0,0); + } + return QModelIndex(); +} + +QModelIndex SearchResultTreeModel::prev(const QModelIndex &idx) const +{ + QModelIndex parent = idx.parent(); + if (parent.isValid()) { + int row = idx.row(); + if (row > 0) { + // Same parent + return index(row - 1, 0, parent); + } else { + // Prev parent + int parentRow = parent.row(); + QModelIndex prevParent; + if (parentRow > 0 ) { + prevParent = index(parentRow - 1, 0); + } else { + // Wrap around + prevParent = index(rowCount() - 1, 0); + } + return prevParent.child(rowCount(prevParent) - 1, 0); + } + } else { + // We are on a top level item + int row = idx.row(); + if (row > 0) { + QModelIndex prevParent = index(row - 1, 0); + return prevParent.child(rowCount(prevParent) ,0); + } + } + return QModelIndex(); +} diff --git a/src/plugins/find/searchresulttreemodel.h b/src/plugins/find/searchresulttreemodel.h index b4036c0e7b64b91525292d328399100af3ab3957..dacbf9e6b425a59b76e3e383355d287246c26e19 100644 --- a/src/plugins/find/searchresulttreemodel.h +++ b/src/plugins/find/searchresulttreemodel.h @@ -57,6 +57,9 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QModelIndex next(const QModelIndex &idx) const; + QModelIndex prev(const QModelIndex &idx) const; + signals: void jumpToSearchResult(const QString &fileName, int lineNumber, int searchTermStart, int searchTermLength); diff --git a/src/plugins/find/searchresulttreeview.cpp b/src/plugins/find/searchresulttreeview.cpp index b12e3f15885a0f33c8f5833132eb9b2ed7dcaf4e..7b5cc6ca35d44e0eb7e3c315c2901a3fce0631a8 100644 --- a/src/plugins/find/searchresulttreeview.cpp +++ b/src/plugins/find/searchresulttreeview.cpp @@ -99,3 +99,8 @@ void SearchResultTreeView::keyPressEvent(QKeyEvent *e) } QTreeView::keyPressEvent(e); } + +SearchResultTreeModel *SearchResultTreeView::model() const +{ + return m_model; +} diff --git a/src/plugins/find/searchresulttreeview.h b/src/plugins/find/searchresulttreeview.h index 1fcf03599f4d148b2ebe414da3f02d5e45afc1e9..37d137e81581dc9d621da5f3a9c95795b3a0b941 100644 --- a/src/plugins/find/searchresulttreeview.h +++ b/src/plugins/find/searchresulttreeview.h @@ -48,6 +48,8 @@ public: void setAutoExpandResults(bool expand); void setTextEditorFont(const QFont &font); + SearchResultTreeModel *model() const; + signals: void jumpToSearchResult(int index, const QString &fileName, int lineNumber, int searchTermStart, int searchTermLength); @@ -56,8 +58,6 @@ public slots: void clear(); void appendResultLine(int index, const QString &fileName, int lineNumber, const QString &lineText, int searchTermStart, int searchTermLength); - -private slots: void emitJumpToSearchResult(const QModelIndex &index); protected: diff --git a/src/plugins/find/searchresultwindow.cpp b/src/plugins/find/searchresultwindow.cpp index 19c252a417792f8054bd6c7eda754a37f6ea32fe..334bb862d9ceaa1d81a3c64d84483b7b916273ea 100644 --- a/src/plugins/find/searchresultwindow.cpp +++ b/src/plugins/find/searchresultwindow.cpp @@ -35,6 +35,7 @@ #include <QtCore/QFile> #include <QtCore/QTextStream> #include <QtCore/QSettings> +#include <QtCore/QDebug> #include <QtGui/QListWidget> #include <QtGui/QToolButton> @@ -102,6 +103,7 @@ void SearchResultWindow::clearContents() m_searchResultTreeView->clear(); qDeleteAll(m_items); m_items.clear(); + navigateStateChanged(); } void SearchResultWindow::showNoMatchesFound() @@ -160,8 +162,8 @@ ResultWindowItem *SearchResultWindow::addResult(const QString &fileName, int lin // We didn't have an item before, set the focus to the m_searchResultTreeView m_searchResultTreeView->setFocus(); m_searchResultTreeView->selectionModel()->select(m_searchResultTreeView->model()->index(0, 0, QModelIndex()), QItemSelectionModel::Select); + emit navigateStateChanged(); } - return item; } @@ -198,3 +200,39 @@ int SearchResultWindow::priorityInStatusBar() const { return 80; } + +bool SearchResultWindow::canNext() +{ + return m_searchResultTreeView->model()->rowCount(); +} + +bool SearchResultWindow::canPrevious() +{ + return m_searchResultTreeView->model()->rowCount(); +} + +void SearchResultWindow::goToNext() +{ + if (!m_searchResultTreeView->model()->rowCount()) + return; + QModelIndex idx = m_searchResultTreeView->model()->next(m_searchResultTreeView->currentIndex()); + if (idx.isValid()) { + m_searchResultTreeView->setCurrentIndex(idx); + m_searchResultTreeView->emitJumpToSearchResult(idx); + } +} +void SearchResultWindow::goToPrev() +{ + if (!m_searchResultTreeView->model()->rowCount()) + return; + QModelIndex idx = m_searchResultTreeView->model()->prev(m_searchResultTreeView->currentIndex()); + if (idx.isValid()) { + m_searchResultTreeView->setCurrentIndex(idx); + m_searchResultTreeView->emitJumpToSearchResult(idx); + } +} + +bool SearchResultWindow::canNavigate() +{ + return true; +} diff --git a/src/plugins/find/searchresultwindow.h b/src/plugins/find/searchresultwindow.h index da371971cf795910ca7880f139381461512ed3bc..83d4c9f3b1f699f9881f9d4ed70f5506445ff904 100644 --- a/src/plugins/find/searchresultwindow.h +++ b/src/plugins/find/searchresultwindow.h @@ -75,6 +75,12 @@ public: bool canFocus(); void setFocus(); + bool canNext(); + bool canPrevious(); + void goToNext(); + void goToPrev(); + bool canNavigate(); + void setTextEditorFont(const QFont &font); public slots: diff --git a/src/plugins/git/gitoutputwindow.cpp b/src/plugins/git/gitoutputwindow.cpp index 6985b64baeb3d71ca11b7429ef4ea7ee34370802..369df74fcac3c14c22c9ab1669a114644f48e86b 100644 --- a/src/plugins/git/gitoutputwindow.cpp +++ b/src/plugins/git/gitoutputwindow.cpp @@ -117,3 +117,27 @@ int GitOutputWindow::priorityInStatusBar() const { return -1; } + +bool GitOutputWindow::canNext() +{ + return false; +} + +bool GitOutputWindow::canPrevious() +{ + return false; +} + +void GitOutputWindow::goToNext() +{ +} + +void GitOutputWindow::goToPrev() +{ + +} + +bool GitOutputWindow::canNavigate() +{ + return false; +} diff --git a/src/plugins/git/gitoutputwindow.h b/src/plugins/git/gitoutputwindow.h index 8ada72c16be3b3f178d5893ed01118051215b138..81eff4fe66be8d05633edf348ea7880a85e7364d 100644 --- a/src/plugins/git/gitoutputwindow.h +++ b/src/plugins/git/gitoutputwindow.h @@ -59,6 +59,12 @@ public: bool hasFocus(); void setFocus(); + bool canNext(); + bool canPrevious(); + void goToNext(); + void goToPrev(); + bool canNavigate(); + public slots: void setText(const QString &text); void append(const QString &text); diff --git a/src/plugins/perforce/perforceoutputwindow.cpp b/src/plugins/perforce/perforceoutputwindow.cpp index 0ed35c401c77c711520d79f7a745cce4ecf1d459..93cdc5442c9a8074b292f5ccaf2c3ae461980498 100644 --- a/src/plugins/perforce/perforceoutputwindow.cpp +++ b/src/plugins/perforce/perforceoutputwindow.cpp @@ -159,3 +159,28 @@ int PerforceOutputWindow::priorityInStatusBar() const { return -1; } + +bool PerforceOutputWindow::canNext() +{ + return false; +} + +bool PerforceOutputWindow::canPrevious() +{ + return false; +} + +void PerforceOutputWindow::goToNext() +{ + +} + +void PerforceOutputWindow::goToPrev() +{ + +} + +bool PerforceOutputWindow::canNavigate() +{ + return false; +} diff --git a/src/plugins/perforce/perforceoutputwindow.h b/src/plugins/perforce/perforceoutputwindow.h index d88d5b57789648a532cadf3b2c463938c66c5566..da17a5d3f6d4bd598f0cc429d74a2cdf77326d57 100644 --- a/src/plugins/perforce/perforceoutputwindow.h +++ b/src/plugins/perforce/perforceoutputwindow.h @@ -61,6 +61,12 @@ public: bool hasFocus(); void setFocus(); + bool canNext(); + bool canPrevious(); + void goToNext(); + void goToPrev(); + bool canNavigate(); + public slots: void append(const QString &txt, bool doPopup = false); diff --git a/src/plugins/projectexplorer/compileoutputwindow.cpp b/src/plugins/projectexplorer/compileoutputwindow.cpp index 493e6c492dcf6d66b4b44ca418dfb35f23c7f87b..eeab3f133b1ea511c1676c90867b7d8788dcb8b6 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.cpp +++ b/src/plugins/projectexplorer/compileoutputwindow.cpp @@ -93,3 +93,28 @@ int CompileOutputWindow::priorityInStatusBar() const { return 50; } + +bool CompileOutputWindow::canNext() +{ + return false; +} + +bool CompileOutputWindow::canPrevious() +{ + return false; +} + +void CompileOutputWindow::goToNext() +{ + +} + +void CompileOutputWindow::goToPrev() +{ + +} + +bool CompileOutputWindow::canNavigate() +{ + return false; +} diff --git a/src/plugins/projectexplorer/compileoutputwindow.h b/src/plugins/projectexplorer/compileoutputwindow.h index 55a4b988b004c0a35151f8eadafbe3470e4d41dd..f18c9a4b01ef88f7cb333bd82599b30189d11b10 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.h +++ b/src/plugins/projectexplorer/compileoutputwindow.h @@ -57,6 +57,12 @@ public: bool hasFocus(); void setFocus(); + bool canNext(); + bool canPrevious(); + void goToNext(); + void goToPrev(); + bool canNavigate(); + private: QPlainTextEdit *m_textEdit; }; diff --git a/src/plugins/projectexplorer/outputwindow.cpp b/src/plugins/projectexplorer/outputwindow.cpp index 3ead27b6105c43eae5361abdd9f52e01eb0231c8..74adafc2feeaf1a7a12f9867ce3c9925bfd9d881 100644 --- a/src/plugins/projectexplorer/outputwindow.cpp +++ b/src/plugins/projectexplorer/outputwindow.cpp @@ -305,6 +305,30 @@ RunControl* OutputPane::runControlForTab(int index) const return m_outputWindows.key(qobject_cast<OutputWindow *>(m_tabWidget->widget(index))); } +bool OutputPane::canNext() +{ + return false; +} + +bool OutputPane::canPrevious() +{ + return false; +} + +void OutputPane::goToNext() +{ + +} + +void OutputPane::goToPrev() +{ + +} + +bool OutputPane::canNavigate() +{ + return false; +} /*******************/ @@ -350,368 +374,3 @@ void OutputWindow::insertLine() appendPlainText(QString()); } -#if 0 -OutputWindow::OutputWindow(QWidget *parent) - : QAbstractScrollArea(parent) -{ - max_lines = 1000; - width_used = 0; - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - same_height = true; - block_scroll = false; - setWindowTitle(tr("Application Output Window")); - setWindowIcon(QIcon(":/qt4projectmanager/images/window.png")); -} - -void OutputWindow::changed() { - int remove = lines.size() - max_lines; - if (remove > 0) { - selection_start.line -= remove; - selection_end.line -= remove; - selection_start = qMax(selection_start, Selection()); - selection_end = qMax(selection_end, Selection()); - if (remove > verticalScrollBar()->value()) { - if (same_height) - viewport()->scroll(0, -remove * fontMetrics().lineSpacing()); - else - viewport()->update(); - } else { - block_scroll = true; - verticalScrollBar()->setValue(verticalScrollBar()->value() - remove); - block_scroll = false; - } - while (remove--) - lines.removeFirst(); - } - - verticalScrollBar()->setRange(0, lines.size() - 1); - -} - - -bool OutputWindow::getCursorPos(int *lineNumber, int *position, const QPoint &pos) { - if (lines.isEmpty()) - return false; - *lineNumber = verticalScrollBar()->value(); - - int x = 4 - horizontalScrollBar()->value(); - - int spacing = fontMetrics().lineSpacing(); - int leading = fontMetrics().leading(); - int height = 0; - - QTextLayout textLayout; - textLayout.setFont(font()); - - if (same_height && pos.y() > 0) { - int skipLines = pos.y() / spacing; - height += skipLines * spacing; - *lineNumber = qMin(*lineNumber + skipLines, lines.size() - 1); - } - - same_height = true; - - while ( *lineNumber < lines.size()) { - textLayout.setText(lines.at(*lineNumber)); - - textLayout.beginLayout(); - while (1) { - QTextLine line = textLayout.createLine(); - if (!line.isValid()) - break; - line.setLineWidth(INT_MAX/256); - height += leading; - line.setPosition(QPoint(x, height)); - height += static_cast<int>(line.height()); - } - textLayout.endLayout(); - if (height > pos.y()) { - *position = textLayout.lineAt(0).xToCursor(pos.x()); - break; - } - ++*lineNumber; - } - return true; -} - -void OutputWindow::setNumberOfLines(int max) -{ - max_lines = qMax(1, max); - while (lines.size() > max_lines) - lines.removeLast(); - changed(); -} - -int OutputWindow::numberOfLines() const -{ - return max_lines; -} - -bool OutputWindow::hasSelectedText() const -{ - return selection_start != selection_end; -} - -void OutputWindow::clearSelection() -{ - bool hadSelectedText = hasSelectedText(); - selection_start = selection_end = Selection(); - if (hadSelectedText) - viewport()->update(); -} - -QString OutputWindow::selectedText() const -{ - Selection sel_start = qMin(selection_start, selection_end); - Selection sel_end = qMax(selection_start, selection_end); - QString text; - - if (sel_start.line == sel_end.line) { - text += lines.at(sel_start.line).mid(sel_start.pos, sel_end.pos - sel_start.pos); - } else { - int line = sel_start.line; - text += lines.at(line++).mid(sel_start.pos); - text += QLatin1Char('\n'); - while (line < sel_end.line) { - text += lines.at(line++); - text += QLatin1Char('\n'); - } - text += lines.at(sel_end.line).left(sel_end.pos); - } - return text; -} - -void OutputWindow::appendOutput(const QString &text) -{ - lines.append(text); - if (same_height) - viewport()->update( - QRect(0, (lines.size() - verticalScrollBar()->value() - 1) * fontMetrics().lineSpacing(), - viewport()->width(), viewport()->height())); - else - viewport()->update(); - - changed(); - int top = lines.size() - (viewport()->height() / fontMetrics().lineSpacing()); - if (verticalScrollBar()->value() == top - 1) - verticalScrollBar()->setValue(top); -} - -void OutputWindow::clear() -{ - clearSelection(); - lines.clear(); - viewport()->update(); -} - -void OutputWindow::copy() -{ - if (hasSelectedText()) - QApplication::clipboard()->setText(selectedText()); -} - -void OutputWindow::selectAll() -{ - selection_start = Selection(); - selection_end.line = lines.size() - 1; - selection_end.pos = lines.last().length() - 1; - viewport()->update(); -} - -void OutputWindow::scrollContentsBy(int dx, int dy) -{ - if (block_scroll) - return; - if (dx && dy) { - viewport()->update(); - } else if (dx && !dy) { - viewport()->scroll(dx, 0); - } else { - if (same_height) { - viewport()->scroll(0, fontMetrics().lineSpacing() * dy); - } else { - viewport()->update(); - } - } -} - -void OutputWindow::keyPressEvent(QKeyEvent *e) -{ - bool accept = true; - if (e == QKeySequence::Copy) { - copy(); - } else if (e == QKeySequence::SelectAll) { - selectAll(); - } else if (e->key() == Qt::Key_Enter - || e->key() == Qt::Key_Return) { - insertLine(); - } else { - accept = false; - } - - if (accept) - e->accept(); - else - QAbstractScrollArea::keyPressEvent(e); -} - -void OutputWindow::paintEvent(QPaintEvent *e) -{ - int lineNumber = verticalScrollBar()->value(); - - int x = 4 - horizontalScrollBar()->value(); - QPainter p(viewport()); - - int spacing = fontMetrics().lineSpacing(); - int leading = fontMetrics().leading(); - int height = 0; - - QTextLayout textLayout; - textLayout.setFont(font()); - - QTextCharFormat selectionFormat; - selectionFormat.setBackground(palette().highlight()); - selectionFormat.setForeground(palette().highlightedText()); - - if (e->rect().top() <= 0 && e->rect().bottom() >= viewport()->rect().bottom()) - width_used = 0; // recalculate - - if (same_height) { - int skipLines = e->rect().top() / spacing; - height += skipLines * spacing; - lineNumber += skipLines; - } - - same_height = true; - - Selection sel_start = qMin(selection_start, selection_end); - Selection sel_end = qMax(selection_start, selection_end); - - while ( lineNumber < lines.size() && height <= e->rect().bottom()) { - - QString line = lines.at(lineNumber); - - if (line.size() == 1 && line.at(0) == QChar::ParagraphSeparator) { - int y = height + spacing/2; - p.drawLine(e->rect().left(), y, e->rect().right(), y); - height += spacing; - - } else { - textLayout.setText(line); - textLayout.beginLayout(); - while (1) { - QTextLine line = textLayout.createLine(); - if (!line.isValid()) - break; - line.setLineWidth(INT_MAX/256); - height += leading; - line.setPosition(QPoint(x, height)); - height += static_cast<int>(line.height()); - - same_height = same_height && (line.height() + leading) == spacing; - width_used = qMax(width_used, 8 + static_cast<int>(line.naturalTextWidth())); - } - textLayout.endLayout(); - - if (lineNumber >= sel_start.line && lineNumber <= sel_end.line) { - QVector<QTextLayout::FormatRange> selection(1); - selection[0].start = (lineNumber == sel_start.line)? sel_start.pos : 0; - selection[0].length = ((lineNumber == sel_end.line) ? sel_end.pos : lines.at(lineNumber).size()) - selection[0].start; - selection[0].format = selectionFormat; - - textLayout.draw(&p, QPoint(0, 0), selection); - } else { - textLayout.draw(&p, QPoint(0, 0)); - } - } - - - ++lineNumber; - } - - horizontalScrollBar()->setRange(0, qMax(0, width_used - viewport()->width())); - if (horizontalScrollBar()->pageStep() != viewport()->width()) - horizontalScrollBar()->setPageStep(viewport()->width()); - if (height > viewport()->height()) - verticalScrollBar()->setPageStep(lineNumber - verticalScrollBar()->value()); - else if (verticalScrollBar()->pageStep() != viewport()->height() / fontMetrics().lineSpacing()) - verticalScrollBar()->setPageStep(viewport()->height() / fontMetrics().lineSpacing()); -} - -void OutputWindow::mousePressEvent(QMouseEvent *e) -{ - if (e->button() == Qt::LeftButton) { - clearSelection(); - if (getCursorPos(&selection_start.line, &selection_start.pos, e->pos())) { - selection_end = selection_start; - autoscroll = 0; - } - } -} - -void OutputWindow::timerEvent(QTimerEvent *e) -{ - if (e->timerId() == autoscroll_timer.timerId()) { - int autoscroll = 0; - if (lastMouseMove.y() < 0) - autoscroll = -1; - else if (lastMouseMove.y() > viewport()->height()) - autoscroll = 1; - if (autoscroll) { - verticalScrollBar()->setValue(verticalScrollBar()->value() + autoscroll); - OutputWindow::mouseMoveEvent(0); - } - } - QAbstractScrollArea::timerEvent(e); -} - -void OutputWindow::mouseReleaseEvent(QMouseEvent *e) -{ - if (e->button() == Qt::LeftButton) { - autoscroll_timer.stop(); - if (hasSelectedText() && QApplication::clipboard()->supportsSelection()) - QApplication::clipboard()->setText(selectedText(), QClipboard::Selection); - } -} - -void OutputWindow::mouseMoveEvent(QMouseEvent *e) -{ - if (e) { - lastMouseMove = e->pos(); - if (viewport()->rect().contains(e->pos())) - autoscroll_timer.stop(); - else - autoscroll_timer.start(20, this); - } - - - Selection old = selection_end; - if (!getCursorPos(&selection_end.line, &selection_end.pos, lastMouseMove)) - return; - if (same_height) { - Selection from = qMin(old, selection_end); - Selection to = qMax(old, selection_end); - viewport()->update(QRect(0, -1 + (from.line - verticalScrollBar()->value()) * fontMetrics().lineSpacing(), - viewport()->width(), 2 + (to.line - from.line + 1) * fontMetrics().lineSpacing())); - } else { - viewport()->update(); - } -} - -void OutputWindow::contextMenuEvent(QContextMenuEvent * e) -{ - QMenu menu(this); - QAction *clearAction = menu.addAction("Clear", this, SLOT(clear())); - QAction *copyAction = menu.addAction("Copy", this, SLOT(copy()), QKeySequence::Copy); - QAction *selectAllAction = menu.addAction("Select All", this, SLOT(selectAll()), QKeySequence::SelectAll); - if (lines.empty()) { - clearAction->setDisabled(true); - selectAllAction->setDisabled(true); - } - if (!hasSelectedText()) - copyAction->setDisabled(true); - - menu.exec(e->globalPos()); -} - -#endif // 0 diff --git a/src/plugins/projectexplorer/outputwindow.h b/src/plugins/projectexplorer/outputwindow.h index 7542269bfc54559ef1b597b891c0128c1aceeb2c..225ae4a3080bbe898c22325b1294c768f5236ca6 100644 --- a/src/plugins/projectexplorer/outputwindow.h +++ b/src/plugins/projectexplorer/outputwindow.h @@ -70,6 +70,12 @@ public: bool hasFocus(); void setFocus(); + bool canNext(); + bool canPrevious(); + void goToNext(); + void goToPrev(); + bool canNavigate(); + void appendOutput(const QString &out); // ApplicationOutputspecifics diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index e3a431be859ce486e440645beded58ddac472940..2af18a03b788ec6b7da545717c3fddf3329983fc 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -319,6 +319,7 @@ void TaskWindow::clearContents() m_model->clear(); m_copyAction->setEnabled(false); emit tasksChanged(); + navigateStateChanged(); } void TaskWindow::visibilityChanged(bool /* b */) @@ -333,6 +334,8 @@ void TaskWindow::addItem(ProjectExplorer::BuildParserInterface::PatternType type ++m_errorCount; m_copyAction->setEnabled(true); emit tasksChanged(); + if (m_model->rowCount() == 1) + navigateStateChanged(); } void TaskWindow::showTaskInFile(const QModelIndex &index) @@ -406,8 +409,6 @@ bool TaskWindow::canFocus() return m_model->rowCount(); } -#include <QDebug> - void TaskWindow::setFocus() { if (m_model->rowCount()) { @@ -418,6 +419,55 @@ void TaskWindow::setFocus() } } +bool TaskWindow::canNext() +{ + return m_model->rowCount(); +} + +bool TaskWindow::canPrevious() +{ + return m_model->rowCount(); +} + +void TaskWindow::goToNext() +{ + if (!m_model->rowCount()) + return; + QModelIndex currentIndex = m_listview->currentIndex(); + if (currentIndex.isValid()) { + int row = currentIndex.row() + 1; + if (row == m_model->rowCount()) + row = 0; + currentIndex = m_model->index(row, 0); + } else { + currentIndex = m_model->index(0, 0); + } + m_listview->setCurrentIndex(currentIndex); + showTaskInFile(currentIndex); +} + +void TaskWindow::goToPrev() +{ + if (!m_model->rowCount()) + return; + QModelIndex currentIndex = m_listview->currentIndex(); + if (currentIndex.isValid()) { + int row = currentIndex.row() -1; + if (row < 0) + row = m_model->rowCount() - 1; + currentIndex = m_model->index(row, 0); + } else { + currentIndex = m_model->index(m_model->rowCount()-1, 0); + } + m_listview->setCurrentIndex(currentIndex); + showTaskInFile(currentIndex); +} + +bool TaskWindow::canNavigate() +{ + return true; +} + ///// // Delegate ///// diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h index fffd6904e77cebc86de0ec6ed4f24b4d17d6c01b..862fa7dbceeed21e2662dd082f3b2cbc36b9711d 100644 --- a/src/plugins/projectexplorer/taskwindow.h +++ b/src/plugins/projectexplorer/taskwindow.h @@ -74,6 +74,12 @@ public: bool hasFocus(); void setFocus(); + bool canNext(); + bool canPrevious(); + void goToNext(); + void goToPrev(); + bool canNavigate(); + signals: void tasksChanged(); diff --git a/src/plugins/subversion/subversionoutputwindow.cpp b/src/plugins/subversion/subversionoutputwindow.cpp index 387c88f3f331d725957ea9ba34344f2c1f0f5dc1..e7191bd1c9c56a095105184f5746f771564ec357 100644 --- a/src/plugins/subversion/subversionoutputwindow.cpp +++ b/src/plugins/subversion/subversionoutputwindow.cpp @@ -100,3 +100,28 @@ bool SubversionOutputWindow::hasFocus() void SubversionOutputWindow::setFocus() { } + +bool SubversionOutputWindow::canNext() +{ + return false; +} + +bool SubversionOutputWindow::canPrevious() +{ + return false; +} + +void SubversionOutputWindow::goToNext() +{ + +} + +void SubversionOutputWindow::goToPrev() +{ + +} + +bool SubversionOutputWindow::canNavigate() +{ + return false; +} diff --git a/src/plugins/subversion/subversionoutputwindow.h b/src/plugins/subversion/subversionoutputwindow.h index fc5b76eec46310347f8de6b35ca662b458e2d104..35c22423b11d5c725d0a031ec86e628e167528ba 100644 --- a/src/plugins/subversion/subversionoutputwindow.h +++ b/src/plugins/subversion/subversionoutputwindow.h @@ -59,9 +59,15 @@ public: int priorityInStatusBar() const; void visibilityChanged(bool visible); - virtual bool canFocus(); - virtual bool hasFocus(); - virtual void setFocus(); + bool canFocus(); + bool hasFocus(); + void setFocus(); + + bool canNext(); + bool canPrevious(); + void goToNext(); + void goToPrev(); + bool canNavigate(); public slots: void append(const QString &txt, bool popup = false);