From 47d455dd55be855e4cc691c32f687f723d9247ee Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmrml/kmrml/kcontrol/Makefile.am | 25 ++ kmrml/kmrml/kcontrol/indexcleaner.cpp | 96 ++++++ kmrml/kmrml/kcontrol/indexcleaner.h | 53 +++ kmrml/kmrml/kcontrol/indexer.cpp | 190 +++++++++++ kmrml/kmrml/kcontrol/indexer.h | 68 ++++ kmrml/kmrml/kcontrol/indextest.cpp | 43 +++ kmrml/kmrml/kcontrol/indextest.h | 26 ++ kmrml/kmrml/kcontrol/kcmkmrml.cpp | 146 +++++++++ kmrml/kmrml/kcontrol/kcmkmrml.desktop | 176 ++++++++++ kmrml/kmrml/kcontrol/kcmkmrml.h | 52 +++ kmrml/kmrml/kcontrol/mainpage.cpp | 501 +++++++++++++++++++++++++++++ kmrml/kmrml/kcontrol/mainpage.h | 109 +++++++ kmrml/kmrml/kcontrol/serverconfigwidget.ui | 272 ++++++++++++++++ 13 files changed, 1757 insertions(+) create mode 100644 kmrml/kmrml/kcontrol/Makefile.am create mode 100644 kmrml/kmrml/kcontrol/indexcleaner.cpp create mode 100644 kmrml/kmrml/kcontrol/indexcleaner.h create mode 100644 kmrml/kmrml/kcontrol/indexer.cpp create mode 100644 kmrml/kmrml/kcontrol/indexer.h create mode 100644 kmrml/kmrml/kcontrol/indextest.cpp create mode 100644 kmrml/kmrml/kcontrol/indextest.h create mode 100644 kmrml/kmrml/kcontrol/kcmkmrml.cpp create mode 100644 kmrml/kmrml/kcontrol/kcmkmrml.desktop create mode 100644 kmrml/kmrml/kcontrol/kcmkmrml.h create mode 100644 kmrml/kmrml/kcontrol/mainpage.cpp create mode 100644 kmrml/kmrml/kcontrol/mainpage.h create mode 100644 kmrml/kmrml/kcontrol/serverconfigwidget.ui (limited to 'kmrml/kmrml/kcontrol') diff --git a/kmrml/kmrml/kcontrol/Makefile.am b/kmrml/kmrml/kcontrol/Makefile.am new file mode 100644 index 00000000..c1330cfd --- /dev/null +++ b/kmrml/kmrml/kcontrol/Makefile.am @@ -0,0 +1,25 @@ +LIB_KMRMLSTUFF = $(top_builddir)/kmrml/kmrml/lib/libkmrmlstuff.la + +kde_module_LTLIBRARIES = kcm_kmrml.la + +kcm_kmrml_la_SOURCES = kcmkmrml.cpp mainpage.cpp indexer.cpp serverconfigwidget.ui indexcleaner.cpp +kcm_kmrml_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +kcm_kmrml_la_LIBADD = $(LIB_KMRMLSTUFF) $(LIB_KIO) +INCLUDES= -I$(top_srcdir)/kmrml/kmrml/lib $(all_includes) + +kcm_kmrml_la_METASOURCES = AUTO + +noinst_HEADERS = kcmkmrml.h mainpage.h serverconfigwidget.h indexer.h indexcleaner.h + +xdg_apps_DATA = kcmkmrml.desktop + +#check_PROGRAMS = indextest +#indextest_SOURCES = indextest.cpp indexer.cpp +#indextest_LDADD = $(LIB_KMRMLSTUFF) $(LIB_KDECORE) +#indextest_LDFLAGS = $(all_libraries) + + + +#pics_DATA = play.png +#picsdir = $(kde_datadir)/kcontrol/pics + diff --git a/kmrml/kmrml/kcontrol/indexcleaner.cpp b/kmrml/kmrml/kcontrol/indexcleaner.cpp new file mode 100644 index 00000000..5f5eea93 --- /dev/null +++ b/kmrml/kmrml/kcontrol/indexcleaner.cpp @@ -0,0 +1,96 @@ +#include +#include + +#include +#include "indexcleaner.h" + +#include +#if KDE_VERSION < 306 + #define QUOTE( x ) x +#else + #define QUOTE( x ) KProcess::quote( x ) +#endif + +using namespace KMrmlConfig; + +IndexCleaner::IndexCleaner( const QStringList& dirs, + const KMrml::Config *config, + QObject *parent, const char *name ) + : QObject( parent, name ), + m_dirs( dirs ), + m_config( config ), + m_process( 0L ) +{ + m_stepSize = 100 / dirs.count(); +} + +IndexCleaner::~IndexCleaner() +{ + if ( m_process ) + { + m_process->kill(); + delete m_process; + m_process = 0L; + } +} + +void IndexCleaner::start() +{ + startNext(); +} + +void IndexCleaner::slotExited( KProcess *proc ) +{ + emit advance( m_stepSize ); + + if ( !proc->normalExit() ) + kdWarning() << "Error removing old indexed directory" << endl; + + m_process = 0L; + + startNext(); +} + +void IndexCleaner::startNext() +{ + if ( m_dirs.isEmpty() ) + { + emit advance( 100 ); + emit finished(); + return; + } + +#if KDE_VERSION < 306 + m_process = new KShellProcess(); +#else + m_process = new KProcess(); + m_process->setUseShell( true ); +#endif + connect( m_process, SIGNAL( processExited( KProcess * )), + SLOT( slotExited( KProcess * ) )); + + QString cmd = m_config->removeCollectionCommandLine(); + + QString dir = m_dirs.first(); + m_dirs.pop_front(); + + int index = cmd.find( "%d" ); + if ( index != -1 ) + cmd.replace( index, 2, QUOTE( dir ) ); + else // no %d? What else can we do? + cmd.append( QString::fromLatin1(" ") + QUOTE( dir ) ); + + *m_process << cmd; + + if ( !m_process->start() ) + { + kdWarning() << "Error starting: " << cmd << endl; + + delete m_process; + m_process = 0L; + + startNext(); + } +} + +#include "indexcleaner.moc" diff --git a/kmrml/kmrml/kcontrol/indexcleaner.h b/kmrml/kmrml/kcontrol/indexcleaner.h new file mode 100644 index 00000000..0ddcaac4 --- /dev/null +++ b/kmrml/kmrml/kcontrol/indexcleaner.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** $Id$ +** +** Copyright (C) 2002 Carsten Pfeiffer +** +****************************************************************************/ + +#ifndef INDEXCLEANER_H +#define INDEXCLEANER_H + +#include +#include + +class KProcess; + +namespace KMrml +{ + class Config; +} + +namespace KMrmlConfig +{ + class IndexCleaner : public QObject + { + Q_OBJECT + + public: + IndexCleaner( const QStringList& dirs, const KMrml::Config *config, + QObject *parent = 0, const char *name = 0 ); + ~IndexCleaner(); + + void start(); + + signals: + void advance( int value ); + void finished(); + + private slots: + void slotExited( KProcess * ); + + private: + int m_stepSize; + void startNext(); + + QStringList m_dirs; + const KMrml::Config *m_config; + KProcess *m_process; + }; + +} + + +#endif // INDEXCLEANER_H diff --git a/kmrml/kmrml/kcontrol/indexer.cpp b/kmrml/kmrml/kcontrol/indexer.cpp new file mode 100644 index 00000000..a3bb6b7d --- /dev/null +++ b/kmrml/kmrml/kcontrol/indexer.cpp @@ -0,0 +1,190 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Carsten Pfeiffer + + 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, version 2. + + 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include +#include +#include +#include + +#include "indexer.h" + +#include +#if KDE_VERSION < 306 + #define QUOTE( x ) x +#else + #define QUOTE( x ) KProcess::quote( x ) +#endif + +using namespace KMrmlConfig; + +Indexer::Indexer( const KMrml::Config* config, + QObject *parent, const char *name ) + : QObject( parent, name ), + m_config( config ), + m_dirCount( 0 ) +{ + m_process = new KProcIO(); +#if KDE_VERSION >= 306 + m_process->setUseShell( true ); +#endif + m_process->setEnvironment( "LC_ALL", "C" ); + connect( m_process, SIGNAL( processExited( KProcess * )), + SLOT( processFinished( KProcess * ))); + connect( m_process, SIGNAL( readReady( KProcIO * )), + SLOT( slotCanRead( KProcIO * )) ); +} + +Indexer::~Indexer() +{ + delete m_process; +} + +void Indexer::startIndexing( const QStringList& dirs ) +{ + if ( m_process->isRunning() ) + return; + + m_dirs = dirs; + m_dirCount = dirs.count(); + processNext(); +} + +void Indexer::processFinished( KProcess *proc ) +{ + // still more directories to index? + if ( !m_dirs.isEmpty() ) + processNext(); + else + { + if ( proc->normalExit() ) + emit finished( proc->exitStatus() ); + else + emit finished( -1000 ); + } +} + + +void Indexer::processNext() +{ + m_currentDir = m_dirs.first(); + m_dirs.pop_front(); + while ( m_currentDir.endsWith( "/" ) ) + m_currentDir.remove( m_currentDir.length() -1, 1 ); + + m_process->resetAll(); + + QString cmd = m_config->addCollectionCommandLine().simplifyWhiteSpace().stripWhiteSpace(); + + // in the commandline, replace %d with the directory to process and + // %t with the thumbnail dir + int index = cmd.find( "%d" ); // ### QFile::encodeName()? + if ( index != -1 ) + cmd.replace( index, 2, QUOTE( m_currentDir ) ); + index = cmd.find( "%t" ); + if ( index != -1 ) + cmd.replace( index, 2, QUOTE(m_currentDir + "_thumbnails") ); + +// qDebug("****** command: %s", cmd.latin1()); +#if KDE_VERSION >= 306 + *m_process << cmd; +#else + QStringList params = QStringList::split( ' ', cmd ); + QStringList::Iterator it = params.begin(); + for ( ; it != params.end(); ++it ) + *m_process << *it; +#endif + + emit progress( 0, i18n("Next Folder:
%1").arg( m_currentDir )); + m_process->start(); +} + +void Indexer::slotCanRead( KProcIO *proc ) +{ + static const QString& sprogress = KGlobal::staticQString("PROGRESS: "); + static const QString& r1 = /* PROGRESS: 1 of 6 done (15%) */ + KGlobal::staticQString( "(\\d+) of (\\d+) done \\((\\d+)%\\)" ); + + QString line; + int bytes = -1; + while ( (bytes = proc->readln( line )) != -1 ) + { + // examine the output. + // We're looking for lines like: + // PROGRESS: 1 of 6 done (15%) + // PROGRESS: 99% + // PROGRESS: 100% + + if ( !line.startsWith( sprogress ) ) // uninteresting debug output + continue; + else // parse output + { + // cut off "PROGRESS: " + line = line.mid( sprogress.length() ); + line = line.simplifyWhiteSpace().stripWhiteSpace(); +// qDebug("*** START LINE ***"); +// qDebug("%s", line.latin1()); +// qDebug("*** END LINE ***"); + + // case 1: image processing, below 99% + if ( line.at( line.length() -1 ) == ')' ) + { + QRegExp regxp( r1 ); + int pos = regxp.search( line ); + if ( pos > -1 ) + { + QString currentFile = regxp.cap( 1 ); + QString numFiles = regxp.cap( 2 ); + QString percent = regxp.cap( 3 ); + +// qDebug( "current: %s, number: %s, percent: %s", currentFile.latin1(), numFiles.latin1(), percent.latin1()); + bool ok = false; + int perc = percent.toInt( &ok ); + if ( ok ) + { + uint dirsLeft = m_dirs.count(); + QString message = i18n( "Processing folder %1 of %2:
%3
File %4 of %5.
").arg( m_dirCount - dirsLeft ).arg( m_dirCount).arg( m_currentDir ).arg( currentFile ).arg( numFiles ); + emit progress( perc, message ); + } + } + } + + + // case 2: file writing, 99% or done, 100% + else + { + QString percent = line.left( line.length() - 1 ); + + bool ok = false; + int number = percent.toInt( &ok ); + if ( ok ) + { + QString message = (number == 100) ? + i18n("Finished.") : i18n("Writing data..."); + emit progress( number, message ); + } + else + kdDebug() << "Error while parsing gift-add-collection.pl output" << endl; + } + } + } +} + +#include "indexer.moc" diff --git a/kmrml/kmrml/kcontrol/indexer.h b/kmrml/kmrml/kcontrol/indexer.h new file mode 100644 index 00000000..97335a70 --- /dev/null +++ b/kmrml/kmrml/kcontrol/indexer.h @@ -0,0 +1,68 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Carsten Pfeiffer + + 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, version 2. + + 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef INDEXER_H +#define INDEXER_H + +#include + +#include + +class KProcess; +class KProcIO; + +namespace KMrmlConfig +{ + class Indexer : public QObject + { + Q_OBJECT + + public: + Indexer( const KMrml::Config *config, + QObject *parent = 0L, const char *name = 0 ); + ~Indexer(); + + void startIndexing( const QStringList& dirs ); + void stop(); + + signals: + void progress( int percent, const QString& text ); + void finished( int returnCode ); + + + private slots: + void slotCanRead( KProcIO * ); + void processFinished( KProcess * ); + + private: + void processNext(); + + KProcIO *m_process; + const KMrml::Config *m_config; + + uint m_dirCount; + QStringList m_dirs; + QString m_currentDir; + + }; + + +} + + +#endif // INDEXER_H diff --git a/kmrml/kmrml/kcontrol/indextest.cpp b/kmrml/kmrml/kcontrol/indextest.cpp new file mode 100644 index 00000000..161ca798 --- /dev/null +++ b/kmrml/kmrml/kcontrol/indextest.cpp @@ -0,0 +1,43 @@ +#include "indexer.h" +#include +#include "indextest.moc" + +#include +#include +#include + +using namespace KMrmlConfig; + +IndexTest::IndexTest() +{ + KMrml::Config *config = new KMrml::Config( KGlobal::config() ); + Indexer *indexer = new Indexer( *config, this ); + connect( indexer, SIGNAL( finished( bool )), SLOT( slotFinished( bool ))); + connect( indexer, SIGNAL( progress( int, const QString& )), + SLOT( slotProgress( int, const QString& ))); + + indexer->startIndexing( "/home/gis/testcoll" ); +} + +IndexTest::~IndexTest() +{ + +} + +void IndexTest::slotFinished( bool success ) +{ + qDebug("##### FINISHED: %i", success ); +} + +void IndexTest::slotProgress( int percent, const QString& message ) +{ + qDebug("--- progress: %i: %s", percent, message.latin1()); +} + +int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "indextest" ); + IndexTest *test = new IndexTest(); + + return app.exec(); +} diff --git a/kmrml/kmrml/kcontrol/indextest.h b/kmrml/kmrml/kcontrol/indextest.h new file mode 100644 index 00000000..5f85f5f1 --- /dev/null +++ b/kmrml/kmrml/kcontrol/indextest.h @@ -0,0 +1,26 @@ +/**************************************************************************** +** $Id$ +** +** Copyright (C) 2002 Carsten Pfeiffer +** +****************************************************************************/ + +#ifndef INDEXTEST_H +#define INDEXTEST_H + +class IndexTest : public QObject +{ + Q_OBJECT + +public: + IndexTest(); + ~IndexTest(); + +private slots: + void slotFinished( bool success ); + void slotProgress( int percent, const QString& message ); + +}; + + +#endif // INDEXTEST_H diff --git a/kmrml/kmrml/kcontrol/kcmkmrml.cpp b/kmrml/kmrml/kcontrol/kcmkmrml.cpp new file mode 100644 index 00000000..43e46b03 --- /dev/null +++ b/kmrml/kmrml/kcontrol/kcmkmrml.cpp @@ -0,0 +1,146 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Carsten Pfeiffer + + 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, version 2. + + 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kcmkmrml.h" +#include + +#include "mainpage.h" +#include + +using namespace KMrmlConfig; + +static const int COL_FILENAME = 1; + +typedef KGenericFactory MrmlFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_kmrml, MrmlFactory("kmrml") ) + +KCMKMrml::KCMKMrml(QWidget *parent, const char *name, const QStringList & ): + KCModule(MrmlFactory::instance(), parent, name) +{ + KAboutData* ab = new KAboutData( + "kcmkmrml", + I18N_NOOP("KCMKMrml"), + KMRML_VERSION, + I18N_NOOP("Advanced Search Control Module"), + KAboutData::License_GPL, + I18N_NOOP( "Copyright 2002, Carsten Pfeiffer" ), + 0, + "http://devel-home.kde.org/~pfeiffer/kmrml/" ); + ab->addAuthor( "Carsten Pfeiffer", 0, "pfeiffer@kde.org" ); + setAboutData( ab ); + + QVBoxLayout *layout = new QVBoxLayout( this ); + layout->setSpacing( KDialog::spacingHint() ); + m_mainPage = new MainPage( this, "main page" ); + + layout->addWidget( m_mainPage ); + + connect( m_mainPage, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ))); + + checkGiftInstallation(); +} + +KCMKMrml::~KCMKMrml() +{ +} + +void KCMKMrml::checkGiftInstallation() +{ + QString giftExe = KGlobal::dirs()->findExe( "gift" ); + QString giftAddCollectionExe = KGlobal::dirs()->findExe( "gift-add-collection.pl" ); + + if ( giftExe.isEmpty() || giftAddCollectionExe.isEmpty() ) + { + QString errorMessage = + i18n("Cannot find executables \"gift\" and/or \"gift-add-collection.pl\" in the PATH.\n" + "Please install the \"GNU Image Finding Tool\"."); + KMessageBox::error( this, errorMessage ); + m_mainPage->hide(); + QLabel *errorLabel = new QLabel( errorMessage, this ); + errorLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) ); + KURLLabel *urlLabel = new KURLLabel( "http://www.gnu.org/software/gift", QString::null, this ); + urlLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + connect( urlLabel, SIGNAL( leftClickedURL( const QString& )), kapp, SLOT( invokeBrowser( const QString& )) ); + QLayout *l = layout(); + l->addItem( new QSpacerItem( 0, 10, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); + l->add( errorLabel ); + l->add( urlLabel ); + l->addItem( new QSpacerItem( 0, 10, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); + errorLabel->show(); + } + else + load(); +} + +void KCMKMrml::defaults() +{ + if (KMessageBox::warningContinueCancel(this, + i18n("Do you really want the configuration to be reset " + "to the defaults?"), i18n("Reset Configuration"), KStdGuiItem::cont()) + != KMessageBox::Continue) + return; + + m_mainPage->resetDefaults(); + + emit changed( true ); +} + +void KCMKMrml::load() +{ + m_mainPage->load(); + + emit changed( true ); +} + +void KCMKMrml::save() +{ + m_mainPage->save(); + + emit changed( false ); +} + +QString KCMKMrml::quickHelp() const +{ + return i18n("

Image Index

" + "KDE can make use of the GNU Image Finding Tool (GIFT) to " + "perform queries based not just on filenames, but on " + "file content." + "

For example, you can search for an image by giving an example " + "image that looks similar to the one you are looking for.

" + "

For this to work, your image directories need to be " + "indexed by, for example, the GIFT server.

" + "

Here you can configure the servers (you can also query " + "remote servers) and the directories to index.

" + ); +} + +#include "kcmkmrml.moc" diff --git a/kmrml/kmrml/kcontrol/kcmkmrml.desktop b/kmrml/kmrml/kcontrol/kcmkmrml.desktop new file mode 100644 index 00000000..d9dd1f02 --- /dev/null +++ b/kmrml/kmrml/kcontrol/kcmkmrml.desktop @@ -0,0 +1,176 @@ +[Desktop Entry] +Exec=kcmshell kcmkmrml +Icon=folder_image +Type=Application + +X-KDE-ModuleType=Library +X-KDE-Library=kmrml + +Name=Image Index +Name[ar]=فهرس الصور +Name[bg]=Графичен индекс +Name[br]=Meneger ar skeudenn +Name[bs]=Indeks slika +Name[ca]=Índex d'imatge +Name[cs]=Rejstřík obrázků +Name[cy]=Mynegai Delweddau +Name[da]=Billedindeks +Name[de]=Bildindex +Name[el]=Ευρετήριο εικόνων +Name[eo]=Bildindekso +Name[es]=Índice de imágenes +Name[et]=Pildiindeks +Name[eu]=Irudiaren indizea +Name[fa]=نمایۀ تصویر +Name[fi]=Kuvahakemisto +Name[fr]=Indexation des images +Name[gl]=Índice imaxe +Name[he]=אינדקס תמונות +Name[hi]=छवि सूची +Name[hu]=Képkereső +Name[is]=Myndayfirlit +Name[it]=Indice di immagini +Name[ja]=画像インデックス +Name[kk]=Кескіндер индексі +Name[km]=លិបិក្រម​រូបភាព +Name[lt]=Paveikslėlių rodyklė +Name[ms]=Indeks Imej +Name[nb]=Bildeindeks +Name[nds]=Bildindex +Name[ne]=छवि अनुक्रमणिका +Name[nl]=Afbeeldingenindex +Name[nn]=Biletindeks +Name[nso]=Palo ya Ponagalo +Name[pl]=Spis obrazków +Name[pt]=Índice de Imagens +Name[pt_BR]=Índice de Imagens +Name[ro]=Index imagini +Name[ru]=Индексирование изображений +Name[se]=Govvaindeaksa +Name[sk]=Katalóg obrázkov +Name[sl]=Seznam slik +Name[sr]=Индекс слика +Name[sr@Latn]=Indeks slika +Name[sv]=Bildindex +Name[ta]=பிம்ப அட்டவணை +Name[tg]=Индексатсия кардани тасвирот +Name[th]=ดัชนีรูปภาพ +Name[tr]=Resim İndeksi +Name[uk]=Індекс зображень +Name[uz]=Rasm indeksi +Name[uz@cyrillic]=Расм индекси +Name[ven]=Index ya tshifanyiso +Name[wa]=Indecse des imådjes +Name[xh]=Isalathisi Somfanekiso +Name[zh_CN]=图像索引 +Name[zh_HK]=圖像索引 +Name[zh_TW]=影像索引 +Name[zu]=Isiqalo Sesithombe + +Comment=Configuration for using the GNU Image Finding Tool +Comment[ar]=اعدادات لاستخدام أداة GNU للبحث عن الصور +Comment[bg]=Настройване на програмата за индексиране и търсене на изображения +Comment[bs]=Podešavanje za upotrebu GNU Alata za pronalaženje slika +Comment[ca]=Configuració per a l'ús de l'eina de cerca d'imatges GNU +Comment[cs]=Konfigurace používání nástroje GNU Image Finding Tool +Comment[cy]=Ffurfweddiad am ddefnyddio'r Erfyn Canfod Delweddau GNU +Comment[da]=Indstilling for brug af GNU Image Finding Tool +Comment[de]=Einrichtung für die Benutzung des GNU Bildersuchwerkzeugs (GNU Image Finding Tool) +Comment[el]=Ρύθμιση για τη χρήση του εργαλείου αναζήτησης εικόνων GIFT +Comment[es]=Configuración para utilizar la herramienta de búsqueda de imágenes de GNU +Comment[et]=Seadistused GNU pildileidmisrakenduse kasutamiseks +Comment[eu]=GNU irudi aurkitzailea erabiltzeko konfigurazioa +Comment[fa]=پیکربندی برای استفاده از ابزار یافتن تصویر GNU +Comment[fi]=Asetukset GNU Image Finding Tool -ohjelman käyttöä varten +Comment[fr]=Configuration pour l'utilisation du GNU Image Finding Tool +Comment[gl]=Configuración para empregar a «GNU Image Finding Tool» +Comment[he]=שינוי הגדרות כלי חיפוש התמונות של GNU +Comment[hi]=ग्नू छवि खोज औज़ार को उपयोग करने के लिए कॉन्फ़िगरेशन +Comment[hu]=A GIFT képkereső szolgáltatás beállításai +Comment[is]=Stillingar til þess að nota GNU myndleitartólið +Comment[it]=Configurazione della ricerca delle immagini +Comment[ja]=GIFT (GNU Image Finding Tool) を使用するための設定 +Comment[kk]=GNU Image Finding Tool кескінді табу құралын пайдалану баптаулары +Comment[km]=ការ​កំណត់​រចនាសម្ព័ន្ធ​ដើម្បី​ប្រើ​ឧបករណ៍​ស្វែងរក​រូបភាព​របស់ GNU +Comment[lt]=GNU paveikslėlių paieškos įrankio konfigūracija +Comment[ms]=Konfigurasi untuk mengguna Alat Carian Imej GNU +Comment[nb]=Tilpass GNU bildesøkingsverktøy +Comment[nds]=Inrichten för dat GNU-Bildsöökwarktüüch +Comment[ne]=GNU छवि फेला पार्ने उपकरण प्रयोगका लागि कन्फिगरेसन +Comment[nl]=Configuratie voor het gebruik van de GNU Image Finding Tool +Comment[nn]=Oppsett av GNU Image Finding Tool +Comment[pl]=Konfiguracja Gifta (narzędzia do szukania obrazków GNU) +Comment[pt]=Configuração da Ferramenta de Procura de Imagens da GNU +Comment[pt_BR]=Configuração para o uso da Ferramenta de Procura de Imagens GNU +Comment[ro]=Configurare pentru GNU Image Finding Tool +Comment[ru]=Настройка использования программы поиска изображений GNU Image Finding Tool +Comment[se]=Heivet GNU Image Finding Tool +Comment[sk]=Konfigurácia pre GNU Image Finding Tool +Comment[sl]=Nastavitve za uporabo orodja GNU za iskanje slik +Comment[sr]=Подешавање коришћења GNU-овог алата за тражење слика +Comment[sr@Latn]=Podešavanje korišćenja GNU-ovog alata za traženje slika +Comment[sv]=Inställning för att använda GNU:s bildsökverktyg +Comment[ta]=GNU பிம்ப தேடுதல் கருவியை பயன்படுத்துவதற்கான அமைப்பு +Comment[tg]=Танзимоти истифодабарии барномаиҷустуҷӯи тасвироти GNU Image Finding Tool +Comment[tr]=GNU Resim Bulma Aracı yapılandırması +Comment[uk]=Налаштування засобу пошуку зображень GNU +Comment[ven]=Nzudzanyo yau shumisa tshishumiswa tshau toda tshifanyiso tsha GNU +Comment[wa]=Apontiaedje po-z eployî l' usteye di cweraedje d' imådjes di GNU +Comment[xh]=Uqwalaselo lokusebenzisa Isixhobo Sokufumana Umfanekiso we GNU +Comment[zh_CN]=使用 GNU 图像查找工具的配置 +Comment[zh_HK]=GNU 圖像搜尋工具的設定 +Comment[zh_TW]= GNU 影像搜尋工具組態 +Comment[zu]=Inhlanganiselo yokusebenzisa Ithuluzi Lokuthola Isithombe se-GNU + +Keywords=Images,Search,Query,Find,Gift,kmrml,mrml,CBIR +Keywords[ar]=صور,بحث,استعلام,Find,Gift,kmrml,mrml,CBIR +Keywords[bg]=изображения, търсене, заявка, картинка, картинки, снимки, Images, Search, Query, Find, Gift, kmrml, mrml, CBIR +Keywords[bs]=Images,Search,Query,Find,Gift,kmrml,mrml,CBIR,slike,pretraga,upit,nađi +Keywords[ca]=Imatges,Cerca,Consulta,Busca,Gift,kmrml,mrml,CBIR +Keywords[cs]=Obrázky,Hledat,Dotaz,Najít,Gift,kmrml,mrml,CBIR +Keywords[cy]=Delweddau,Chwilio,Canfod,Gift,kmrml,mrml,CBIR +Keywords[da]=Billeder,Søgning,Forespørgsel,Find,Gave,kmrml,mrml,CBIR +Keywords[de]=Bilder,Suche,Anfrage,finden,Geschenk,kmrml,mrml,CBIR +Keywords[el]=Εικόνες,Αναζήτηση,Ερώτηση,Αναζήτηση,Gift,kmrml,mrml,CBIR +Keywords[es]=Imágenes,Búsqueda,Consulta,Buscar,Gift,kmrml,mrml,CBIR +Keywords[et]=pildid,otsing,päring,leia,Gift,kmrml,mrml,CBIR +Keywords[eu]=Irudiak,Bilaketa,Bilatu,Galdetu,Gift,kmrml,mrml,CBIR +Keywords[fa]=تصاویر، جستجو، پرس‌و‌جو، یافتن، Gift،kmrml،mrml،CBIR +Keywords[fi]=Kuvat,Haku,Etsi,Lahja,kmrml,mrml,CBIR +Keywords[fr]=Images,Recherche,Requête,Chercher,Gift,kmrml,mrml,CBIR +Keywords[gl]=Images,Search,Query,Find,Gift,kmrml,mrml,CBIR, imaxes, procura +Keywords[he]=תמונות,חיפוש,שאילתה,Gift,kmrml,mrml,CBIR, Images,Search,Query,Find +Keywords[hi]=छवि, खोज,ढूंढ,तलाश,उपहार,केएमआरएमएल,एमआरएमएल,सीबीआईआर +Keywords[hu]=képek,keresés,lekérdezés,találat,Gift,kmrml,mrml,CBIR +Keywords[it]=immagini,ricerca,trovare,Gift,kmrml,mrml,CBIR +Keywords[ja]=画像,検索,クエリ,検索,Gift,kmrml,mrml,CBIR +Keywords[km]=រូបភាព,ស្វែងរក,សួរ,រក,Gift,kmrml,mrml,CBIR +Keywords[lt]=Images,Search,Query,Find,Gift,kmrml,mrml,CBIR, paveikslėliai,paieška,paklausimas +Keywords[nb]=Bilder,Søk,Spørringer,Finn,Gift,kmrml,mrml,CBIR +Keywords[nds]=Biller,Söök,Anfraag,söken,Gaav,kmrml,mrml,CBIR +Keywords[nl]=illustraties,figuren,figuur,afbeeldingen,plaatjes,zoeken,find,gift,kmrml,mrml,CBIR,images +Keywords[nn]=bilete,søk,spørjing,finn,gåve,kmrml,mrml,CBIR +Keywords[nso]=Diponagalo,Nyaka,Kgokgonego,Hwetsa,Mpho,kmrml,mrml,CBIR +Keywords[pl]=Obrazki,Szukanie,Zapytanie,Szukaj,Gift,kmrml,mrml,CBIR +Keywords[pt]=Imagens,Procurar,Pesquisar,Encontrar,Prenda,kmrml,mrml,CBIR +Keywords[pt_BR]=Imagens,Busca,Consulta,Procurar,Presente,kmrml,mrml,CBIR +Keywords[ro]=imagini,căutare,caută,interogare,găseşte,dar,kmrml,mrml,CBIR +Keywords[ru]=изображения,поиск,запрос,kmrml,mrml,CBIR +Keywords[sk]=Obrázky,Hľadanie,Dotazy,Nájsť,kmrml,mrml,CBIR +Keywords[sl]=slike,iskanje,povpraševanje,išči,najdi,gift,kmrml,mrml,CBIR +Keywords[sr]=Images,Search,Query,Find,Gift,kmrml,mrml,CBIR,слике,тражи,упит,нађи,поклон +Keywords[sr@Latn]=Images,Search,Query,Find,Gift,kmrml,mrml,CBIR,slike,traži,upit,nađi,poklon +Keywords[sv]=Bilder,Sök,Förfrågan,Hitta,Gift,kmrml,mrml,CBIR +Keywords[ta]=பிம்பங்கள், தேடு, கேள்வி, கண்டுபிடி,பரிசு,kmrml,mrml,CBIR +Keywords[tg]=тасвирот,ҷустуҷӯӣ,дархост,kmrml,mrml,CBIR +Keywords[tr]=Resimler,Ara,Arama,kmrml,mrml,CBIR +Keywords[uk]=зображення,пошук,запит,знайти,подарунок,kmrml,mrml,CBIR +Keywords[ven]=Zwifanyiso,Toda,Mbudziso,Wana,Mpho,kmrml,mrml,CBIR +Keywords[wa]=Imådjes,Cweri,Cweraedje,Trover,Gift,kmrml,mrml,CBIR +Keywords[xh]=Imifanekiso,Uphendlo,Ubuzo,fumana,Isiphiwo,kmrml,mrml,CBIR +Keywords[zh_CN]=Images,Search,Query,Find,Gift,kmrml,mrml,CBIR,图像,搜索,查询,查找,礼物 +Keywords[zh_HK]=Images,Search,Query,Find,Gift,kmrml,mrml,CBIR,圖像,搜尋,查詢,尋找 +Keywords[zh_TW]=Images,Search,Query,Find,Gift,kmrml,mrml,CBIR,影像,搜尋,查詢,尋找 +Keywords[zu]=Izithombe,Funa,Buza,Thola,Isipho,kmrml,mrml,CBIR + +Categories=Qt;KDE;Settings;X-KDE-settings-system; diff --git a/kmrml/kmrml/kcontrol/kcmkmrml.h b/kmrml/kmrml/kcontrol/kcmkmrml.h new file mode 100644 index 00000000..b0bb2443 --- /dev/null +++ b/kmrml/kmrml/kcontrol/kcmkmrml.h @@ -0,0 +1,52 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Carsten Pfeiffer + + 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, version 2. + + 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KCMKMRML_H +#define KCMKMRML_H + +#include + +class KAboutData; +class KURLRequester; + +namespace KMrmlConfig +{ + class MainPage; + + class KCMKMrml : public KCModule + { + Q_OBJECT + + public: + KCMKMrml(QWidget *parent, const char *name, const QStringList &); + virtual ~KCMKMrml(); + + virtual void defaults(); + virtual void load(); + virtual void save(); + virtual QString quickHelp() const; + + private: + void checkGiftInstallation(); + + MainPage *m_mainPage; + }; + +} + +#endif diff --git a/kmrml/kmrml/kcontrol/mainpage.cpp b/kmrml/kmrml/kcontrol/mainpage.cpp new file mode 100644 index 00000000..514b9cf6 --- /dev/null +++ b/kmrml/kmrml/kcontrol/mainpage.cpp @@ -0,0 +1,501 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Carsten Pfeiffer + + 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, version 2. + + 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include // MAX_PORT_VALUE + +#include "serverconfigwidget.h" +#include "mainpage.h" +#include "indexer.h" +#include "indexcleaner.h" + +#include +#include + +using namespace KMrmlConfig; + + +MainPage::MainPage( QWidget *parent, const char *name ) + : QVBox( parent, name ), + m_indexer( 0L ), + m_indexCleaner( 0L ), + m_progressDialog( 0L ), + m_performIndexing( false ), + m_locked( false ) +{ + m_config = new KMrml::Config(); + setSpacing( KDialog::spacingHint() ); + + QVGroupBox *gBox = new QVGroupBox( i18n("Indexing Server Configuration"), + this ); + m_serverWidget = new ServerConfigWidget( gBox, "server config widget" ); + QString tip = i18n("Hostname of the Indexing Server"); + QToolTip::add( m_serverWidget->m_hostLabel, tip ); + QToolTip::add( m_serverWidget->m_hostCombo, tip ); + + m_serverWidget->m_portInput->setRange( 0, MAX_PORT_VALUE ); + +#if KDE_VERSION >= 306 + KURLRequester *requester = new KURLRequester( this, "dir requester" ); + requester->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly ); + requester->setURL( KGlobalSettings::documentPath() ); + connect( requester, SIGNAL( openFileDialog( KURLRequester * )), + SLOT( slotRequesterClicked( KURLRequester * ))); + + m_listBox = new KEditListBox( i18n("Folders to Be Indexed" ), + requester->customEditor(), this, "listbox", + false, + KEditListBox::Add | KEditListBox::Remove ); +#else + m_listBox = new KEditListBox( i18n("Folders to Be Indexed" ), + this, "listbox", false, + KEditListBox::Add | KEditListBox::Remove ); +#endif + + connect( m_listBox, SIGNAL( changed() ), SLOT( slotDirectoriesChanged() )); + connect( m_serverWidget->m_hostCombo, SIGNAL( textChanged(const QString&)), + SLOT( slotHostChanged() )); + connect( m_serverWidget->m_portInput, SIGNAL( valueChanged( int )), + SLOT( slotPortChanged( int ) )); + connect ( m_serverWidget->m_useAuth, SIGNAL( toggled(bool) ), + SLOT( slotUseAuthChanged( bool ) )); + connect( m_serverWidget->m_userEdit, SIGNAL( textChanged( const QString&)), + SLOT( slotUserChanged( const QString& ) )); + connect( m_serverWidget->m_passEdit, SIGNAL( textChanged( const QString&)), + SLOT( slotPassChanged( const QString& ) )); + + connect( m_serverWidget->m_addButton, SIGNAL( clicked() ), + SLOT( slotAddClicked() )); + connect( m_serverWidget->m_removeButton, SIGNAL( clicked() ), + SLOT( slotRemoveClicked() )); + + connect( m_serverWidget->m_hostCombo, SIGNAL( activated( const QString& )), + SLOT( slotHostActivated( const QString& ))); + connect( m_serverWidget->m_hostCombo, SIGNAL( returnPressed() ), + SLOT( slotAddClicked() )); + + connect( m_serverWidget->m_autoPort, SIGNAL( toggled( bool ) ), + SLOT( slotAutoPortChanged( bool ) )); + + m_serverWidget->m_hostCombo->setTrapReturnKey( true ); + m_serverWidget->m_hostCombo->setFocus(); +} + +MainPage::~MainPage() +{ + delete m_config; +} + +void MainPage::resetDefaults() +{ + blockSignals( true ); + + initFromSettings( KMrml::ServerSettings::defaults() ); + + m_serverWidget->m_hostCombo->clear(); + m_serverWidget->m_hostCombo->insertItem( m_settings.host ); + + m_listBox->clear(); + + // slotHostChanged(); not necessary, will be called by Qt signals + slotUseAuthChanged( m_serverWidget->m_useAuth->isChecked() ); + + blockSignals( false ); +} + +void MainPage::load() +{ + blockSignals( true ); + + initFromSettings( m_config->defaultSettings() ); + + m_serverWidget->m_hostCombo->clear(); + m_serverWidget->m_hostCombo->insertStringList( m_config->hosts() ); + m_serverWidget->m_hostCombo->setCurrentItem( m_settings.host ); + + m_listBox->clear(); + m_listBox->insertStringList( m_config->indexableDirectories() ); + + // slotHostChanged(); not necessary, will be called by Qt signals + slotUseAuthChanged( m_serverWidget->m_useAuth->isChecked() ); + + blockSignals( false ); +} + +void MainPage::save() +{ + m_config->addSettings( m_settings ); + m_config->setDefaultHost( m_settings.host ); + + QStringList indexDirs = m_listBox->items(); + QStringList oldIndexDirs = m_config->indexableDirectories(); + QStringList removedDirs = difference( oldIndexDirs, indexDirs ); + + m_config->setIndexableDirectories( indexDirs ); + if ( indexDirs.isEmpty() ) + KMessageBox::information( this, + i18n("You did not specify any folders to " + "be indexed. This means you will be " + "unable to perform queries on your " + "computer."), + "kcmkmrml_no_directories_specified" ); + + if ( m_config->sync() ) + KIO::SlaveConfig::self()->reset(); + + processIndexDirs( removedDirs ); +} + +QStringList MainPage::difference( const QStringList& oldIndexDirs, + const QStringList& newIndexDirs ) const +{ + QStringList result; + + QString slash = QString::fromLatin1("/"); + QStringList::ConstIterator oldIt = oldIndexDirs.begin(); + QString oldDir, newDir; + + for ( ; oldIt != oldIndexDirs.end(); oldIt++ ) + { + bool removed = true; + oldDir = *oldIt; + + while ( oldDir.endsWith( slash ) ) // remove slashes + oldDir.remove( oldDir.length() - 1, 1 ); + + QStringList::ConstIterator newIt = newIndexDirs.begin(); + for ( ; newIt != newIndexDirs.end(); newIt++ ) + { + newDir = *newIt; + while ( newDir.endsWith( slash ) ) // remove slashes + newDir.remove( newDir.length() - 1, 1 ); + + if ( oldDir == newDir ) + { + removed = false; + break; + } + } + + if ( removed ) + result.append( *oldIt ); // not oldDir -- maybe gift needs slashes + } + + return result; +} + +void MainPage::initFromSettings( const KMrml::ServerSettings& settings ) +{ + m_settings = settings; + + m_locked = true; + + m_serverWidget->m_portInput->setValue( settings.configuredPort ); + m_serverWidget->m_autoPort->setChecked( settings.autoPort ); + m_serverWidget->m_useAuth->setChecked( settings.useAuth ); + m_serverWidget->m_userEdit->setText( settings.user ); + m_serverWidget->m_passEdit->setText( settings.pass ); + + m_locked = false; +} + +void MainPage::slotHostActivated( const QString& host ) +{ + // implicitly save the current settings when another host was chosen + m_config->addSettings( m_settings ); + + initFromSettings( m_config->settingsForHost( host ) ); +} + +void MainPage::slotHostChanged() +{ + QString host = m_serverWidget->m_hostCombo->currentText(); + m_listBox->setEnabled( (host == "localhost") ); + + KMrml::ServerSettings settings = m_config->settingsForHost( host ); + enableWidgetsFor( settings ); +} + +void MainPage::slotUseAuthChanged( bool enable ) +{ + m_settings.useAuth = enable; + m_serverWidget->m_userEdit->setEnabled( enable ); + m_serverWidget->m_passEdit->setEnabled( enable ); + + if ( enable ) + m_serverWidget->m_userEdit->setFocus(); + + if ( !m_locked ) + changed(); +} + +void MainPage::slotUserChanged( const QString& user ) +{ + if ( m_locked ) + return; + + m_settings.user = user; + changed(); +} + +void MainPage::slotPassChanged( const QString& pass ) +{ + if ( m_locked ) + return; + + m_settings.pass = pass; + changed(); +} + +void MainPage::slotPortChanged( int port ) +{ + if ( m_locked ) + return; + + m_settings.configuredPort = (unsigned short int) port; + changed(); +} + +void MainPage::slotAutoPortChanged( bool on ) +{ + if ( m_locked ) + return; + + m_settings.autoPort = on; + m_serverWidget->m_portInput->setEnabled( !on ); + changed(); +} + +void MainPage::slotRequesterClicked( KURLRequester *requester ) +{ + static bool init = true; + if ( !init ) + return; + + init = false; + + requester->setCaption(i18n("Select Folder You Want to Index")); +} + +void MainPage::slotAddClicked() +{ + QString host = m_serverWidget->m_hostCombo->currentText(); + m_settings.host = host; + + m_config->addSettings( m_settings ); + m_serverWidget->m_hostCombo->insertItem( host ); + m_serverWidget->m_hostCombo->setCurrentItem( host ); + + enableWidgetsFor( m_settings ); +} + +void MainPage::slotRemoveClicked() +{ + QString host = m_serverWidget->m_hostCombo->currentText(); + if ( host.isEmpty() ) // should never happen + return; + + m_config->removeSettings( host ); + m_serverWidget->m_hostCombo->removeItem( m_serverWidget->m_hostCombo->currentItem() ); + m_serverWidget->m_hostCombo->setCurrentItem( 0 ); + + host = m_serverWidget->m_hostCombo->currentText(); + initFromSettings( m_config->settingsForHost( host ) ); +} + +void MainPage::enableWidgetsFor( const KMrml::ServerSettings& settings ) +{ + QString host = settings.host; + bool enableWidgets = (m_config->hosts().findIndex( host ) > -1); + m_serverWidget->m_addButton->setEnabled(!enableWidgets && !host.isEmpty()); + m_serverWidget->m_removeButton->setEnabled( enableWidgets && + !host.isEmpty() && + host != "localhost" ); + + m_serverWidget->m_autoPort->setEnabled( host == "localhost" ); + bool portEnable = enableWidgets && (settings.autoPort || + !m_serverWidget->m_autoPort->isEnabled()); + m_serverWidget->m_portLabel->setEnabled( portEnable && !m_serverWidget->m_autoPort->isChecked()); + m_serverWidget->m_portInput->setEnabled( portEnable && !m_serverWidget->m_autoPort->isChecked()); + + m_serverWidget->m_useAuth->setEnabled( enableWidgets ); + m_serverWidget->m_userLabel->setEnabled( enableWidgets ); + m_serverWidget->m_passLabel->setEnabled( enableWidgets ); + m_serverWidget->m_userEdit->setEnabled( enableWidgets ); + m_serverWidget->m_passEdit->setEnabled( enableWidgets ); + + bool useAuth = m_serverWidget->m_useAuth->isChecked(); + m_serverWidget->m_userEdit->setEnabled( useAuth ); + m_serverWidget->m_passEdit->setEnabled( useAuth ); +} + +void MainPage::slotDirectoriesChanged() +{ + m_performIndexing = true; + changed(); +} + +void MainPage::processIndexDirs( const QStringList& removeDirs ) +{ + // ### how to remove indexed directories? + if ( !m_performIndexing || + (removeDirs.isEmpty() && m_config->indexableDirectories().isEmpty()) ) + return; + + delete m_progressDialog; + delete m_indexCleaner; + m_indexCleaner = 0L; + delete m_indexer; + m_indexer = 0L; + + m_progressDialog = new KProgressDialog( this, "indexing dialog", + i18n("Removing old Index Files"), + i18n("Processing..."), + true ); + m_progressDialog->setAutoClose( false ); + m_progressDialog->setMinimumWidth( 300 ); + connect( m_progressDialog, SIGNAL( cancelClicked() ), + SLOT( slotCancelIndexing() )); + + // argh -- don't automatically show the dialog + m_progressDialog->setMinimumDuration( INT_MAX ); + + if ( !removeDirs.isEmpty() ) + { + m_indexCleaner = new IndexCleaner( removeDirs, m_config, this ); + connect( m_indexCleaner, SIGNAL( advance( int ) ), + m_progressDialog->progressBar(), SLOT( advance( int ) )); + connect( m_indexCleaner, SIGNAL( finished() ), + SLOT( slotMaybeIndex() ) ); + m_indexCleaner->start(); + } + else + { + slotMaybeIndex(); + } + if ( m_progressDialog ) + m_progressDialog->exec(); +} + +void MainPage::slotMaybeIndex() +{ + delete m_indexCleaner; // Stop in the name of the law! + m_indexCleaner = 0L; + + m_progressDialog->setLabel( i18n("Finished.") ); + + if ( m_config->indexableDirectories().isEmpty() ) + return; + + if ( KMessageBox::questionYesNo( this, + i18n("The settings have been saved. Now, " + "the configured directories need to " + "be indexed. This may take a while. " + "Do you want to do this now?"), + i18n("Start Indexing Now?"), + i18n("Index"), i18n("Do Not Index"), + "ask_startIndexing" + ) != KMessageBox::Yes ) + return; + m_progressDialog->setCaption( i18n("Indexing Folders") ); + m_progressDialog->setLabel( i18n("Processing...") ); + m_progressDialog->progressBar()->setProgress( 0 ); + + // do the indexing + m_indexer = new Indexer( m_config, this, "Indexer" ); + connect( m_indexer, SIGNAL( progress( int, const QString& )), + SLOT( slotIndexingProgress( int, const QString& ) )); + connect( m_indexer, SIGNAL( finished( int )), + SLOT( slotIndexingFinished( int ) )); + m_indexer->startIndexing( m_config->indexableDirectories() ); +} + + +void MainPage::slotIndexingProgress( int percent, const QString& message ) +{ + m_progressDialog->progressBar()->setValue( percent ); + m_progressDialog->setLabel( message ); +} + +void MainPage::slotIndexingFinished( int returnCode ) +{ + if ( returnCode != 0 ) + { + QString syserr; + if ( returnCode == 127 ) + syserr = i18n("Is the \"GNU Image Finding Tool\" properly installed?"); + else + { + char *err = strerror( returnCode ); + if ( err ) + syserr = QString::fromLocal8Bit( err ); + else + syserr = i18n("Unknown error: %1").arg( returnCode ); + } + + KMessageBox::detailedError( this, i18n("An error occurred during indexing. The index might be invalid."), + syserr, i18n("Indexing Aborted") ); + } + else + m_performIndexing = false; + + delete m_indexer; + m_indexer = 0L; + if ( m_progressDialog ) + { + m_progressDialog->deleteLater(); + m_progressDialog = 0L; + } +} + +void MainPage::slotCancelIndexing() +{ + delete m_indexCleaner; + m_indexCleaner = 0L; + + delete m_indexer; + m_indexer = 0L; + if ( m_progressDialog ) + { + m_progressDialog->deleteLater(); + m_progressDialog = 0L; + } +} + + +#include "mainpage.moc" diff --git a/kmrml/kmrml/kcontrol/mainpage.h b/kmrml/kmrml/kcontrol/mainpage.h new file mode 100644 index 00000000..e91b4168 --- /dev/null +++ b/kmrml/kmrml/kcontrol/mainpage.h @@ -0,0 +1,109 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Carsten Pfeiffer + + 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, version 2. + + 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef MAINPAGE_H +#define MAINPAGE_H + +#include + +#include + +class QCheckBox; +class KComboBox; +class KEditListBox; +class KIntNumInput; +class KLineEdit; +class KProgressDialog; +class KURLRequester; + +namespace KMrml +{ + class Config; +} + +class ServerConfigWidget; + +namespace KMrmlConfig +{ + class Indexer; + class IndexCleaner; + + class MainPage : public QVBox + { + Q_OBJECT + + public: + MainPage( QWidget *parent, const char *name ); + ~MainPage(); + + void resetDefaults(); + void load(); + void save(); + + signals: + void changed( bool ); + + private slots: + void changed() { emit changed( true ); } + void slotRequesterClicked( KURLRequester * ); + void slotHostChanged(); + void slotUseAuthChanged( bool ); + void slotUserChanged( const QString& ); + void slotPassChanged( const QString& ); + void slotPortChanged( int ); + void slotAutoPortChanged( bool ); + + void slotAddClicked(); + void slotRemoveClicked(); + + void slotHostActivated( const QString& ); + + void slotDirectoriesChanged(); + + void slotMaybeIndex(); + void slotIndexingProgress( int percent, const QString& message ); + void slotIndexingFinished( int returnCode ); + void slotCancelIndexing(); + + + private: + void enableWidgetsFor( const KMrml::ServerSettings& settings ); + void initFromSettings( const KMrml::ServerSettings& settings ); + + void processIndexDirs( const QStringList& removedDirs ); + + QStringList difference( const QStringList& oldIndexDirs, + const QStringList& newIndexDirs ) const; + + ServerConfigWidget *m_serverWidget; + KEditListBox *m_listBox; + KMrml::Config *m_config; + KMrmlConfig::Indexer *m_indexer; + KMrmlConfig::IndexCleaner *m_indexCleaner; + KProgressDialog *m_progressDialog; + + KMrml::ServerSettings m_settings; + bool m_performIndexing; + bool m_locked; + }; + +} + + + +#endif // MAINPAGE_H diff --git a/kmrml/kmrml/kcontrol/serverconfigwidget.ui b/kmrml/kmrml/kcontrol/serverconfigwidget.ui new file mode 100644 index 00000000..e0a08007 --- /dev/null +++ b/kmrml/kmrml/kcontrol/serverconfigwidget.ui @@ -0,0 +1,272 @@ + +ServerConfigWidget + + + ServerConfigWidget + + + + 0 + 0 + 455 + 321 + + + + + unnamed + + + 11 + + + 6 + + + + Layout7 + + + + unnamed + + + 0 + + + 6 + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + m_hostCombo + + + + 3 + 0 + 0 + 0 + + + + true + + + + + m_addButton + + + &Add + + + + + m_removeButton + + + &Remove + + + + + + + Layout6 + + + + unnamed + + + 0 + + + 6 + + + + m_portInput + + + + 7 + 0 + 0 + 0 + + + + TCP/IP Port Number of the Indexing Server + + + + + m_autoPort + + + Au&to + + + Tries to automatically determine the port. This works only for local servers. + + + + + Spacer3 + + + Horizontal + + + Expanding + + + + 200 + 0 + + + + + + + + m_hostLabel + + + Ho&stname: + + + m_hostCombo + + + + + m_portLabel + + + P&ort: + + + m_portInput + + + + + + + m_useAuth + + + Per&form authentication + + + + + Layout12 + + + + unnamed + + + 0 + + + 6 + + + + Spacer1 + + + Horizontal + + + Fixed + + + + 16 + 16 + + + + + + Layout6 + + + + unnamed + + + 0 + + + 6 + + + + m_userLabel + + + &Username: + + + m_userEdit + + + + + m_passEdit + + + + + m_passLabel + + + &Password: + + + m_passEdit + + + + + m_userEdit + + + + + + + + + + m_hostCombo + m_addButton + m_removeButton + m_portInput + m_useAuth + m_userEdit + m_passEdit + + + -- cgit v1.2.3