Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
aa41af8c
Commit
aa41af8c
authored
15 years ago
by
Tobias Hunger
Browse files
Options
Downloads
Patches
Plain Diff
Use task handlers in taskwindow
Reviewed-by: dt
parent
18178718
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/projectexplorer/taskwindow.cpp
+72
-79
72 additions, 79 deletions
src/plugins/projectexplorer/taskwindow.cpp
src/plugins/projectexplorer/taskwindow.h
+4
-4
4 additions, 4 deletions
src/plugins/projectexplorer/taskwindow.h
with
76 additions
and
83 deletions
src/plugins/projectexplorer/taskwindow.cpp
+
72
−
79
View file @
aa41af8c
...
@@ -29,18 +29,17 @@
...
@@ -29,18 +29,17 @@
#include
"taskwindow.h"
#include
"taskwindow.h"
#include
"itaskhandler.h"
#include
"projectexplorerconstants.h"
#include
"task.h"
#include
"task.h"
#include
<coreplugin/actionmanager/actionmanager.h>
#include
<coreplugin/actionmanager/actionmanager.h>
#include
<coreplugin/actionmanager/command.h>
#include
<coreplugin/coreconstants.h>
#include
<coreplugin/coreconstants.h>
#include
<coreplugin/vcsmanager.h>
#include
<coreplugin/icontext.h>
#include
<coreplugin/iversioncontrol.h>
#include
<coreplugin/editormanager/editormanager.h>
#include
<coreplugin/icore.h>
#include
<coreplugin/icore.h>
#include
<coreplugin/uniqueidmanager.h>
#include
<coreplugin/uniqueidmanager.h>
#include
<coreplugin/actionmanager/command.h>
#include
<extensionsystem/pluginmanager.h>
#include
<texteditor/basetexteditor.h>
#include
<texteditor/itexteditor.h>
#include
<QtCore/QDir>
#include
<QtCore/QDir>
#include
<QtCore/QFileInfo>
#include
<QtCore/QFileInfo>
...
@@ -485,8 +484,9 @@ public:
...
@@ -485,8 +484,9 @@ public:
Internal
::
TaskFilterModel
*
m_filter
;
Internal
::
TaskFilterModel
*
m_filter
;
Internal
::
TaskView
*
m_listview
;
Internal
::
TaskView
*
m_listview
;
Internal
::
TaskWindowContext
*
m_taskWindowContext
;
Internal
::
TaskWindowContext
*
m_taskWindowContext
;
QAction
*
m_copyAction
;
QMenu
*
m_contextMenu
;
QAction
*
m_vcsAnnotateAction
;
QModelIndex
m_contextMenuIndex
;
ITaskHandler
*
m_defaultHandler
;
QToolButton
*
m_filterWarningsButton
;
QToolButton
*
m_filterWarningsButton
;
QToolButton
*
m_categoriesButton
;
QToolButton
*
m_categoriesButton
;
QMenu
*
m_categoriesMenu
;
QMenu
*
m_categoriesMenu
;
...
@@ -508,7 +508,7 @@ static QToolButton *createFilterButton(QIcon icon, const QString &toolTip,
...
@@ -508,7 +508,7 @@ static QToolButton *createFilterButton(QIcon icon, const QString &toolTip,
TaskWindow
::
TaskWindow
()
:
d
(
new
TaskWindowPrivate
)
TaskWindow
::
TaskWindow
()
:
d
(
new
TaskWindowPrivate
)
{
{
Core
::
ICore
*
core
=
Core
::
ICore
::
instance
()
;
d
->
m_defaultHandler
=
0
;
d
->
m_model
=
new
Internal
::
TaskModel
;
d
->
m_model
=
new
Internal
::
TaskModel
;
d
->
m_filter
=
new
Internal
::
TaskFilterModel
(
d
->
m_model
);
d
->
m_filter
=
new
Internal
::
TaskFilterModel
(
d
->
m_model
);
...
@@ -525,31 +525,24 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate)
...
@@ -525,31 +525,24 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate)
d
->
m_listview
->
setAttribute
(
Qt
::
WA_MacShowFocusRect
,
false
);
d
->
m_listview
->
setAttribute
(
Qt
::
WA_MacShowFocusRect
,
false
);
d
->
m_taskWindowContext
=
new
Internal
::
TaskWindowContext
(
d
->
m_listview
);
d
->
m_taskWindowContext
=
new
Internal
::
TaskWindowContext
(
d
->
m_listview
);
core
->
addContextObject
(
d
->
m_taskWindowContext
);
Core
::
ICore
::
instance
()
->
addContextObject
(
d
->
m_taskWindowContext
);
d
->
m_copyAction
=
new
QAction
(
QIcon
(
Core
::
Constants
::
ICON_COPY
),
tr
(
"&Copy"
),
this
);
Core
::
Command
*
command
=
core
->
actionManager
()
->
registerAction
(
d
->
m_copyAction
,
Core
::
Constants
::
COPY
,
d
->
m_taskWindowContext
->
context
());
d
->
m_listview
->
addAction
(
command
->
action
());
connect
(
d
->
m_copyAction
,
SIGNAL
(
triggered
()),
SLOT
(
copy
()));
// Annotate using VCS: Make visible in all contexts
d
->
m_vcsAnnotateAction
=
new
QAction
(
tr
(
"&Annotate"
),
this
);
d
->
m_vcsAnnotateAction
->
setToolTip
(
"Annotate using version control system"
);
QList
<
int
>
annotateContext
=
d
->
m_taskWindowContext
->
context
();
annotateContext
<<
Core
::
ICore
::
instance
()
->
uniqueIDManager
()
->
uniqueIdentifier
(
QLatin1String
(
Core
::
Constants
::
C_GLOBAL
));
command
=
core
->
actionManager
()
->
registerAction
(
d
->
m_vcsAnnotateAction
,
QLatin1String
(
"ProjectExplorer.Task.VCS_Annotate"
),
annotateContext
);
d
->
m_listview
->
addAction
(
command
->
action
());
connect
(
d
->
m_vcsAnnotateAction
,
SIGNAL
(
triggered
()),
SLOT
(
vcsAnnotate
()));
connect
(
d
->
m_listview
->
selectionModel
(),
SIGNAL
(
currentChanged
(
QModelIndex
,
QModelIndex
)),
connect
(
d
->
m_listview
->
selectionModel
(),
SIGNAL
(
currentChanged
(
QModelIndex
,
QModelIndex
)),
tld
,
SLOT
(
currentChanged
(
QModelIndex
,
QModelIndex
)));
tld
,
SLOT
(
currentChanged
(
QModelIndex
,
QModelIndex
)));
connect
(
d
->
m_listview
,
SIGNAL
(
activated
(
QModelIndex
)),
connect
(
d
->
m_listview
,
SIGNAL
(
activated
(
QModelIndex
)),
this
,
SLOT
(
showTaskInFi
le
(
QModelIndex
)));
this
,
SLOT
(
triggerDefaultHand
le
r
(
QModelIndex
)));
connect
(
d
->
m_listview
,
SIGNAL
(
clicked
(
QModelIndex
)),
connect
(
d
->
m_listview
,
SIGNAL
(
clicked
(
QModelIndex
)),
this
,
SLOT
(
showTaskInFile
(
QModelIndex
)));
this
,
SLOT
(
triggerDefaultHandler
(
QModelIndex
)));
d
->
m_contextMenu
=
new
QMenu
(
d
->
m_listview
);
connect
(
d
->
m_contextMenu
,
SIGNAL
(
triggered
(
QAction
*
)),
this
,
SLOT
(
contextMenuEntryTriggered
(
QAction
*
)));
d
->
m_listview
->
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
connect
(
d
->
m_listview
,
SIGNAL
(
customContextMenuRequested
(
QPoint
)),
this
,
SLOT
(
showContextMenu
(
QPoint
)));
d
->
m_filterWarningsButton
=
createFilterButton
(
taskTypeIcon
(
Task
::
Warning
),
d
->
m_filterWarningsButton
=
createFilterButton
(
taskTypeIcon
(
Task
::
Warning
),
tr
(
"Show Warnings"
),
tr
(
"Show Warnings"
),
...
@@ -568,13 +561,12 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate)
...
@@ -568,13 +561,12 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate)
qRegisterMetaType
<
ProjectExplorer
::
Task
>
(
"ProjectExplorer::Task"
);
qRegisterMetaType
<
ProjectExplorer
::
Task
>
(
"ProjectExplorer::Task"
);
qRegisterMetaType
<
QList
<
ProjectExplorer
::
Task
>
>
(
"QList<ProjectExplorer::Task>"
);
qRegisterMetaType
<
QList
<
ProjectExplorer
::
Task
>
>
(
"QList<ProjectExplorer::Task>"
);
updateActions
();
}
}
TaskWindow
::~
TaskWindow
()
TaskWindow
::~
TaskWindow
()
{
{
Core
::
ICore
::
instance
()
->
removeContextObject
(
d
->
m_taskWindowContext
);
Core
::
ICore
::
instance
()
->
removeContextObject
(
d
->
m_taskWindowContext
);
cleanContextMenu
();
delete
d
->
m_filterWarningsButton
;
delete
d
->
m_filterWarningsButton
;
delete
d
->
m_listview
;
delete
d
->
m_listview
;
delete
d
->
m_filter
;
delete
d
->
m_filter
;
...
@@ -596,7 +588,6 @@ void TaskWindow::clearTasks(const QString &categoryId)
...
@@ -596,7 +588,6 @@ void TaskWindow::clearTasks(const QString &categoryId)
{
{
d
->
m_model
->
clearTasks
(
categoryId
);
d
->
m_model
->
clearTasks
(
categoryId
);
updateActions
();
emit
tasksChanged
();
emit
tasksChanged
();
navigateStateChanged
();
navigateStateChanged
();
}
}
...
@@ -615,7 +606,6 @@ void TaskWindow::addTask(const Task &task)
...
@@ -615,7 +606,6 @@ void TaskWindow::addTask(const Task &task)
{
{
d
->
m_model
->
addTask
(
task
);
d
->
m_model
->
addTask
(
task
);
updateActions
();
emit
tasksChanged
();
emit
tasksChanged
();
navigateStateChanged
();
navigateStateChanged
();
}
}
...
@@ -624,65 +614,73 @@ void TaskWindow::removeTask(const Task &task)
...
@@ -624,65 +614,73 @@ void TaskWindow::removeTask(const Task &task)
{
{
d
->
m_model
->
removeTask
(
task
);
d
->
m_model
->
removeTask
(
task
);
updateActions
();
emit
tasksChanged
();
emit
tasksChanged
();
navigateStateChanged
();
navigateStateChanged
();
}
}
void
TaskWindow
::
showTaskInFi
le
(
const
QModelIndex
&
index
)
void
TaskWindow
::
triggerDefaultHand
le
r
(
const
QModelIndex
&
index
)
{
{
if
(
!
index
.
isValid
())
if
(
!
index
.
isValid
())
return
;
return
;
QString
file
=
index
.
data
(
Internal
::
TaskModel
::
File
).
toString
();
int
line
=
index
.
data
(
Internal
::
TaskModel
::
Line
).
toInt
();
if
(
file
.
isEmpty
()
||
line
==
-
1
)
return
;
QFileInfo
fi
(
file
);
// Find a default handler to use:
if
(
fi
.
exists
())
{
if
(
!
d
->
m_defaultHandler
)
{
TextEditor
::
BaseTextEditor
::
openEditorAt
(
fi
.
canonicalFilePath
(),
line
);
QList
<
ITaskHandler
*>
handlers
=
ExtensionSystem
::
PluginManager
::
instance
()
->
getObjects
<
ITaskHandler
>
();
Core
::
EditorManager
::
instance
()
->
ensureEditorManagerVisible
();
foreach
(
ITaskHandler
*
handler
,
handlers
)
{
if
(
handler
->
id
()
==
QLatin1String
(
Constants
::
SHOW_TASK_IN_EDITOR
))
{
d
->
m_defaultHandler
=
handler
;
break
;
}
}
}
Q_ASSERT
(
d
->
m_defaultHandler
);
Task
task
(
index
.
data
(
Internal
::
TaskModel
::
Task_t
).
value
<
Task
>
());
if
(
d
->
m_defaultHandler
->
canHandle
(
task
))
{
d
->
m_defaultHandler
->
handle
(
task
);
}
else
{
if
(
!
QFileInfo
(
task
.
file
).
exists
())
d
->
m_model
->
setFileNotFound
(
index
,
true
);
}
}
else
d
->
m_model
->
setFileNotFound
(
index
,
true
);
d
->
m_listview
->
selectionModel
()
->
setCurrentIndex
(
index
,
QItemSelectionModel
::
Select
);
d
->
m_listview
->
selectionModel
()
->
select
(
index
,
QItemSelectionModel
::
ClearAndSelect
);
}
}
// Right-click VCS annotate: Find version control and point it to line
void
TaskWindow
::
showContextMenu
(
const
QPoint
&
position
)
void
TaskWindow
::
vcsAnnotate
()
{
{
const
QModelIndex
index
=
d
->
m_listview
->
selectionModel
()
->
currentIndex
(
);
QModelIndex
index
=
d
->
m_listview
->
indexAt
(
position
);
if
(
!
index
.
isValid
())
if
(
!
index
.
isValid
())
return
;
return
;
const
QString
file
=
index
.
data
(
Internal
::
TaskModel
::
File
).
toString
();
d
->
m_contextMenuIndex
=
index
;
const
int
line
=
index
.
data
(
Internal
::
TaskModel
::
Line
).
toInt
();
cleanContextMenu
();
const
QFileInfo
fi
(
file
);
if
(
fi
.
exists
())
Task
task
=
index
.
data
(
Internal
::
TaskModel
::
Task_t
).
value
<
Task
>
();
if
(
Core
::
IVersionControl
*
vc
=
Core
::
ICore
::
instance
()
->
vcsManager
()
->
findVersionControlForDirectory
(
fi
.
absolutePath
()))
if
(
vc
->
supportsOperation
(
Core
::
IVersionControl
::
AnnotateOperation
))
QList
<
ITaskHandler
*>
handlers
=
ExtensionSystem
::
PluginManager
::
instance
()
->
getObjects
<
ITaskHandler
>
();
vc
->
vcsAnnotate
(
fi
.
absoluteFilePath
(),
line
);
foreach
(
ITaskHandler
*
handler
,
handlers
)
{
if
(
handler
==
d
->
m_defaultHandler
)
continue
;
QAction
*
action
=
handler
->
createAction
(
d
->
m_contextMenu
);
action
->
setEnabled
(
handler
->
canHandle
(
task
));
action
->
setData
(
qVariantFromValue
(
qobject_cast
<
QObject
*>
(
handler
)));
d
->
m_contextMenu
->
addAction
(
action
);
}
d
->
m_contextMenu
->
popup
(
d
->
m_listview
->
mapToGlobal
(
position
));
}
}
void
TaskWindow
::
co
py
(
)
void
TaskWindow
::
co
ntextMenuEntryTriggered
(
QAction
*
action
)
{
{
const
QModelIndex
index
=
d
->
m_listview
->
selectionModel
()
->
currentIndex
();
if
(
action
->
isEnabled
())
{
if
(
!
index
.
isValid
())
Task
task
=
d
->
m_contextMenuIndex
.
data
(
Internal
::
TaskModel
::
Task_t
).
value
<
Task
>
();
return
;
ITaskHandler
*
handler
=
qobject_cast
<
ITaskHandler
*>
(
action
->
data
().
value
<
QObject
*>
());
const
QString
file
=
index
.
data
(
Internal
::
TaskModel
::
File
).
toString
();
if
(
!
handler
)
const
QString
line
=
index
.
data
(
Internal
::
TaskModel
::
Line
).
toString
();
return
;
const
QString
description
=
index
.
data
(
Internal
::
TaskModel
::
Description
).
toString
();
handler
->
handle
(
task
);
QString
type
;
switch
(
index
.
data
(
Internal
::
TaskModel
::
Type
).
toInt
())
{
case
Task
::
Error
:
type
=
"error: "
;
break
;
case
Task
::
Warning
:
type
=
"warning: "
;
break
;
}
}
}
QApplication
::
clipboard
()
->
setText
(
file
+
':'
+
line
+
": "
+
type
+
description
);
void
TaskWindow
::
cleanContextMenu
()
{
QList
<
QAction
*>
actions
=
d
->
m_contextMenu
->
actions
();
qDeleteAll
(
actions
);
d
->
m_contextMenu
->
clear
();
}
}
void
TaskWindow
::
setShowWarnings
(
bool
show
)
void
TaskWindow
::
setShowWarnings
(
bool
show
)
...
@@ -791,7 +789,7 @@ void TaskWindow::goToNext()
...
@@ -791,7 +789,7 @@ void TaskWindow::goToNext()
currentIndex
=
d
->
m_filter
->
index
(
0
,
0
);
currentIndex
=
d
->
m_filter
->
index
(
0
,
0
);
}
}
d
->
m_listview
->
setCurrentIndex
(
currentIndex
);
d
->
m_listview
->
setCurrentIndex
(
currentIndex
);
showTaskInFi
le
(
currentIndex
);
triggerDefaultHand
le
r
(
currentIndex
);
}
}
void
TaskWindow
::
goToPrev
()
void
TaskWindow
::
goToPrev
()
...
@@ -808,7 +806,7 @@ void TaskWindow::goToPrev()
...
@@ -808,7 +806,7 @@ void TaskWindow::goToPrev()
currentIndex
=
d
->
m_filter
->
index
(
d
->
m_filter
->
rowCount
()
-
1
,
0
);
currentIndex
=
d
->
m_filter
->
index
(
d
->
m_filter
->
rowCount
()
-
1
,
0
);
}
}
d
->
m_listview
->
setCurrentIndex
(
currentIndex
);
d
->
m_listview
->
setCurrentIndex
(
currentIndex
);
showTaskInFi
le
(
currentIndex
);
triggerDefaultHand
le
r
(
currentIndex
);
}
}
bool
TaskWindow
::
canNavigate
()
bool
TaskWindow
::
canNavigate
()
...
@@ -816,11 +814,6 @@ bool TaskWindow::canNavigate()
...
@@ -816,11 +814,6 @@ bool TaskWindow::canNavigate()
return
true
;
return
true
;
}
}
void
TaskWindow
::
updateActions
()
{
d
->
m_copyAction
->
setEnabled
(
d
->
m_model
->
tasks
().
count
()
>
0
);
}
QIcon
TaskWindow
::
taskTypeIcon
(
int
t
)
const
QIcon
TaskWindow
::
taskTypeIcon
(
int
t
)
const
{
{
return
d
->
m_model
->
taskTypeIcon
(
static_cast
<
Task
::
TaskType
>
(
t
));
return
d
->
m_model
->
taskTypeIcon
(
static_cast
<
Task
::
TaskType
>
(
t
));
...
...
This diff is collapsed.
Click to expand it.
src/plugins/projectexplorer/taskwindow.h
+
4
−
4
View file @
aa41af8c
...
@@ -88,15 +88,15 @@ signals:
...
@@ -88,15 +88,15 @@ signals:
void
tasksChanged
();
void
tasksChanged
();
private
slots
:
private
slots
:
void
showTaskInFi
le
(
const
QModelIndex
&
index
);
void
triggerDefaultHand
le
r
(
const
QModelIndex
&
index
);
void
copy
(
);
void
showContextMenu
(
const
QPoint
&
position
);
void
vcsAnnotate
(
);
void
contextMenuEntryTriggered
(
QAction
*
);
void
setShowWarnings
(
bool
);
void
setShowWarnings
(
bool
);
void
updateCategoriesMenu
();
void
updateCategoriesMenu
();
void
filterCategoryTriggered
(
QAction
*
action
);
void
filterCategoryTriggered
(
QAction
*
action
);
private
:
private
:
void
updateActions
();
void
cleanContextMenu
();
int
sizeHintForColumn
(
int
column
)
const
;
int
sizeHintForColumn
(
int
column
)
const
;
TaskWindowPrivate
*
d
;
TaskWindowPrivate
*
d
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment