| 1 | /************************************************************************** |
| 2 | * |
| 3 | * Copyright 2014 Canonical Ltd. |
| 4 | * Copyright 2014 Carlos J Mazieri <[email protected]> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Lesser General Public License as published by |
| 8 | * the Free Software Foundation; version 3. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | * File: placesmodel.h |
| 19 | * Date: 21/04/2014 |
| 20 | */ |
| 21 | |
| 22 | #ifndef PLACESMODEL_H |
| 23 | #define PLACESMODEL_H |
| 24 | |
| 25 | #include <QAbstractListModel> |
| 26 | #include <QIcon> |
| 27 | |
| 28 | class PlacesModel : public QAbstractListModel |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | public: |
| 32 | explicit PlacesModel(QObject *parent = 0); |
| 33 | |
| 34 | virtual QVariant data(const QModelIndex &index, int role) const; |
| 35 | virtual int rowCount(const QModelIndex &) const |
| 36 | { return m_places.count(); } |
| 37 | |
| 38 | QString pathFrom(int row) const; |
| 39 | |
| 40 | private: |
| 41 | void addPlace(const QString& n, |
| 42 | const QString& i, |
| 43 | const QStringList& u); |
| 44 | |
| 45 | private: |
| 46 | struct Place |
| 47 | { |
| 48 | public: |
| 49 | Place(const QString&n, const QString& i): |
| 50 | name(n), |
| 51 | icon(i) |
| 52 | { |
| 53 | |
| 54 | } |
| 55 | QString name; |
| 56 | QIcon icon; |
| 57 | QString urlPath; |
| 58 | }; |
| 59 | |
| 60 | QList<Place> m_places; |
| 61 | }; |
| 62 | |
| 63 | #endif // PLACESMODEL_H |