Commit ef47dac3 authored by Jesper Pedersen's avatar Jesper Pedersen

added KIPI support to KimDaBa - porting the actual plugins are still work in...

added KIPI support to KimDaBa - porting the actual plugins are still work in progress, and so are the plugin into KimDaBa, but this work is already so much that I do not want it on my laptop only ;-)

svn path=/trunk/kdeextragear-2/kimdaba/; revision=306363
parent 666fa43a
......@@ -35,10 +35,11 @@ kimdaba_SOURCES = main.cpp \
viewhandler.cpp drawhandler.cpp searchfolder.cpp speeddisplay.cpp deletedialog.cpp \
datefolder.cpp groupCounter.cpp membermap.cpp categoryimageconfig.cpp browseritemfactory.cpp \
externalpopup.cpp optionmatcher.cpp donate.cpp deletethumbnailsdialog.cpp thumbnailbuilder.cpp \
kdateedit.cpp viewersizeconfig.cpp export.cpp import.cpp importmatcher.cpp
kdateedit.cpp viewersizeconfig.cpp export.cpp import.cpp importmatcher.cpp \
myimageinfo.cpp myimagecollection.cpp plugininterface.cpp
kimdaba_LDFLAGS = $(all_libraries) $(KDE_RPATH)
kimdaba_LDADD = $(LIB_KIO) $(COMPAT_LIBS) -lktexteditor -ljpeg
kimdaba_LDADD = $(LIB_KIO) $(COMPAT_LIBS) -lktexteditor -ljpeg -lkipi
METASOURCES = AUTO
KDE_CXXFLAGS = $(USE_THREADS) $(KIMDABA_CXXFLAGS)
......
if test x$have_kipi = xno; then
echo ""
echo ""
echo "------------------------------------------"
echo " W A R N I N G "
echo "------------------------------------------"
echo ""
echo "You are missing the KIPI plugin interface from kdeextragear-libs-1"
echo "Compilation of KimDaBa has therefore been disabled."
echo ""
echo ""
fi
......@@ -33,8 +33,19 @@ AM_CONDITIONAL(compile_LIBKIMDABA_COMPAT, test -n "$kimdaba_need_compat")
AC_LANG_RESTORE
# -- End KDE 3.1 check ----------------------------------------------
# Add these flags only when compiling for KDE 3.2.x and above.
if test -z "$kimdaba_need_compat"; then
KIMDABA_CXXFLAGS="-DQT_NO_CAST_ASCII -DQT_CAST_NO_ASCII"
fi
AC_SUBST(KIMDABA_CXXFLAGS)
#### KIPI must be installed
AC_MSG_CHECKING(if KIPI is installed)
KDE_CHECK_HEADER(libkipi/interface.h, have_kipi=yes, have_kipi=no)
if test "$have_kipi" = "no"; then
AC_MSG_WARN([Can't find KIPI (KDE Image Plugin Interface)
Please install kdeextrager-libs-1 to get the most out of KimDaBa]);
DO_NOT_COMPILE="$DO_NOT_COMPILE kimdaba"
fi
<!DOCTYPE kpartgui>
<kpartgui name="kimdaba" version="14">
<kpartgui name="kimdaba" version="17">
<MenuBar>
<Menu name="file">
<Action name="exportHTML"/>
<Action name="import"/>
<Action name="export"/>
<ActionList name="file_actions"/>
<Separator/>
</Menu>
<Menu name="edit" >
<Action name="deleteSelected" />
......@@ -32,6 +34,12 @@
<Action name="setDefaultScopePositive" />
<Action name="setDefaultScopeNegative" />
</Menu>
<separator/>
<Menu name="tools">
<text>&amp;Tools</text>
<ActionList name="tool_actions"/>
</Menu>
<ActionList name="image_actions"/>
</Menu>
<Menu name="maintenance">
<text>&amp;Maintenance</text>
......
......@@ -67,6 +67,9 @@
#include <kedittoolbar.h>
#include "export.h"
#include "import.h"
#include "plugininterface.h"
#include <libkipi/pluginloader.h>
#include <libkipi/plugin.h>
MainView* MainView::_instance = 0;
......@@ -132,6 +135,8 @@ MainView::MainView( QWidget* parent, const char* name )
statusBar()->message(i18n("Welcome to KimDaBa"), 5000 );
QTimer::singleShot( 0, this, SLOT( delayedInit() ) );
loadPlugins();
}
void MainView::delayedInit()
......@@ -640,7 +645,7 @@ void MainView::setupMenuBar()
new KAction( i18n("Donate Money..."), 0, this, SLOT( donateMoney() ), actionCollection(), "donate" );
connect( _thumbNailView, SIGNAL( changed() ), this, SLOT( slotChanges() ) );
createGUI( QString::fromLatin1( "kimdabaui.rc" ) );
createGUI( QString::fromLatin1( "kimdabaui.rc" ), false );
}
void MainView::slotExportToHTML()
......@@ -1151,4 +1156,45 @@ void MainView::slotReenableMessages()
}
void MainView::loadPlugins()
{
// Sets up the plugin interface, and load the plugins
PluginInterface* interface = new PluginInterface( this, "demo interface" );
KIPI::PluginLoader* loader = new KIPI::PluginLoader( interface );
loader->loadPlugins();
QPtrList<KAction> fileActions;
QPtrList<KAction> imageActions;
QPtrList<KAction> toolsActions;
KIPI::PluginLoader::List list = loader->pluginList();
for( QPtrListIterator<KIPI::Plugin> it( list ); *it; ++it ) {
KIPI::Plugin* plugin = *it;
QPtrList<KAction>* popup = 0;
if ( plugin->category() == KIPI::IMAGESPLUGIN )
popup = &imageActions;
else if ( plugin->category() == KIPI::EXPORTPLUGIN || plugin->category() == KIPI::IMPORTPLUGIN )
popup = &fileActions;
else if ( plugin->category() == KIPI::TOOLSPLUGIN )
popup = &toolsActions;
if ( popup ) {
KActionCollection *actions = plugin->actionCollection();
for (unsigned int i=0; i < actions->count(); i++) {
popup->append( actions->action(i) );
}
}
else {
qDebug("No menu found for %s", plugin->id().latin1());
}
}
// For this to work I need to pass false as second arg for createGUI
plugActionList( QString::fromLatin1("file_actions"), fileActions );
plugActionList( QString::fromLatin1("image_actions"), imageActions );
plugActionList( QString::fromLatin1("tool_actions"), toolsActions );
}
#include "mainview.moc"
......@@ -44,6 +44,8 @@ public:
MainView( QWidget* parent, const char* name = 0 );
static void configureImages( const ImageInfoList& list, bool oneAtATime );
static MainView* theMainView();
ImageInfoList selected();
ImageInfoList currentView();
protected slots:
bool slotExit();
......@@ -92,8 +94,6 @@ protected slots:
protected:
void configureImages( bool oneAtATime );
ImageInfoList selected();
ImageInfoList currentView();
QString welcome();
virtual void closeEvent( QCloseEvent* e );
void setupMenuBar();
......@@ -107,6 +107,7 @@ protected:
void configImages( const ImageInfoList& list, bool oneAtATime );
void updateStates( bool thumbNailView );
ImageInfoList getSelectedOnDisk();
void loadPlugins();
private:
static MainView* _instance;
......
#include "myimagecollection.h"
#include "mainview.h"
#include "imagedb.h"
MyImageCollection::MyImageCollection( Type tp )
: _tp( tp )
{
}
QString MyImageCollection::name()
{
qDebug("NYI: MyImageCollection::name()" );
return QString::fromLatin1( "a name" ); // PENDING(blackie) implement
}
QString MyImageCollection::comment()
{
return QString::null;
}
KURL::List MyImageCollection::images()
{
switch ( _tp ) {
case CurrentAlbum:
return imageListToUrlList( ImageDB::instance()->currentContext( false ) );
case CurrentView:
return imageListToUrlList( MainView::theMainView()->currentView() );
case CurrentSelection:
return imageListToUrlList( MainView::theMainView()->selected() );
}
return KURL::List();
}
KURL MyImageCollection::root()
{
// PENDING(blackie) implement
return KURL();
}
KURL::List MyImageCollection::imageListToUrlList( const ImageInfoList& imageList )
{
KURL::List urlList;
for( ImageInfoListIterator it( imageList ); *it; ++it ) {
KURL url;
url.setPath( (*it)->fileName() );
urlList.append( url );
}
return urlList;
}
#ifndef MYIMAGECOLLECTION_H
#define MYIMAGECOLLECTION_H
#ifdef HAVE_KIPI
#include <libkipi/imagecollectionshared.h>
#include "imageinfo.h"
class MyImageCollection :public KIPI::ImageCollectionShared
{
public:
enum Type { CurrentAlbum, CurrentView, CurrentSelection };
MyImageCollection( Type tp );
virtual QString name();
virtual QString comment();
virtual KURL::List images();
virtual KURL root();
protected:
KURL::List imageListToUrlList( const ImageInfoList& list );
private:
Type _tp;
};
#endif // HAVE_KIPI
#endif /* MYIMAGECOLLECTION_H */
#include "myimageinfo.h"
MyImageInfo::MyImageInfo( const KURL& url )
: KIPI::ImageInfoShared( url )
{
}
QString MyImageInfo::name()
{
return QString::fromLatin1("a name"); // PENDING(blackie) implement
}
QString MyImageInfo::description()
{
return QString::fromLatin1("a name"); // PENDING(blackie) implement
}
QMap<QString,QVariant> MyImageInfo::attributes()
{
return QMap<QString,QVariant>(); // PENDING(blackie) implement
}
#ifndef MYIMAGEINFO_H
#define MYIMAGEINFO_H
#include <libkipi/imageinfoshared.h>
class MyImageInfo :public KIPI::ImageInfoShared
{
public:
MyImageInfo( const KURL& url );
virtual QString name();
virtual QString description();
virtual QMap<QString,QVariant> attributes();
};
#endif /* MYIMAGEINFO_H */
#include "plugininterface.h"
#include <libkipi/imagecollection.h>
#include "myimagecollection.h"
#include "myimageinfo.h"
PluginInterface::PluginInterface( QObject *parent, const char *name )
:KIPI::Interface( parent, name )
{
}
KIPI::ImageCollection PluginInterface::currentAlbum()
{
return KIPI::ImageCollection( new MyImageCollection( MyImageCollection::CurrentAlbum ) );
}
KIPI::ImageCollection PluginInterface::currentView()
{
return KIPI::ImageCollection( new MyImageCollection( MyImageCollection::CurrentView ) );
}
KIPI::ImageCollection PluginInterface::currentSelection()
{
return KIPI::ImageCollection( new MyImageCollection( MyImageCollection::CurrentSelection ) );
}
QValueList<KIPI::ImageCollection> PluginInterface::allAlbums()
{
qDebug("QValueList<ImageCollection> PluginInterface::allAlbums() not implemented!");
return QValueList<KIPI::ImageCollection>(); // PENDING(blackie) implement
}
KIPI::ImageInfo PluginInterface::info( const KURL& url )
{
return KIPI::ImageInfo( new MyImageInfo( url ) );
}
#ifndef KIMDABA_PLUGININTERFACE_H
#define KIMDABA_PLUGININTERFACE_H
#include <libkipi/interface.h>
#include <qvaluelist.h>
#include <libkipi/imagecollection.h>
#include <libkipi/imageinfo.h>
#include <kurl.h>
class PluginInterface :public KIPI::Interface
{
Q_OBJECT
public:
PluginInterface( QObject *parent, const char *name=0);
virtual KIPI::ImageCollection currentAlbum();
virtual KIPI::ImageCollection currentView();
virtual KIPI::ImageCollection currentSelection();
virtual QValueList<KIPI::ImageCollection> allAlbums();
virtual KIPI::ImageInfo info( const KURL& );
};
#endif /* PLUGININTERFACE_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