~ubuntu-branches/ubuntu/vivid/qpdfview/vivid

« back to all changes in this revision

Viewing changes to sources/bookmarkmodel.h

  • Committer: Package Import Robot
  • Author(s): Benjamin Eltzner
  • Date: 2014-10-22 21:49:15 UTC
  • mfrom: (1.2.15)
  • Revision ID: package-import@ubuntu.com-20141022214915-agqeoe318lzs2s4d
Tags: 0.4.12-1
* New upstream release.
* Fixed option to zoom to selection and implemented tiled rendering
  (Closes: #739554)
* Enable support for qt5 and poppler-qt5.
* Explicit dependence on hicolor-icon-theme.

Show diffs side-by-side

added added

removed removed

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