Hi,

attached is a patch that adds a shortcut to move to the next Task in the 
TaskList (using F6 currently). 

Details:
--------
The only thing to discuss here is the way TaskModel::nextTask() works. I have 
added two different implementations: one simple version which simply moves to 
the next task, and one more sophisticated implementation which first cycles 
through all errors, then through the warnings and finally through the unknown 
types. 

Most of the time my task list looks like the following:
[info about the next error]
[another info about the next error]
[*first error*]
[yet another info about the next error]
[*another error*]
[info about the previous error]
[...]

In most cases only the errors are important for me. Maybe another good 
implementation would be to always jump to the next error, if there is one, 
otherwise jump to the next non-error item. What do you think?

I use to hang out on #qt-creator (choenig) if you're looking for me.
I'd be happy to get some feedback or ideas for further improvements :-).

thanks and
take care, have fun
/christian





From c698d470a1021e348ac2695df91818eaa61ccc64 Mon Sep 17 00:00:00 2001
From: Christian Hoenig <[email protected]>
Date: Sat, 28 Mar 2009 09:29:38 +0100
Subject: [PATCH] Goto next task with F6

---
 src/plugins/projectexplorer/buildmanager.cpp       |    6 +++
 src/plugins/projectexplorer/buildmanager.h         |    1 +
 src/plugins/projectexplorer/projectexplorer.cpp    |   12 +++++
 src/plugins/projectexplorer/projectexplorer.h      |    2 +
 .../projectexplorer/projectexplorerconstants.h     |    1 +
 src/plugins/projectexplorer/taskwindow.cpp         |   48 ++++++++++++++++++++
 src/plugins/projectexplorer/taskwindow.h           |    1 +
 7 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp
index 2852147..d7b66a2 100644
--- a/src/plugins/projectexplorer/buildmanager.cpp
+++ b/src/plugins/projectexplorer/buildmanager.cpp
@@ -176,6 +176,12 @@ void BuildManager::gotoTaskWindow()
     m_taskWindow->popup(true);
 }
 
+void BuildManager::gotoNextTask()
+{
+    m_taskWindow->popup(false);
+    m_taskWindow->gotoNextTask();
+}
+
 void BuildManager::startBuildQueue()
 {
     if (!m_running) {
diff --git a/src/plugins/projectexplorer/buildmanager.h b/src/plugins/projectexplorer/buildmanager.h
index 5129269..7f84edd 100644
--- a/src/plugins/projectexplorer/buildmanager.h
+++ b/src/plugins/projectexplorer/buildmanager.h
@@ -70,6 +70,7 @@ public:
     bool tasksAvailable() const;
     //shows with focus
     void gotoTaskWindow();
+    void gotoNextTask();
 
     void buildProject(Project *p, const QString &configuration);
     void buildProjects(const QList<Project *> &projects, const QList<QString> &configurations);
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index af22896..2082b08 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -558,6 +558,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
     // FIXME: Eike, look here! cmd->setDefaultKeySequence(QKeySequence(tr("F9")));
     mbuild->addAction(cmd, Constants::G_BUILD_TASK);
 
+    // jump to next task
+    m_nextTaskAction = new QAction(tr("Go to next Task"), this);
+    cmd = am->registerAction(m_nextTaskAction, Constants::GOTONEXTTASK, globalcontext);
+    cmd->setDefaultKeySequence(QKeySequence(tr("F6")));
+    mbuild->addAction(cmd, Constants::G_BUILD_TASK);
+
     // cancel build action
     m_cancelBuildAction = new QAction(tr("Cancel Build"), this);
     cmd = am->registerAction(m_cancelBuildAction, Constants::CANCELBUILD, globalcontext);
@@ -658,6 +664,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
     connect(m_unloadAction, SIGNAL(triggered()), this, SLOT(unloadProject()));
     connect(m_clearSession, SIGNAL(triggered()), this, SLOT(clearSession()));
     connect(m_taskAction, SIGNAL(triggered()), this, SLOT(goToTaskWindow()));
+    connect(m_nextTaskAction, SIGNAL(triggered()), this, SLOT(goToNextTask()));
     connect(m_addNewFileAction, SIGNAL(triggered()), this, SLOT(addNewFile()));
     connect(m_addExistingFilesAction, SIGNAL(triggered()), this, SLOT(addExistingFiles()));
     connect(m_openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
@@ -1601,6 +1608,11 @@ void ProjectExplorerPlugin::goToTaskWindow()
     m_buildManager->gotoTaskWindow();
 }
 
+void ProjectExplorerPlugin::goToNextTask()
+{
+    m_buildManager->gotoNextTask();
+}
+
 void ProjectExplorerPlugin::updateContextMenuActions()
 {
     if (ProjectNode *projectNode = qobject_cast<ProjectNode*>(m_currentNode)) {
diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h
index b18545a..08c27ef 100644
--- a/src/plugins/projectexplorer/projectexplorer.h
+++ b/src/plugins/projectexplorer/projectexplorer.h
@@ -155,6 +155,7 @@ private slots:
     void runProjectContextMenu();
     void savePersistentSettings();
     void goToTaskWindow();
+    void goToNextTask();
 
     void updateContextMenuActions();
     void addNewFile();
@@ -228,6 +229,7 @@ private:
     QAction *m_cancelBuildAction;
     QAction *m_debugAction;
     QAction *m_taskAction;
+    QAction *m_nextTaskAction;
     QAction *m_addNewFileAction;
     QAction *m_addExistingFilesAction;
     QAction *m_openFileAction;
diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h
index 0a749cc..a9638b2 100644
--- a/src/plugins/projectexplorer/projectexplorerconstants.h
+++ b/src/plugins/projectexplorer/projectexplorerconstants.h
@@ -59,6 +59,7 @@ const char * const DEBUG                = "ProjectExplorer.Debug";
 const char * const DEPENDENCIES         = "ProjectExplorer.Dependencies";
 const char * const FINDINALLPROJECTS    = "ProjectExplorer.FindInAllProjects";
 const char * const GOTOTASKWINDOW       = "ProjectExplorer.GoToTaskWindow";
+const char * const GOTONEXTTASK         = "ProjectExplorer.GoToNextTask";
 const char * const SHOWPROPERTIES       = "ProjectExplorer.ShowProperties";
 const char * const ADDNEWFILE           = "ProjectExplorer.AddNewFile";
 const char * const ADDEXISTINGFILES     = "ProjectExplorer.AddExistingFiles";
diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp
index e3a431b..f83ea81 100644
--- a/src/plugins/projectexplorer/taskwindow.cpp
+++ b/src/plugins/projectexplorer/taskwindow.cpp
@@ -80,6 +80,7 @@ public:
     int sizeOfFile();
     int sizeOfLineNumber();
     QModelIndex firstError() const;
+    QModelIndex nextTask(const QModelIndex & previousSelected) const;
     void setFileNotFound(const QModelIndex &index, bool b);
 
     enum Roles { File = Qt::UserRole, Line, Description, FileNotFound, Type };
@@ -244,6 +245,46 @@ QModelIndex TaskModel::firstError() const
     return QModelIndex();
 }
 
+QModelIndex TaskModel::nextTask(const QModelIndex & previousSelected) const
+{
+//    BEGIN == THIS IS THE SIMPLE VERSION =====================================================
+//    int rowOfNextTask = previousSelected.isValid() ? previousSelected.row()+1 : 0;
+//    if (rowOfNextTask < m_items.size()) {
+//        return index(rowOfNextTask, 0);
+//    }
+//
+//    return QModelIndex();
+//    END ==== THIS IS THE SIMPLE VERSION =====================================================
+
+    int previousType = ProjectExplorer::BuildParserInterface::Error;
+    int nextRow = 0;
+
+    if (previousSelected.isValid() && previousSelected.row() < m_items.size()) {
+        nextRow = previousSelected.row() + 1;
+        previousType = m_items[nextRow - 1].type;
+    };
+
+    // try to find the next task of same type, then try to find the next task of
+    const int size = m_items.size();
+    forever {
+        for (int i=nextRow; i<size; ++i) {
+            if (m_items.at(i).type == previousType) {
+                return index(i, 0);
+            }
+        }
+
+        // restart at the beginning
+        nextRow = 0;
+
+        // 'downgrade' previousType
+        if (previousType > ProjectExplorer::BuildParserInterface::Unknown) {
+            --previousType;
+        } else {
+            return QModelIndex();
+        }
+    }
+}
+
 void TaskModel::setFileNotFound(const QModelIndex &idx, bool b)
 {
     if (idx.isValid() && idx.row() < m_items.size()) {
@@ -396,6 +437,13 @@ void TaskWindow::gotoFirstError()
         showTaskInFile(idx);
 }
 
+void TaskWindow::gotoNextTask()
+{
+    QModelIndex idx = m_model->nextTask(m_listview->currentIndex());
+    if (idx.isValid())
+        showTaskInFile(idx);
+}
+
 bool TaskWindow::hasFocus()
 {
     return m_listview->hasFocus();
diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h
index fffd690..46cb191 100644
--- a/src/plugins/projectexplorer/taskwindow.h
+++ b/src/plugins/projectexplorer/taskwindow.h
@@ -70,6 +70,7 @@ public:
     int numberOfErrors() const;
 
     void gotoFirstError();
+    void gotoNextTask();
     bool canFocus();
     bool hasFocus();
     void setFocus();
-- 
1.6.0.6

_______________________________________________
Qt-creator mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-creator

Reply via email to