Commit bc6dcce5 authored by Henrique Pinto's avatar Henrique Pinto

* New part and new app.

   Reason for them: I don't believe there's any benefit
   in Ark being a KUniqueApplication, and starting a new
   part from scratch seems easier than cleaning up ArkWidget.

svn path=/branches/work/libarchive-based-ark/ark/; revision=689291
parent 4ffa338a
project(ark)
add_subdirectory( part )
add_subdirectory( app )
add_subdirectory( pics )
ADD_DEFINITIONS(-D_LARGEFILE64_SOURCE)
......@@ -24,12 +26,6 @@ install(TARGETS ark DESTINATION ${BIN_INSTALL_DIR} )
########### next target ###############
set(archivemodeltest_SRCS modeltest.cpp archivemodel.cpp)
kde4_add_executable(archivemodeltest ${archivemodeltest_SRCS})
target_link_libraries(archivemodeltest ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} kerfuffle)
########### next target ###############
set(arkpart_PART_SRCS ${libark_common_SRCS}
ark_part.cpp
filelistview.cpp
......@@ -37,7 +33,6 @@ set(arkpart_PART_SRCS ${libark_common_SRCS}
arkwidget.cpp
arkviewer.cpp
extractiondialog.cpp
archivemodel.cpp
)
kde4_add_ui_files(arkpart_PART_SRCS general.ui )
......
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
set( ark_SRCS main.cpp
mainwindow.cpp
)
kde4_add_executable( arknew ${ark_SRCS} )
target_link_libraries( arknew ${KDE4_KPARTS_LIBS} )
install( TARGETS arknew DESTINATION ${BIN_INSTALL_DIR} )
########### install files ###############
install( FILES ark.desktop DESTINATION ${XDG_APPS_DIR} )
install( FILES arkui.rc DESTINATION ${DATA_INSTALL_DIR}/ark )
[Desktop Entry]
Encoding=UTF-8
MimeType=application/x-gzip;application/x-lha;application/x-tar;application/x-compressed-tar;application/x-bzip-compressed-tar;application/zip;application/x-bzip;application/x-tzo;application/x-lzop;application/x-rar;application/x-zoo;application/x-tarz;application/x-archive;application/x-bzip;application/x-java-archive;application/x-deb
GenericName=Archiving Tool
GenericName[af]=Argiveer Program
GenericName[ar]=أداة أرشفة
GenericName[br]=Ostilh merañ an Dielloù
GenericName[ca]=Eina d'arxivament
GenericName[cs]=Archivační nástroj
GenericName[cy]=Erfyn Archifo
GenericName[da]=Arkiveringsværktøj
GenericName[de]=Archivprogramm
GenericName[el]=Εργαλείο αρχειοθέτησης
GenericName[eo]=Arĥivilo
GenericName[es]=Archivador
GenericName[et]=Arhiivide haldamise rakendus
GenericName[eu]=Artxibaketa Tresna
GenericName[fa]=ابزار بایگانی
GenericName[fi]=Pakettienhallintatyökalu
GenericName[fr]=Outil de manipulation d'archives
GenericName[ga]=Uirlis Chartlannaithe
GenericName[he]=כלי לניהול ארכיונים
GenericName[hr]=Uslužni program za arhiviranje
GenericName[hu]=Fájltömörítő
GenericName[is]=Vinna með safnskrár
GenericName[it]=Strumento di archiviazione
GenericName[ja]=アーカイバツール
GenericName[kk]=Архивтеу құралы
GenericName[km]=ឧបករណ៍​ប័ណ្ណសារ
GenericName[lt]=Archyvavimo priemonė
GenericName[lv]=Arhivēšanas Rīks
GenericName[mk]=Алатка за архивирање
GenericName[ms]=Alatan Pengarkiban
GenericName[nb]=Arkiveringsverktøy
GenericName[nds]=Archivwarktüüch
GenericName[ne]=उपकरण सङ्ग्रह गर्दै
GenericName[nl]=Archiefgereedschap
GenericName[nn]=Arkiveringsverktøy
GenericName[pa]=ਪੁਰਾਲੇਖ ਸੰਦ
GenericName[pl]=Narzędzie do archiwizacji
GenericName[pt]=Ferramenta de Armazenamento
GenericName[pt_BR]=Ferramenta de Arquivamento
GenericName[ro]=Utilitar de arhivare
GenericName[ru]=Утилита работы с архивами
GenericName[sl]=Orodje za ravnanje z arhivi
GenericName[sr]=Алат за архивирање
GenericName[sr@latin]=Alat za arhiviranje
GenericName[sv]=Arkiveringsverktyg
GenericName[ta]=காப்பக கருவி
GenericName[tg]=Асбобҳои Бойгонӣ
GenericName[tr]=Arşivleme Aracı
GenericName[uk]=Засіб роботи з архівами
GenericName[uz]=Архивлаш воситаси
GenericName[wa]=Usteye d' årtchivaedje
GenericName[x-test]=xxArchiving Toolxx
GenericName[xh]=Isixhobo Sokuphatha i Archive
GenericName[zh_TW]=壓縮工具
Name=Ark
Name[ar]=أرك
Name[eo]=Arĥivilo
Name[ne]=आर्क
Name[pa]=ਆਕ
Name[ta]=ஆர்க்
Name[x-test]=xxArkxx
Exec=ark -caption "%c" %U
Icon=ark
Path=
DocPath=ark/index.html
Type=Application
Terminal=false
SwallowExec=
SwallowTitle=
X-DBUS-StartupType=Unique
X-KDE-HasTempFileOption=true
Categories=Qt;KDE;Utility;X-KDE-Utilities-File;
InitialPreference=3
<!DOCTYPE kpartgui>
<kpartgui name="ark" version="12">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
<Action name="new_window"/>
<Merge/>
</Menu>
<Menu name="settings" >
<DefineGroup append="show_merge" name="show_merge" />
</Menu>
<Merge/>
</MenuBar>
<Menu name="archive_popup">
<Action name="file_new"/>
<Action name="file_open"/>
<Action name="file_close"/>
<Separator lineSeparator="true"/>
<Merge/>
</Menu>
</kpartgui>
#include <KApplication>
#include <KCmdLineArgs>
#include <KLocale>
#include <KAboutData>
#include <QByteArray>
#include "mainwindow.h"
int main( int argc, char **argv )
{
KAboutData aboutData( "ark", 0, ki18n( "Ark" ),
"2.9.999", ki18n( "KDE Archiving tool" ),
KAboutData::License_GPL,
ki18n( "(c) 1997-2007, The Various Ark Developers" )
);
aboutData.addAuthor( ki18n("Henrique Pinto"),
ki18n( "Maintainer" ),
"henrique.pinto@kdemail.net" );
aboutData.addAuthor( ki18n("Helio Chissini de Castro"),
ki18n( "Former maintainer" ),
"helio@kde.org" );
aboutData.addAuthor( ki18n("Georg Robbers"),
KLocalizedString(),
"Georg.Robbers@urz.uni-hd.de" );
aboutData.addAuthor( ki18n("Roberto Selbach Teixeira"),
KLocalizedString(),
"maragato@kde.org" );
aboutData.addAuthor( ki18n("Francois-Xavier Duranceau"),
KLocalizedString(),
"duranceau@kde.org" );
aboutData.addAuthor( ki18n("Emily Ezust (Corel Corporation)"),
KLocalizedString(),
"emilye@corel.com" );
aboutData.addAuthor( ki18n("Michael Jarrett (Corel Corporation)"),
KLocalizedString(),
"michaelj@corel.com" );
aboutData.addAuthor( ki18n("Robert Palmbos"),
KLocalizedString(),
"palm9744@kettering.edu" );
aboutData.addCredit( ki18n("Bryce Corkins"),
ki18n( "Icons" ),
"dbryce@attglobal.net" );
aboutData.addCredit( ki18n("Liam Smit"),
ki18n( "Ideas, help with the icons" ),
"smitty@absamail.co.za" );
aboutData.addCredit( ki18n( "Andrew Smith" ),
ki18n( "bkisofs code" ),
QByteArray(),
"http://littlesvr.ca/misc/contactandrew.php" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions option;
option.add("+[url]", ki18n( "URL of an archive to be opened" ));
KCmdLineArgs::addCmdLineOptions( option );
KCmdLineArgs::addTempFileOption();
KApplication application;
if ( application.isSessionRestored() )
{
RESTORE( MainWindow );
}
else
{
// TODO open the url if the user supplied one
MainWindow *window = new MainWindow;
window->show();
}
return application.exec();
}
#include "mainwindow.h"
#include <KParts/ComponentFactory>
#include <KMessageBox>
#include <KApplication>
#include <KLocale>
#include <KActionCollection>
#include <KStandardAction>
#include <KFileDialog>
MainWindow::MainWindow( QWidget * )
: KParts::MainWindow( )
{
setXMLFile( "arkui.rc" );
m_part = KParts::ComponentFactory::createPartInstanceFromLibrary<KParts::ReadWritePart>( "libarkpartnew", this, this );
if ( !m_part )
{
KMessageBox::error( this, i18n( "Unable to find Ark's KPart component, please check your installation." ) );
return;
}
setupActions();
m_part->setObjectName( "ArkPart" );
setCentralWidget( m_part->widget() );
createGUI( m_part );
if ( !initialGeometrySet() )
{
resize( 640, 480 );
}
setAutoSaveSettings( "MainWindow" );
}
MainWindow::~MainWindow()
{
}
void MainWindow::setupActions()
{
KStandardAction::open( this, SLOT( openArchive() ), actionCollection() );
KStandardAction::quit( this, SLOT( quit() ), actionCollection() );
}
void MainWindow::openArchive()
{
KUrl url = KFileDialog::getOpenUrl();
if ( !url.isEmpty() )
{
m_part->openUrl( url );
}
}
void MainWindow::quit()
{
kapp->closeAllWindows();
}
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <KParts/MainWindow>
#include <KParts/ReadWritePart>
class MainWindow: public KParts::MainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0 );
~MainWindow();
private slots:
void openArchive();
void quit();
private:
void setupActions();
KParts::ReadWritePart *m_part;
};
#endif // MAINWINDOW_H
......@@ -1180,16 +1180,14 @@ Arch * ArkWidget::getNewArchive( const QString & _fileName, const QString& _mime
Arch * newArch = 0;
QString type = _mimetype.isNull()? KMimeType::findByUrl( KUrl::fromPath(_fileName) )->name() : _mimetype;
ArchType archtype = ArchiveFormatInfo::self()->archTypeForMimeType(type);
kDebug( 1601 ) << "archtype is recognised as: " << archtype << endl;
if(0 == (newArch = Arch::archFactory(archtype, _fileName, _mimetype)))
if(0 == (newArch = Arch::factory(_fileName, _mimetype)))
{
KMessageBox::error(this, i18n("Unknown archive format or corrupted archive") );
emit request_file_quit();
return NULL;
}
m_archType = archtype;
m_archType = UNKNOWN_FORMAT;
m_fileListView->setUpdatesEnabled(true);
return newArch;
}
......@@ -1253,7 +1251,7 @@ ArkWidget::slotCreate(Arch * _newarch, bool _success, const QString & _filename,
void
ArkWidget::openArchive( const QString & _filename )
{
Arch *newArch = Arch::archFactory( UNKNOWN_FORMAT, _filename, m_openAsMimeType);
Arch *newArch = Arch::factory( _filename, m_openAsMimeType);
if ( !newArch )
{
emit setWindowCaption( QString() );
......
......@@ -64,11 +64,11 @@ void Arch::extractFile( const QVariant & fileName, const QString & destinationDi
extractFiles( l, destinationDir );
}
Arch *Arch::archFactory( ArchType /*aType*/,
const QString &filename,
const QString &/*openAsMimeType*/ )
Arch *Arch::factory( const QString & filename,
const QString & requestedMimeType )
{
QString mimeType = KMimeType::findByPath( filename )->name();
qRegisterMetaType<ArchiveEntry>( "ArchiveEntry" );
QString mimeType = requestedMimeType.isEmpty()? KMimeType::findByPath( filename )->name() : requestedMimeType;
KService::List offers = KMimeTypeTrader::self()->query( mimeType, "Kerfuffle/Plugin", "(exist Library)" );
if ( !offers.isEmpty() )
......@@ -113,4 +113,5 @@ QStringList Arch::supportedMimeTypes()
return supported;
}
#include "arch.moc"
......@@ -85,9 +85,7 @@ class KERFUFFLE_EXPORT Arch : public QObject
QString fileName() const { return m_filename; }
bool isReadOnly() { return m_readOnly; }
static Arch *archFactory( ArchType aType,
const QString &filename,
const QString &openAsMimeType = QString() );
static Arch *factory( const QString & filename, const QString & requestedMimeType = QString() );
static QStringList supportedMimeTypes();
signals:
......
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2007 Henrique Pinto <henrique.pinto@kdemail.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "kerfuffle/arch.h"
#include "archivemodel.h"
#include <QtGui>
#include <KApplication>
#include <kcmdlineargs.h>
#include <klocale.h>
int main( int argc, char **argv )
{
KCmdLineArgs::init( argc,argv, "archivemodeltest", 0, ki18n( "archivemodeltest" ), 0 );
KApplication app;
qRegisterMetaType<ArchiveEntry>( "ArchiveEntry" );
ArchiveModel model( Arch::archFactory( UNKNOWN_FORMAT, "/home/kde-devel/ark_test.iso", "wololo" ) );
QTreeView view;
view.setModel( &model );
view.show();
return app.exec();
}
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_BINARY_DIR}/..
)
ADD_DEFINITIONS(-D_LARGEFILE64_SOURCE)
set(arkpart_PART_SRCS
part.cpp
#filelistview.cpp
#arkutils.cpp
#arkwidget.cpp
#arkviewer.cpp
#extractiondialog.cpp
archivemodel.cpp
)
#kde4_add_kcfg_files(arkpart_PART_SRCS settings.kcfgc)
#kde4_add_ui_files(arkpart_PART_SRCS general.ui )
kde4_add_plugin(arkpartnew WITH_PREFIX ${arkpart_PART_SRCS})
target_link_libraries(arkpartnew kerfuffle ${KDE4_KFILE_LIBS} ${KDE4_THREADWEAVER_LIBRARIES} ${LIBARCHIVE_LIBRARY} ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KPARTS_LIBS})
install(TARGETS arkpartnew DESTINATION ${PLUGIN_INSTALL_DIR})
########### install files ###############
install( FILES ark_part_new.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES ark_part_new.rc DESTINATION ${DATA_INSTALL_DIR}/ark )
......@@ -22,7 +22,11 @@
#include "kerfuffle/arch.h"
#include <QList>
#include <QPixmap>
#include <KLocale>
#include <KMimeType>
#include <KIconLoader>
class ArchiveDirNode;
......@@ -53,6 +57,7 @@ class ArchiveNode
virtual bool isDir() const { return false; }
QPixmap m_icon;
private:
ArchiveEntry m_entry;
ArchiveDirNode *m_parent;
......@@ -66,6 +71,7 @@ class ArchiveDirNode: public ArchiveNode
ArchiveDirNode( ArchiveDirNode *parent, const ArchiveEntry & entry )
: ArchiveNode( parent, entry )
{
m_icon = KIconLoader::global()->loadMimeTypeIcon( KMimeType::mimeType( "inode/directory" )->iconName(), K3Icon::Small );
}
~ArchiveDirNode()
......@@ -134,6 +140,13 @@ QVariant ArchiveModel::data( const QModelIndex &index, int role ) const
{
case Qt::DisplayRole:
return node->name();
case Qt::DecorationRole:
if ( node->m_icon.isNull() )
{
KMimeType::Ptr mimeType = KMimeType::findByPath( node->entry()[ FileName ].toString(), 0, true );
node->m_icon = KIconLoader::global()->loadMimeTypeIcon( mimeType->iconName(), K3Icon::Small );
}
return node->m_icon;
default:
return QVariant();
}
......
[Desktop Entry]
Encoding=UTF-8
Icon=ark
Name=Archiver
Comment=Archive Handling Tool
ServiceTypes=Browser/View
X-KDE-Library=libarkpart-new
Type=Service
<!DOCTYPE kpartgui>
<kpartgui name="ark_part" version="1">
<MenuBar>
</MenuBar>
<ToolBar name="mainToolBar">
</ToolBar>
</kpartgui>
#include "part.h"
#include "archivemodel.h"
#include <KParts/GenericFactory>
#include <KAboutData>
#include <QTreeView>
typedef KParts::GenericFactory<Part> Factory;
K_EXPORT_COMPONENT_FACTORY( libarkpartnew, Factory );
Part::Part( QWidget *parentWidget, QObject *parent, const QStringList& args )
: KParts::ReadWritePart( parent ), m_model( 0 ), m_view( new QTreeView( parentWidget ) )
{
Q_UNUSED( args );
setComponentData( Factory::componentData() );
setXMLFile( "ark_part_new.rc" );
setWidget( m_view );
}
Part::~Part()
{
}
KAboutData* Part::createAboutData()
{
return new KAboutData( "ark", 0, ki18n( "ArkPart" ), "3.0" );
}
bool Part::openFile()
{
delete m_model;
m_model = new ArchiveModel( Arch::factory( localFilePath() ), this );
m_view->setModel( m_model );
return true;
}
bool Part::saveFile()
{
return true;
}
#ifndef PART_H
#define PART_H
#include <KParts/Part>
class ArchiveModel;
class QTreeView;
class KAboutData;
class Part: public KParts::ReadWritePart
{
Q_OBJECT
public:
Part( QWidget *parentWidget, QObject *parent, const QStringList & );
~Part();
static KAboutData* createAboutData();
virtual bool openFile();
virtual bool saveFile();
private:
ArchiveModel *m_model;
QTreeView *m_view;
};
#endif // PART_H
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