forked from qt-creator/qt-creator
Make TaskMarks clickable and jump to the right task in the taskwindow
That means it is no longer possible to make bookmarks on lines with errors or warnings by simply clicking. That's not nice. It might be better to do something different, but let's see how the feedback to this is. Change-Id: I34788ff638ed49c21001d03cd60f992ffabd6153 Reviewed-by: hjk <qthjk@ovi.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -45,6 +45,9 @@ public:
|
|||||||
: BaseTextMark(fileName, lineNumber), m_id(id), m_visible(visible)
|
: BaseTextMark(fileName, lineNumber), m_id(id), m_visible(visible)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
bool clickable() const;
|
||||||
|
void clicked();
|
||||||
|
|
||||||
void updateLineNumber(int lineNumber);
|
void updateLineNumber(int lineNumber);
|
||||||
void removedFromEditor();
|
void removedFromEditor();
|
||||||
bool visible() const;
|
bool visible() const;
|
||||||
@@ -69,6 +72,16 @@ bool TaskMark::visible() const
|
|||||||
return m_visible;
|
return m_visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TaskMark::clickable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskMark::clicked()
|
||||||
|
{
|
||||||
|
ProjectExplorerPlugin::instance()->taskHub()->taskMarkClicked(m_id);
|
||||||
|
}
|
||||||
|
|
||||||
TaskHub::TaskHub()
|
TaskHub::TaskHub()
|
||||||
: m_errorIcon(QLatin1String(":/projectexplorer/images/compile_error.png")),
|
: m_errorIcon(QLatin1String(":/projectexplorer/images/compile_error.png")),
|
||||||
m_warningIcon(QLatin1String(":/projectexplorer/images/compile_warning.png"))
|
m_warningIcon(QLatin1String(":/projectexplorer/images/compile_warning.png"))
|
||||||
@@ -114,6 +127,11 @@ void TaskHub::updateTaskLineNumber(unsigned int id, int line)
|
|||||||
emit taskLineNumberUpdated(id, line);
|
emit taskLineNumberUpdated(id, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaskHub::taskMarkClicked(unsigned int id)
|
||||||
|
{
|
||||||
|
emit showTask(id);
|
||||||
|
}
|
||||||
|
|
||||||
void TaskHub::setCategoryVisibility(const Core::Id &categoryId, bool visible)
|
void TaskHub::setCategoryVisibility(const Core::Id &categoryId, bool visible)
|
||||||
{
|
{
|
||||||
emit categoryVisibilityChanged(categoryId, visible);
|
emit categoryVisibilityChanged(categoryId, visible);
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public:
|
|||||||
void clearTasks(const Core::Id &categoryId = Core::Id());
|
void clearTasks(const Core::Id &categoryId = Core::Id());
|
||||||
void removeTask(const Task &task);
|
void removeTask(const Task &task);
|
||||||
void updateTaskLineNumber(unsigned int id, int line);
|
void updateTaskLineNumber(unsigned int id, int line);
|
||||||
|
void taskMarkClicked(unsigned int id);
|
||||||
void setCategoryVisibility(const Core::Id &categoryId, bool visible);
|
void setCategoryVisibility(const Core::Id &categoryId, bool visible);
|
||||||
|
|
||||||
void popup(bool withFocus);
|
void popup(bool withFocus);
|
||||||
@@ -67,6 +68,7 @@ signals:
|
|||||||
void taskLineNumberUpdated(unsigned int id, int line);
|
void taskLineNumberUpdated(unsigned int id, int line);
|
||||||
void categoryVisibilityChanged(const Core::Id &categoryId, bool visible);
|
void categoryVisibilityChanged(const Core::Id &categoryId, bool visible);
|
||||||
void popupRequested(bool withFocus);
|
void popupRequested(bool withFocus);
|
||||||
|
void showTask(unsigned int id);
|
||||||
private:
|
private:
|
||||||
const QIcon m_errorIcon;
|
const QIcon m_errorIcon;
|
||||||
const QIcon m_warningIcon;
|
const QIcon m_warningIcon;
|
||||||
|
|||||||
@@ -148,11 +148,18 @@ void TaskModel::removeTask(const Task &task)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TaskModel::rowForId(unsigned int id)
|
||||||
|
{
|
||||||
|
QList<Task>::const_iterator it = qLowerBound(m_tasks.constBegin(), m_tasks.constEnd(), id, sortById);
|
||||||
|
if (it == m_tasks.constEnd())
|
||||||
|
return -1;
|
||||||
|
return it - m_tasks.constBegin();
|
||||||
|
}
|
||||||
|
|
||||||
void TaskModel::updateTaskLineNumber(unsigned int id, int line)
|
void TaskModel::updateTaskLineNumber(unsigned int id, int line)
|
||||||
{
|
{
|
||||||
QList<Task>::iterator it = qLowerBound(m_tasks.begin(), m_tasks.end(), id, sortById);
|
int i = rowForId(id);
|
||||||
QTC_ASSERT(it != m_tasks.end(), return)
|
QTC_ASSERT(i != -1, return)
|
||||||
int i = it - m_tasks.begin();
|
|
||||||
if (m_tasks.at(i).taskId == id) {
|
if (m_tasks.at(i).taskId == id) {
|
||||||
m_tasks[i].movedLine = line;
|
m_tasks[i].movedLine = line;
|
||||||
emit dataChanged(index(i, 0), index(i, 0));
|
emit dataChanged(index(i, 0), index(i, 0));
|
||||||
@@ -444,6 +451,15 @@ void TaskFilterModel::handleReset()
|
|||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QModelIndex TaskFilterModel::mapFromSource(const QModelIndex &idx) const
|
||||||
|
{
|
||||||
|
updateMapping();
|
||||||
|
QList<int>::const_iterator it = qBinaryFind(m_mapping.constBegin(), m_mapping.constEnd(), idx.row());
|
||||||
|
if (it == m_mapping.constEnd())
|
||||||
|
return QModelIndex();
|
||||||
|
return index(it - m_mapping.constBegin(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
QModelIndex TaskFilterModel::mapToSource(const QModelIndex &index) const
|
QModelIndex TaskFilterModel::mapToSource(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
updateMapping();
|
updateMapping();
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ public:
|
|||||||
|
|
||||||
bool hasFile(const QModelIndex &index) const;
|
bool hasFile(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
int rowForId(unsigned int id);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
class CategoryData
|
class CategoryData
|
||||||
@@ -161,6 +162,7 @@ public:
|
|||||||
bool hasFile(const QModelIndex &index) const
|
bool hasFile(const QModelIndex &index) const
|
||||||
{ return m_sourceModel->hasFile(mapToSource(index)); }
|
{ return m_sourceModel->hasFile(mapToSource(index)); }
|
||||||
|
|
||||||
|
QModelIndex mapFromSource(const QModelIndex &idx) const;
|
||||||
private slots:
|
private slots:
|
||||||
void handleNewRows(const QModelIndex &index, int first, int last);
|
void handleNewRows(const QModelIndex &index, int first, int last);
|
||||||
void handleRemovedRows(const QModelIndex &index, int first, int last);
|
void handleRemovedRows(const QModelIndex &index, int first, int last);
|
||||||
|
|||||||
@@ -304,6 +304,8 @@ TaskWindow::TaskWindow(TaskHub *taskhub) : d(new TaskWindowPrivate)
|
|||||||
this, SLOT(setCategoryVisibility(Core::Id,bool)));
|
this, SLOT(setCategoryVisibility(Core::Id,bool)));
|
||||||
connect(d->m_taskHub, SIGNAL(popupRequested(bool)),
|
connect(d->m_taskHub, SIGNAL(popupRequested(bool)),
|
||||||
this, SLOT(popup(bool)));
|
this, SLOT(popup(bool)));
|
||||||
|
connect(d->m_taskHub, SIGNAL(showTask(uint)),
|
||||||
|
this, SLOT(showTask(uint)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskWindow::~TaskWindow()
|
TaskWindow::~TaskWindow()
|
||||||
@@ -388,6 +390,14 @@ void TaskWindow::updatedTaskLineNumber(unsigned int id, int line)
|
|||||||
emit tasksChanged();
|
emit tasksChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaskWindow::showTask(unsigned int id)
|
||||||
|
{
|
||||||
|
int sourceRow = d->m_model->rowForId(id);
|
||||||
|
QModelIndex sourceIdx = d->m_model->index(sourceRow, 0);
|
||||||
|
QModelIndex filterIdx = d->m_filter->mapFromSource(sourceIdx);
|
||||||
|
d->m_listview->setCurrentIndex(filterIdx);
|
||||||
|
}
|
||||||
|
|
||||||
void TaskWindow::triggerDefaultHandler(const QModelIndex &index)
|
void TaskWindow::triggerDefaultHandler(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ private slots:
|
|||||||
void addTask(const ProjectExplorer::Task &task);
|
void addTask(const ProjectExplorer::Task &task);
|
||||||
void removeTask(const ProjectExplorer::Task &task);
|
void removeTask(const ProjectExplorer::Task &task);
|
||||||
void updatedTaskLineNumber(unsigned int id, int line);
|
void updatedTaskLineNumber(unsigned int id, int line);
|
||||||
|
void showTask(unsigned int id);
|
||||||
void clearTasks(const Core::Id &categoryId);
|
void clearTasks(const Core::Id &categoryId);
|
||||||
void setCategoryVisibility(const Core::Id &categoryId, bool visible);
|
void setCategoryVisibility(const Core::Id &categoryId, bool visible);
|
||||||
|
|
||||||
|
|||||||
@@ -4443,12 +4443,22 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
|||||||
int n = d->extraAreaToggleMarkBlockNumber;
|
int n = d->extraAreaToggleMarkBlockNumber;
|
||||||
d->extraAreaToggleMarkBlockNumber = -1;
|
d->extraAreaToggleMarkBlockNumber = -1;
|
||||||
if (cursor.blockNumber() == n) {
|
if (cursor.blockNumber() == n) {
|
||||||
|
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(cursor.block().userData())) {
|
||||||
|
foreach (ITextMark *mark, data->marks()) {
|
||||||
|
if (mark->clickable()) {
|
||||||
|
mark->clicked();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int line = n + 1;
|
int line = n + 1;
|
||||||
ITextEditor::MarkRequestKind kind;
|
ITextEditor::MarkRequestKind kind;
|
||||||
if (QApplication::keyboardModifiers() & Qt::ShiftModifier)
|
if (QApplication::keyboardModifiers() & Qt::ShiftModifier)
|
||||||
kind = ITextEditor::BookmarkRequest;
|
kind = ITextEditor::BookmarkRequest;
|
||||||
else
|
else
|
||||||
kind = ITextEditor::BreakpointRequest;
|
kind = ITextEditor::BreakpointRequest;
|
||||||
|
|
||||||
emit editor()->markRequested(editor(), line, kind);
|
emit editor()->markRequested(editor(), line, kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ public:
|
|||||||
|
|
||||||
enum MarkRequestKind {
|
enum MarkRequestKind {
|
||||||
BreakpointRequest,
|
BreakpointRequest,
|
||||||
BookmarkRequest
|
BookmarkRequest,
|
||||||
|
TaskMarkRequest
|
||||||
};
|
};
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@@ -84,3 +84,11 @@ double ITextMark::widthFactor() const
|
|||||||
{
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ITextMark::clickable() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ITextMark::clicked()
|
||||||
|
{}
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ public:
|
|||||||
void setPriority(Priority prioriy);
|
void setPriority(Priority prioriy);
|
||||||
virtual bool visible() const;
|
virtual bool visible() const;
|
||||||
virtual double widthFactor() const;
|
virtual double widthFactor() const;
|
||||||
|
virtual bool clickable() const;
|
||||||
|
virtual void clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_lineNumber;
|
int m_lineNumber;
|
||||||
|
|||||||
Reference in New Issue
Block a user