Commit f412b417 authored by Karel Slaný's avatar Karel Slaný

Function existingWritableLoc() accepts QStandardPaths::DocumentsLocation.

parent 1bb5cd8d
......@@ -40,37 +40,37 @@
QString appAttachDirPath(void)
{
return getDefaultAttachmentSaveLocation() + QDir::separator() +
return dfltAttachSavingLoc() + QDir::separator() +
QLatin1String(DATOVKA_BASE_DIR_NAME);
}
QString appCertDirPath(void)
{
return setDatovkaPath(getDefaultAttachmentSaveLocation(),
return setDatovkaPath(dfltAttachSavingLoc(),
DATOVKA_CERT_DIR_NAME);
}
QString appEmailDirPath(const QString &msgIdStr)
{
return setDatovkaPath(getDefaultAttachmentSaveLocation(),
return setDatovkaPath(dfltAttachSavingLoc(),
QString(DATOVKA_MAIL_DIR_NAME) + QDir::separator() + msgIdStr);
}
QString appMsgAttachDirPath(const QString &msgIdStr)
{
return setDatovkaPath(getDefaultAttachmentSaveLocation(), msgIdStr);
return setDatovkaPath(dfltAttachSavingLoc(), msgIdStr);
}
QString appTmpDirPath(void)
{
return setDatovkaPath(getDefaultAttachmentSaveLocation(),
return setDatovkaPath(dfltAttachSavingLoc(),
DATOVKA_TEMP_DIR_NAME);
}
void removeDirFromDocLoc(const QString &dirName)
{
QString folderPath(
setDatovkaPath(getDefaultAttachmentSaveLocation(), dirName));
setDatovkaPath(dfltAttachSavingLoc(), dirName));
if (folderPath.isEmpty()) {
return;
......@@ -80,13 +80,14 @@ void removeDirFromDocLoc(const QString &dirName)
dir.removeRecursively();
}
QString existingWritableLocation(int type)
QString existingWritableLoc(int type)
{
enum QStandardPaths::StandardLocation locationType;
switch (type) {
case QStandardPaths::AppDataLocation:
case QStandardPaths::AppLocalDataLocation:
case QStandardPaths::DocumentsLocation:
locationType = (enum QStandardPaths::StandardLocation) type;
break;
default: /* All other types are not used. */
......@@ -111,14 +112,14 @@ QString existingWritableLocation(int type)
return dirName;
}
QString getDefaultAttachmentSaveLocation(void)
QString dfltAttachSavingLoc(void)
{
return QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
return existingWritableLoc(QStandardPaths::DocumentsLocation);
}
QString getDefaultDbAndConfigLocation(void)
QString dfltDbAndConfigLoc(void)
{
return existingWritableLocation(QStandardPaths::AppDataLocation);
return existingWritableLoc(QStandardPaths::AppDataLocation);
}
QStringList zfoFilesFromDir(const QString &dirPath, bool subdirs)
......
......@@ -87,21 +87,21 @@ void removeDirFromDocLoc(const QString &dirName);
* @param[in] type Location type, must match supported QStandardPaths::StandardLocation.
* @return Directory name of existing directory or empty string on error.
*/
QString existingWritableLocation(int type);
QString existingWritableLoc(int type);
/*!
* @brief Return path for attachment saving.
*
* @return Path to location where attachment can be stored.
*/
QString getDefaultAttachmentSaveLocation(void);
QString dfltAttachSavingLoc(void);
/*!
* @brief Return default location for database files and datovka.conf.
*
* @return Location path or empty string on error.
*/
QString getDefaultDbAndConfigLocation(void);
QString dfltDbAndConfigLoc(void);
/*!
* @brief Get full paths of ZFO files in supplied directory.
......
......@@ -467,8 +467,7 @@ int main(int argc, char *argv[])
# error("The application is likely to crash; see QTBUG-66005.")
# endif
#endif /* Q_OS_ANDROID */
QString dirName(
existingWritableLocation(QStandardPaths::AppDataLocation));
QString dirName(existingWritableLoc(QStandardPaths::AppDataLocation));
if (dirName.isEmpty()) {
logErrorNL("%s",
"Cannot determine application data location.");
......
......@@ -24,7 +24,6 @@
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QStandardPaths>
#include "src/datovka_shared/localisation/localisation.h"
#include "src/datovka_shared/settings/records_management.h"
......@@ -118,7 +117,7 @@ void Settings::saveToSettings(QSettings &settings) const
settings.setValue(SETTINGS_LAST_UPDATE, m_lastUpdate);
if (dbsLocation != getDefaultDbAndConfigLocation()) {
if (dbsLocation != dfltDbAndConfigLoc()) {
settings.setValue(SETTINGS_DBS_LOCATION, dbsLocation);
}
......@@ -195,7 +194,7 @@ void Settings::loadFromSettings(const QSettings &settings)
SETTINGS_GLOBAL_GROUP "/" SETTINGS_DBS_LOCATION).toString();
if (dbsLocation.isEmpty()) {
dbsLocation = getDefaultDbAndConfigLocation();
dbsLocation = dfltDbAndConfigLoc();
}
/* Records management settings. */
......@@ -206,7 +205,7 @@ void Settings::loadFromSettings(const QSettings &settings)
QString Settings::settingsPath(void)
{
QString settingsPath(getDefaultDbAndConfigLocation());
QString settingsPath(dfltDbAndConfigLoc());
if (settingsPath.isEmpty()) {
return QString();
......
......@@ -198,7 +198,7 @@ void GlobalSettingsQmlWrapper::setZfoDbSizeMBs(int zfoDbSizeMBs)
bool GlobalSettingsQmlWrapper::showDefaultButton(void) const
{
if (GlobInstcs::setPtr != Q_NULLPTR) {
return GlobInstcs::setPtr->dbsLocation != getDefaultDbAndConfigLocation();
return GlobInstcs::setPtr->dbsLocation != dfltDbAndConfigLoc();
} else {
Q_ASSERT(0);
return false;
......@@ -313,7 +313,7 @@ QString GlobalSettingsQmlWrapper::changeDbPath(const QString &currentLocation,
bool setDefaultLocation)
{
QString newLocation = getDefaultDbAndConfigLocation();
QString newLocation(dfltDbAndConfigLoc());
if (!setDefaultLocation) {
/* TODO - Use new QML input dialogue instead of
......
......@@ -27,7 +27,6 @@
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QStandardPaths>
#include "src/common.h"
#include "src/io/filesystem.h"
......
......@@ -28,7 +28,6 @@
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QStandardPaths>
#include "src/common.h"
#include "src/io/filesystem.h"
......
......@@ -29,7 +29,6 @@
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QStandardPaths>
#include "src/auxiliaries/email_helper.h"
#include "src/common.h"
......
......@@ -28,7 +28,6 @@
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QStandardPaths>
#include "src/io/filesystem.h"
#include "src/log/log.h"
......@@ -38,8 +37,7 @@
bool ZfoDb::openDb(const QString &fileName, bool storeToDisk)
{
QString dirName(existingWritableLocation(
QStandardPaths::AppDataLocation));
QString dirName(dfltDbAndConfigLoc());
if (storeToDisk && dirName.isEmpty() & fileName.isEmpty()) {
Q_ASSERT(0);
......
Markdown is supported
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