source: terepaima/terepaima-0.4.16/sources/bookmarkmodel.h

desarrollostretch
Last change on this file was 1f4adec, checked in by aosorio <aosorio@…>, 8 years ago

Agregado proyecto base, esto luego del dh_make -f

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2
3Copyright 2014-2015 Adam Reichold
4
5This file is part of qpdfview.
6
7qpdfview is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 2 of the License, or
10(at your option) any later version.
11
12qpdfview is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with qpdfview.  If not, see <http://www.gnu.org/licenses/>.
19
20*/
21
22#ifndef BOOKMARKMODEL_H
23#define BOOKMARKMODEL_H
24
25#include <QAbstractListModel>
26
27#include <QDateTime>
28#include <QHash>
29
30namespace qpdfview
31{
32
33struct BookmarkItem
34{
35    int page;
36
37    QString label;
38    QString comment;
39    QDateTime modified;
40
41    BookmarkItem(int page, const QString& label = QString(), const QString& comment = QString(), const QDateTime& modified = QDateTime::currentDateTime()) :
42        page(page),
43        label(label),
44        comment(comment),
45        modified(modified) {}
46
47};
48
49class BookmarkModel : public QAbstractListModel
50{
51    Q_OBJECT
52
53public:
54    static BookmarkModel* fromPath(const QString& path, bool create = false);
55
56    static QList< QString > knownPaths();
57
58    static void forgetPath(const QString& path);
59    static void forgetAllPaths();
60
61
62    bool isEmpty() const { return m_bookmarks.isEmpty(); }
63
64    void addBookmark(const BookmarkItem& bookmark);
65    void removeBookmark(const BookmarkItem& bookmark);
66
67    void findBookmark(BookmarkItem& bookmark) const;
68
69
70    enum
71    {
72        PageRole = Qt::UserRole + 1,
73        LabelRole,
74        CommentRole,
75        ModifiedRole
76    };
77
78    Qt::ItemFlags flags(const QModelIndex&) const;
79
80    int columnCount(const QModelIndex& parent = QModelIndex()) const;
81    int rowCount(const QModelIndex& parent = QModelIndex()) const;
82
83    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
84
85private:
86    Q_DISABLE_COPY(BookmarkModel)
87
88    static QHash< QString, BookmarkModel* > s_instances;
89    BookmarkModel(QObject* parent = 0);
90
91    QList< BookmarkItem > m_bookmarks;
92
93};
94
95} // qpdfview
96
97#endif // BOOKMARKMODEL_H
Note: See TracBrowser for help on using the repository browser.