summaryrefslogtreecommitdiffstats
path: root/wayland
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-07-17 00:44:22 +0200
committerHolger Freyther <holger+qt@freyther.de>2017-09-12 06:15:12 +0000
commit097cbe38ab5730d21f2c21eac9d3b56055c5ba36 (patch)
tree83c24c177742acd44f4876a3250547a0c1054db9 /wayland
parent3bc5f85963ce7792e887595381f00134e6938e34 (diff)
democompositor: Add method to scan entire directory for files
Make this and the addFile a public slot to be more easily. Take all files from the directory and ignore the suffix. Change-Id: I8017c3a873a962ab0b4e7e5c9946403f1ee0ffcd Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'wayland')
-rw-r--r--wayland/democompositor/apps/applistmodel.cpp12
-rw-r--r--wayland/democompositor/apps/applistmodel.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/wayland/democompositor/apps/applistmodel.cpp b/wayland/democompositor/apps/applistmodel.cpp
index 542f8a7..10c4c15 100644
--- a/wayland/democompositor/apps/applistmodel.cpp
+++ b/wayland/democompositor/apps/applistmodel.cpp
@@ -52,6 +52,8 @@
#include "appparser.h"
#include "applog.h"
+#include <QtCore/QDirIterator>
+
static QHash<int, QByteArray> modelRoles()
{
QHash<int, QByteArray> roles;
@@ -116,6 +118,16 @@ void AppListModel::addFile(const QString& fileName)
endResetModel();
}
+void AppListModel::addDir(const QString& dirName)
+{
+ QDirIterator dirIt(dirName, QDir::Files | QDir::NoDotAndDotDot | QDir::Readable);
+
+ beginResetModel();
+ while (dirIt.hasNext())
+ doAddFile(dirIt.next());
+ endResetModel();
+}
+
void AppListModel::doAddFile(const QString& fileName)
{
bool ok;
diff --git a/wayland/democompositor/apps/applistmodel.h b/wayland/democompositor/apps/applistmodel.h
index f8fc3e0..1cd79b4 100644
--- a/wayland/democompositor/apps/applistmodel.h
+++ b/wayland/democompositor/apps/applistmodel.h
@@ -78,7 +78,9 @@ public:
QVariant data(const QModelIndex& index, int role) const Q_DECL_OVERRIDE;
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
+public Q_SLOTS:
void addFile(const QString& fileName);
+ void addDir(const QString& dirName);
private:
void doAddFile(const QString& fileName);