--- kdeaddons/konq-plugins/arkplugin/arkplugin.cpp 2006/03/12 01:18:18 517743 +++ kdeaddons/konq-plugins/arkplugin/arkplugin.cpp 2006/04/01 23:42:40 525413 @@ -58,10 +58,15 @@ KGlobal::locale()->insertCatalogue("ark_plugin"); extMimeTypes(); - m_list = popupmenu->fileItemList(); + KFileItemList itemList = popupmenu->fileItemList(); + for ( KFileItem *item = itemList.first(); item; item = itemList.next() ) + { + m_urlList.append( item->url() ); + m_urlStringList.append( item->url().url() ); + } m_dir = popupmenu->url().url() + "/"; - unsigned int itemCount = m_list.count(); - KFileItemListIterator it( m_list ); + unsigned int itemCount = m_urlList.count(); + KFileItemListIterator it( itemList ); KFileItem * item; bool hasArchives = false; bool hasOther = false; @@ -84,15 +89,15 @@ QString ext; KActionMenu * actionMenu; KAction * action; - if ( hasOther && m_list.first()->name()!="." && popupmenu->protocolInfo().supportsWriting() ) // don't try to compress if we right click on a folder without files selected + if ( hasOther && itemList.first()->name()!="." && popupmenu->protocolInfo().supportsWriting() ) // don't try to compress if we right click on a folder without files selected { compMimeTypes(); actionMenu = new KActionMenu( i18n( "Compress" ), "ark", actionCollection(), "ark_compress_menu" ); m_ext = m_conf->readEntry( "LastExtension", ".tar.gz" ); if ( itemCount == 1 ) { - item = m_list.first(); - m_name = m_list.first()->name(); + item = itemList.first(); + m_name = itemList.first()->name(); action = new KAction( i18n( "Compress as %1" ).arg( m_name + m_ext ), 0, this, SLOT( slotCompressAsDefault() ), actionCollection() ); } @@ -109,7 +114,7 @@ m_addToMenu = new KActionMenu( i18n( "Add To" ), actionCollection(), "arkaddtomnu" ); - if ( m_list.first()->url().isLocalFile() ) + if ( itemList.first()->url().isLocalFile() ) actionMenu->insert( m_addToMenu ); connect( m_compAsMenu->popupMenu(), SIGNAL( aboutToShow() ), @@ -136,7 +141,7 @@ // stolen from arkwidget.cpp if ( itemCount == 1 ) { - QString targetName = m_list.first()->name(); + QString targetName = itemList.first()->name(); stripExtension( targetName ); action = new KAction( i18n( "Extract to %1" ).arg( targetName ), 0, this, SLOT( slotExtractToSubfolders() ), actionCollection() ); @@ -187,7 +192,7 @@ (*eit).remove( '*' ); if ( *eit == ".tar.bz" ) // tbz mimetype, has tar.bz as first entry :} *eit = ".tar.bz2"; - if ( m_list.count() == 1 ) + if ( m_urlList.count() == 1 ) { action = new KAction( m_name + (*eit), 0, m_compAsMapper, SLOT( map() ), actionCollection() ); @@ -231,7 +236,7 @@ QCString actionName; QStringList::Iterator mit; KURL archive; - QDir dir( m_list.first()->url().directory() ); + QDir dir( m_urlList.first().directory() ); QStringList entries = dir.entryList(); QStringList::Iterator uit = entries.begin(); for ( ; uit != entries.end(); ++uit ) @@ -254,7 +259,7 @@ void ArkMenu::compMimeTypes() { - unsigned int itemCount = m_list.count(); + unsigned int itemCount = m_urlList.count(); bool havegz = false; if ( !KStandardDirs::findExe( "gzip" ).isNull() && m_conf->readBoolEntry( "UseGz", true ) ) @@ -401,14 +406,8 @@ QCString name; QString extension, mimeType; KURL target; - KFileItemListIterator it( m_list ); - KFileItem * item; - QStringList filelist; - while ( ( item = it.current() ) != 0 ) - { - ++it; - filelist.append( item->url().url() ); - } + QStringList filelist( m_urlStringList ); + //if KMimeType returns .ZIP or .RAR. convert them to lowercase if ( m_extensionList[ pos ].contains ( ".ZIP" ) ) m_extensionList[ pos ] = ".zip"; @@ -458,17 +457,10 @@ void ArkMenu::slotCompressAsDefault() { - KFileItemListIterator it( m_list ); - KFileItem * item; KURL name; - QStringList filelist; - while ( ( item = it.current() ) != 0 ) - { - ++it; - filelist.append( item->url().url() ); - } - if ( filelist.count() == 1) - name = filelist.first() + m_ext; + + if ( m_urlStringList.count() == 1) + name = m_urlStringList.first() + m_ext; else { name = m_dir + i18n("Archive") + m_ext; @@ -479,7 +471,7 @@ i++; } } - compressAs( filelist, name ); + compressAs( m_urlStringList, name ); } // make work for URLs @@ -494,16 +486,10 @@ void ArkMenu::slotAddTo( int pos ) { - QStringList args; - args << "--add-to"; - KFileItemListIterator it( m_list ); - KFileItem * item; - while ( ( item = it.current() ) != 0 ) - { - ++it; - args << item->url().url(); - } - KURL archive( m_list.first()->url() ); + QStringList args( m_urlStringList ); + args.prepend( "--add-to" ); + + KURL archive( m_urlStringList.first() ); archive.setPath( archive.directory( false ) ); archive.setFileName( m_archiveList[ pos ].fileName() ); @@ -513,63 +499,53 @@ void ArkMenu::slotAdd() { - QStringList args; - args << "--add"; - KFileItemListIterator it( m_list ); - KFileItem * item; - while ( ( item = it.current() ) != 0 ) - { - ++it; - args << item->url().url(); - } + QStringList args( m_urlStringList ); + args.prepend( "--add" ); + kapp->kdeinitExec( "ark", args ); } void ArkMenu::slotExtractHere() { - QStringList args; - KFileItemListIterator it( m_list ); - KFileItem * item; - while ( ( item = it.current() ) != 0 ) + for ( QValueList::ConstIterator it = m_urlList.constBegin(); + it != m_urlList.constEnd(); + ++it ) { - args.clear(); - ++it; - KURL targetDirectory = item->url(); + QStringList args; + KURL targetDirectory = ( *it ).url(); targetDirectory.setPath( targetDirectory.directory() ); - args << "--extract-to" << targetDirectory.url() << item->url().url(); + args << "--extract-to" << targetDirectory.url() << ( *it ).url(); kapp->kdeinitExec( "ark", args ); } } void ArkMenu::slotExtractToSubfolders() { - QStringList args; - QString dirName; - KURL targetDir; - KFileItemListIterator it( m_list ); - KFileItem * item; - while ( ( item = it.current() ) != 0 ) - { - args.clear(); - ++it; - targetDir = item->url(); + for ( QStringList::ConstIterator it = m_urlStringList.constBegin(); + it != m_urlStringList.constEnd(); + ++it ) + { + KURL targetDir; + QString dirName; + QStringList args; + + targetDir = *it; dirName = targetDir.path(); stripExtension( dirName ); targetDir.setPath( dirName ); - args << "--extract-to" << targetDir.url() << item->url().url(); + args << "--extract-to" << targetDir.url() << *it; kapp->kdeinitExec( "ark", args ); } } void ArkMenu::slotExtractTo() { - QStringList args; - KFileItemListIterator it( m_list ); - KFileItem * item; - while ( ( item = it.current() ) != 0 ) + for ( QStringList::ConstIterator it = m_urlStringList.constBegin(); + it != m_urlStringList.constEnd(); + ++it ) { - ++it; - args << "--extract" << item->url().url(); + QStringList args; + args << "--extract" << *it; kapp->kdeinitExec( "ark", args ); } } --- kdeaddons/konq-plugins/arkplugin/arkplugin.h 2005/09/29 14:33:08 465369 +++ kdeaddons/konq-plugins/arkplugin/arkplugin.h 2006/04/01 23:42:40 525413 @@ -54,7 +54,8 @@ private: QString m_name, m_ext; - KFileItemList m_list; + QValueList m_urlList; + QStringList m_urlStringList; KURL::List m_archiveList; QStringList m_archiveMimeTypes; QStringList m_extractMimeTypes;