~ubuntu-branches/ubuntu/utopic/smb4k/utopic-proposed

« back to all changes in this revision

Viewing changes to smb4k/sharesview/smb4ksharesiconviewitem.cpp

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-05-19 18:54:34 UTC
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: package-import@ubuntu.com-20120519185434-kpqpdrg5i47zm7tl
Tags: upstream-1.0.1
ImportĀ upstreamĀ versionĀ 1.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
    smb4ksharesiconviewitem  -  The items for Smb4K's shares icon view.
3
3
                             -------------------
4
4
    begin                : Di Dez 5 2006
5
 
    copyright            : (C) 2006-2008 by Alexander Reinholdt
6
 
    email                : dustpuppy@users.berlios.de
 
5
    copyright            : (C) 2006-2010 by Alexander Reinholdt
 
6
    email                : alexander.reinholdt@kdemail.net
7
7
 ***************************************************************************/
8
8
 
9
9
/***************************************************************************
35
35
#include <smb4ksharesiconviewitem.h>
36
36
#include <smb4ksharesiconview.h>
37
37
 
38
 
Smb4KSharesIconViewItem::Smb4KSharesIconViewItem( Smb4KShare *share, Smb4KSharesIconView *parent )
39
 
: QListWidgetItem( parent )
 
38
Smb4KSharesIconViewItem::Smb4KSharesIconViewItem( Smb4KSharesIconView *parent, Smb4KShare *share, bool mountpoint )
 
39
: QListWidgetItem( parent ), m_share( *share ), m_mountpoint( mountpoint )
40
40
{
41
41
  setFlags( flags() | Qt::ItemIsDropEnabled );
42
42
 
43
 
  m_data.setShare( share );
 
43
  if ( !m_mountpoint )
 
44
  {
 
45
    setText( m_share.unc() );
 
46
  }
 
47
  else
 
48
  {
 
49
    setText( m_share.path() );
 
50
  }
44
51
 
45
 
  setupItem( m_data.share(), m_data.showMountPoint() );
 
52
  setIcon( m_share.icon() );
46
53
}
47
54
 
48
55
 
52
59
}
53
60
 
54
61
 
55
 
void Smb4KSharesIconViewItem::setupItem( Smb4KShare *share, bool mountpoint )
56
 
{
57
 
  // Set up the icon.
58
 
  KIcon icon;
59
 
 
60
 
  QStringList overlays;
61
 
  overlays.append( "emblem-mounted" );
62
 
 
63
 
  if ( m_data.share()->isInaccessible() )
64
 
  {
65
 
    icon = KIcon( "folder-locked", KIconLoader::global(), overlays );
66
 
  }
67
 
  else
68
 
  {
69
 
    icon = KIcon( "folder-remote", KIconLoader::global(), overlays );
70
 
  }
71
 
 
72
 
  if ( m_data.share()->isForeign() )
73
 
  {
74
 
    m_data.setIcon( icon, QIcon::Disabled );
75
 
  }
76
 
  else
77
 
  {
78
 
    m_data.setIcon( icon );
79
 
  }
80
 
 
81
 
  setIcon( KIcon( m_data.pixmap( KIconLoader::SizeMedium ) ) );
82
 
 
83
 
  // Set up the text.
84
 
  setText( (mountpoint ? m_data.share()->path() : m_data.share()->unc()) );
85
 
 
86
 
  m_data.setShare( share );
87
 
  m_data.setShowMountPoint( mountpoint );
88
 
}
89
 
 
90
 
 
91
62
void Smb4KSharesIconViewItem::setShowMountPoint( bool show )
92
63
{
93
 
  setupItem( m_data.share(), show );
94
 
}
95
 
 
96
 
 
97
 
bool Smb4KSharesIconViewItem::sameShareObject( Smb4KShare *share )
98
 
{
99
 
  return m_data.share()->equals( *share, Smb4KShare::LocalOnly );
100
 
}
101
 
 
102
 
 
103
 
void Smb4KSharesIconViewItem::replaceShareObject( Smb4KShare *share )
104
 
{
105
 
  setupItem( share, m_data.showMountPoint() );
 
64
  m_mountpoint = show;
 
65
  update( &m_share );
 
66
}
 
67
 
 
68
 
 
69
void Smb4KSharesIconViewItem::update( Smb4KShare *share )
 
70
{
 
71
  m_share = *share;
 
72
  
 
73
  if ( !m_mountpoint )
 
74
  {
 
75
    setText( m_share.unc() );
 
76
  }
 
77
  else
 
78
  {
 
79
    setText( m_share.path() );
 
80
  }
 
81
 
 
82
  setIcon( m_share.icon() );
106
83
}