ProjectExplorer: Rename Task::addMark to setMark and make it private

Make TaskHub a friend of Task so that it can still use the method. This
should stop anyone from accidentally calling that.

Change-Id: I36974d0ba874f0cac59b7c57ed667ce2e75e1d4c
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2016-04-11 13:27:42 +02:00
parent 95ac4edfd4
commit 3bc96dad90
3 changed files with 11 additions and 4 deletions

View File

@@ -83,10 +83,10 @@ Task Task::buildConfigurationMissingTask()
Constants::TASK_CATEGORY_BUILDSYSTEM); Constants::TASK_CATEGORY_BUILDSYSTEM);
} }
void Task::addMark(TextEditor::TextMark *mark) void Task::setMark(TextEditor::TextMark *mark)
{ {
QTC_ASSERT(mark, return);
QTC_ASSERT(m_mark.isNull(), return); QTC_ASSERT(m_mark.isNull(), return);
m_mark = QSharedPointer<TextEditor::TextMark>(mark); m_mark = QSharedPointer<TextEditor::TextMark>(mark);
} }

View File

@@ -37,6 +37,8 @@
namespace ProjectExplorer { namespace ProjectExplorer {
class TaskHub;
// Documentation inside. // Documentation inside.
class PROJECTEXPLORER_EXPORT Task class PROJECTEXPLORER_EXPORT Task
{ {
@@ -66,7 +68,6 @@ public:
int movedLine = -1; // contains a line number if the line was moved in the editor int movedLine = -1; // contains a line number if the line was moved in the editor
Core::Id category; Core::Id category;
QIcon icon; QIcon icon;
void addMark(TextEditor::TextMark *mark);
// Having a QList<QTextLayout::FormatRange> in Task isn't that great // Having a QList<QTextLayout::FormatRange> in Task isn't that great
// It would be cleaner to split up the text into // It would be cleaner to split up the text into
@@ -79,8 +80,12 @@ public:
QList<QTextLayout::FormatRange> formats; QList<QTextLayout::FormatRange> formats;
private: private:
void setMark(TextEditor::TextMark *mark);
QSharedPointer<TextEditor::TextMark> m_mark; QSharedPointer<TextEditor::TextMark> m_mark;
static unsigned int s_nextId; static unsigned int s_nextId;
friend class TaskHub;
}; };
bool PROJECTEXPLORER_EXPORT operator==(const Task &t1, const Task &t2); bool PROJECTEXPLORER_EXPORT operator==(const Task &t1, const Task &t2);

View File

@@ -134,6 +134,8 @@ void TaskHub::addTask(Task task)
{ {
QTC_ASSERT(m_registeredCategories.contains(task.category), return); QTC_ASSERT(m_registeredCategories.contains(task.category), return);
QTC_ASSERT(!task.description.isEmpty(), return); QTC_ASSERT(!task.description.isEmpty(), return);
QTC_ASSERT(!task.isNull(), return);
QTC_ASSERT(task.m_mark.isNull(), return);
if (task.file.isEmpty()) if (task.file.isEmpty())
task.line = -1; task.line = -1;
@@ -146,7 +148,7 @@ void TaskHub::addTask(Task task)
auto mark = new TaskMark(task.taskId, task.file.toString(), task.line, task.type, !task.icon.isNull()); auto mark = new TaskMark(task.taskId, task.file.toString(), task.line, task.type, !task.icon.isNull());
mark->setIcon(task.icon); mark->setIcon(task.icon);
mark->setPriority(TextEditor::TextMark::LowPriority); mark->setPriority(TextEditor::TextMark::LowPriority);
task.addMark(mark); task.setMark(mark);
} }
emit m_instance->taskAdded(task); emit m_instance->taskAdded(task);
} }