[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [pairs/frameworks] /: porting to QStandardPaths (most works is from a GCI 2014 task [Toby Chen])
From:       Marco Calignano <marco.calignano () gmail ! com>
Date:       2014-12-07 12:27:52
Message-ID: E1XxawK-00004y-CD () scm ! kde ! org
[Download RAW message or body]

Git commit 7a44b47b363b7df94fd7a4ccccb3c0cc88eca1bc by Marco Calignano.
Committed on 07/12/2014 at 12:19.
Pushed by calignano into branch 'frameworks'.

porting to QStandardPaths (most works is from a GCI 2014 task [Toby Chen])

M  +8    -3    game/playersmodel.cpp
M  +12   -7    game/themesmodel.cpp
M  +0    -1    pairseditor/mainwindow.cpp
M  +0    -1    pairseditor/pairsthemeeditor.cpp

http://commits.kde.org/pairs/7a44b47b363b7df94fd7a4ccccb3c0cc88eca1bc

diff --git a/game/playersmodel.cpp b/game/playersmodel.cpp
index 43def27..caf8c9f 100644
--- a/game/playersmodel.cpp
+++ b/game/playersmodel.cpp
@@ -22,13 +22,12 @@
 
 #include "playersmodel.h"
 #include "pairsplayer.h"
-#include <KStandardDirs>
 #include <KConfig>
 #include <KConfigGroup>
 #include <KLocalizedString>
-#include <KGlobal>
 #include <krandom.h>
 #include <QDebug>
+#include <QDirIterator>
 #include <QFileSystemWatcher>
 #include "themesmodel.h"
 
@@ -41,7 +40,13 @@ PlayersModel::PlayersModel(QObject* parent)
     names.insert(Time, "time");
     names.insert(Selected, "selected");
     setRoleNames(names);
-    m_playerIcons = KGlobal::dirs()->findAllResources("appdata", QLatin1String( \
"players/*.svg")); +    QStringList dirs = \
QStandardPaths::locateAll(QStandardPaths::DataLocation, QLatin1String("players/"), \
QStandardPaths::LocateDirectory); +    Q_FOREACH (const QString& dir, dirs) {
+        QDirIterator it(dir, QStringList() << QStringLiteral("*.svg"));
+        while (it.hasNext()) {
+            m_playerIcons.append(it.next());
+        }
+    }
     for(QStringList::iterator it=m_playerIcons.begin(), itEnd=m_playerIcons.end(); \
                it!=itEnd; ++it) {
         *it = QUrl::fromLocalFile(*it).toString();
     }
diff --git a/game/themesmodel.cpp b/game/themesmodel.cpp
index 614c12e..2c9ef97 100644
--- a/game/themesmodel.cpp
+++ b/game/themesmodel.cpp
@@ -23,9 +23,9 @@
 #include "themesmodel.h"
 #include "themeiconsprovider.h"
 #include "pairstheme.h"
-#include <KStandardDirs>
-#include <KGlobal>
 #include <krandom.h>
+#include <QDirIterator>
+#include <QStandardPaths>
 #include <QDebug>
 
 ThemesModel::ThemesModel(QObject* parent, const QString &filePath): \
QStandardItemModel(parent) @@ -34,10 +34,9 @@ ThemesModel::ThemesModel(QObject* \
parent, const QString &filePath): QStandardIte  \
names.insert(PairsTheme::CardTypeRole, "type");  \
names.insert(PairsTheme::LanguagesRole, "languages");  setRoleNames(names);
-//     qDebug() << "file path:"<< filePath;
-	if(filePath.isEmpty())
+    if(filePath.isEmpty())
 	{
-		QStringList themesdirs=KGlobal::dirs()->findDirs("appdata", "themes");
+		QStringList themesdirs = QStandardPaths::locateAll(QStandardPaths::DataLocation, \
"themes", QStandardPaths::LocateDirectory);  m_fs=new QFileSystemWatcher(this);
 		m_fs->addPaths(themesdirs);
 		connect(m_fs, SIGNAL(directoryChanged(QString)), SLOT(reload()));
@@ -66,8 +65,14 @@ void ThemesModel::reload()
 {
     m_fs->blockSignals(true);
     clear();
-    const QStringList themes = KGlobal::dirs()->findAllResources("appdata", \
                QLatin1String( "themes/*.pairs.*" ));
-
+    QStringList themes;
+    QStringList dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation, \
QLatin1String( "themes" ),QStandardPaths::LocateDirectory); +    Q_FOREACH (const \
QString& dir, dirs) { +        QDirIterator it(dir, QStringList() << \
QStringLiteral("*.pairs.*")); +        while (it.hasNext()) {
+            themes.append(it.next());
+        }
+    }
     Q_FOREACH(const QString& themePath, themes) {
         PairsTheme* theme = new PairsTheme(themePath);
 
diff --git a/pairseditor/mainwindow.cpp b/pairseditor/mainwindow.cpp
index e000c06..ad08163 100644
--- a/pairseditor/mainwindow.cpp
+++ b/pairseditor/mainwindow.cpp
@@ -33,7 +33,6 @@
 #include <QtCore/QProcess>
 #include <QAction>
 #include <KGlobal>
-#include <KStandardDirs>
 #include <KStandardAction>
 #include <kdeversion.h>
 #include <KUrlRequester>
diff --git a/pairseditor/pairsthemeeditor.cpp b/pairseditor/pairsthemeeditor.cpp
index 3ce9359..865cefc 100644
--- a/pairseditor/pairsthemeeditor.cpp
+++ b/pairseditor/pairsthemeeditor.cpp
@@ -23,7 +23,6 @@
 #include "pairsthemeeditor.h"
 #include <QtCore/QDebug>
 #include <KLocalizedString>
-#include <KStandardDirs>
 #include <QtXmlPatterns/QXmlSchemaValidator>
 #include <QtXmlPatterns/QXmlSchema>
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic