File indexing completed on 2024-05-12 04:57:56
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2014 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #ifndef BOOKMARKITEM_H 0019 #define BOOKMARKITEM_H 0020 0021 #include <QString> 0022 #include <QList> 0023 #include <QIcon> 0024 #include <QElapsedTimer> 0025 #include <QUrl> 0026 0027 #include "qzcommon.h" 0028 0029 class FALKON_EXPORT BookmarkItem 0030 { 0031 public: 0032 enum Type { 0033 Root, 0034 Url, 0035 Folder, 0036 Separator, 0037 Invalid 0038 }; 0039 0040 explicit BookmarkItem(Type type, BookmarkItem* parent = nullptr); 0041 ~BookmarkItem(); 0042 0043 Type type() const; 0044 void setType(Type type); 0045 0046 bool isFolder() const; 0047 bool isUrl() const; 0048 bool isSeparator() const; 0049 0050 BookmarkItem* parent() const; 0051 QList<BookmarkItem*> children() const; 0052 0053 QIcon icon(); 0054 void setIcon(const QIcon &icon); 0055 0056 QString urlString() const; 0057 0058 QUrl url() const; 0059 void setUrl(const QUrl &url); 0060 0061 QString title() const; 0062 void setTitle(const QString &title); 0063 0064 QString description() const; 0065 void setDescription(const QString &description); 0066 0067 QString keyword() const; 0068 void setKeyword(const QString &keyword); 0069 0070 int visitCount() const; 0071 void setVisitCount(int count); 0072 0073 // Increments visitCount() (may also update last load time when implemented) 0074 void updateVisitCount(); 0075 0076 // Expanded state in Manager 0077 bool isExpanded() const; 0078 void setExpanded(bool expanded); 0079 0080 // Expanded state in Sidebar 0081 bool isSidebarExpanded() const; 0082 void setSidebarExpanded(bool expanded); 0083 0084 void addChild(BookmarkItem* child, int index = -1); 0085 void removeChild(BookmarkItem* child); 0086 0087 static Type typeFromString(const QString &string); 0088 static QString typeToString(Type type); 0089 0090 private: 0091 Type m_type; 0092 BookmarkItem* m_parent; 0093 QList<BookmarkItem*> m_children; 0094 0095 QUrl m_url; 0096 QString m_title; 0097 QString m_description; 0098 QString m_keyword; 0099 QIcon m_icon; 0100 QElapsedTimer m_iconTime; 0101 int m_visitCount; 0102 bool m_expanded; 0103 bool m_sidebarExpanded; 0104 }; 0105 0106 #endif // BOOKMARKITEM_H