Commit 77acc1f2 authored by Henrique Pinto's avatar Henrique Pinto
Browse files

* Remove the 'edit' action, so that we don't have to link to KDE3 support libraries anymore

 * Rename 'extractFile' to 'extractFiles', as it takes a list of files
 * Arch::remove(): pass the QStringList as a const reference instead of a pointer


svn path=/branches/work/libarchive-based-ark/ark/; revision=672760
parent 3cd1fc32
......@@ -17,7 +17,7 @@ kde4_add_ui_files(ark_KDEINIT_SRCS general.ui )
kde4_add_kdeinit_executable( ark ${ark_KDEINIT_SRCS})
target_link_libraries(kdeinit_ark ${KDE4_KDE3SUPPORT_LIBS} )
target_link_libraries(kdeinit_ark ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KPARTS_LIBS})
install(TARGETS kdeinit_ark DESTINATION ${LIB_INSTALL_DIR})
......@@ -54,7 +54,7 @@ kde4_add_ui_files(arkpart_PART_SRCS general.ui )
kde4_add_plugin(arkpart WITH_PREFIX ${arkpart_PART_SRCS})
target_link_libraries(arkpart ${KDE4_KFILE_LIBS} ${KDE4_THREADWEAVER_LIBRARIES} ${LIBARCHIVE_LIBRARY})
target_link_libraries(arkpart ${KDE4_KFILE_LIBS} ${KDE4_THREADWEAVER_LIBRARIES} ${LIBARCHIVE_LIBRARY} ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KPARTS_LIBS})
install(TARGETS arkpart DESTINATION ${PLUGIN_INSTALL_DIR})
......
......@@ -45,7 +45,6 @@
#include <KMimeType>
#include <KLocale>
#include <KPasswordDialog>
#include <K3Process>
#include <KStandardDirs>
// the archive types
......@@ -61,9 +60,16 @@ Arch::~Arch()
{
}
Arch *Arch::archFactory( ArchType aType,
void Arch::extractFile( const QString & fileName, const QString & destinationDir )
{
QStringList l;
l << fileName;
extractFiles( l, destinationDir );
}
Arch *Arch::archFactory( ArchType /*aType*/,
ArkWidget *parent, const QString &filename,
const QString &openAsMimeType )
const QString &/*openAsMimeType*/ )
{
return new LibArchiveHandler( parent, filename );
}
......
......@@ -57,7 +57,6 @@
class QByteArray;
class QStringList;
class K3Process;
class ArkWidget;
......@@ -86,12 +85,13 @@ class Arch : public QObject
virtual void open() = 0;
virtual void create() = 0;
virtual void remove( QStringList * ) = 0;
virtual void remove( const QStringList & ) = 0;
virtual void addFile( const QStringList & ) = 0;
virtual void addDir( const QString & ) = 0;
virtual void extractFile( const QStringList &, const QString & _destDir ) = 0;
virtual void extractFile( const QString & fileName, const QString & destinationDir );
virtual void extractFiles( const QStringList & fileList, const QString & destinationDir ) = 0;
virtual bool passwordRequired() { return false; }
......
......@@ -147,11 +147,6 @@ ArkPart::setupActions()
actionCollection()->addAction("open_with", openWithAction );
connect(openWithAction, SIGNAL(triggered(bool) ), awidget, SLOT(slotOpenWith()));
editAction = new KAction(i18n("Edit &With..."), this);
actionCollection()->addAction("edit", editAction );
connect(editAction, SIGNAL(triggered(bool) ), awidget, SLOT(action_edit()));
selectAllAction = KStandardAction::selectAll(awidget->fileList(), SLOT(selectAll()), actionCollection());
actionCollection()->addAction("select_all", selectAllAction);
......@@ -218,7 +213,6 @@ void ArkPart::fixEnables()
);
viewAction->setEnabled( b );
openWithAction->setEnabled( b );
editAction->setEnabled( b && !bReadOnly ); // You can't edit files in read-only archives
emit fixActionState( bHaveFiles );
}
......@@ -236,7 +230,6 @@ void ArkPart::initialEnables()
addFileAction->setEnabled(false);
addDirAction->setEnabled(false);
openWithAction->setEnabled(false);
editAction->setEnabled(false);
awidget->searchBar()->setEnabled(false);
}
......@@ -254,7 +247,6 @@ void ArkPart::disableActions()
addFileAction->setEnabled(false);
addDirAction->setEnabled(false);
openWithAction->setEnabled(false);
editAction->setEnabled(false);
awidget->searchBar()->setEnabled(false);
}
......
......@@ -134,7 +134,6 @@ private:
QAction *openWithAction;
QAction *deselectAllAction;
QAction *invertSelectionAction;
QAction *editAction;
// the following have different enable rules from the above KActions
KAction *popupViewAction;
......
......@@ -295,7 +295,7 @@ ArkWidget::convertTo( const KUrl & u )
m_convert_tmpDir = new KTempDir( tmpDir() + "convtmp" );
connect( arch, SIGNAL( sigExtract( bool ) ), this, SLOT( convertSlotExtractDone( bool ) ) );
m_convert_saveAsURL = u;
arch->extractFile( QStringList(), m_convert_tmpDir->name() );
arch->extractFiles( QStringList(), m_convert_tmpDir->name() );
}
void
......@@ -509,7 +509,7 @@ ArkWidget::extractToSlotOpenDone( bool success )
{
disableAll();
connect( arch, SIGNAL( sigExtract( bool ) ), this, SLOT( extractToSlotExtractDone( bool ) ) );
arch->extractFile( QStringList(), extractDir );
arch->extractFiles( QStringList(), extractDir );
}
else
{
......@@ -1261,7 +1261,7 @@ ArkWidget::action_delete()
disableAll();
busy( i18n( "Removing..." ) );
connect( arch, SIGNAL( sigDelete( bool ) ), this, SLOT( slotDeleteDone( bool ) ) );
arch->remove(&list);
arch->remove(list);
kDebug(1601) << "-ArkWidget::action_delete" << endl;
}
......@@ -1339,7 +1339,7 @@ ArkWidget::prepareViewFiles( const QStringList & fileList )
it != fileList.end(); ++it)
QFile::remove(destTmpDirectory + *it);
arch->extractFile( fileList, destTmpDirectory );
arch->extractFiles( fileList, destTmpDirectory );
}
bool
......@@ -1503,7 +1503,7 @@ ArkWidget::action_extract()
disableAll();
busy( i18n( "Extracting..." ) );
connect( arch, SIGNAL( sigExtract( bool ) ), this, SLOT( slotExtractDone() ) );
arch->extractFile(QStringList(), extractDir);
arch->extractFiles(QStringList(), extractDir);
}
}
}
......@@ -1530,7 +1530,7 @@ ArkWidget::action_extract()
busy( i18n( "Extracting..." ) );
connect( arch, SIGNAL( sigExtract( bool ) ),
this, SLOT( slotExtractDone() ) );
arch->extractFile(selectedFiles, extractDir); // extract selected files
arch->extractFiles(selectedFiles, extractDir); // extract selected files
}
}
}
......@@ -1556,107 +1556,6 @@ ArkWidget::action_extract()
return true;
}
void
ArkWidget::action_edit()
{
// begin an edit. This is like a view, but once the process exits,
// the file is put back into the archive. If the user tries to quit or
// close the archive, there will be a warning that any changes to the
// files open under "Edit" will be lost unless the archive remains open.
// [hmm, does that really make sense? I'll leave it for now.]
busy( i18n( "Extracting..." ) );
connect( arch, SIGNAL( sigExtract( bool ) ), this,
SLOT( editSlotExtractDone() ) );
showCurrentFile();
}
void
ArkWidget::editSlotExtractDone()
{
disconnect( arch, SIGNAL( sigExtract( bool ) ),
this, SLOT( editSlotExtractDone() ) );
ready();
editStart();
// avoid race condition, don't do updates if application is exiting
if( m_fileListView )
{
m_fileListView->setUpdatesEnabled(true);
fixEnables();
}
}
void
ArkWidget::editStart()
{
kDebug(1601) << "Edit in progress..." << endl;
KUrl::List list;
// edit will be in progress until the K3Process terminates.
KOpenWithDialog l( list, i18n("Edit with:"), QString(), this );
if ( l.exec() )
{
K3Process *kp = new K3Process;
m_strFileToView = m_strFileToView.right(m_strFileToView.length() - 5 );
*kp << l.text() << m_strFileToView;
connect( kp, SIGNAL(processExited(K3Process *)),
this, SLOT(slotEditFinished(K3Process *)) );
if ( kp->start(K3Process::NotifyOnExit, K3Process::AllOutput) == false )
{
KMessageBox::error(0, i18n("Trouble editing the file..."));
}
}
}
void
ArkWidget::slotEditFinished(K3Process *kp)
{
kDebug(1601) << "+ArkWidget::slotEditFinished" << endl;
connect( arch, SIGNAL( sigAdd( bool ) ), this, SLOT( editSlotAddDone( bool ) ) );
delete kp;
QStringList list;
// now put the file back into the archive.
list.append(m_strFileToView);
disableAll();
// BUG: this puts any edited file back at the archive toplevel...
// there's only one file, and it's in the temp directory.
// If the filename has more than three /'s then we should
// change to the first level directory so that the paths
// come out right.
QStringList::Iterator it = list.begin();
QString filename = *it;
QString path;
if (filename.count('/') > 3)
{
kDebug(1601) << "Filename is originally: " << filename << endl;
int i = filename.indexOf('/', 5);
path = filename.left(1+i);
kDebug(1601) << "Changing to dir: " << path << endl;
QDir::setCurrent(path);
filename = filename.right(filename.length()-i-1);
// HACK!! We need a relative path. If I have "file:", it
// will look like an absolute path. So five spaces here to get
// chopped off later....
filename = " " + filename;
*it = filename;
}
busy( i18n( "Readding edited file..." ) );
arch->addFile( list );
kDebug(1601) << "-ArkWidget::slotEditFinished" << endl;
}
void
ArkWidget::editSlotAddDone( bool success )
{
ready();
disconnect( arch, SIGNAL( sigAdd( bool ) ), this, SLOT( editSlotAddDone( bool ) ) );
slotAddDone( success );
}
void
ArkWidget::action_view()
{
......
......@@ -128,7 +128,6 @@ protected slots:
void action_delete();
bool action_extract();
void slotOpenWith();
void action_edit();
void doPopup(QTreeWidgetItem *, const QPoint &, int); // right-click menus
void viewFile(QTreeWidgetItem*); // doubleClick view files
......@@ -140,7 +139,6 @@ protected slots:
void slotExtractDone();
void slotExtractRemoteDone(KJob *job);
void slotAddDone(bool);
void slotEditFinished(K3Process *);
signals:
void openUrlRequest( const KUrl & url );
void request_file_quit();
......@@ -199,7 +197,6 @@ private: // methods
void extractOnlyOpenDone();
void extractRemoteInitiateMoving( const KUrl & target );
void editStart();
void busy( const QString & text );
void holdBusy();
......@@ -210,8 +207,6 @@ private: // methods
const QString guessName( const KUrl & archive );
private slots:
void editSlotExtractDone();
void editSlotAddDone( bool success );
void viewSlotExtractDone( bool success );
void openWithSlotExtractDone();
......
......@@ -194,11 +194,11 @@ void LibArchiveHandler::addDir( const QString & )
{
}
void LibArchiveHandler::remove( QStringList* )
void LibArchiveHandler::remove( const QStringList & )
{
}
void LibArchiveHandler::extractFile( const QStringList & files, const QString& destinationDir )
void LibArchiveHandler::extractFiles( const QStringList & files, const QString& destinationDir )
{
ExtractionJob *job = new ExtractionJob( fileName(), files, destinationDir, this );
connect( job, SIGNAL( done( ThreadWeaver::Job* ) ),
......
......@@ -45,8 +45,8 @@ class LibArchiveHandler: public Arch
virtual void addFile( const QStringList & );
virtual void addDir( const QString & );
virtual void remove( QStringList* );
virtual void extractFile( const QStringList & files, const QString& destinationDir );
virtual void remove( const QStringList & );
virtual void extractFiles( const QStringList & files, const QString& destinationDir );
private slots:
void listingDone( ThreadWeaver::Job* );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment