forked from qt-creator/qt-creator
Todo: Spread use of Utils::FilePath a bit
Change-Id: I0c6caacad76740dfc23e7a0be40ead776e1d5253 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Todo {
|
namespace Todo {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -90,7 +91,7 @@ void TodoItemsProvider::updateList()
|
|||||||
// Show only items of the current file if any
|
// Show only items of the current file if any
|
||||||
if (m_settings.scanningScope == ScanningScopeCurrentFile) {
|
if (m_settings.scanningScope == ScanningScopeCurrentFile) {
|
||||||
if (m_currentEditor)
|
if (m_currentEditor)
|
||||||
m_itemsList = m_itemsHash.value(m_currentEditor->document()->filePath().toString());
|
m_itemsList = m_itemsHash.value(m_currentEditor->document()->filePath());
|
||||||
// Show only items of the current sub-project
|
// Show only items of the current sub-project
|
||||||
} else if (m_settings.scanningScope == ScanningScopeSubProject) {
|
} else if (m_settings.scanningScope == ScanningScopeSubProject) {
|
||||||
if (m_startupProject)
|
if (m_startupProject)
|
||||||
@@ -121,21 +122,19 @@ void TodoItemsProvider::createScanners()
|
|||||||
|
|
||||||
void TodoItemsProvider::setItemsListWithinStartupProject()
|
void TodoItemsProvider::setItemsListWithinStartupProject()
|
||||||
{
|
{
|
||||||
QHashIterator<QString, QList<TodoItem> > it(m_itemsHash);
|
QHashIterator<FilePath, QList<TodoItem> > it(m_itemsHash);
|
||||||
const QSet<QString> fileNames
|
const auto filePaths = QSet<FilePath>::fromList(m_startupProject->files(Project::SourceFiles));
|
||||||
= QSet<QString>::fromList(Utils::transform(m_startupProject->files(Project::SourceFiles),
|
|
||||||
&Utils::FilePath::toString));
|
|
||||||
|
|
||||||
QVariantMap settings = m_startupProject->namedSettings(Constants::SETTINGS_NAME_KEY).toMap();
|
QVariantMap settings = m_startupProject->namedSettings(Constants::SETTINGS_NAME_KEY).toMap();
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
QString fileName = it.key();
|
const FilePath filePath = it.key();
|
||||||
if (fileNames.contains(fileName)) {
|
if (filePaths.contains(filePath)) {
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
for (const QVariant &pattern : settings[Constants::EXCLUDES_LIST_KEY].toList()) {
|
for (const QVariant &pattern : settings[Constants::EXCLUDES_LIST_KEY].toList()) {
|
||||||
QRegExp re(pattern.toString());
|
QRegExp re(pattern.toString());
|
||||||
if (re.indexIn(fileName) != -1) {
|
if (re.indexIn(filePath.toString()) != -1) {
|
||||||
skip = true;
|
skip = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -154,31 +153,28 @@ void TodoItemsProvider::setItemsListWithinSubproject()
|
|||||||
ProjectNode *projectNode = node->parentProjectNode();
|
ProjectNode *projectNode = node->parentProjectNode();
|
||||||
if (projectNode) {
|
if (projectNode) {
|
||||||
// FIXME: The name doesn't match the implementation that lists all files.
|
// FIXME: The name doesn't match the implementation that lists all files.
|
||||||
QSet<Utils::FilePath> subprojectFileNames;
|
QSet<FilePath> subprojectFileNames;
|
||||||
projectNode->forEachGenericNode([&](Node *node) {
|
projectNode->forEachGenericNode([&](Node *node) {
|
||||||
subprojectFileNames.insert(node->filePath());
|
subprojectFileNames.insert(node->filePath());
|
||||||
});
|
});
|
||||||
|
|
||||||
// files must be both in the current subproject and the startup-project.
|
// files must be both in the current subproject and the startup-project.
|
||||||
const QSet<QString> fileNames
|
const auto fileNames
|
||||||
= QSet<QString>::fromList(Utils::transform(m_startupProject->files(Project::SourceFiles),
|
= QSet<FilePath>::fromList(m_startupProject->files(Project::SourceFiles));
|
||||||
&Utils::FilePath::toString));
|
QHashIterator<FilePath, QList<TodoItem> > it(m_itemsHash);
|
||||||
QHashIterator<QString, QList<TodoItem> > it(m_itemsHash);
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
if (subprojectFileNames.contains(Utils::FilePath::fromString(it.key()))
|
if (subprojectFileNames.contains(it.key()) && fileNames.contains(it.key()))
|
||||||
&& fileNames.contains(it.key())) {
|
|
||||||
m_itemsList << it.value();
|
m_itemsList << it.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void TodoItemsProvider::itemsFetched(const QString &fileName, const QList<TodoItem> &items)
|
void TodoItemsProvider::itemsFetched(const QString &fileName, const QList<TodoItem> &items)
|
||||||
{
|
{
|
||||||
// Replace old items with new ones
|
// Replace old items with new ones
|
||||||
m_itemsHash.insert(fileName, items);
|
m_itemsHash.insert(FilePath::fromString(fileName), items);
|
||||||
|
|
||||||
m_shouldUpdateList = true;
|
m_shouldUpdateList = true;
|
||||||
}
|
}
|
||||||
|
@@ -60,7 +60,7 @@ private:
|
|||||||
TodoItemsModel *m_itemsModel;
|
TodoItemsModel *m_itemsModel;
|
||||||
|
|
||||||
// All to-do items are stored here regardless current scanning scope
|
// All to-do items are stored here regardless current scanning scope
|
||||||
QHash<QString, QList<TodoItem> > m_itemsHash;
|
QHash<Utils::FilePath, QList<TodoItem> > m_itemsHash;
|
||||||
|
|
||||||
// This list contains only those to-do items that are within current scanning scope
|
// This list contains only those to-do items that are within current scanning scope
|
||||||
QList<TodoItem> m_itemsList;
|
QList<TodoItem> m_itemsList;
|
||||||
|
Reference in New Issue
Block a user