libosmscout 1.1.1
Loading...
Searching...
No Matches
InstalledMapsModel.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_INSTALLEDMAPSMODEL_H
2#define OSMSCOUT_CLIENT_QT_INSTALLEDMAPSMODEL_H
3
4/*
5 This source is part of the libosmscout-map library
6 Copyright (C) 2018 Lukáš Karas
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
23
25
26#include <QAbstractListModel>
27
30
31namespace osmscout {
32
37class OSMSCOUT_CLIENT_QT_API InstalledMapsModel : public QAbstractListModel {
38Q_OBJECT
39
40signals:
41 void databaseListChanged(QList<QDir> databaseDirectories);
42
43public slots:
45
46public:
48
50
51 enum Roles {
52 NameRole = Qt::UserRole, // localized name
53 PathRole = Qt::UserRole + 1, // logical path of map
54 DirectoryRole = Qt::UserRole + 2, // directory
55 TimeRole = Qt::UserRole + 3, // generating time of map
56 ByteSizeRole = Qt::UserRole + 4, // size on the disk in bytes
57 SizeRole = Qt::UserRole + 5, // human readable size on the disk
58 VersionRole = Qt::UserRole + 6,
59 };
60 Q_ENUM(Roles)
61
62 Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override;
63 Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override;
64 QHash<int, QByteArray> roleNames() const override;
65 Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override;
66
72 Q_INVOKABLE bool deleteMap(int row);
73 Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
74
82 Q_INVOKABLE QVariant timeOfMap(const QStringList& path);
83
84private:
85 QList<MapDirectory> dirs;
86 MapManagerRef mapManager;
87
88 Slot<std::vector<std::filesystem::path>> databaseListChangedSlot {
89 [this](const std::vector<std::filesystem::path> &paths) {
91 }
92 };
93};
94
95}
96
97#endif //OSMSCOUT_CLIENT_QT_INSTALLEDMAPSMODEL_H
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
Q_INVOKABLE bool deleteMap(int row)
Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override
void databaseListChanged(QList< QDir > databaseDirectories)
QHash< int, QByteArray > roleNames() const override
Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
Q_INVOKABLE QVariant timeOfMap(const QStringList &path)
Roles
Definition InstalledMapsModel.h:51
@ TimeRole
Definition InstalledMapsModel.h:55
@ ByteSizeRole
Definition InstalledMapsModel.h:56
@ PathRole
Definition InstalledMapsModel.h:53
@ DirectoryRole
Definition InstalledMapsModel.h:54
@ SizeRole
Definition InstalledMapsModel.h:57
@ VersionRole
Definition InstalledMapsModel.h:58
@ NameRole
Definition InstalledMapsModel.h:52
Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const override
Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override
Definition Signal.h:98
Definition Area.h:39
OSMSCOUT_CLIENT_QT_API QList< QDir > PathVectorToQDirList(const std::vector< std::filesystem::path > &paths)
STL namespace.