libosmscout
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
libosmscout-client-qt
include
osmscoutclientqt
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
24
#include <
osmscoutclientqt/ClientQtImportExport.h
>
25
26
#include <QAbstractListModel>
27
28
#include <
osmscoutclientqt/MapDownloader.h
>
29
#include <
osmscoutclientqt/QtStdConverters.h
>
30
31
namespace
osmscout
{
32
37
class
OSMSCOUT_CLIENT_QT_API
InstalledMapsModel
:
public
QAbstractListModel {
38
Q_OBJECT
39
40
signals:
41
void
databaseListChanged
(QList<QDir> databaseDirectories);
42
43
public
slots:
44
void
onDatabaseListChanged
();
45
46
public
:
47
InstalledMapsModel
();
48
49
virtual
~InstalledMapsModel
();
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
84
private:
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) {
90
emit
databaseListChanged
(
PathVectorToQDirList
(paths));
91
}
92
};
93
};
94
95
}
96
97
#endif
//OSMSCOUT_CLIENT_QT_INSTALLEDMAPSMODEL_H
ClientQtImportExport.h
OSMSCOUT_CLIENT_QT_API
#define OSMSCOUT_CLIENT_QT_API
Definition
ClientQtImportExport.h:45
MapDownloader.h
QtStdConverters.h
osmscout::InstalledMapsModel::InstalledMapsModel
InstalledMapsModel()
osmscout::InstalledMapsModel::deleteMap
Q_INVOKABLE bool deleteMap(int row)
osmscout::InstalledMapsModel::data
Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override
osmscout::InstalledMapsModel::onDatabaseListChanged
void onDatabaseListChanged()
osmscout::InstalledMapsModel::~InstalledMapsModel
virtual ~InstalledMapsModel()
osmscout::InstalledMapsModel::databaseListChanged
void databaseListChanged(QList< QDir > databaseDirectories)
osmscout::InstalledMapsModel::roleNames
QHash< int, QByteArray > roleNames() const override
osmscout::InstalledMapsModel::removeRows
Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
osmscout::InstalledMapsModel::timeOfMap
Q_INVOKABLE QVariant timeOfMap(const QStringList &path)
osmscout::InstalledMapsModel::Roles
Roles
Definition
InstalledMapsModel.h:51
osmscout::InstalledMapsModel::TimeRole
@ TimeRole
Definition
InstalledMapsModel.h:55
osmscout::InstalledMapsModel::ByteSizeRole
@ ByteSizeRole
Definition
InstalledMapsModel.h:56
osmscout::InstalledMapsModel::PathRole
@ PathRole
Definition
InstalledMapsModel.h:53
osmscout::InstalledMapsModel::DirectoryRole
@ DirectoryRole
Definition
InstalledMapsModel.h:54
osmscout::InstalledMapsModel::SizeRole
@ SizeRole
Definition
InstalledMapsModel.h:57
osmscout::InstalledMapsModel::VersionRole
@ VersionRole
Definition
InstalledMapsModel.h:58
osmscout::InstalledMapsModel::NameRole
@ NameRole
Definition
InstalledMapsModel.h:52
osmscout::InstalledMapsModel::rowCount
Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const override
osmscout::InstalledMapsModel::flags
Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override
osmscout::Slot
Definition
Signal.h:98
osmscout
Definition
Area.h:39
osmscout::PathVectorToQDirList
OSMSCOUT_CLIENT_QT_API QList< QDir > PathVectorToQDirList(const std::vector< std::filesystem::path > &paths)
std
STL namespace.
Generated by
1.17.0