File indexing completed on 2024-04-21 15:42:58

0001 /***************************************************************************
0002     The item for Smb4K's shares view.
0003                              -------------------
0004     begin                : Di Dez 5 2006
0005     copyright            : (C) 2006-2019 by Alexander Reinholdt
0006     email                : alexander.reinholdt@kdemail.net
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *   This program is free software; you can redistribute it and/or modify  *
0011  *   it under the terms of the GNU General Public License as published by  *
0012  *   the Free Software Foundation; either version 2 of the License, or     *
0013  *   (at your option) any later version.                                   *
0014  *                                                                         *
0015  *   This program is distributed in the hope that it will be useful, but   *
0016  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
0017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
0018  *   General Public License for more details.                              *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program; if not, write to the                         *
0022  *   Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,*
0023  *   MA 02110-1335, USA                                                    *
0024  ***************************************************************************/
0025 
0026 #ifdef HAVE_CONFIG_H
0027 #include <config.h>
0028 #endif
0029 
0030 // application specific includes
0031 #include "smb4ksharesviewitem.h"
0032 #include "smb4ksharesview.h"
0033 #include "core/smb4kshare.h"
0034 
0035 
0036 Smb4KSharesViewItem::Smb4KSharesViewItem(Smb4KSharesView *parent, const SharePtr &share)
0037 : QListWidgetItem(parent), m_share(share)
0038 {
0039   setFlags(flags() | Qt::ItemIsDropEnabled);
0040   setItemAlignment(parent->viewMode());
0041   
0042   m_tooltip = new Smb4KToolTip();
0043   m_tooltip->setup(Smb4KToolTip::SharesView, m_share);
0044  
0045   setText(m_share->displayString());
0046   setIcon(m_share->icon());
0047 }
0048 
0049 
0050 Smb4KSharesViewItem::~Smb4KSharesViewItem()
0051 {
0052   delete m_tooltip;
0053 }
0054 
0055 
0056 void Smb4KSharesViewItem::update()
0057 {
0058   m_tooltip->update(Smb4KToolTip::SharesView, m_share);
0059   
0060   setText(m_share->displayString());
0061   setIcon(m_share->icon());
0062 }
0063 
0064 
0065 Smb4KToolTip* Smb4KSharesViewItem::tooltip()
0066 {
0067   return m_tooltip;
0068 }
0069 
0070 
0071 void Smb4KSharesViewItem::setItemAlignment(QListView::ViewMode mode)
0072 {
0073   switch (mode)
0074   {
0075     case QListView::IconMode:
0076     {
0077       setTextAlignment(Qt::AlignHCenter|Qt::AlignTop);
0078       break;
0079     }
0080     case QListView::ListMode:
0081     {
0082       setTextAlignment(Qt::AlignAbsolute|Qt::AlignVCenter);
0083       break;
0084     }
0085     default:
0086     {
0087       break;
0088     }
0089   }
0090 }
0091 
0092