logic: reduce access to filesystem while indexing

* use canonical filepath cache in cxx indexer
* made constructors of FilePath explicit
* use FilePath at more places instead of string
* forward declares FilePath wherever possible
This commit is contained in:
malte_langkabel
2017-05-04 10:55:16 +02:00
parent 55d3f9c189
commit 054b8fab17
156 changed files with 656 additions and 444 deletions
+5 -5
View File
@@ -31,7 +31,7 @@ void QtAbout::setupAbout()
"}"
);
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "about/about.css").c_str());
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("about/about.css"))).c_str());
QVBoxLayout* windowLayout = new QVBoxLayout();
windowLayout->setContentsMargins(10, 10, 10, 0);
@@ -45,7 +45,7 @@ void QtAbout::setupAbout()
QVBoxLayout* column = new QVBoxLayout();
row->addLayout(column);
QtDeviceScaledPixmap sourcetrailLogo((ResourcePaths::getGuiPath() + "about/logo_sourcetrail.png").c_str());
QtDeviceScaledPixmap sourcetrailLogo((ResourcePaths::getGuiPath().str() + "about/logo_sourcetrail.png").c_str());
sourcetrailLogo.scaleToHeight(150);
QLabel* sourcetrailLogoLabel = new QLabel(this);
sourcetrailLogoLabel->setPixmap(sourcetrailLogo.pixmap());
@@ -59,7 +59,7 @@ void QtAbout::setupAbout()
QVBoxLayout* column = new QVBoxLayout();
row->addLayout(column);
QtDeviceScaledPixmap closePixmap((ResourcePaths::getGuiPath() + "about/icon_close.png").c_str());
QtDeviceScaledPixmap closePixmap((ResourcePaths::getGuiPath().str() + "about/icon_close.png").c_str());
closePixmap.scaleToHeight(20);
QPushButton* closeButton = new QPushButton(this);
closeButton->setIcon(QIcon(closePixmap.pixmap()));
@@ -139,14 +139,14 @@ void QtAbout::setupAbout()
QHBoxLayout* rowAcknowledgementsLogos = new QHBoxLayout();
column->addLayout(rowAcknowledgementsLogos);
QtDeviceScaledPixmap fhsLogo((ResourcePaths::getGuiPath() + "about/logo_fhs.png").c_str());
QtDeviceScaledPixmap fhsLogo((ResourcePaths::getGuiPath().str() + "about/logo_fhs.png").c_str());
fhsLogo.scaleToHeight(30);
QLabel* fhsLabel = new QLabel(this);
fhsLabel->setPixmap(fhsLogo.pixmap());
fhsLabel->resize(fhsLogo.width(), fhsLogo.height());
rowAcknowledgementsLogos->addWidget(fhsLabel);
QtDeviceScaledPixmap awsLogo((ResourcePaths::getGuiPath() + "about/logo_aws.png").c_str());
QtDeviceScaledPixmap awsLogo((ResourcePaths::getGuiPath().str() + "about/logo_aws.png").c_str());
awsLogo.scaleToHeight(30);
QLabel* awsLabel = new QLabel(this);
awsLabel->setPixmap(awsLogo.pixmap());
+2 -2
View File
@@ -24,8 +24,8 @@ QtBookmarkBrowser::~QtBookmarkBrowser()
void QtBookmarkBrowser::setupBookmarkBrowser()
{
setStyleSheet((
utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css") +
utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css")
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))) +
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("bookmark_view/bookmark_view.css")))
).c_str());
m_headerBackground = new QWidget(m_window);
+2 -2
View File
@@ -113,8 +113,8 @@ void QtBookmarkCreator::setupBookmarkCreator()
void QtBookmarkCreator::refreshStyle()
{
setStyleSheet((
utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css") +
utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css")
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))) +
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("bookmark_view/bookmark_view.css")))
).c_str());
}
+4 -4
View File
@@ -340,8 +340,8 @@ QBoxLayout* QtIndexingDialog::createLayout()
);
setStyleSheet((
utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css") +
utility::getStyleSheet(ResourcePaths::getGuiPath() + "indexing_dialog/indexing_dialog.css")
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))) +
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("indexing_dialog/indexing_dialog.css")))
).c_str());
QVBoxLayout* layout = new QVBoxLayout(this);
@@ -419,7 +419,7 @@ void QtIndexingDialog::addErrorLabel(QBoxLayout* layout)
m_errorLabel->setObjectName("errorCount");
m_errorLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
std::string text = ResourcePaths::getGuiPath() + "indexing_dialog/error.png";
std::string text = ResourcePaths::getGuiPath().str() + "indexing_dialog/error.png";
m_errorLabel->setIcon(QPixmap(text.c_str()));
layout->addWidget(m_errorLabel, 0, Qt::AlignRight);
@@ -448,7 +448,7 @@ void QtIndexingDialog::addButtons(QBoxLayout* layout)
void QtIndexingDialog::addFlag()
{
QtDeviceScaledPixmap flag((ResourcePaths::getGuiPath() + "indexing_dialog/flag.png").c_str());
QtDeviceScaledPixmap flag((ResourcePaths::getGuiPath().str() + "indexing_dialog/flag.png").c_str());
flag.scaleToWidth(120);
QLabel* flagLabel = new QLabel(this);
@@ -72,7 +72,7 @@ void QtKeyboardShortcuts::populateWindow(QWidget* widget)
widget->setLayout(layout);
widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "keyboard_shortcuts/keyboard_shortcuts.css").c_str());
widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("keyboard_shortcuts/keyboard_shortcuts.css"))).c_str());
}
void QtKeyboardShortcuts::windowReady()
+1 -2
View File
@@ -7,7 +7,6 @@
#include "LicenseChecker.h"
#include "qt/utility/utilityQt.h"
#include "utility/file/FilePath.h"
#include "utility/ResourcePaths.h"
QtLicense::QtLicense(QWidget *parent)
@@ -121,7 +120,7 @@ void QtLicense::populateWindow(QWidget* widget)
void QtLicense::windowReady()
{
m_content->setStyleSheet(m_content->styleSheet() + utility::getStyleSheet(ResourcePaths::getGuiPath() + "license/license.css").c_str());
m_content->setStyleSheet(m_content->styleSheet() + utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("license/license.css"))).c_str());
addLogo();
+11 -11
View File
@@ -102,13 +102,13 @@ QtMainWindow::QtMainWindow()
setCentralWidget(nullptr);
setDockNestingEnabled(true);
setWindowIcon(QIcon((ResourcePaths::getGuiPath() + "icon/logo_1024_1024.png").c_str()));
setWindowIcon(QIcon((ResourcePaths::getGuiPath().str() + "icon/logo_1024_1024.png").c_str()));
setWindowFlags(Qt::Widget);
QApplication* app = dynamic_cast<QApplication*>(QCoreApplication::instance());
app->installEventFilter(new MouseReleaseFilter(this));
app->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "main.css").c_str());
app->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("main.css"))).c_str());
m_recentProjectAction = new QAction*[ApplicationSettings::getInstance()->getMaxRecentProjectsCount()];
@@ -187,7 +187,7 @@ void QtMainWindow::hideView(View* view)
void QtMainWindow::loadLayout()
{
QSettings settings(UserPaths::getWindowSettingsPath().c_str(), QSettings::IniFormat);
QSettings settings(UserPaths::getWindowSettingsPath().str().c_str(), QSettings::IniFormat);
settings.beginGroup("MainWindow");
resize(settings.value("size", QSize(600, 400)).toSize());
@@ -203,7 +203,7 @@ void QtMainWindow::loadLayout()
void QtMainWindow::loadDockWidgetLayout()
{
QSettings settings(UserPaths::getWindowSettingsPath().c_str(), QSettings::IniFormat);
QSettings settings(UserPaths::getWindowSettingsPath().str().c_str(), QSettings::IniFormat);
this->restoreState(settings.value("DOCK_LOCATIONS").toByteArray());
for (DockWidget dock : m_dockWidgets)
@@ -215,7 +215,7 @@ void QtMainWindow::loadDockWidgetLayout()
void QtMainWindow::saveLayout()
{
QSettings settings(UserPaths::getWindowSettingsPath().c_str(), QSettings::IniFormat);
QSettings settings(UserPaths::getWindowSettingsPath().str().c_str(), QSettings::IniFormat);
settings.beginGroup("MainWindow");
settings.setValue("maximized", isMaximized());
@@ -362,12 +362,12 @@ void QtMainWindow::enteredLicense()
void QtMainWindow::showDataFolder()
{
QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getUserDataPath()).c_str(), QUrl::TolerantMode));
QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getUserDataPath().str()).c_str(), QUrl::TolerantMode));
}
void QtMainWindow::showLogFolder()
{
QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getLogPath()).c_str(), QUrl::TolerantMode));
QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getLogPath().str()).c_str(), QUrl::TolerantMode));
}
void QtMainWindow::showStartScreen()
@@ -416,7 +416,7 @@ void QtMainWindow::newProject()
void QtMainWindow::newProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
{
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
wizzard->newProjectFromSolution(ideId, solutionPath);
wizzard->newProjectFromSolution(ideId, FilePath(solutionPath));
}
void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths)
@@ -438,7 +438,7 @@ void QtMainWindow::openProject()
if (!fileName.isEmpty())
{
MessageLoadProject(fileName.toStdString(), false).dispatch();
MessageLoadProject(FilePath(fileName.toStdString()), false).dispatch();
m_windowStack.clearWindows();
}
}
@@ -528,7 +528,7 @@ void QtMainWindow::resetZoom()
void QtMainWindow::resetWindowLayout()
{
FileSystem::remove(UserPaths::getWindowSettingsPath());
FileSystem::copyFile(ResourcePaths::getFallbackPath() + "window_settings.ini", UserPaths::getWindowSettingsPath());
FileSystem::copyFile(ResourcePaths::getFallbackPath().concat(FilePath("window_settings.ini")), UserPaths::getWindowSettingsPath());
loadDockWidgetLayout();
}
@@ -537,7 +537,7 @@ void QtMainWindow::openRecentProject()
QAction *action = qobject_cast<QAction *>(sender());
if (action)
{
MessageLoadProject(action->data().toString().toStdString(), false).dispatch();
MessageLoadProject(FilePath(action->data().toString().toStdString()), false).dispatch();
m_windowStack.clearWindows();
}
}
@@ -4,6 +4,8 @@
#include <QListWidget>
#include <QPushButton>
#include "utility/file/FilePath.h"
QtSelectPathsDialog::QtSelectPathsDialog(const QString& title, const QString& description, QWidget* parent)
: QtTextEditDialog(title, description, parent)
{
@@ -17,7 +19,7 @@ std::vector<FilePath> QtSelectPathsDialog::getPathsList() const
{
if (m_list->item(i)->checkState() == Qt::Checked)
{
checkedPaths.push_back(m_list->item(i)->text().toStdString());
checkedPaths.push_back(FilePath(m_list->item(i)->text().toStdString()));
}
}
+1 -1
View File
@@ -2,8 +2,8 @@
#define QT_SELECT_PATHS_DIALOG_H
#include "qt/window/QtTextEditDialog.h"
#include "utility/file/FilePath.h"
class FilePath;
class QListWidget;
class QtSelectPathsDialog
+2 -2
View File
@@ -25,11 +25,11 @@ QtSplashScreen::QtSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f)
: QSplashScreen(pixmap, f)
, m_state(0)
{
QtDeviceScaledPixmap foreground((ResourcePaths::getGuiPath() + "splash_white.png").c_str());
QtDeviceScaledPixmap foreground((ResourcePaths::getGuiPath().str() + "splash_white.png").c_str());
foreground.scaleToHeight(pixmap.size().height() * 0.8);
m_foreground = foreground.pixmap();
QtDeviceScaledPixmap background((ResourcePaths::getGuiPath() + "splash_blue.png").c_str());
QtDeviceScaledPixmap background((ResourcePaths::getGuiPath().str() + "splash_blue.png").c_str());
background.scaleToHeight(pixmap.size().height() * 0.9);
m_background = background.pixmap();
}
+7 -7
View File
@@ -49,7 +49,7 @@ void QtRecentProjectButton::handleButtonClick()
{
if (m_projectExists)
{
MessageLoadProject(m_projectFilePath.str(), false).dispatch();
MessageLoadProject(m_projectFilePath, false).dispatch();
}
else
{
@@ -139,12 +139,12 @@ size_t i = 0;
}
i++;
}
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "startscreen/startscreen.css").c_str());
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("startscreen/startscreen.css"))).c_str());
}
void QtStartScreen::setupStartScreen(bool unlocked)
{
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "startscreen/startscreen.css").c_str());
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("startscreen/startscreen.css"))).c_str());
addLogo();
QHBoxLayout* layout = new QHBoxLayout();
@@ -261,10 +261,10 @@ void QtStartScreen::setupStartScreen(bool unlocked)
col->addSpacing(20);
m_cppIcon = new QIcon((ResourcePaths::getGuiPath() + "icon/cpp_icon.png").c_str());
m_cIcon = new QIcon((ResourcePaths::getGuiPath() + "icon/c_icon.png").c_str());
m_javaIcon = new QIcon((ResourcePaths::getGuiPath() + "icon/java_icon.png").c_str());
m_projectIcon = new QIcon((ResourcePaths::getGuiPath() + "icon/empty_icon.png").c_str());
m_cppIcon = new QIcon((ResourcePaths::getGuiPath().str() + "icon/cpp_icon.png").c_str());
m_cIcon = new QIcon((ResourcePaths::getGuiPath().str() + "icon/c_icon.png").c_str());
m_javaIcon = new QIcon((ResourcePaths::getGuiPath().str() + "icon/java_icon.png").c_str());
m_projectIcon = new QIcon((ResourcePaths::getGuiPath().str() + "icon/empty_icon.png").c_str());
for (int i = 0
; i < ApplicationSettings::getInstance()->getMaxRecentProjectsCount()
; i++)
+3 -3
View File
@@ -77,7 +77,7 @@ QSize QtWindow::sizeHint() const
void QtWindow::setup()
{
m_content->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css").c_str());
m_content->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))).c_str());
QVBoxLayout* layout = new QVBoxLayout();
layout->setContentsMargins(25, 30, 25, 0);
@@ -140,7 +140,7 @@ void QtWindow::setSizeGripStyle(bool isBlack)
"QSizeGrip {"
" max-height: 16px;"
" max-width: 16px;"
" border-image: url(" + ResourcePaths::getGuiPath() + "window/" + path + ");"
" border-image: url(" + ResourcePaths::getGuiPath().str() + "window/" + path + ");"
"}"
));
}
@@ -426,7 +426,7 @@ void QtWindow::setupDone()
void QtWindow::addLogo()
{
QtDeviceScaledPixmap sourcetrailLogo((ResourcePaths::getGuiPath() + "window/logo.png").c_str());
QtDeviceScaledPixmap sourcetrailLogo((ResourcePaths::getGuiPath().str() + "window/logo.png").c_str());
sourcetrailLogo.scaleToWidth(240);
@@ -467,7 +467,7 @@ void QtProjectWizzard::sourcePathsJava()
void QtProjectWizzard::sourcePathsJavaMaven()
{
std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_sourceGroupSettings)->setMavenDependenciesDirectory(
"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), " ", "_") + "/maven"
FilePath("./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), " ", "_") + "/maven")
);
QtProjectWizzardWindow* window = createWindowWithSummary(
@@ -85,7 +85,7 @@ void QtProjectWizzardContentData::save()
if (m_projectName)
{
m_projectSettings->setProjectName(m_projectName->text().toStdString());
m_projectSettings->setProjectFileLocation(m_projectFileLocation->getText().toStdString());
m_projectSettings->setProjectFileLocation(FilePath(m_projectFileLocation->getText().toStdString()));
}
if (m_standard)
@@ -239,7 +239,7 @@ void QtProjectWizzardContentDataCDB::save()
{
QtProjectWizzardContentData::save();
FilePath path = m_buildFilePicker->getText().toStdString();
FilePath path(m_buildFilePicker->getText().toStdString());
FilePath absPath = m_projectSettings->makePathAbsolute(m_projectSettings->expandPath(path)); // maybe we can use SourceGroupSettings for this... that's where the the cdb path is stored.
if (!absPath.exists() || absPath.extension() != ".json")
{
@@ -260,7 +260,7 @@ bool QtProjectWizzardContentDataCDB::check()
return false;
}
FilePath path = m_buildFilePicker->getText().toStdString();
FilePath path(m_buildFilePicker->getText().toStdString());
FilePath absPath = m_projectSettings->makePathAbsolute(m_projectSettings->expandPath(path));
if (!absPath.exists() || absPath.extension() != ".json")
{
@@ -115,7 +115,7 @@ void QtProjectWizzardContentPathSourceMaven::save()
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_settings);
if (javaSettings)
{
javaSettings->setMavenProjectFilePath(m_picker->getText().toStdString());
javaSettings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdString()));
javaSettings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked());
}
}
@@ -202,6 +202,6 @@ void QtProjectWizzardContentPathDependenciesMaven::save()
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_settings);
if (javaSettings)
{
javaSettings->setMavenDependenciesDirectory(m_picker->getText().toStdString());
javaSettings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdString()));
}
}
@@ -271,7 +271,7 @@ void QtProjectWizzardContentPreferences::load()
if (m_mavenPath)
{
m_mavenPath->setText(QString::fromStdString(appSettings->getMavenPath()));
m_mavenPath->setText(QString::fromStdString(appSettings->getMavenPath().str()));
}
}
@@ -316,7 +316,7 @@ void QtProjectWizzardContentPreferences::save()
if (m_mavenPath)
{
appSettings->setMavenPath(m_mavenPath->getText().toStdString());
appSettings->setMavenPath(FilePath(m_mavenPath->getText().toStdString()));
}
}
@@ -111,7 +111,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
{
QToolButton* b = createProjectButton(
utility::insertLineBreaksAtBlankSpaces(sourceGroupTypeToProjectSetupString(projectIt.type), 15).c_str(),
(ResourcePaths::getGuiPath() + "icon/" + m_projectTypeIconName[projectIt.type] + ".png").c_str()
(ResourcePaths::getGuiPath().str() + "icon/" + m_projectTypeIconName[projectIt.type] + ".png").c_str()
);
b->setProperty("source_group_type", int(projectIt.type));
projectButtons->addButton(b);