Commit 319cd64b authored by Artem Fedoskin's avatar Artem Fedoskin

Added KSPaths - wrapper for QStandardPaths. It provides support for...

Added KSPaths - wrapper for QStandardPaths. It provides support for platform-specific paths on Android. Changed QStandardPaths::DataLocation with QStandardPaths::GenericDataLocation for use on Windows
parent 1ef4f937
......@@ -17,13 +17,14 @@
#include "catalogdb.h"
#include "kstars/version.h"
#include "../kstars/auxiliary/kspaths.h"
bool CatalogDB::Initialize() {
skydb_ = QSqlDatabase::addDatabase("QSQLITE", "skydb");
QString dbfile = QStandardPaths::locate(QStandardPaths::DataLocation, QString("skycomponents.sqlite"));
QString dbfile = KSPaths::locate(QStandardPaths::GenericDataLocation, QString("skycomponents.sqlite"));
if (dbfile.isEmpty())
dbfile = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QString("/skycomponents.sqlite");
dbfile = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QString("/skycomponents.sqlite");
QFile testdb(dbfile);
bool first_run = false;
......
......@@ -446,6 +446,7 @@ set(kstars_extra_SRCS
auxiliary/qcustomplot.cpp
auxiliary/profileinfo.cpp
auxiliary/filedownloader.cpp
auxiliary/kspaths.cpp
time/simclock.cpp
time/kstarsdatetime.cpp
time/timezonerule.cpp
......
......@@ -20,6 +20,7 @@
#include <QStandardPaths>
#include "byteorder.h"
#include "auxiliary/kspaths.h"
class BinFileHelper;
......@@ -53,7 +54,7 @@ void BinFileHelper::clearFields() {
}
bool BinFileHelper::testFileExists( const QString &fileName ) {
QString FilePath = QStandardPaths::locate(QStandardPaths::DataLocation, fileName );
QString FilePath = KSPaths::locate(QStandardPaths::GenericDataLocation, fileName );
QByteArray b = FilePath.toLatin1();
const char *filepath = b.data();
FILE *f = fopen(filepath, "rb");
......@@ -66,7 +67,7 @@ bool BinFileHelper::testFileExists( const QString &fileName ) {
}
FILE *BinFileHelper::openFile(const QString &fileName) {
QString FilePath = QStandardPaths::locate(QStandardPaths::DataLocation, fileName );
QString FilePath = KSPaths::locate(QStandardPaths::GenericDataLocation, fileName );
init();
QByteArray b = FilePath.toLatin1();
const char *filepath = b.data();
......
......@@ -34,6 +34,7 @@
#include "Options.h"
#include "skyobjects/starobject.h"
#include "skyqpainter.h"
#include "kspaths.h"
ColorScheme::ColorScheme() : FileName() {
//Each color has two names associated with it. The KeyName is its
......@@ -233,7 +234,7 @@ bool ColorScheme::save( const QString &name ) {
if ( filename.at(i)==' ' ) filename.replace( i, 1, "-" );
filename = filename.append( ".colors" );
file.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + filename ) ; //determine filename in local user KDE directory tree.
file.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + filename ) ; //determine filename in local user KDE directory tree.
if ( file.exists() || !file.open( QIODevice::ReadWrite | QIODevice::Append ) ) {
QString message = i18n( "Local color scheme file could not be opened.\nScheme cannot be recorded." );
......@@ -248,7 +249,7 @@ bool ColorScheme::save( const QString &name ) {
file.close();
}
file.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "colors.dat" ) ; //determine filename in local user KDE directory tree.
file.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "colors.dat" ) ; //determine filename in local user KDE directory tree.
if ( !file.open( QIODevice::ReadWrite | QIODevice::Append ) ) {
QString message = i18n( "Local color scheme index file could not be opened.\nScheme cannot be recorded." );
......
......@@ -30,6 +30,7 @@
#include <QFile>
#include <QDebug>
#include <QStandardPaths>
#include "kspaths.h"
FOV::Shape FOV::intToShape(int s)
......@@ -187,7 +188,7 @@ QList<FOV*> FOV::defaults()
void FOV::writeFOVs(const QList<FOV*> fovs)
{
QFile f;
f.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "fov.dat" ) ;
f.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "fov.dat" ) ;
if ( ! f.open( QIODevice::WriteOnly ) ) {
qDebug() << "Could not open fov.dat.";
......@@ -211,7 +212,7 @@ QList<FOV*> FOV::readFOVs()
{
QFile f;
QList<FOV*> fovs;
f.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "fov.dat" ) ;
f.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "fov.dat" ) ;
if( !f.exists() ) {
fovs = defaults();
......
......@@ -88,7 +88,10 @@ void KSFileReader::showProgress()
//printf("%8d %8d %3d\n", m_curLine, m_totalLines, percent );
if ( percent > 100 ) percent = 100;
emit progressText( QString("%1 (%2%)").arg( m_label ).arg( percent ) );
//#ifdef ANDROID
// Can cause crashes on Android
qApp->processEvents();
//#endif
}
......
......@@ -94,7 +94,7 @@ public:
/** @short opens the file with full path fname and uses that
* file for the QTextStream. open() locates QStandardPaths::DataLocation behind the scenes,
* so passing fname such that
* QString fname = QStandardPaths::locate(QStandardPaths::DataLocation, "file_name" );
* QString fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "file_name" );
* is equivalent
*
* @param fname full path to directory + name of the file to open
......
#include "auxiliary/kspaths.h"
#include <QFileInfo>
#include <QDebug>
QString KSPaths::locate(QStandardPaths::StandardLocation location, const QString &fileName,
QStandardPaths::LocateOptions options) {
#ifdef ANDROID
QString file = QStandardPaths::locate(location,fileName,options);
if(file.isEmpty()) {
file = "/data/data/org.kde.kstars/qt-reserved-files/share/kstars/" + fileName;
if (!QFileInfo(file).exists()) {
return QString();
}
}
return file;
#else
return QStandardPaths::locate(location, "kstars" + QDir::separator() +
fileName,options);
#endif
}
QStringList KSPaths::locateAll(QStandardPaths::StandardLocation location, const QString &fileName,
QStandardPaths::LocateOptions options) {
#ifdef ANDROID
QStringList file = QStandardPaths::locateAll(location,fileName,options);
if(file.isEmpty()) {
QString f = "/data/data/org.kde.kstars/qt-reserved-files/share/kstars/" + fileName;
if (QFileInfo(f).exists()) {
file[0] = f;
}
}
return file;
#else
return QStandardPaths::locateAll(location, "kstars" + QDir::separator() +
fileName,options);
#endif
}
/** *************************************************************************
kspaths.h - K Desktop Planetarium
-------------------
begin : 20/05/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
/** *************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KSPATHS_H_
#define KSPATHS_H_
#include <QStandardPaths>
#include <QDir>
/**
*@class KSPaths
*@short Wrapper for QStandardPaths with Android assets support
*The purpose of this class is to search for resources on some platforms with paths that are not
*provided by QStandardPaths (e.g. assets:/ on Android that).
*@author Artem Fedoskin
*@version 1.0
*/
class KSPaths
{
public:
static QString locate(QStandardPaths::StandardLocation location, const QString &fileName,
QStandardPaths::LocateOptions options = QStandardPaths::LocateFile);
static QStringList locateAll(QStandardPaths::StandardLocation, const QString &fileNames,
QStandardPaths::LocateOptions options = QStandardPaths::LocateFile);
static inline QString writableLocation(QStandardPaths::StandardLocation type) {
return QStandardPaths::writableLocation(type) + "kstars" + QDir::separator();
}
};
#endif
......@@ -23,6 +23,7 @@
#include "artificialhorizoncomponent.h"
#include "version.h"
#include "linelist.h"
#include "kspaths.h"
/*
* TODO (spacetime):
......@@ -35,7 +36,7 @@
bool KSUserDB::Initialize() {
// Every logged in user has their own db.
userdb_ = QSqlDatabase::addDatabase("QSQLITE", "userdb");
QString dbfile = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "userdb.sqlite";
QString dbfile = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "userdb.sqlite";
QFile testdb(dbfile);
bool first_run = false;
if (!testdb.exists()) {
......@@ -61,7 +62,7 @@ bool KSUserDB::Initialize() {
version.setTable("Version");
version.select();
QSqlRecord record = version.record(0);
qDebug() << " Verion string is " << record.value("Version").toString();
qDebug() << " Version string is " << record.value("Version").toString();
version.clear();
// If prior to 2.4.0 upgrade database for horizon table
......@@ -112,7 +113,7 @@ bool KSUserDB::Initialize() {
}
}
}
userdb_.close();
userdb_.close();
return true;
}
......@@ -706,7 +707,7 @@ void KSUserDB::GetAllFilters(QList<OAL::Filter *> &filter_list) {
#if 0
bool KSUserDB::ImportFlags() {
QString flagfilename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "flags.dat";
QString flagfilename = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "flags.dat";
QFile flagsfile(flagfilename);
if (!flagsfile.exists()) {
return false; // No upgrade needed. Flags file doesn't exist.
......@@ -737,7 +738,7 @@ bool KSUserDB::ImportFlags() {
}
bool KSUserDB::ImportUsers() {
QString usersfilename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "observerlist.xml";
QString usersfilename = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "observerlist.xml";
QFile usersfile(usersfilename);
if (!usersfile.exists()) {
......@@ -798,7 +799,7 @@ bool KSUserDB::ImportUsers() {
}
bool KSUserDB::ImportEquipment() {
QString equipfilename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "equipmentlist.xml";
QString equipfilename = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "equipmentlist.xml";
QFile equipfile(equipfilename);
if (!equipfile.exists()) {
......
......@@ -27,12 +27,13 @@
#include <QStandardPaths>
#include <cmath>
#include "auxiliary/kspaths.h"
namespace KSUtils {
bool openDataFile( QFile &file, const QString &s ) {
QString FileName = QStandardPaths::locate(QStandardPaths::DataLocation, s );
QString FileName = KSPaths::locate(QStandardPaths::GenericDataLocation, s );
if ( !FileName.isNull() ) {
file.setFileName( FileName );
return file.open( QIODevice::ReadOnly );
......
......@@ -25,7 +25,7 @@
#include <kns3/downloaddialog.h>
#include <QStandardPaths>
#include "kspaths.h"
#include "kstarsdata.h"
#include "geolocation.h"
#include "widgets/dmsbox.h"
......@@ -83,11 +83,11 @@ KSWizard::KSWizard( QWidget *parent ) :
//Load images into banner frames.
QPixmap im;
if( im.load(QStandardPaths::locate(QStandardPaths::DataLocation, "wzstars.png")) )
if( im.load(KSPaths::locate(QStandardPaths::GenericDataLocation, "wzstars.png")) )
welcome->Banner->setPixmap( im );
if( im.load(QStandardPaths::locate(QStandardPaths::DataLocation, "wzgeo.png")) )
if( im.load(KSPaths::locate(QStandardPaths::GenericDataLocation, "wzgeo.png")) )
location->Banner->setPixmap( im );
if( im.load(QStandardPaths::locate(QStandardPaths::DataLocation, "wzdownload.png")) )
if( im.load(KSPaths::locate(QStandardPaths::GenericDataLocation, "wzdownload.png")) )
download->Banner->setPixmap( im );
//connect signals/slots
......
......@@ -67,6 +67,7 @@
#include "skycomponents/constellationboundarylines.h"
#include "skycomponents/skymapcomposite.h"
#include "kspaths.h"
DetailDialog::DetailDialog(SkyObject *o, const KStarsDateTime &ut, GeoLocation *geo, QWidget *parent ) :
KPageDialog( parent ),
......@@ -611,7 +612,7 @@ void DetailDialog::addLink() {
//Also, update the user's custom image links database
//check for user's image-links database. If it doesn't exist, create it.
file.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "image_url.dat" ) ; //determine filename in local user KDE directory tree.
file.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "image_url.dat" ) ; //determine filename in local user KDE directory tree.
if ( !file.open( QIODevice::ReadWrite | QIODevice::Append ) ) {
QString message = i18n( "Custom image-links file could not be opened.\nLink cannot be recorded for future sessions." );
......@@ -630,7 +631,7 @@ void DetailDialog::addLink() {
selectedObject->InfoTitle().append( adialog->desc() );
//check for user's image-links database. If it doesn't exist, create it.
file.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "info_url.dat" ) ; //determine filename in local user KDE directory tree.
file.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "info_url.dat" ) ; //determine filename in local user KDE directory tree.
if ( !file.open( QIODevice::ReadWrite | QIODevice::Append ) ) {
QString message = i18n( "Custom information-links file could not be opened.\nLink cannot be recorded for future sessions." );
......@@ -925,13 +926,13 @@ void DetailDialog::updateLocalDatabase(int type, const QString &search_line, con
// Info Links
case 0:
// Get name for our local info_url file
URLFile.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "info_url.dat" ) ;
URLFile.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "info_url.dat" ) ;
break;
// Image Links
case 1:
// Get name for our local info_url file
URLFile.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "image_url.dat" ) ;
URLFile.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "image_url.dat" ) ;
break;
}
......@@ -1158,7 +1159,7 @@ void DetailDialog::updateThumbnail() {
QPointer<ThumbnailPicker> tp = new ThumbnailPicker( selectedObject, *Thumbnail, this );
if ( tp->exec() == QDialog::Accepted ) {
QString fname = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "thumb-" + selectedObject->name().toLower().remove( ' ' ) + ".png" ;
QString fname = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "thumb-" + selectedObject->name().toLower().remove( ' ' ) + ".png" ;
Data->Image->setPixmap( *(tp->image()) );
......
......@@ -31,6 +31,7 @@
#include <QStandardPaths>
#include "kstarsdata.h"
#include "kspaths.h"
LocationDialogUI::LocationDialogUI( QWidget *parent ) : QFrame( parent )
{
......@@ -303,7 +304,7 @@ bool LocationDialog::updateCity(CityOperation operation)
}*/
QSqlDatabase mycitydb = QSqlDatabase::database("mycitydb");
QString dbfile = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "mycitydb.sqlite";
QString dbfile = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "mycitydb.sqlite";
// If it doesn't exist, create it
if (QFile::exists(dbfile) == false)
......
......@@ -31,6 +31,7 @@
#include "guide/rcalibration.h"
#include "guideadaptor.h"
#include "kspaths.h"
namespace Ekos
{
......@@ -1021,7 +1022,7 @@ void Guide::checkExposureValue(ISD::CCDChip *targetChip, double exposure, IPStat
bool Guide::loadDarkFrame(double exposure)
{
QString filename = QString("dark-%1-%2.fits").arg(QString(currentCCD->getDeviceName()).replace(" ", "_")).arg(QString::number(exposure, 'f', 2));
QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + filename;
QString path = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + filename;
if (darkImage == NULL)
darkImage = new FITSData();
......@@ -1031,7 +1032,7 @@ bool Guide::loadDarkFrame(double exposure)
void Guide::saveDarkFrame()
{
QString filename = QString("dark-%1-%2.fits").arg(QString(currentCCD->getDeviceName()).replace(" ", "_")).arg(QString::number(darkExposure, 'f', 2));
QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + filename;
QString path = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + filename;
if (darkImage->saveFITS(path) == 0)
appendLogText(i18n("Saved new dark frame %1 to library.", path));
......
......@@ -25,6 +25,7 @@
#include "../phd2.h"
#include "../ekosmanager.h"
#include "kstars.h"
#include "kspaths.h"
#include "Options.h"
......@@ -114,7 +115,7 @@ rguider::rguider(cgmath *mathObject, Ekos::Guide *parent)
ui.ditherPixels->setValue(Options::ditherPixels());
ui.spinBox_AOLimit->setValue(Options::aOLimit());
QString logFileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/guide_log.txt";
QString logFileName = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/guide_log.txt";
logFile.setFileName(logFileName);
}
......
......@@ -25,6 +25,7 @@
#include "../guide.h"
#include "../fitsviewer/fitsviewer.h"
#include "../fitsviewer/fitsview.h"
#include "kspaths.h"
#include "../ekosmanager.h"
......@@ -1061,7 +1062,7 @@ void rcalibration::toggleAutoSquareSize(bool enable)
void rcalibration::clearDarkLibrary()
{
QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
QString path = KSPaths::writableLocation(QStandardPaths::GenericDataLocation);
QDir dir(path);
dir.setNameFilters(QStringList() << "dark-*");
......
......@@ -41,6 +41,7 @@
#include "kstarsdata.h"
#include "ksutils.h"
#include "indilistener.h"
#include "kspaths.h"
#include <config-kstars.h>
......@@ -867,7 +868,7 @@ bool DriverManager::readINDIHosts()
lastGroup = NULL;
file.setFileName( QStandardPaths::locate(QStandardPaths::DataLocation, indiFile ) );
file.setFileName( KSPaths::locate(QStandardPaths::GenericDataLocation, indiFile ) );
if ( file.fileName().isEmpty() || !file.open( QIODevice::ReadOnly ) )
return false;
......@@ -967,7 +968,7 @@ bool DriverManager::readXMLDrivers()
if (fileInfo.fileName() == "drivers.xml")
{
// Let first attempt to load the local version of drivers.xml
driverName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "drivers.xml";
driverName = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "drivers.xml";
// If found, we continue, otherwise, we load the system file
if (driverName.isEmpty() == false && QFile(driverName).exists())
......@@ -1448,7 +1449,7 @@ void DriverManager::saveHosts()
QFile file;
QString hostData;
file.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "indihosts.xml" ) ; //determine filename in local user KDE directory tree.
file.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "indihosts.xml" ) ; //determine filename in local user KDE directory tree.
if ( !file.open( QIODevice::WriteOnly))
{
......
......@@ -31,6 +31,7 @@
#include "guimanager.h"
#include "kstarsdata.h"
#include "fov.h"
#include "kspaths.h"
#include <ekos/ekosmanager.h>
......@@ -1105,7 +1106,7 @@ void CCD::processBLOB(IBLOB* bp)
QString currentDir;
if (targetChip->isBatchMode() == false)
currentDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
currentDir = KSPaths::writableLocation(QStandardPaths::TempLocation);
else
currentDir = fitsDir.isEmpty() ? Options::fitsDir() : fitsDir;
......
......@@ -513,7 +513,7 @@ bool INDIDriver::readXMLDrivers()
if (fileInfo.fileName() == "drivers.xml")
{
// Let first attempt to load the local version of drivers.xml
driverName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + "drivers.xml";
driverName = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + "drivers.xml";
// If found, we continue, otherwise, we load the system file
if (driverName.isEmpty() == false && QFile(driverName).exists())
......@@ -929,7 +929,7 @@ void INDIDriver::saveHosts()
QFile file;
QString hostData;
file.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + "indihosts.xml" ) ; //determine filename in local user KDE directory tree.
file.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + "indihosts.xml" ) ; //determine filename in local user KDE directory tree.
if ( !file.open( QIODevice::WriteOnly))
{
......
......@@ -34,6 +34,7 @@
#include "ksutils.h"
#include "ksfilereader.h"
#include "ksnumbers.h"
#include "auxiliary/kspaths.h"
#include "skyobjects/skyobject.h"
#include "skycomponents/supernovaecomponent.h"
#include "skycomponents/skymapcomposite.h"
......@@ -156,8 +157,8 @@ bool KStarsData::initialize() {
//Initialize SkyMapComposite//
emit progressText(i18n("Loading sky objects" ) );
m_SkyComposite = new SkyMapComposite(0);
//Load Image URLs//
emit progressText( i18n("Loading Image URLs" ) );
if( !readURLData( "image_url.dat", 0 ) && !nonFatalErrorMessage( "image_url.dat" ) )
return false;
......@@ -344,8 +345,8 @@ SkyObject* KStarsData::objectNamed( const QString &name ) {
bool KStarsData::readCityData()
{
QSqlDatabase citydb = QSqlDatabase::addDatabase("QSQLITE", "citydb");
QString dbfile = QStandardPaths::locate(QStandardPaths::DataLocation, "citydb.sqlite");
//QString dbfile = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "citydb.sqlite";
QString dbfile = KSPaths::locate(QStandardPaths::GenericDataLocation, "citydb.sqlite");
//QString dbfile = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "citydb.sqlite";
citydb.setDatabaseName(dbfile);
if (citydb.open() == false)
{
......@@ -382,7 +383,7 @@ bool KStarsData::readCityData()
// Reading local database
QSqlDatabase mycitydb = QSqlDatabase::addDatabase("QSQLITE", "mycitydb");
dbfile = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "mycitydb.sqlite";
dbfile = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "mycitydb.sqlite";
if (QFile::exists(dbfile))
{
......@@ -457,7 +458,7 @@ bool KStarsData::openUrlFile(const QString &urlfile, QFile & file) {
fileFound = true;
} else {
// Try to load locale file, if not successful, load regular urlfile and then copy it to locale.
file.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + urlfile ) ;
file.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + urlfile ) ;
if ( file.open( QIODevice::ReadOnly ) ) {
//local file found. Now, if global file has newer timestamp, then merge the two files.
//First load local file into QStringList
......@@ -469,7 +470,7 @@ bool KStarsData::openUrlFile(const QString &urlfile, QFile & file) {
//Find global file(s) in findAllResources() list.
QFileInfo fi_local( file.fileName() );
QStringList flist = QStandardPaths::locateAll(QStandardPaths::DataLocation, urlfile);
QStringList flist = KSPaths::locateAll(QStandardPaths::DataLocation, urlfile);
for ( int i=0; i< flist.size(); i++ ) {
if ( flist[i] != file.fileName() ) {
QFileInfo fi_global( flist[i] );
......@@ -533,7 +534,7 @@ bool KStarsData::openUrlFile(const QString &urlfile, QFile & file) {
if ( QLocale().language() != QLocale::English )
qDebug() << "No localized URL file; using default English file.";
// we found urlfile, we need to copy it to locale
localeFile.setFileName( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + urlfile ) ;
localeFile.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + urlfile ) ;
if (localeFile.open(QIODevice::WriteOnly)) {
QTextStream readStream(&file);
QTextStream writeStream(&localeFile);
......
......@@ -45,6 +45,7 @@
#include "oal/observeradd.h"
#include "skycomponents/skymapcomposite.h"
#include "texturemanager.h"
#include "kspaths.h"
#include <config-kstars.h>
#include <QStandardPaths>
......@@ -328,7 +329,7 @@ void KStars::initActions() {
addColorMenuItem( i18n("&Moonless Night" ), "cs_moonless-night" );
//Add any user-defined color schemes:
QFile file( QStandardPaths::locate(QStandardPaths::DataLocation, "colors.dat" ) ); //determine filename in local user KDE directory tree.
QFile file( KSPaths::locate(QStandardPaths::GenericDataLocation, "colors.dat" ) ); //determine filename in local user KDE directory tree.
if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
QTextStream stream( &file );
while ( !stream.atEnd() ) {
......
......@@ -19,12 +19,13 @@
#include <KLocalizedString>
#include <QStandardPaths>
#include "kspaths.h"