summaryrefslogtreecommitdiffstats
path: root/kview/modules/browser
diff options
context:
space:
mode:
Diffstat (limited to 'kview/modules/browser')
-rw-r--r--kview/modules/browser/Makefile.am15
-rw-r--r--kview/modules/browser/kmyfileitemlist.cpp41
-rw-r--r--kview/modules/browser/kmyfileitemlist.h39
-rw-r--r--kview/modules/browser/kviewbrowser.cpp179
-rw-r--r--kview/modules/browser/kviewbrowser.desktop130
-rw-r--r--kview/modules/browser/kviewbrowser.h62
-rw-r--r--kview/modules/browser/kviewbrowser.rc18
7 files changed, 484 insertions, 0 deletions
diff --git a/kview/modules/browser/Makefile.am b/kview/modules/browser/Makefile.am
new file mode 100644
index 00000000..001eefd0
--- /dev/null
+++ b/kview/modules/browser/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = -I$(top_srcdir)/kview $(all_includes)
+
+kde_module_LTLIBRARIES = kview_browserplugin.la
+
+kview_browserplugin_la_SOURCES = kmyfileitemlist.cpp kviewbrowser.cpp
+kview_browserplugin_la_LIBADD = $(LIB_KFILE) $(LIB_KPARTS) -lkdeprint
+kview_browserplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+plugdir = $(kde_datadir)/kviewviewer/kpartplugins
+plug_DATA = kviewbrowser.desktop kviewbrowser.rc
+
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kviewbrowserplugin.pot
diff --git a/kview/modules/browser/kmyfileitemlist.cpp b/kview/modules/browser/kmyfileitemlist.cpp
new file mode 100644
index 00000000..534e0876
--- /dev/null
+++ b/kview/modules/browser/kmyfileitemlist.cpp
@@ -0,0 +1,41 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ 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.
+
+*/
+// $Id$
+
+#include "kmyfileitemlist.h"
+#include <kfileitem.h>
+
+KMyFileItemList::KMyFileItemList() {}
+KMyFileItemList::KMyFileItemList( const QPtrList<KFileItem> & l ) : QPtrList<KFileItem>( l ) {}
+
+KMyFileItemList & KMyFileItemList::operator=( const QPtrList<KFileItem> & l )
+{
+ return (KMyFileItemList &)QPtrList<KFileItem>::operator=( l );
+}
+
+int KMyFileItemList::compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 )
+{
+ KFileItem * fileitem1 = static_cast<KFileItem *>( item1 );
+ KFileItem * fileitem2 = static_cast<KFileItem *>( item2 );
+ if( fileitem1->name() == fileitem2->name() )
+ return 0;
+ else if( fileitem1->name() > fileitem2->name() )
+ return 1;
+ else
+ return -1;
+}
diff --git a/kview/modules/browser/kmyfileitemlist.h b/kview/modules/browser/kmyfileitemlist.h
new file mode 100644
index 00000000..052fce53
--- /dev/null
+++ b/kview/modules/browser/kmyfileitemlist.h
@@ -0,0 +1,39 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ 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.
+
+*/
+// $Id$
+
+#ifndef __kmyfileitemlist_h__
+#define __kmyfileitemlist_h__
+
+#include <qptrlist.h>
+class KFileItem;
+
+class KMyFileItemList : public QPtrList<KFileItem>
+{
+ public:
+ KMyFileItemList();
+ KMyFileItemList( const QPtrList<KFileItem> & );
+ KMyFileItemList & operator=( const QPtrList<KFileItem> & );
+
+ protected:
+ virtual int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 );
+};
+
+// vim:sw=4:ts=4
+
+#endif
diff --git a/kview/modules/browser/kviewbrowser.cpp b/kview/modules/browser/kviewbrowser.cpp
new file mode 100644
index 00000000..6da318b7
--- /dev/null
+++ b/kview/modules/browser/kviewbrowser.cpp
@@ -0,0 +1,179 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ 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.
+
+*/
+// $Id$
+
+#include "kviewbrowser.h"
+#include "kmyfileitemlist.h"
+
+#include <qcursor.h>
+
+#include <kdirlister.h>
+#include <kaction.h>
+#include <klocale.h>
+#include <kgenericfactory.h>
+#include <kdebug.h>
+#include <kimageviewer/viewer.h>
+#include <kimageviewer/canvas.h>
+#include <kparts/browserextension.h>
+#include <kapplication.h>
+#include <kimageio.h>
+
+typedef KGenericFactory<KViewBrowser> KViewBrowserFactory;
+K_EXPORT_COMPONENT_FACTORY( kview_browserplugin, KViewBrowserFactory( "kviewbrowserplugin" ) )
+
+KViewBrowser::KViewBrowser( QObject* parent, const char* name, const QStringList & )
+ : Plugin( parent, name )
+ , m_pDirLister( 0 )
+ , m_pFileItemList( 0 )
+ , m_bShowCurrent( false )
+{
+ m_pViewer = static_cast<KImageViewer::Viewer *>( parent );
+ if( m_pViewer )
+ {
+ m_paBack = KStdAction::back ( this, SLOT( slotBack() ), actionCollection(), "previous_image" );
+ m_paBack->setShortcut( SHIFT+Key_Left );
+ m_paForward = KStdAction::forward( this, SLOT( slotForward() ), actionCollection(), "next_image" );
+ m_paForward->setShortcut( SHIFT+Key_Right );
+ m_pExtension = m_pViewer->browserExtension();
+ }
+ else
+ kdWarning( 4630 ) << "no KImageViewer interface found - the browser plugin won't work" << endl;
+}
+
+KViewBrowser::~KViewBrowser()
+{
+ delete m_pDirLister;
+ delete m_pFileItemList;
+}
+
+void KViewBrowser::openURL(const KURL &u)
+{
+ if (m_pViewer)
+ {
+ // Opening new URL resets zoom, so remember it.
+ double oldZoom = m_pViewer->canvas()->zoom();
+ m_pViewer->openURL(u);
+ m_pViewer->canvas()->setZoom(oldZoom);
+ }
+ if( m_pExtension )
+ {
+ emit m_pExtension->setLocationBarURL( u.prettyURL() );
+ }
+}
+
+void KViewBrowser::slotBack()
+{
+ setupDirLister();
+ if( ! m_pFileItemList )
+ return;
+
+ KFileItem * item = m_pFileItemList->prev();
+ if( ! item )
+ item = m_pFileItemList->last();
+ if( item )
+ {
+ kdDebug( 4630 ) << item->url().prettyURL() << endl;
+ openURL( item->url() );
+ }
+ else
+ kdDebug( 4630 ) << "no file found" << endl;
+ m_bShowCurrent = false;
+}
+
+void KViewBrowser::slotForward()
+{
+ setupDirLister();
+ if( ! m_pFileItemList )
+ return;
+
+ KFileItem * item = m_bShowCurrent ? m_pFileItemList->current() : m_pFileItemList->next();
+ if( ! item )
+ item = m_pFileItemList->first();
+ if( item )
+ {
+ kdDebug( 4630 ) << item->url().prettyURL() << endl;
+ openURL( item->url() );
+ }
+ else
+ kdDebug( 4630 ) << "no file found" << endl;
+ m_bShowCurrent = false;
+}
+
+void KViewBrowser::slotNewItems( const KFileItemList & items )
+{
+ kdDebug( 4630 ) << k_funcinfo << endl;
+ delete m_pFileItemList;
+ m_pFileItemList = new KMyFileItemList( items );
+ m_pFileItemList->sort();
+
+ // set the current pointer on the currently open image
+ KFileItem * item = m_pFileItemList->first();
+ for( ; item; item = m_pFileItemList->next() )
+ if( item->url() == m_pViewer->url() )
+ break;
+}
+
+void KViewBrowser::slotDeleteItem( KFileItem * item )
+{
+ bool setToFirst = false;
+ if( m_pFileItemList->current() == item )
+ {
+ // The current image is being removed
+ // we have to take care, that the next slotForward call returns the new current item
+ m_bShowCurrent = true;
+
+ if( m_pFileItemList->getLast() == item )
+ // The the current image is the last image - wrap around to the first
+ setToFirst = true;
+ }
+
+ m_pFileItemList->remove( item );
+
+ if( setToFirst )
+ ( void )m_pFileItemList->first();
+}
+
+void KViewBrowser::setupDirLister()
+{
+ if( ! m_pDirLister )
+ {
+ kdDebug( 4630 ) << "create new KDirLister" << endl;
+ m_pDirLister = new KDirLister();
+ m_pDirLister->setMimeFilter( KImageIO::mimeTypes( KImageIO::Reading ) );
+ m_pDirLister->setShowingDotFiles( true );
+ connect( m_pDirLister, SIGNAL( newItems( const KFileItemList & ) ), SLOT( slotNewItems( const KFileItemList & ) ) );
+ connect( m_pDirLister, SIGNAL( deleteItem( KFileItem * ) ), SLOT( slotDeleteItem( KFileItem * ) ) );
+ }
+ if( m_pDirLister->url() != KURL( m_pViewer->url().directory( true, false ) ) )
+ {
+ QApplication::setOverrideCursor( WaitCursor );
+ QString url = m_pViewer->url().prettyURL();
+ int pos = url.findRev( "/" );
+ url = url.left( (unsigned int)pos );
+ kdDebug( 4630 ) << "open KDirLister for " << url << endl;
+ m_pDirLister->openURL( KURL( url ));
+ while( ! m_pDirLister->isFinished() )
+ kapp->processEvents();
+ //while( ! m_pFileItemList )
+ //kapp->processEvents();
+ QApplication::restoreOverrideCursor();
+ }
+}
+
+// vim:sw=4:ts=4:cindent
+#include "kviewbrowser.moc"
diff --git a/kview/modules/browser/kviewbrowser.desktop b/kview/modules/browser/kviewbrowser.desktop
new file mode 100644
index 00000000..a5b66bcc
--- /dev/null
+++ b/kview/modules/browser/kviewbrowser.desktop
@@ -0,0 +1,130 @@
+[Desktop Entry]
+Icon=browser
+Type=Service
+ServiceTypes=KPluginInfo
+
+X-KDE-PluginInfo-Author=Matthias Kretz
+X-KDE-PluginInfo-Email=kretz@kde.org
+X-KDE-PluginInfo-Name=kviewbrowser
+X-KDE-PluginInfo-Category=General
+X-KDE-PluginInfo-Version=1.0
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true
+
+Name=Browser
+Name[af]=Blaaier
+Name[ar]=المتصفح
+Name[bg]=Браузър
+Name[br]=Furcher
+Name[bs]=Preglednik
+Name[ca]=Fullejador
+Name[cs]=Prohlížeč
+Name[cy]=Porydd
+Name[el]=Περιηγητής
+Name[eo]=Trair-Rigardilo
+Name[es]=Navegador
+Name[et]=Sirvija
+Name[eu]=Nabegatzailea
+Name[fa]=مرورگر
+Name[fi]=Selain
+Name[fr]=Navigateur
+Name[ga]=Brabhsálaí
+Name[gl]=Explorador
+Name[he]=דפדפן
+Name[hi]=ब्राउज़र
+Name[hr]=Preglednik
+Name[hu]=Böngésző
+Name[is]=Flakkari
+Name[ja]=ブラウザ
+Name[kk]=Шолғыш
+Name[km]=កម្មវិធី​រុករក
+Name[lt]=Naršyklė
+Name[ms]=Pelayar
+Name[nb]=Leser
+Name[nds]=Kieker
+Name[ne]=ब्राउजर
+Name[nl]=Bladeren
+Name[nn]=Snøgglesar
+Name[nso]=Seinyakisi
+Name[pa]=ਝਲਕਾਰਾ
+Name[pl]=Przeglądarka
+Name[pt]=Navegador
+Name[pt_BR]=Navegador
+Name[ro]=Navigator
+Name[ru]=Просмотр
+Name[se]=Bláđđejeaddji
+Name[sk]=Prehliadač
+Name[sl]=Brskalnik
+Name[sr]=Прегледач
+Name[sr@Latn]=Pregledač
+Name[sv]=Bläddrare
+Name[ta]=உலாவி
+Name[tg]=Воқеъанигор
+Name[tr]=Tarayıcı
+Name[uk]=Навігатор
+Name[uz]=Brauzer
+Name[uz@cyrillic]=Браузер
+Name[ven]=Burausa
+Name[wa]=Foyteuse
+Name[xh]=Umkhangeli wencwadi
+Name[zh_CN]=浏览器
+Name[zh_HK]=瀏覽器
+Name[zh_TW]=瀏覽器
+Name[zu]=Umcingi
+Comment=Enables you to browse through all of the images in the current directory.
+Comment[af]=Aktiveer jy na blaai deur alle van die beelde in die huidige gids.
+Comment[ar]=يمكنك من تصفَح كل الصور في الدليل الحالي.
+Comment[bg]=Преглед на изображенията в текущата директория
+Comment[bs]=Omogućuje vam da pregledate sve slike u trenutnom direktoriju.
+Comment[ca]=Us permet navegar entre totes les imatges del directori actual.
+Comment[cs]=Umožňuje procházet všechny obrázky v aktuálním adresáři.
+Comment[cy]=Alluogi i chi bori drwy pob delwedd yn y cyfeiriadur cyfredol.
+Comment[da]=Lader dig gennemse alle billederne i denne mappe.
+Comment[de]=Ermöglicht das Durchsehen der Bilder im aktuellen Ordner.
+Comment[el]=Σας επιτρέπει να περιηγηθείτε σε όλες τις εικόνες στον τρέχον κατάλογο.
+Comment[eo]=Permesas al vi povas trarigardi ĉiujn bildojn en la nuna dosierujo.
+Comment[es]=Le permite navegar por todas las imágenes del directorio actual.
+Comment[et]=Võimaldab sirvida aktiivse kataloogi kõiki pilte.
+Comment[eu]=Uneko direktorioko irudien artean nabigatzen uzten dizu.
+Comment[fa]=برای مرور تمام تصاویر موجود در فهرست راهنمای جاری شما را توانا می‌کند.
+Comment[fi]=Mahdollistaa nykyisessä kansiossa olevien kuvien selailun
+Comment[fr]=Permet de naviguer parmi les images dans le dossier courant.
+Comment[gl]=Permítelle navegar a través de todas as imaxes no directorio actual.
+Comment[he]=מאפשר לך לעיין בכל התמונות שבספריה הנוכחית
+Comment[hi]=मौज़ूदा डिरेक्ट्री के सभी छवियों को ब्राउज़ करने में आपको सक्षम बनाता है.
+Comment[hu]=Lehetővé teszi az aktuális könyvtárban található képek áttekintését, böngészését.
+Comment[is]=Gerir þér kleyft að flakka í öllum myndunum í þessari möppu.
+Comment[it]=Permette di navigare tra le immagini nella directory corrente.
+Comment[ja]=現在のディレクトリのすべての画像をブラウズできるようになります。
+Comment[kk]=Назардағы қапшықтағы барлық кескіндерді шолу құралы.
+Comment[km]=អាច​ឲ្យ​អ្នក​រកមើល​រូបភាព​ទាំងអស់ នៅ​ក្នុង​ថត​បច្ចុប្បន្ន ។
+Comment[lt]=Leidžia jums naršyti visuose paveikslėliuose esamame aplanke.
+Comment[ms]=Membolehkan anda melayar semua imej dalam direktori semasa.
+Comment[nb]=Lar deg bla gjennom alle bildene i den gjeldende katalogen.
+Comment[nds]=Dörkieken vun all Biller binnen den aktuellen Orner.
+Comment[ne]=हालको डाइरेक्टरिमा छविको सबै तिर ब्राउज गर्न तपाईँलाई सक्षम पार्दछ ।
+Comment[nl]=Hiermee kunt u door alle afbeeldingen in de huidige map bladeren.
+Comment[nn]=Let deg bla gjennom alle bileta i ein katalog.
+Comment[nso]=Ego dumelela go inyakisa kago diponagalo kamoka kago tshupetso ya bjale.
+Comment[pl]=Pozwala na przeglądanie wszystkich obrazków w bieżącym katalogu.
+Comment[pt]=Permite-lhe navegar por todas as imagens na directoria actual.
+Comment[pt_BR]=Habilita você a navegar por todas as imagens no diretório atual.
+Comment[ro]=Vă permite să navigaţi prin toate imaginile din directorul curent.
+Comment[ru]=Просмотр всех изображений в текущей папке.
+Comment[se]=Diktá du bláđđet buot govaid čađa dán ozus.
+Comment[sk]=Umožňuje prechádzať mezi obrázkami v aktuálnom priečinku.
+Comment[sl]=Omogoča vam brskanje po vseh slikah v trenutni mapi.
+Comment[sr]=Омогућава вам да прегледате све слике у текућем директоријуму
+Comment[sr@Latn]=Omogućava vam da pregledate sve slike u tekućem direktorijumu
+Comment[sv]=Låter dig bläddra igenom alla bilder i den aktuella katalogen.
+Comment[ta]=நடப்பு அடைவில் உள்ள பிம்பங்களை எல்லாம் பார்க்க முடியும்.
+Comment[tg]=Намоиши тамоми тасвирот дар каталоги ҷорӣ.
+Comment[tr]=Bulunduğunuz dizindeki tüm resimler arasında gezinmenizi sağlar.
+Comment[uk]=Дозволяє навігацію всіх зображень в поточному каталозі.
+Comment[ven]=Ini konisa u tshimbidza kha zwifanyiso zwothe kha tsumbavhulwo ya zwino.
+Comment[wa]=Vos permete di foyter dins totes les imådjes do ridant do moumint.
+Comment[xh]=Ikuvumela ukuba ukwazi ukukhangela yonke imifanekiso kulawulo lwangoku.
+Comment[zh_CN]=使您能够浏览当前目录中的所有图像。
+Comment[zh_HK]=讓您瀏覽當前目錄的所有圖像。
+Comment[zh_TW]=讓您瀏覽目前目錄的所有影像。
+Comment[zu]=Ikuvumela ukuba ucinge ngokwedlulela izithombe ohlwini lwamafayela lwamanje.
diff --git a/kview/modules/browser/kviewbrowser.h b/kview/modules/browser/kviewbrowser.h
new file mode 100644
index 00000000..3ed918b6
--- /dev/null
+++ b/kview/modules/browser/kviewbrowser.h
@@ -0,0 +1,62 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ 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.
+
+*/
+// $Id$
+
+#ifndef __kviewbrowser_h
+#define __kviewbrowser_h
+
+#include <kparts/plugin.h>
+#include <kfileitem.h>
+
+namespace KImageViewer { class Viewer; }
+
+namespace KParts { class BrowserExtension; }
+class KAction;
+class KDirLister;
+class KMyFileItemList;
+
+class KViewBrowser : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ KViewBrowser( QObject* parent, const char* name, const QStringList & );
+ virtual ~KViewBrowser();
+
+private slots:
+ void slotBack();
+ void slotForward();
+
+ void slotNewItems( const KFileItemList & );
+ void slotDeleteItem( KFileItem * item );
+
+private:
+ void setupDirLister();
+ void openURL(const KURL &);
+
+ KImageViewer::Viewer * m_pViewer;
+ KDirLister * m_pDirLister;
+ KMyFileItemList * m_pFileItemList;
+ KParts::BrowserExtension * m_pExtension;
+ bool m_bShowCurrent;
+
+ KAction * m_paBack;
+ KAction * m_paForward;
+};
+
+// vim:sw=4:ts=4:cindent
+#endif
diff --git a/kview/modules/browser/kviewbrowser.rc b/kview/modules/browser/kviewbrowser.rc
new file mode 100644
index 00000000..9a57cabb
--- /dev/null
+++ b/kview/modules/browser/kviewbrowser.rc
@@ -0,0 +1,18 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="kviewbrowser" library="kview_browserplugin">
+ <MenuBar>
+ <Menu name="tools"><Text>&amp;Tools</Text>
+ <Action name="previous_image"/>
+ <Action name="next_image"/>
+ </Menu>
+ </MenuBar>
+ <ToolBar name="extraToolBar">
+ <text>Extra Toolbar</text>
+ <Action name="previous_image"/>
+ <Action name="next_image"/>
+ </ToolBar>
+ <Menu name="popupmenu">
+ <Action name="previous_image"/>
+ <Action name="next_image"/>
+ </Menu>
+</kpartplugin>