libosmscout  1.1.1
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 
28 #include <osmscout/MapManager.h>
29 
30 namespace osmscout {
31 
36 class OSMSCOUT_CLIENT_QT_API InstalledMapsModel : public QAbstractListModel {
37 Q_OBJECT
38 
39 signals:
40  void databaseListChanged();
41 
42 public slots:
43  void onDatabaseListChanged();
44 
45 public:
47 
48  virtual ~InstalledMapsModel();
49 
50  enum Roles {
51  NameRole = Qt::UserRole, // localized name
52  PathRole = Qt::UserRole + 1, // logical path of map
53  DirectoryRole = Qt::UserRole + 2, // directory
54  TimeRole = Qt::UserRole + 3, // generating time of map
55  };
56  Q_ENUM(Roles)
57 
58  Q_INVOKABLE virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
59  Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role) const;
60  virtual QHash<int, QByteArray> roleNames() const;
61  Q_INVOKABLE virtual Qt::ItemFlags flags(const QModelIndex &index) const;
62 
68  Q_INVOKABLE bool deleteMap(int row);
69  Q_INVOKABLE virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
70 
78  Q_INVOKABLE QVariant timeOfMap(const QStringList& path);
79 
80 private:
81  QList<MapDirectory> dirs;
82  MapManagerRef mapManager;
83 };
84 
85 }
86 
87 #endif //OSMSCOUT_CLIENT_QT_INSTALLEDMAPSMODEL_H
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
std::shared_ptr< MapManager > MapManagerRef
Definition: MapManager.h:232
Definition: Area.h:38
Definition: InstalledMapsModel.h:36
Roles
Definition: InstalledMapsModel.h:50