From a1d164895fac7fd705c8cb37c4c94700be32a0a2 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 5 Oct 2018 21:07:45 +0200 Subject: bookmarks: fix new/delete buttons --- lib/bookmarks/bookmarkitem.cpp | 136 ----------------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 lib/bookmarks/bookmarkitem.cpp (limited to 'lib/bookmarks/bookmarkitem.cpp') diff --git a/lib/bookmarks/bookmarkitem.cpp b/lib/bookmarks/bookmarkitem.cpp deleted file mode 100644 index 4715b6f..0000000 --- a/lib/bookmarks/bookmarkitem.cpp +++ /dev/null @@ -1,136 +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 -#include - -BookmarkItem::BookmarkItem(const QVector &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) -{ - if(m_type == Folder || m_type == Root) { - m_children.insert(position, 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(this)); - - return 0; -} -- cgit v1.2.1