]> git.tdb.fi Git - xinema.git/blobdiff - remote/source/directorymodel.h
Overhaul BrowsePage to look and feel better
[xinema.git] / remote / source / directorymodel.h
diff --git a/remote/source/directorymodel.h b/remote/source/directorymodel.h
new file mode 100644 (file)
index 0000000..7c09420
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef DIRECTORYMODEL_H_
+#define DIRECTORYMODEL_H_
+
+#include <QAbstractListModel>
+#include <QList>
+
+class DirectoryModel: public QAbstractListModel
+{
+       Q_OBJECT
+
+       Q_ENUMS(EntryType)
+
+public:
+       enum EntryType
+       {
+               ParentDir,
+               SubDir,
+               File
+       };
+
+private:
+       struct Entry
+       {
+               QString name;
+               EntryType type;
+
+               bool operator<(const Entry &) const;
+       };
+
+       QList<Entry> entries;
+
+public:
+       void clear();
+       void add_entry(const QString &, EntryType);
+
+       virtual QHash<int, QByteArray> roleNames() const;
+       virtual int rowCount(const QModelIndex &) const;
+       virtual QVariant data(const QModelIndex &, int) const;
+};
+
+#endif