~dani.behzi/saghar/trunk

« back to all changes in this revision

Viewing changes to src/bookmarks.h

  • Committer: Danial Behzadi
  • Date: 2015-02-05 21:45:44 UTC
  • Revision ID: dani.behzi@gmail.com-20150205214544-6e80ydwmb9ekzwl6
UploadĀ Source

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *  This file is part of Saaghar, a Persian poetry software                *
 
3
 *                                                                         *
 
4
 *  Copyright (C) 2010-2014 by S. Razi Alavizadeh                          *
 
5
 *  E-Mail: <s.r.alavizadeh@gmail.com>, WWW: <http://pozh.org>             *
 
6
 *                                                                         *
 
7
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).       *
 
8
 * All rights reserved.                                                    *
 
9
 * Contact: Nokia Corporation (qt-info@nokia.com)                          *
 
10
 *                                                                         *
 
11
 * This file is part of the examples of the Qt Toolkit.                    *
 
12
 *                                                                         *
 
13
 * $QT_BEGIN_LICENSE:BSD$                                                  *
 
14
 * You may use this file under the terms of the BSD license as follows:    *
 
15
 *                                                                         *
 
16
 * "Redistribution and use in source and binary forms, with or without     *
 
17
 * modification, are permitted provided that the following conditions are  *
 
18
 * met:                                                                    *
 
19
 *   * Redistributions of source code must retain the above copyright      *
 
20
 *     notice, this list of conditions and the following disclaimer.       *
 
21
 *   * Redistributions in binary form must reproduce the above copyright   *
 
22
 *     notice, this list of conditions and the following disclaimer in     *
 
23
 *     the documentation and/or other materials provided with the          *
 
24
 *     distribution.                                                       *
 
25
 *   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor  *
 
26
 *     the names of its contributors may be used to endorse or promote     *
 
27
 *     products derived from this software without specific prior written  *
 
28
 *     permission.                                                         *
 
29
 *                                                                         *
 
30
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     *
 
31
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       *
 
32
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR   *
 
33
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT    *
 
34
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   *
 
35
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        *
 
36
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   *
 
37
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   *
 
38
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     *
 
39
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   *
 
40
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."   *
 
41
 * $QT_END_LICENSE$                                                        *
 
42
 *                                                                         *
 
43
 ***************************************************************************/
 
44
 
 
45
#ifndef BOOKMARKS_H
 
46
#define BOOKMARKS_H
 
47
 
 
48
#include <QDomDocument>
 
49
#include <QHash>
 
50
#include <QIcon>
 
51
#include <QTreeWidget>
 
52
 
 
53
class Bookmarks : public QTreeWidget
 
54
{
 
55
    Q_OBJECT
 
56
 
 
57
public:
 
58
    Bookmarks(QWidget* parent = 0);
 
59
 
 
60
    bool read(QIODevice* device);
 
61
    bool write(QIODevice* device);
 
62
    bool updateBookmarkState(const QString &type, const QVariant &data, bool state);
 
63
    QStringList bookmarkList(const QString &type);
 
64
    void insertBookmarkList(const QVariantList &list);
 
65
 
 
66
private slots:
 
67
    bool unBookmarkItem(QTreeWidgetItem* item = 0);
 
68
    void doubleClicked(QTreeWidgetItem* item, int column);
 
69
    void updateDomElement(QTreeWidgetItem* item, int column);
 
70
    void filterItems(const QString &str);
 
71
 
 
72
private:
 
73
    QDomElement findChildNode(const QString &tagName, const QString &type);
 
74
    void parseFolderElement(const QDomElement &element,
 
75
                            QTreeWidgetItem* parentItem = 0, const QString &elementID = QString());
 
76
    QTreeWidgetItem* createItem(const QDomElement &element,
 
77
                                QTreeWidgetItem* parentItem = 0, const QString &elementID = QString());
 
78
 
 
79
    QDomDocument m_domDocument;
 
80
    QHash<QTreeWidgetItem*, QDomElement> m_domElementForItem;
 
81
    QIcon m_folderIcon;
 
82
    QIcon m_bookmarkIcon;
 
83
 
 
84
signals:
 
85
    void showBookmarkedItem(const QString &, const QString &, const QString &, bool, bool);
 
86
};
 
87
 
 
88
#endif