[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeutils/ark
From:       Henrique Pinto <tawhaki () gmail ! com>
Date:       2007-08-05 19:32:17
Message-ID: 1186342337.804843.15704.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 696741 by henrique:

 * Action for creating an archive
   Crashes on KFileDialog. Apparently, KFileDialog::getSaveFileName() doesn't like it \
when we add "application/x-zip-compressed" to the list of MIME-types in the filter. I \
haven't investigated why yet.


 M  +1 -0      app/arkui.rc  
 M  +15 -1     app/mainwindow.cpp  
 M  +1 -0      app/mainwindow.h  
 M  +19 -0     kerfuffle/archive.cpp  
 M  +1 -0      kerfuffle/archive.h  
 M  +4 -0      kerfuffle/kerfufflePlugin.desktop  
 M  +1 -0      part/interface.h  
 M  +5 -0      part/part.cpp  
 M  +1 -0      part/part.h  
 M  +9 -1      plugins/bk/bkplugin.cpp  
 M  +4 -1      plugins/bk/bkplugin.h  
 M  +1 -0      plugins/libzipplugin/kerfuffle_libzip.desktop  


--- trunk/KDE/kdeutils/ark/app/arkui.rc #696740:696741
@@ -10,6 +10,7 @@
 </MenuBar>
 <ToolBar noMerge="1" name="mainToolBar">
 	<text>Main Toolbar</text>
+	<Action name="file_new"/>
 	<Action name="file_open_recent"/>
 </ToolBar>
 </kpartgui>
--- trunk/KDE/kdeutils/ark/app/mainwindow.cpp #696740:696741
@@ -73,6 +73,7 @@
 
 void MainWindow::setupActions()
 {
+	KStandardAction::openNew( this, SLOT( newArchive() ), actionCollection() );
 	KStandardAction::open( this, SLOT( openArchive() ), actionCollection() );
 	KStandardAction::quit( this, SLOT( quit() ), actionCollection() );
 
@@ -137,5 +138,18 @@
 
 void MainWindow::quit()
 {
-	kapp->closeAllWindows();
+	close();
 }
+
+void MainWindow::newArchive()
+{
+	Interface *iface = qobject_cast<Interface*>( m_part );
+	Q_ASSERT( iface );
+	QStringList mimeTypes = iface->supportedWriteMimeTypes();
+
+	kDebug( 1601 ) << k_funcinfo << "Supported mimetypes are" << mimeTypes.join( " " );
+
+	QString saveFile = KFileDialog::getSaveFileName( KUrl( "kfiledialog:///ArkNewDir" \
), +	                                                 mimeTypes.join( " " ) );
+	openUrl( KUrl( saveFile ) );
+}
--- trunk/KDE/kdeutils/ark/app/mainwindow.h #696740:696741
@@ -35,6 +35,7 @@
 		~MainWindow();
 
 	private slots:
+		void newArchive();
 		void openArchive();
 		void openUrl( const KUrl& url );
 		void quit();
--- trunk/KDE/kdeutils/ark/kerfuffle/archive.cpp #696740:696741
@@ -89,4 +89,23 @@
 		}
 		return supported;
 	}
+
+	QStringList supportedWriteMimeTypes()
+	{
+		QStringList supported;
+		KService::List offers = KServiceTypeTrader::self()->query( "Kerfuffle/Plugin", \
"(exist Library) and ([X-KDE-Kerfuffle-ReadWrite] == true)" ); +
+		foreach( KService::Ptr service, offers )
+		{
+			foreach( const QString& mimeType, service->serviceTypes() )
+			{
+				if ( !mimeType.contains( "Kerfuffle" ) )
+				{
+					supported << mimeType;
+				}
+			}
+		}
+		kDebug( 1601 ) << k_funcinfo << "Returning" << supported;
+		return supported;
+	}
 } // namespace Kerfuffle
--- trunk/KDE/kdeutils/ark/kerfuffle/archive.h #696740:696741
@@ -66,6 +66,7 @@
 
 	Archive* factory( const QString & filename, const QString & requestedMimeType = \
QString() ) KERFUFFLE_EXPORT;  QStringList supportedMimeTypes() KERFUFFLE_EXPORT;
+	QStringList supportedWriteMimeTypes() KERFUFFLE_EXPORT;
 } // namespace Kerfuffle
 
 
--- trunk/KDE/kdeutils/ark/kerfuffle/kerfufflePlugin.desktop #696740:696741
@@ -16,4 +16,8 @@
 [PropertyDef::X-KDE-Kerfuffle-APIRevision]
 Type=int
 
+# Is the plugin read-write or not? (i.e., can it create archives?)
+[PropertyDef::X-KDE-Kerfuffle-ReadWrite]
+Type=bool
 
+
--- trunk/KDE/kdeutils/ark/part/interface.h #696740:696741
@@ -30,6 +30,7 @@
 		virtual ~Interface() {}
 
 		virtual QStringList supportedMimeTypes() const = 0;
+		virtual QStringList supportedWriteMimeTypes() const = 0;
 };
 
 Q_DECLARE_INTERFACE( Interface, "org.kde.kerfuffle.partinterface/0.42" )
--- trunk/KDE/kdeutils/ark/part/part.cpp #696740:696741
@@ -197,6 +197,11 @@
 	return Kerfuffle::supportedMimeTypes();
 }
 
+QStringList Part::supportedWriteMimeTypes() const
+{
+	return Kerfuffle::supportedWriteMimeTypes();
+}
+
 void Part::slotLoadingStarted()
 {
 	QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
--- trunk/KDE/kdeutils/ark/part/part.h #696740:696741
@@ -50,6 +50,7 @@
 		virtual bool saveFile();
 
 		QStringList supportedMimeTypes() const;
+		QStringList supportedWriteMimeTypes() const;
 
 	private slots:
 		void slotLoadingStarted();
--- trunk/KDE/kdeutils/ark/plugins/bk/bkplugin.cpp #696740:696741
@@ -25,7 +25,7 @@
 #include <KDebug>
 
 BKInterface::BKInterface( const QString & filename, QObject *parent )
-	: ReadOnlyArchiveInterface( filename, parent )
+	: ReadWriteArchiveInterface( filename, parent )
 {
 }
 
@@ -117,5 +117,13 @@
 	return true;
 }
 
+bool BKInterface::addFiles( const QStringList & files )
+{
+}
+
+bool BKInterface::deleteFiles( const QList<QVariant> & files )
+{
+}
+
 KERFUFFLE_PLUGIN_FACTORY( BKInterface )
 
--- trunk/KDE/kdeutils/ark/plugins/bk/bkplugin.h #696740:696741
@@ -26,7 +26,7 @@
 
 using namespace Kerfuffle;
 
-class BKInterface: public ReadOnlyArchiveInterface
+class BKInterface: public ReadWriteArchiveInterface
 {
 	Q_OBJECT
 	public:
@@ -36,6 +36,9 @@
 		bool list();
 		bool copyFiles( const QList<QVariant> & files, const QString & \
destinationDirectory, bool preservePaths );  
+		bool addFiles( const QStringList & files );
+		bool deleteFiles( const QList<QVariant> & files );
+
 	private:
 		bool browse( BkFileBase* base, const QString& prefix = QString() );
 
--- trunk/KDE/kdeutils/ark/plugins/libzipplugin/kerfuffle_libzip.desktop \
#696740:696741 @@ -11,6 +11,7 @@
 X-KDE-PluginInfo-License=BSD
 X-KDE-Priority=150
 X-KDE-Kerfuffle-APIRevision=1
+X-KDE-Kerfuffle-ReadWrite=true
 Name=kerfuffle_libzip
 Name[sv]=Kerfuffle Libzip
 Comment=libzip plugin for Kerfuffle


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic