Commit ab7191c0 authored by Laurent Montel's avatar Laurent Montel
Browse files

Reduce duplicate code

parent b9dc166c
......@@ -17,10 +17,10 @@ AkonadiDatabaseToolsJob::~AkonadiDatabaseToolsJob() = default;
bool AkonadiDatabaseToolsJob::canStart() const
{
return !processExist().isEmpty() && (mTool != AkonadiDatabaseToolsUtils::AkonadiDatabaseTool::Unknown);
return !akonadiProcessPath().isEmpty() && (mTool != AkonadiDatabaseToolsUtils::AkonadiDatabaseTool::Unknown);
}
QString AkonadiDatabaseToolsJob::processExist() const
QString AkonadiDatabaseToolsJob::akonadiProcessPath() const
{
return QStandardPaths::findExecutable(QStringLiteral("akonadictl"));
}
......@@ -42,7 +42,7 @@ void AkonadiDatabaseToolsJob::start()
break;
case AkonadiDatabaseToolsUtils::Vacuum: {
mProcess = new QProcess(this);
mProcess->setProgram(QStandardPaths::findExecutable(QStringLiteral("akonadictl")));
mProcess->setProgram(akonadiProcessPath());
mProcess->setArguments(QStringList() << QStringLiteral("vacuum"));
connect(mProcess, &QProcess::finished, this, [this]() {
Q_EMIT finished();
......@@ -59,7 +59,7 @@ void AkonadiDatabaseToolsJob::start()
}
case AkonadiDatabaseToolsUtils::Fsck: {
mProcess = new QProcess(this);
mProcess->setProgram(QStandardPaths::findExecutable(QStringLiteral("akonadictl")));
mProcess->setProgram(akonadiProcessPath());
mProcess->setArguments(QStringList() << QStringLiteral("fsck"));
connect(mProcess, &QProcess::finished, this, [this]() {
Q_EMIT finished();
......
......@@ -28,7 +28,7 @@ Q_SIGNALS:
void finished();
private:
Q_REQUIRED_RESULT QString processExist() const;
Q_REQUIRED_RESULT QString akonadiProcessPath() const;
AkonadiDatabaseToolsUtils::AkonadiDatabaseTool mTool = AkonadiDatabaseToolsUtils::AkonadiDatabaseTool::Unknown;
QProcess *mProcess = nullptr;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment