File indexing completed on 2024-12-01 04:37:20

0001 /*
0002     The item for Smb4K's shares view.
0003 
0004     SPDX-FileCopyrightText: 2006-2021 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 // application specific includes
0009 #include "smb4ksharesviewitem.h"
0010 #include "core/smb4kshare.h"
0011 #include "smb4ksharesview.h"
0012 
0013 Smb4KSharesViewItem::Smb4KSharesViewItem(Smb4KSharesView *parent, const SharePtr &share)
0014     : QListWidgetItem(parent)
0015     , m_share(share)
0016 {
0017     setFlags(flags() | Qt::ItemIsDropEnabled);
0018     setItemAlignment(parent->viewMode());
0019 
0020     setText(m_share->displayString());
0021     setIcon(m_share->icon());
0022 }
0023 
0024 Smb4KSharesViewItem::~Smb4KSharesViewItem()
0025 {
0026 }
0027 
0028 void Smb4KSharesViewItem::update()
0029 {
0030     setText(m_share->displayString());
0031     setIcon(m_share->icon());
0032 }
0033 
0034 void Smb4KSharesViewItem::setItemAlignment(QListView::ViewMode mode)
0035 {
0036     switch (mode) {
0037     case QListView::IconMode: {
0038         setTextAlignment(Qt::AlignHCenter | Qt::AlignTop);
0039         break;
0040     }
0041     case QListView::ListMode: {
0042         setTextAlignment(Qt::AlignAbsolute | Qt::AlignVCenter);
0043         break;
0044     }
0045     default: {
0046         break;
0047     }
0048     }
0049 }