aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks/model/bookmarkitem.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-01-14 23:34:13 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2020-01-14 23:34:13 +0200
commit4c71c8571ceb10b29e6550cd0d8eb928049e6851 (patch)
tree2130c586e6be37185ca382e68ff645710d6c5e63 /lib/bookmarks/model/bookmarkitem.cpp
parentFix if statements in PKGBUILD (diff)
downloadsmolbote-4c71c8571ceb10b29e6550cd0d8eb928049e6851.tar.xz
Move/rename files for readability
- add BookmarkFormat <<|>> BookmarkModel operators
Diffstat (limited to 'lib/bookmarks/model/bookmarkitem.cpp')
-rw-r--r--lib/bookmarks/model/bookmarkitem.cpp139
1 files changed, 0 insertions, 139 deletions
diff --git a/lib/bookmarks/model/bookmarkitem.cpp b/lib/bookmarks/model/bookmarkitem.cpp
deleted file mode 100644
index 21d034f..0000000
--- a/lib/bookmarks/model/bookmarkitem.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "bookmarkitem.h"
-#include <QApplication>
-#include <QStyle>
-
-BookmarkItem::BookmarkItem(const QVector<QVariant> &data, Type type, BookmarkItem *parent)
-{
- m_parentItem = parent;
-
- m_type = type;
- if(m_type == Folder) {
- m_icon.addPixmap(qApp->style()->standardPixmap(QStyle::SP_DirClosedIcon), QIcon::Normal, QIcon::Off);
- m_icon.addPixmap(qApp->style()->standardPixmap(QStyle::SP_DirOpenIcon), QIcon::Normal, QIcon::On);
- } else if(m_type == Bookmark)
- m_icon.addPixmap(qApp->style()->standardPixmap(QStyle::SP_FileIcon));
-
- m_data.resize(FieldCount);
- for(int i = 0; i < FieldCount; ++i) {
- m_data[i] = data.value(i, QVariant());
- }
-}
-
-BookmarkItem::~BookmarkItem()
-{
- qDeleteAll(m_children);
-}
-
-BookmarkItem *BookmarkItem::parent() const
-{
- return m_parentItem;
-}
-
-bool BookmarkItem::appendChild(BookmarkItem *childItem)
-{
- // Only folders can have children, so only append them on folders
- // This way, we don't need to add checks to the other methods
- if(m_type == Folder || m_type == Root) {
- m_children.append(childItem);
- return true;
- }
-
- return false;
-}
-
-bool BookmarkItem::insertChild(int position, BookmarkItem *childItem)
-{
- // position is invalid (-1) when dropping an item onto the folder, which leads to crash
- // make sure that position passed is >= 0 (insert item at first position)
-
- if(m_type == Folder || m_type == Root) {
- m_children.insert(qMax(position, 0), childItem);
- return true;
- }
-
- return false;
-}
-
-bool BookmarkItem::removeChildAt(int index, int count)
-{
- if(index < 0 || index + count > m_children.size())
- return false;
-
- // delete the item at index count times
- for(int i = 0; i < count; ++i) {
- delete m_children.takeAt(index);
- }
- return true;
-}
-
-BookmarkItem *BookmarkItem::takeChild(int index, BookmarkItem *newParent)
-{
- m_children[index]->m_parentItem = newParent;
- return m_children.takeAt(index);
-}
-
-BookmarkItem *BookmarkItem::child(int index) const
-{
- return m_children.value(index);
-}
-
-int BookmarkItem::childCount() const
-{
- return m_children.count();
-}
-
-QVariant BookmarkItem::data(Fields column) const
-{
- return m_data.value(column);
-}
-
-bool BookmarkItem::setData(Fields column, const QVariant &data)
-{
- if(column >= FieldCount)
- return false;
-
- m_data[column] = data;
- return true;
-}
-
-QIcon BookmarkItem::icon() const
-{
- return m_icon;
-}
-
-bool BookmarkItem::isExpanded() const
-{
- return m_isExpanded;
-}
-
-void BookmarkItem::setExpanded(bool expanded)
-{
- if(m_type == BookmarkItem::Folder)
- m_isExpanded = expanded;
-}
-
-QString BookmarkItem::tooltip() const
-{
- return m_data.value(Tags).toStringList().join(", ");
-}
-
-BookmarkItem::Type BookmarkItem::type() const
-{
- return m_type;
-}
-
-int BookmarkItem::row() const
-{
- if(m_parentItem)
- return m_parentItem->m_children.indexOf(const_cast<BookmarkItem *>(this));
-
- return 0;
-}