Просмотр исходного кода

[winphone] A try to fix cache problem on winphone

Dmitry Yu Okunev лет назад: 8
Родитель
Сommit
fc1606163c
2 измененных файлов с 10 добавлено и 1 удалено
  1. 8 1
      redmine.cpp
  2. 2 0
      redmine.h

+ 8 - 1
redmine.cpp

@@ -22,10 +22,17 @@
 
 #include <QDir>
 #include <QFile>
+#include <QStandardPaths>
 
 Redmine::Redmine()
 {
 	this->setBaseUrl ( SERVER_URL );
+
+#ifdef __MOBILE__
+	this->cacheBasePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+#else
+	this->cacheBasePath = "cache/";
+#endif
 }
 
 Redmine::~Redmine()
@@ -99,7 +106,7 @@ int Redmine::init()
 
 void Redmine::cacheLoad()
 {
-	QDir dir = QDir ( "cache/" + this->apiKey() );
+	QDir dir = QDir ( this->cacheBasePath + this->apiKey() );
 	QFileInfoList fileInfoList = dir.entryInfoList ( QDir::Files );
 
 	for ( int i = 0; i < fileInfoList.size(); ++i ) {

+ 2 - 0
redmine.h

@@ -50,6 +50,8 @@ private:
 
 	void callback_cache ( QNetworkReply *reply, QJsonDocument *obj, void *_real_callback_info );
 
+	QString cacheBasePath;
+
 public:
 
 	QString apiKey ( QString apiKey );