41
41
#include <kio/copyjob.h>
42
42
#include <kjobuidelegate.h>
43
#include <kstandarddirs.h>
44
#include <kglobalsettings.h>
44
46
// application specific includes
45
47
#include <smb4ksharesview_part.h>
46
48
#include <smb4kshareslistviewitem.h>
47
49
#include <smb4ksharesiconviewitem.h>
48
#include <../dialogs/smb4ksynchronizationdialog.h>
50
#include <../tooltips/smb4ktooltip.h>
49
51
#include <core/smb4kshare.h>
50
52
#include <core/smb4kcore.h>
51
53
#include <core/smb4ksettings.h>
52
54
#include <core/smb4kglobal.h>
55
#include <core/smb4kmounter.h>
56
#include <core/smb4ksynchronizer.h>
57
#include <core/smb4kbookmarkhandler.h>
54
59
using namespace Smb4KGlobal;
56
typedef KParts::GenericFactory<Smb4KSharesViewPart> Smb4KSharesViewPartFactory;
57
K_EXPORT_COMPONENT_FACTORY( libsmb4ksharesview, Smb4KSharesViewPartFactory )
60
Smb4KSharesViewPart::Smb4KSharesViewPart( QWidget *parentWidget, QObject *parent, const QStringList &args )
61
: KParts::Part( parent ), m_mode( IconMode )
61
K_PLUGIN_FACTORY( Smb4KSharesViewPartFactory, registerPlugin<Smb4KSharesViewPart>(); )
62
K_EXPORT_PLUGIN( Smb4KSharesViewPartFactory( "Smb4KSharesViewPart" ) );
65
Smb4KSharesViewPart::Smb4KSharesViewPart( QWidget *parentWidget, QObject *parent, const QList<QVariant> &args )
66
: KParts::Part( parent ), m_mode( IconMode ), m_bookmark_shortcut( true ), m_silent( false )
63
68
// Parse the arguments.
64
69
for ( int i = 0; i < args.size(); ++i )
66
if ( args.at( i ).startsWith( "viewmode" ) )
71
if ( args.at( i ).toString().startsWith( "viewmode" ) )
68
if ( QString::compare( args.at( i ).section( "=", 1, 1 ).trimmed(), "list" ) == 0 )
73
if ( QString::compare( args.at( i ).toString().section( "=", 1, 1 ).trimmed(), "list" ) == 0 )
105
137
// will not be shown.
108
// Import the shares:
111
140
// Load settings:
114
143
// Add some connections:
115
connect( Smb4KCore::mounter(), SIGNAL( updated() ),
116
this, SLOT( slotMountedShares() ) );
118
connect( Smb4KCore::synchronizer(), SIGNAL( state( int ) ),
119
this, SLOT( slotSynchronizationState( int ) ) );
121
connect( kapp, SIGNAL( aboutToQuit() ),
122
this, SLOT( slotAboutToQuit() ) );
144
connect( Smb4KMounter::self(), SIGNAL( mounted( Smb4KShare * ) ),
145
this, SLOT( slotShareMounted( Smb4KShare * ) ) );
147
connect( Smb4KMounter::self(), SIGNAL( unmounted( Smb4KShare * ) ),
148
this, SLOT( slotShareUnmounted( Smb4KShare * ) ) );
150
connect( Smb4KMounter::self(), SIGNAL( updated( Smb4KShare *) ),
151
this, SLOT( slotShareUpdated( Smb4KShare * ) ) );
153
connect( Smb4KMounter::self(), SIGNAL( aboutToStart( Smb4KShare *, int ) ),
154
this, SLOT( slotMounterAboutToStart( Smb4KShare *, int ) ) );
156
connect( Smb4KMounter::self(), SIGNAL( finished( Smb4KShare *, int ) ),
157
this, SLOT( slotMounterFinished( Smb4KShare *, int ) ) );
159
connect( kapp, SIGNAL( aboutToQuit() ),
160
this, SLOT( slotAboutToQuit() ) );
162
connect( KGlobalSettings::self(), SIGNAL( iconChanged( int ) ),
163
this, SLOT( slotIconSizeChanged( int ) ) );
131
172
void Smb4KSharesViewPart::setupView()
133
// First disconnect the signals, so that we do not
134
// get multiple connections.
137
disconnect( m_icon_view, SIGNAL( customContextMenuRequested( const QPoint & ) ),
138
this, SLOT( slotContextMenuRequested( const QPoint & ) ) );
140
disconnect( m_icon_view, SIGNAL( itemSelectionChanged() ),
141
this, SLOT( slotItemSelectionChanged() ) );
143
disconnect( m_icon_view, SIGNAL( itemPressed( QListWidgetItem * ) ),
144
this, SLOT( slotItemPressed( QListWidgetItem * ) ) );
146
disconnect( m_icon_view, SIGNAL( itemExecuted( QListWidgetItem * ) ),
147
this, SLOT( slotItemExecuted( QListWidgetItem * ) ) );
149
disconnect( m_icon_view, SIGNAL( acceptedDropEvent( Smb4KSharesIconViewItem *, QDropEvent * ) ),
150
this, SLOT( slotIconViewDropEvent( Smb4KSharesIconViewItem *, QDropEvent * ) ) );
159
disconnect( m_list_view, SIGNAL( customContextMenuRequested( const QPoint & ) ),
160
this, SLOT( slotContextMenuRequested( const QPoint & ) ) );
162
disconnect( m_list_view, SIGNAL( itemSelectionChanged() ),
163
this, SLOT( slotItemSelectionChanged() ) );
165
disconnect( m_list_view, SIGNAL( itemPressed( QTreeWidgetItem *, int ) ),
166
this, SLOT( slotItemPressed( QTreeWidgetItem *, int ) ) );
168
disconnect( m_list_view, SIGNAL( itemExecuted( QTreeWidgetItem *, int ) ),
169
this, SLOT( slotItemExecuted( QTreeWidgetItem *, int ) ) );
171
disconnect( m_list_view, SIGNAL( acceptedDropEvent( Smb4KSharesListViewItem *, QDropEvent * ) ),
172
this, SLOT( slotListViewDropEvent( Smb4KSharesListViewItem *, QDropEvent * ) ) );
179
174
// Set the widget of this part:
180
175
switch ( m_mode )
184
179
if ( m_list_view )
181
disconnect( m_list_view, SIGNAL( customContextMenuRequested( const QPoint & ) ),
182
this, SLOT( slotContextMenuRequested( const QPoint & ) ) );
184
disconnect( m_list_view, SIGNAL( itemSelectionChanged() ),
185
this, SLOT( slotItemSelectionChanged() ) );
187
disconnect( m_list_view, SIGNAL( itemPressed( QTreeWidgetItem *, int ) ),
188
this, SLOT( slotItemPressed( QTreeWidgetItem *, int ) ) );
190
disconnect( m_list_view, SIGNAL( itemExecuted( QTreeWidgetItem *, int ) ),
191
this, SLOT( slotItemExecuted( QTreeWidgetItem *, int ) ) );
193
disconnect( m_list_view, SIGNAL( acceptedDropEvent( Smb4KSharesListViewItem *, QDropEvent * ) ),
194
this, SLOT( slotListViewDropEvent( Smb4KSharesListViewItem *, QDropEvent * ) ) );
186
196
delete m_list_view;
187
197
m_list_view = NULL;
194
204
if ( !m_icon_view )
196
206
m_icon_view = new Smb4KSharesIconView( m_container );
198
207
m_layout->addWidget( m_icon_view, 0, 0, 0 );
200
208
m_icon_view->setVisible( true );
209
m_container->setFocusProxy( m_icon_view );
212
int icon_size = KIconLoader::global()->currentSize( KIconLoader::Desktop );
213
m_icon_view->setIconSize( QSize( icon_size, icon_size ) );
215
connect( m_icon_view, SIGNAL( customContextMenuRequested( const QPoint & ) ),
216
this, SLOT( slotContextMenuRequested( const QPoint & ) ) );
218
connect( m_icon_view, SIGNAL( itemSelectionChanged() ),
219
this, SLOT( slotItemSelectionChanged() ) );
221
connect( m_icon_view, SIGNAL( itemPressed( QListWidgetItem * ) ),
222
this, SLOT( slotItemPressed( QListWidgetItem * ) ) );
224
connect( m_icon_view, SIGNAL( itemExecuted( QListWidgetItem * ) ),
225
this, SLOT( slotItemExecuted( QListWidgetItem * ) ) );
227
connect( m_icon_view, SIGNAL( acceptedDropEvent( Smb4KSharesIconViewItem *, QDropEvent * ) ),
228
this, SLOT( slotIconViewDropEvent( Smb4KSharesIconViewItem *, QDropEvent * ) ) );
207
connect( m_icon_view, SIGNAL( customContextMenuRequested( const QPoint & ) ),
208
this, SLOT( slotContextMenuRequested( const QPoint & ) ) );
210
connect( m_icon_view, SIGNAL( itemSelectionChanged() ),
211
this, SLOT( slotItemSelectionChanged() ) );
213
connect( m_icon_view, SIGNAL( itemPressed( QListWidgetItem * ) ),
214
this, SLOT( slotItemPressed( QListWidgetItem * ) ) );
216
connect( m_icon_view, SIGNAL( itemExecuted( QListWidgetItem * ) ),
217
this, SLOT( slotItemExecuted( QListWidgetItem * ) ) );
219
connect( m_icon_view, SIGNAL( acceptedDropEvent( Smb4KSharesIconViewItem *, QDropEvent * ) ),
220
this, SLOT( slotIconViewDropEvent( Smb4KSharesIconViewItem *, QDropEvent * ) ) );
226
239
if ( m_icon_view )
241
disconnect( m_icon_view, SIGNAL( customContextMenuRequested( const QPoint & ) ),
242
this, SLOT( slotContextMenuRequested( const QPoint & ) ) );
244
disconnect( m_icon_view, SIGNAL( itemSelectionChanged() ),
245
this, SLOT( slotItemSelectionChanged() ) );
247
disconnect( m_icon_view, SIGNAL( itemPressed( QListWidgetItem * ) ),
248
this, SLOT( slotItemPressed( QListWidgetItem * ) ) );
250
disconnect( m_icon_view, SIGNAL( itemExecuted( QListWidgetItem * ) ),
251
this, SLOT( slotItemExecuted( QListWidgetItem * ) ) );
253
disconnect( m_icon_view, SIGNAL( acceptedDropEvent( Smb4KSharesIconViewItem *, QDropEvent * ) ),
254
this, SLOT( slotIconViewDropEvent( Smb4KSharesIconViewItem *, QDropEvent * ) ) );
228
256
delete m_icon_view;
229
257
m_icon_view = NULL;
236
264
if ( !m_list_view )
238
266
m_list_view = new Smb4KSharesListView( m_container );
240
267
m_layout->addWidget( m_list_view, 0, 0, 0 );
242
268
m_list_view->setVisible( true );
269
m_container->setFocusProxy( m_list_view );
272
int icon_size = KIconLoader::global()->currentSize( KIconLoader::Small );
273
m_list_view->setIconSize( QSize( icon_size, icon_size ) );
275
connect( m_list_view, SIGNAL( customContextMenuRequested( const QPoint & ) ),
276
this, SLOT( slotContextMenuRequested( const QPoint & ) ) );
278
connect( m_list_view, SIGNAL( itemSelectionChanged() ),
279
this, SLOT( slotItemSelectionChanged() ) );
281
connect( m_list_view, SIGNAL( itemPressed( QTreeWidgetItem *, int ) ),
282
this, SLOT( slotItemPressed( QTreeWidgetItem *, int ) ) );
284
connect( m_list_view, SIGNAL( itemExecuted( QTreeWidgetItem *, int ) ),
285
this, SLOT( slotItemExecuted( QTreeWidgetItem *, int ) ) );
287
connect( m_list_view, SIGNAL( acceptedDropEvent( Smb4KSharesListViewItem *, QDropEvent * ) ),
288
this, SLOT( slotListViewDropEvent( Smb4KSharesListViewItem *, QDropEvent * ) ) );
249
connect( m_list_view, SIGNAL( customContextMenuRequested( const QPoint & ) ),
250
this, SLOT( slotContextMenuRequested( const QPoint & ) ) );
252
connect( m_list_view, SIGNAL( itemSelectionChanged() ),
253
this, SLOT( slotItemSelectionChanged() ) );
255
connect( m_list_view, SIGNAL( itemPressed( QTreeWidgetItem *, int ) ),
256
this, SLOT( slotItemPressed( QTreeWidgetItem *, int ) ) );
258
connect( m_list_view, SIGNAL( itemExecuted( QTreeWidgetItem *, int ) ),
259
this, SLOT( slotItemExecuted( QTreeWidgetItem *, int ) ) );
261
connect( m_list_view, SIGNAL( acceptedDropEvent( Smb4KSharesListViewItem *, QDropEvent * ) ),
262
this, SLOT( slotListViewDropEvent( Smb4KSharesListViewItem *, QDropEvent * ) ) );
308
332
filemanager_action->setShortcuts( shortcuts );
309
333
connect( filemanager_action, SIGNAL( triggered( bool ) ), this, SLOT( slotFileManager( bool ) ) );
335
KAction *bookmark_action = new KAction( KIcon( "bookmark-new" ), i18n( "Add &Bookmark" ),
336
actionCollection() );
337
if ( m_bookmark_shortcut )
339
bookmark_action->setShortcut( QKeySequence( Qt::CTRL+Qt::Key_B ) );
346
connect( bookmark_action, SIGNAL( triggered( bool ) ), this, SLOT( slotAddBookmark( bool ) ) );
311
348
actionCollection()->addAction( "unmount_action", unmount_action );
313
actionCollection()->addAction( "force_unmount_action", force_action );
315
349
actionCollection()->addAction( "unmount_all_action", unmount_all_action );
350
actionCollection()->addAction( "bookmark_action", bookmark_action );
316
351
actionCollection()->addAction( "synchronize_action", synchronize_action );
317
352
actionCollection()->addAction( "konsole_action", konsole_action );
318
353
actionCollection()->addAction( "filemanager_action", filemanager_action );
320
355
// Disable all actions for now:
321
356
unmount_action->setEnabled( false );
323
force_action->setEnabled( false );
325
357
unmount_all_action->setEnabled( false );
358
bookmark_action->setEnabled( false );
326
359
synchronize_action->setEnabled( false );
327
360
konsole_action->setEnabled( false );
328
361
filemanager_action->setEnabled( false );
497
510
void Smb4KSharesViewPart::customEvent( QEvent *e )
501
case EVENT_LOAD_SETTINGS:
503
// Before we reread the settings, let's save
504
// widget specific things.
510
// (Re-)load the list of shares.
515
case EVENT_SET_FOCUS:
521
if ( m_icon_view->count() != 0 )
523
kDebug() << "Do we need to port the selection stuff?" << endl;
530
m_icon_view->setFocus( Qt::OtherFocusReason );
536
if ( m_list_view->topLevelItemCount() != 0 )
538
kDebug() << "Do we need to port the selection stuff?" << endl;
545
m_list_view->setFocus( Qt::OtherFocusReason );
555
// KListView *view = static_cast<KListView *>( m_widget );
557
// if ( view->childCount() != 0 )
559
// view->setSelected( !view->currentItem() ?
560
// view->firstChild() :
561
// view->currentItem(), true );
512
if ( e->type() == Smb4KEvent::LoadSettings )
514
// Before we reread the settings, let's save
515
// widget specific things.
521
// (Re-)load the list of shares.
526
while ( m_icon_view->count() != 0 )
528
delete m_icon_view->takeItem( 0 );
535
while ( m_list_view->topLevelItemCount() != 0 )
537
delete m_list_view->takeTopLevelItem( 0 );
548
for ( int i = 0; i < mountedSharesList().size(); ++i )
550
slotShareMounted( mountedSharesList().at( i ) );
553
else if ( e->type() == Smb4KEvent::SetFocus )
559
if ( m_icon_view->count() != 0 )
561
kDebug() << "Do we need to port the selection stuff?" << endl;
568
m_icon_view->setFocus( Qt::OtherFocusReason );
573
if ( m_list_view->topLevelItemCount() != 0 )
575
kDebug() << "Do we need to port the selection stuff?" << endl;
582
m_list_view->setFocus( Qt::OtherFocusReason );
591
else if ( e->type() == Smb4KEvent::AddBookmark )
593
slotAddBookmark( false );
574
600
KParts::Part::customEvent( e );
647
673
if ( !items.isEmpty() )
649
675
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( items.first() );
676
bool sync_running = Smb4KSynchronizer::self()->isRunning( item->shareItem() );
651
actionCollection()->action( "unmount_action" )->setEnabled( (!item->itemData()->share()->isForeign() ||
678
actionCollection()->action( "unmount_action" )->setEnabled( (!item->shareItem()->isForeign() ||
652
679
Smb4KSettings::unmountForeignShares()) );
654
actionCollection()->action( "force_unmount_action" )->setEnabled( Smb4KSettings::useForceUnmount() &&
655
(!item->itemData()->share()->isForeign() ||
656
Smb4KSettings::unmountForeignShares()) );
658
Smb4KShare *share = item->itemData()->share();
680
actionCollection()->action( "bookmark_action" )->setEnabled( true );
660
if ( !share->isInaccessible() )
682
if ( !item->shareItem()->isInaccessible() )
662
actionCollection()->action( "synchronize_action" )->setEnabled( !Smb4KSettings::rsync().isEmpty() &&
663
!Smb4KCore::synchronizer()->isRunning() );
664
actionCollection()->action( "konsole_action" )->setEnabled( !Smb4KSettings::konsole().isEmpty() );
684
actionCollection()->action( "synchronize_action" )->setEnabled( !KStandardDirs::findExe( "rsync" ).isEmpty() && !sync_running );
685
actionCollection()->action( "konsole_action" )->setEnabled( !KGlobal::dirs()->findResource( "exe", "konsole" ).isEmpty() );
665
686
actionCollection()->action( "filemanager_action" )->setEnabled( true );
692
711
if ( !items.isEmpty() )
694
713
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( items.first() );
714
bool sync_running = Smb4KSynchronizer::self()->isRunning( item->shareItem() );
696
actionCollection()->action( "unmount_action" )->setEnabled( (!item->itemData()->share()->isForeign() ||
716
actionCollection()->action( "unmount_action" )->setEnabled( (!item->shareItem()->isForeign() ||
697
717
Smb4KSettings::unmountForeignShares()) );
699
actionCollection()->action( "force_unmount_action" )->setEnabled( Smb4KSettings::useForceUnmount() &&
700
(!item->itemData()->share()->isForeign() ||
701
Smb4KSettings::unmountForeignShares()) );
703
Smb4KShare *share = item->itemData()->share();
718
actionCollection()->action( "bookmark_action" )->setEnabled( true );
705
if ( !share->isInaccessible() )
720
if ( !item->shareItem()->isInaccessible() )
707
actionCollection()->action( "synchronize_action" )->setEnabled( !Smb4KSettings::rsync().isEmpty() &&
708
!Smb4KCore::synchronizer()->isRunning() );
709
actionCollection()->action( "konsole_action" )->setEnabled( !Smb4KSettings::konsole().isEmpty() );
722
actionCollection()->action( "synchronize_action" )->setEnabled( !KStandardDirs::findExe( "rsync" ).isEmpty() && !sync_running );
723
actionCollection()->action( "konsole_action" )->setEnabled( !KGlobal::dirs()->findResource( "exe", "konsole" ).isEmpty() );
710
724
actionCollection()->action( "filemanager_action" )->setEnabled( true );
765
788
if ( !shareItem && m_icon_view->selectedItems().isEmpty() )
767
790
actionCollection()->action( "unmount_action" )->setEnabled( false );
769
actionCollection()->action( "force_unmount_action" )->setEnabled( false );
791
actionCollection()->action( "bookmark_action" )->setEnabled( false );
771
792
actionCollection()->action( "synchronize_action" )->setEnabled( false );
772
793
actionCollection()->action( "konsole_action" )->setEnabled( false );
773
794
actionCollection()->action( "filemanager_action" )->setEnabled( false );
777
// Do nothing. This will be done elsewhere.
800
bool sync_running = Smb4KSynchronizer::self()->isRunning( shareItem->shareItem() );
802
actionCollection()->action( "synchronize_action" )->setEnabled( !KStandardDirs::findExe( "rsync" ).isEmpty() &&
804
!shareItem->shareItem()->isInaccessible() );
811
// The rest will be done elsewhere.
782
816
void Smb4KSharesViewPart::slotItemExecuted( QTreeWidgetItem *item, int /*column*/ )
784
// This is a precaution.
785
if ( item != m_list_view->currentItem() )
818
if ( QApplication::keyboardModifiers() == Qt::NoModifier )
787
m_list_view->setCurrentItem( item );
820
// This is a precaution.
821
if ( item != m_list_view->currentItem() )
823
m_list_view->setCurrentItem( item );
830
slotFileManager( false );
794
slotFileManager( false );
798
839
void Smb4KSharesViewPart::slotItemExecuted( QListWidgetItem *item )
800
// This is a precaution.
801
if ( item != m_icon_view->currentItem() )
841
// Do not execute the item when keyboard modifiers were pressed
842
// or the mouse button is not the left one.
843
if ( QApplication::keyboardModifiers() == Qt::NoModifier )
803
m_icon_view->setCurrentItem( item );
845
// This is a precaution.
846
if ( item != m_icon_view->currentItem() )
848
m_icon_view->setCurrentItem( item );
855
slotFileManager( false );
810
slotFileManager( false );
936
void Smb4KSharesViewPart::slotMountedShares()
986
void Smb4KSharesViewPart::slotShareMounted( Smb4KShare *share )
938
// Get the list of shares:
939
QList<Smb4KShare *> *list = mountedSharesList();
941
990
switch ( m_mode )
945
if ( !list->isEmpty() )
947
// Remove obsolete items and unset the current item
948
// if we remove it so that we won't get an unwanted
950
Smb4KSharesIconViewItem *item = NULL;
952
for ( int i = 0; i < m_icon_view->count(); ++i )
954
item = static_cast<Smb4KSharesIconViewItem *>( m_icon_view->item( i ) );
956
Smb4KShare *share = findShareByPath( item->itemData()->share()->path() );
958
if ( !share || (share->isForeign() && !Smb4KSettings::showAllShares()) )
960
if ( item == m_icon_view->currentItem() )
962
m_icon_view->setCurrentItem( NULL );
978
// Insert the new items and update the existing ones.
979
Smb4KSharesIconViewItem *shareItem = NULL;
981
for ( int i = 0; i < list->size(); ++i )
983
// Search for the item in the tree widget. Use the
985
Smb4KSharesIconViewItem *tmp = NULL;
987
for ( int j = 0; j < m_icon_view->count(); ++j )
989
tmp = static_cast<Smb4KSharesIconViewItem *>( m_icon_view->item( j ) );
991
if ( QString::compare( tmp->itemData()->share()->path(), list->at( i )->path() ) == 0 ||
992
QString::compare( tmp->itemData()->share()->canonicalPath(), list->at( i )->canonicalPath() ) == 0 )
1004
if ( !shareItem->sameShareObject( list->at( i ) ) )
1006
shareItem->replaceShareObject( list->at( i ) );
1013
m_icon_view->updateToolTip();
1017
if ( !list->at( i )->isForeign() || Smb4KSettings::showAllShares() )
1019
shareItem = new Smb4KSharesIconViewItem( list->at( i ), m_icon_view );
1020
shareItem->setShowMountPoint( Smb4KSettings::showMountPoint() );
1033
m_icon_view->clear();
994
(void) new Smb4KSharesIconViewItem( m_icon_view, share, Smb4KSettings::showMountPoint() );
1037
995
m_icon_view->sortItems( Qt::AscendingOrder );
996
actionCollection()->action( "unmount_all_action" )->setEnabled(
997
((!onlyForeignMountedShares() || Smb4KSettings::unmountForeignShares()) && m_icon_view->count() != 0) );
1043
if ( !list->isEmpty() )
1045
// Remove obsolete items.
1046
QTreeWidgetItemIterator it( m_list_view );
1047
Smb4KSharesListViewItem *item = NULL;
1051
item = static_cast<Smb4KSharesListViewItem *>( *it );
1053
Smb4KShare *share = findShareByPath( item->itemData()->share()->path() );
1055
if ( !share || (share->isForeign() && !Smb4KSettings::showAllShares()) )
1057
if ( item == m_list_view->currentItem() )
1059
m_list_view->setCurrentItem( NULL );
1077
// Insert the new items and update the existing ones.
1078
Smb4KSharesListViewItem *shareItem = NULL;
1080
for ( int i = 0; i < list->size(); ++i )
1082
// Search for the item in the tree widget. Use the
1084
it = QTreeWidgetItemIterator( m_list_view );
1085
Smb4KSharesListViewItem *tmp = NULL;
1089
tmp = static_cast<Smb4KSharesListViewItem *>( *it );
1091
if ( QString::compare( tmp->itemData()->share()->path(), list->at( i )->path() ) == 0 ||
1092
QString::compare( tmp->itemData()->share()->canonicalPath(), list->at( i )->canonicalPath() ) == 0 )
1106
if ( !shareItem->sameShareObject( list->at( i ) ) )
1108
shareItem->replaceShareObject( list->at( i ) );
1115
m_list_view->updateToolTip();
1119
if ( !list->at( i )->isForeign() || Smb4KSettings::showAllShares() )
1121
shareItem = new Smb4KSharesListViewItem( list->at( i ), m_list_view );
1122
shareItem->setShowMountPoint( Smb4KSettings::showMountPoint() );
1135
m_list_view->clear();
1002
(void) new Smb4KSharesListViewItem( m_list_view, share, Smb4KSettings::showMountPoint() );
1139
1003
m_list_view->sortItems( Smb4KSharesListView::Item, Qt::AscendingOrder );
1149
// Enable the "Unmount All" action.
1150
actionCollection()->action( "unmount_all_action" )->setEnabled( !list->isEmpty() );
1004
actionCollection()->action( "unmount_all_action" )->setEnabled(
1005
((!onlyForeignMountedShares() || Smb4KSettings::unmountForeignShares()) && m_list_view->topLevelItemCount() != 0) );
1016
void Smb4KSharesViewPart::slotShareUnmounted( Smb4KShare *share )
1024
Smb4KSharesIconViewItem *item = NULL;
1026
for ( int i = 0; i < m_icon_view->count(); ++i )
1028
item = static_cast<Smb4KSharesIconViewItem *>( m_icon_view->item( i ) );
1030
if ( item && (QString::compare( item->shareItem()->path(), share->path() ) == 0 ||
1031
QString::compare( item->shareItem()->canonicalPath(), share->canonicalPath() ) == 0) )
1033
if ( item == m_icon_view->currentItem() )
1035
m_icon_view->setCurrentItem( NULL );
1042
delete m_icon_view->takeItem( i );
1051
actionCollection()->action( "unmount_all_action" )->setEnabled(
1052
((!onlyForeignMountedShares() || Smb4KSettings::unmountForeignShares()) && m_icon_view->count() != 0) );
1058
Smb4KSharesListViewItem *item = NULL;
1060
for ( int i = 0; i < m_list_view->topLevelItemCount(); ++i )
1062
item = static_cast<Smb4KSharesListViewItem *>( m_list_view->topLevelItem( i ) );
1064
if ( item && (QString::compare( item->shareItem()->path(), share->path() ) == 0 ||
1065
QString::compare( item->shareItem()->canonicalPath(), share->canonicalPath() ) == 0) )
1067
if ( item == m_list_view->currentItem() )
1069
m_list_view->setCurrentItem( NULL );
1076
delete m_list_view->takeTopLevelItem( i );
1085
actionCollection()->action( "unmount_all_action" )->setEnabled(
1086
((!onlyForeignMountedShares() || Smb4KSettings::unmountForeignShares()) && m_list_view->topLevelItemCount() != 0) );
1098
void Smb4KSharesViewPart::slotShareUpdated( Smb4KShare *share )
1104
Smb4KSharesIconViewItem *item = NULL;
1106
for ( int i = 0; i < m_icon_view->count(); ++i )
1108
item = static_cast<Smb4KSharesIconViewItem *>( m_icon_view->item( i ) );
1110
if ( item && (QString::compare( item->shareItem()->path(), share->path() ) == 0 ||
1111
QString::compare( item->shareItem()->canonicalPath(), share->canonicalPath() ) == 0) )
1113
item->update( share );
1114
m_icon_view->tooltip()->update();
1126
Smb4KSharesListViewItem *item = NULL;
1128
for ( int i = 0; i < m_list_view->topLevelItemCount(); ++i )
1130
item = static_cast<Smb4KSharesListViewItem *>( m_list_view->topLevelItem( i ) );
1132
if ( item && (QString::compare( item->shareItem()->path(), share->path() ) == 0 ||
1133
QString::compare( item->shareItem()->canonicalPath(), share->canonicalPath() ) == 0) )
1135
item->update( share );
1136
m_list_view->tooltip()->update();
1160
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_icon_view->currentItem() );
1164
Smb4KCore::mounter()->unmountShare( item->itemData()->share(), false );
1175
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_list_view->currentItem() );
1179
Smb4KCore::mounter()->unmountShare( item->itemData()->share(), false );
1196
void Smb4KSharesViewPart::slotForceUnmountShare( bool /*checked*/ )
1202
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_icon_view->currentItem() );
1206
Smb4KCore::mounter()->unmountShare( item->itemData()->share(), true );
1217
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_list_view->currentItem() );
1221
Smb4KCore::mounter()->unmountShare( item->itemData()->share(), true );
1160
QList<QListWidgetItem *> selected_items = m_icon_view->selectedItems();
1162
for ( int i = 0; i < selected_items.size(); ++i )
1164
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( selected_items.at( i ) );
1168
Smb4KMounter::self()->unmountShare( item->shareItem(), false, m_icon_view );
1180
QList<QTreeWidgetItem *> selected_items = m_list_view->selectedItems();
1182
for ( int i = 0; i < selected_items.size(); ++i )
1184
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( selected_items.at( i ) );
1188
Smb4KMounter::self()->unmountShare( item->shareItem(), false, m_list_view );
1250
Smb4KSynchronizationDialog *dlg = m_icon_view->findChild<Smb4KSynchronizationDialog *>();
1251
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_icon_view->currentItem() );
1253
if ( item && !item->itemData()->share()->isInaccessible() && !dlg )
1255
dlg = new Smb4KSynchronizationDialog( item->itemData()->share(), m_icon_view );
1257
dlg->setVisible( true );
1234
QList<QListWidgetItem *> selected_items = m_icon_view->selectedItems();
1236
for ( int i = 0; i < selected_items.size(); ++i )
1238
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( selected_items.at( i ) );
1240
if ( item && !item->shareItem()->isInaccessible() )
1242
Smb4KSynchronizer::self()->synchronize( item->shareItem(), m_icon_view );
1268
Smb4KSynchronizationDialog *dlg = m_list_view->findChild<Smb4KSynchronizationDialog *>();
1269
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_list_view->currentItem() );
1271
if ( item && !item->itemData()->share()->isInaccessible() && !dlg )
1273
dlg = new Smb4KSynchronizationDialog( item->itemData()->share(), m_list_view );
1275
dlg->setVisible( true );
1254
QList<QTreeWidgetItem *> selected_items = m_list_view->selectedItems();
1256
for ( int i = 0; i < selected_items.size(); ++i )
1258
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( selected_items.at( i ) );
1260
if ( item && !item->shareItem()->isInaccessible() )
1262
Smb4KSynchronizer::self()->synchronize( item->shareItem(), m_list_view );
1297
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_icon_view->currentItem() );
1299
if ( item && !item->itemData()->share()->isInaccessible() )
1301
Smb4KCore::open( item->itemData()->share(), Smb4KCore::Konsole );
1285
QList<QListWidgetItem *> selected_items = m_icon_view->selectedItems();
1287
for ( int i = 0; i < selected_items.size(); ++i )
1289
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( selected_items.at( i ) );
1291
if ( item && !item->shareItem()->isInaccessible() )
1293
open( item->shareItem(), Konsole );
1313
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_list_view->currentItem() );
1315
if ( item && !item->itemData()->share()->isInaccessible() )
1317
Smb4KCore::open( item->itemData()->share(), Smb4KCore::Konsole );
1305
QList<QTreeWidgetItem *> selected_items = m_list_view->selectedItems();
1307
for ( int i = 0; i < selected_items.size(); ++i )
1309
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( selected_items.at( i ) );
1311
if ( item && !item->shareItem()->isInaccessible() )
1313
open( item->shareItem(), Konsole );
1340
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_icon_view->currentItem() );
1342
if ( item && !item->itemData()->share()->isInaccessible() )
1344
Smb4KCore::open( item->itemData()->share(), Smb4KCore::FileManager );
1355
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_list_view->currentItem() );
1357
if ( item && !item->itemData()->share()->isInaccessible() )
1359
Smb4KCore::open( item->itemData()->share(), Smb4KCore::FileManager );
1376
void Smb4KSharesViewPart::slotSynchronizationState( int state )
1380
case SYNCHRONIZER_START:
1382
actionCollection()->action( "synchronize_action" )->setEnabled( false );
1386
case SYNCHRONIZER_STOP:
1388
actionCollection()->action( "synchronize_action" )->setEnabled( true );
1337
QList<QListWidgetItem *> selected_items = m_icon_view->selectedItems();
1339
for ( int i = 0; i < selected_items.size(); ++i )
1341
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( selected_items.at( i ) );
1343
if ( item && !item->shareItem()->isInaccessible() )
1345
open( item->shareItem(), FileManager );
1357
QList<QTreeWidgetItem *> selected_items = m_list_view->selectedItems();
1359
for ( int i = 0; i < selected_items.size(); ++i )
1361
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( selected_items.at( i ) );
1363
if ( item && !item->shareItem()->isInaccessible() )
1365
open( item->shareItem(), FileManager );
1383
void Smb4KSharesViewPart::slotAddBookmark( bool /*checked */)
1389
QList<QListWidgetItem *> selected_items = m_icon_view->selectedItems();
1390
QList<Smb4KShare *> shares;
1392
if ( !selected_items.isEmpty() )
1394
for ( int i = 0; i < selected_items.size(); ++i )
1396
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( selected_items.at( i ) );
1397
shares << item->shareItem();
1403
// No selected items. Just return.
1407
if ( !shares.isEmpty() )
1409
Smb4KBookmarkHandler::self()->addBookmarks( shares, m_icon_view );
1420
QList<QTreeWidgetItem *> selected_items = m_list_view->selectedItems();
1421
QList<Smb4KShare *> shares;
1423
if ( !selected_items.isEmpty() )
1425
for ( int i = 0; i < selected_items.size(); ++i )
1427
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( selected_items.at( i ) );
1428
shares << item->shareItem();
1434
// No selected items. Just return.
1438
if ( !shares.isEmpty() )
1440
Smb4KBookmarkHandler::self()->addBookmarks( shares, m_list_view );
1457
void Smb4KSharesViewPart::slotMounterAboutToStart( Smb4KShare *share, int process )
1461
case Smb4KMounter::MountShare:
1465
emit setStatusBarText( i18n( "Mounting share %1..." ).arg( share->unc() ) );
1473
case Smb4KMounter::UnmountShare:
1477
emit setStatusBarText( i18n( "Unmounting share %1..." ).arg( share->unc() ) );
1493
void Smb4KSharesViewPart::slotMounterFinished( Smb4KShare */*share*/, int /*process*/ )
1497
emit setStatusBarText( i18n( "Done." ) );