diff options
Diffstat (limited to 'kutils')
54 files changed, 0 insertions, 13234 deletions
diff --git a/kutils/CMakeLists.txt b/kutils/CMakeLists.txt deleted file mode 100644 index 073ffe3a0..000000000 --- a/kutils/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_subdirectory( ksettings ) - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio/kio - ${CMAKE_SOURCE_DIR}/kutils - ${CMAKE_SOURCE_DIR}/interfaces/kregexpeditor -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### headers ################################### - -install( FILES - kfind.h kfinddialog.h kreplace.h kreplacedialog.h - tdecmoduleinfo.h tdecmoduleloader.h kcmultidialog.h - kmultitabbar.h kplugininfo.h tdecmoduleproxy.h - kpluginselector.h tdecmodulecontainer.h - DESTINATION ${INCLUDE_INSTALL_DIR} ) - - -##### other data ################################ - -install( FILES kplugininfo.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} ) - - -#### kutils ##################################### - -set( target kutils ) - -set( ${target}_SRCS - kfind.cpp kfinddialog.cpp kreplace.cpp - kreplacedialog.cpp tdecmoduleinfo.cpp tdecmoduleloader.cpp - kcmultidialog.cpp kmultitabbar.cpp kplugininfo.cpp - tdecmoduleproxy.cpp kpluginselector.cpp tdecmodulecontainer.cpp - tdecmoduleproxyIface.skel tdecmoduleproxyIfaceImpl.cpp -) - -tde_add_library( ${target} SHARED AUTOMOC - SOURCES ${${target}_SRCS} - VERSION 1.2.0 - EMBED ksettings-static - LINK kparts-shared - DESTINATION ${LIB_INSTALL_DIR} - DEPENDENCIES dcopidl -) diff --git a/kutils/Mainpage.dox b/kutils/Mainpage.dox deleted file mode 100644 index 77abe5777..000000000 --- a/kutils/Mainpage.dox +++ /dev/null @@ -1,24 +0,0 @@ -/** @mainpage Some random bits and pieces - -Some utility classes for KSettings, TDECModule and KPlugin. - -@authors -Matthias Kretz \<kretz@kde.org\><br> -Rafael Fernández López \<ereslibre@kde.org\><br> -Matthias Elter \<elter@kde.org\><br> -Daniel Molkentin \<molkentin@kde.org\><br> -Frans Englich \<frans.englich@telia.com\><br> -Tobias Koenig \<tokoe@kde.org\><br> -Matthias Hoelzer-Kluepfel \<hoelzer@kde.org\> - -@maintainers -[Unknown/None] - -@licenses -@lgpl - -*/ - -// DOXYGEN_REFERENCES = tdecore tdeui kio -// DOXYGEN_SET_PROJECT_NAME = KUtils -// vim:ts=4:sw=4:expandtab:filetype=doxygen diff --git a/kutils/Makefile.am b/kutils/Makefile.am deleted file mode 100644 index 5ff9bd041..000000000 --- a/kutils/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -SUBDIRS = ksettings . -INCLUDES = -I$(top_srcdir)/interfaces/kregexpeditor $(all_includes) - -lib_LTLIBRARIES = libkutils.la -libkutils_la_LDFLAGS = $(all_libraries) -no-undefined -version-info 3:0:2 -# Needs KTrader -libkutils_la_LIBADD = ../kio/libkio.la ksettings/libksettings.la $(LIB_QT) $(top_builddir)/dcop/libDCOP.la $(LIB_TDEUI) $(LIB_TDECORE) $(LIB_X11) - -libkutils_la_SOURCES = kfind.cpp kfinddialog.cpp kreplace.cpp \ - kreplacedialog.cpp tdecmoduleinfo.cpp tdecmoduleloader.cpp \ - kcmultidialog.cpp kmultitabbar.cpp kplugininfo.cpp \ - tdecmoduleproxy.cpp kpluginselector.cpp \ - tdecmodulecontainer.cpp tdecmoduleproxyIface.skel \ - tdecmoduleproxyIfaceImpl.cpp - -include_HEADERS = kfind.h kfinddialog.h kreplace.h kreplacedialog.h \ - tdecmoduleinfo.h tdecmoduleloader.h kcmultidialog.h \ - kmultitabbar.h kplugininfo.h tdecmoduleproxy.h \ - kpluginselector.h tdecmodulecontainer.h - -noinst_HEADERS = kmultitabbar_p.h kpluginselector_p.h \ - tdecmoduleproxyIface.h tdecmoduleproxyIfaceImpl.h - -kde_servicetypes_DATA = kplugininfo.desktop - -METASOURCES = AUTO - -DOXYGEN_REFERENCES = tdecore tdeui kio -include ../admin/Doxyfile.am - -# vim: et diff --git a/kutils/TODO b/kutils/TODO deleted file mode 100644 index 7d9f473ab..000000000 --- a/kutils/TODO +++ /dev/null @@ -1,25 +0,0 @@ - -This is a list of random changes to do in KDE 4 with the various KCM* classes. - -* TDECModuleinfo; - - Make it inherit KService; saves a lot of code, simplifies ctors/overloads in surrounding classes - - Implement docPath in KService - - Get rid of loadAll() and do lazy loading in each getter - -* Merge TDECModuleProxy and its DCOP Object class(MI) - -* Get rid of `QStringlist arguments` in TDECModule and all the helper classes(simplify API) - -* Move stuff to d pointers.. Too much hackish solutions otherwise - -* Get rid of bool fallback argument in helper classes(never fails, simplify API) - -* Re-implement the QScrollView(d->view) in TDECModuleProxy; the protection against violation of HIG-clause. It needs kde-core-devel approval. - -* The API in TDECModule, TDECModuleProxy, and the various desktop entries, concerning root loading are butt ugly. It needs cleaning and simplification. - -* There's big confusion regarding /when/ the changed(bool) signal should be emitted, abd by /whom/. This can't be fixed properly in 3.x since it means breaking behavior. In KDE 4 it must be made clear if TDECModuleProxy should take care of emitting appropriate signals for load()/save()/defaults, or if modules manually should handle it(is there a reason?). - -* Root modules in TDECModuleProxy doesn't support D&D, or it is perhaps implemented in QXEmbed? Anyway, this is what the XEmbed Protocol Specification says: - -Solving the drag-and-drop problem, however, is quite easy, since the XDND protocol was carefully designed in a way that makes it possible to support embedded windows. Basically, the embedder has to operate as drag-and-drop proxy for the client. Any XDND messages like XdndEnter, Xdnd,Leave, etc. simply have to be passed through. A toolkit's XDND implementation has to take this situation in consideration. diff --git a/kutils/groups.dox b/kutils/groups.dox deleted file mode 100644 index a4e0a633f..000000000 --- a/kutils/groups.dox +++ /dev/null @@ -1,41 +0,0 @@ -/** -@defgroup main Main classes -*/ - -/** -@defgroup internal Internal classes -*/ - -/** -@defgroup findreplace Find and Replace classes - -These classes implement a generic find/replace function, along with -extensible dialogs. -*/ - -/** -@defgroup plugin Plugin handling classes - -These classes provide an easy and generic way for handling plugins. -*/ - -/** -@defgroup settings Settings UI classes - -These classes provide widgets to build settings dialogs. See KSettings -namespace description for an overview. -*/ - -/** -@defgroup tdecmodule KControl module classes - -Thwse classes provide the KControl module API. -*/ - -/** -@defgroup multitabbar KMultiTabBar related classes - -These classes implement the tab bar often found on the border of KDE -applications' main windows (such as Kate or KDevelop). -*/ - diff --git a/kutils/kcmultidialog.cpp b/kutils/kcmultidialog.cpp deleted file mode 100644 index b09f25e88..000000000 --- a/kutils/kcmultidialog.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/* - Copyright (c) 2000 Matthias Elter <elter@kde.org> - Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> - Copyright (c) 2003 Matthias Kretz <kretz@kde.org> - Copyright (c) 2004 Frans Englich <frans.erglich.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include <tqcursor.h> -#include <tqhbox.h> -#include <tqlayout.h> -#include <tqpushbutton.h> - -#include <kaboutdata.h> -#include <kapplication.h> -#include <kdebug.h> -#include <kiconloader.h> -#include <klibloader.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <kprocess.h> -#include <krun.h> -#include <kstdguiitem.h> -#include <kuser.h> - -#include "tdecmoduleloader.h" -#include "tdecmoduleproxy.h" -#include "kcmultidialog.h" -#include "kcmultidialog.moc" - -class KCMultiDialog::KCMultiDialogPrivate -{ - public: - KCMultiDialogPrivate() - : hasRootKCM( false ), currentModule( 0 ) - {} - - bool hasRootKCM; - TDECModuleProxy* currentModule; -}; - - -KCMultiDialog::KCMultiDialog(TQWidget *parent, const char *name, bool modal) - : KDialogBase(IconList, i18n("Configure"), Help | Default |Cancel | Apply | - Ok | User1 | User2, Ok, parent, name, modal, true, - KStdGuiItem::reset(), KStdGuiItem::adminMode()) - , dialogface( IconList ), d( new KCMultiDialogPrivate ) -{ - init(); -} - -KCMultiDialog::KCMultiDialog( int dialogFace, const TQString & caption, TQWidget * parent, const char * name, bool modal ) - : KDialogBase( dialogFace, caption, Help | Default | Cancel | Apply | Ok | - User1 | User2, Ok, parent, name, modal, true, - KStdGuiItem::reset(), KStdGuiItem::adminMode()) - , dialogface( dialogFace ), d( new KCMultiDialogPrivate ) -{ - init(); -} - -KCMultiDialog::KCMultiDialog( int dialogFace, const KGuiItem &user2, - const KGuiItem &user3, int buttonMask, const TQString &caption, - TQWidget *parent, const char *name, bool modal ) - : KDialogBase( dialogFace, caption, buttonMask | Help | Default | Cancel | - Apply | Ok | User1, Ok, parent, name, modal, true, - KStdGuiItem::reset(), user2, user3 ) - , dialogface( dialogFace ), d( new KCMultiDialogPrivate ) -{ - kdDebug( 710 ) << "Root modules will not work with this constructor. See the API documentation." << endl; - init(); - if ( buttonMask & User2 ) - showButton( User2, true ); -} - -inline void KCMultiDialog::init() -{ - connect( this, TQT_SIGNAL( finished()), TQT_SLOT( dialogClosed())); - showButton( User1, false ); - showButton( User2, false ); - enableButton(Apply, false); - connect(this, TQT_SIGNAL(aboutToShowPage(TQWidget *)), this, TQT_SLOT(slotAboutToShow(TQWidget *))); - setInitialSize(TQSize(640,480)); - moduleParentComponents.setAutoDelete( true ); - -} - -KCMultiDialog::~KCMultiDialog() -{ - OrphanMap::Iterator end2 = m_orphanModules.end(); - for( OrphanMap::Iterator it = m_orphanModules.begin(); it != end2; ++it ) - delete ( *it ); - delete d; -} - -void KCMultiDialog::slotDefault() -{ - int curPageIndex = activePageIndex(); - - ModuleList::Iterator end = m_modules.end(); - for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it ) - if( pageIndex( ( TQWidget * )( *it ).kcm->parent() ) == curPageIndex ) - { - ( *it ).kcm->defaults(); - clientChanged( true ); - return; - } -} - -void KCMultiDialog::slotUser1() -{ - int curPageIndex = activePageIndex(); - - ModuleList::Iterator end = m_modules.end(); - for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it ) - if( pageIndex( ( TQWidget * )( *it ).kcm->parent() ) == curPageIndex ) - { - ( *it ).kcm->load(); - clientChanged( false ); - return; - } -} - -void KCMultiDialog::apply() -{ - TQStringList updatedModules; - ModuleList::Iterator end = m_modules.end(); - for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it ) - { - TDECModuleProxy * m = ( *it ).kcm; - if( m->changed() ) - { - m->save(); - TQStringList * names = moduleParentComponents[ m ]; - kdDebug(710) << k_funcinfo << *names << " saved and added to the list" << endl; - for( TQStringList::ConstIterator it = names->begin(); it != names->end(); ++it ) - if( updatedModules.find( *it ) == updatedModules.end() ) - updatedModules.append( *it ); - } - } - for( TQStringList::const_iterator it = updatedModules.begin(); it != updatedModules.end(); ++it ) - { - kdDebug(710) << k_funcinfo << *it << " " << ( *it ).latin1() << endl; - emit configCommitted( ( *it ).latin1() ); - } - emit configCommitted(); -} - -void KCMultiDialog::slotApply() -{ - TQPushButton *button = actionButton(Apply); - if (button) - button->setFocus(); - emit applyClicked(); - apply(); -} - - -void KCMultiDialog::slotOk() -{ - TQPushButton *button = actionButton(Ok); - if (button) - button->setFocus(); - emit okClicked(); - apply(); - accept(); -} - -void KCMultiDialog::slotHelp() -{ - TQString docPath; - - int curPageIndex = activePageIndex(); - ModuleList::Iterator end = m_modules.end(); - for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it ) - if( pageIndex( ( TQWidget * )( *it ).kcm->parent() ) == curPageIndex ) - { - docPath = ( *it ).kcm->moduleInfo().docPath(); - break; - } - - KURL url( KURL("help:/"), docPath ); - - if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") { - TDEProcess process; - process << "khelpcenter" - << url.url(); - process.start(TDEProcess::DontCare); - process.detach(); - } else { - new KRun(url); - } -} - -void KCMultiDialog::clientChanged(bool state) -{ - kdDebug( 710 ) << k_funcinfo << state << endl; - ModuleList::Iterator end = m_modules.end(); - for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it ) - if( ( *it ).kcm->changed() ) - { - enableButton( Apply, true ); - return; - } - enableButton( Apply, false ); -} - -void KCMultiDialog::addModule(const TQString& path, bool withfallback, TQStringList args) -{ - TQString complete = path; - - if( !path.endsWith( ".desktop" )) - complete += ".desktop"; - - KService::Ptr service = KService::serviceByStorageId( complete ); - - addModule( TDECModuleInfo( service ), TQStringList(), withfallback, args ); -} - -void KCMultiDialog::addModule(const TDECModuleInfo& moduleinfo, - TQStringList parentmodulenames, bool withfallback, TQStringList args) -{ - kdDebug(710) << "KCMultiDialog::addModule " - << moduleinfo.moduleName() << endl; - - if( !moduleinfo.service() ) - return; - - if ( !kapp->authorizeControlModule( moduleinfo.service()->menuId() )) - return; - - if( !TDECModuleLoader::testModule( moduleinfo )) - return; - - TQFrame* page = 0; - if (!moduleinfo.service()->noDisplay()) - switch( dialogface ) - { - case TreeList: - parentmodulenames += moduleinfo.moduleName(); - page = addHBoxPage( parentmodulenames, moduleinfo.comment(), - SmallIcon( moduleinfo.icon(), - IconSize( KIcon::Small ) ) ); - break; - case IconList: - page = addHBoxPage( moduleinfo.moduleName(), - moduleinfo.comment(), DesktopIcon( moduleinfo.icon(), - KIcon::SizeMedium ) ); - break; - case Plain: - page = plainPage(); - ( new TQHBoxLayout( page ) )->setAutoAdd( true ); - break; - default: - kdError( 710 ) << "unsupported dialog face for KCMultiDialog" - << endl; - break; - } - if(!page) { - TDECModuleLoader::unloadModule(moduleinfo); - return; - } - TDECModuleProxy * module; - if( m_orphanModules.contains( moduleinfo.service() ) ) - { - // the TDECModule already exists - it was removed from the dialog in - // removeAllModules - module = m_orphanModules[ moduleinfo.service() ]; - m_orphanModules.remove( moduleinfo.service() ); - kdDebug( 710 ) << "Use TDECModule from the list of orphans for " << - moduleinfo.moduleName() << ": " << module << endl; - - module->reparent( page, 0, TQPoint( 0, 0 ), true ); - - if( module->changed() ) - clientChanged( true ); - - if( activePageIndex() == -1 ) - showPage( pageIndex( page ) ); - } - else - { - module = new TDECModuleProxy( moduleinfo, withfallback, page, 0, args ); - TQStringList parentComponents = moduleinfo.service()->property( - "X-TDE-ParentComponents" ).toStringList(); - moduleParentComponents.insert( module, - new TQStringList( parentComponents ) ); - - connect(module, TQT_SIGNAL(changed(bool)), this, TQT_SLOT(clientChanged(bool))); - - if( m_modules.count() == 0 ) - aboutToShowPage( page ); - } - CreatedModule cm; - cm.kcm = module; - cm.service = moduleinfo.service(); - m_modules.append( cm ); - if ( moduleinfo.needsRootPrivileges() && - !d->hasRootKCM && - !KUser().isSuperUser() ) /* If we're embedded, it's true */ - { - d->hasRootKCM = true; - showButton( User2, true ); - if( plainPage() ) // returns 0 if we're not a Plain dialog - slotAboutToShow( page ); // Won't be called otherwise, necessary for adminMode button - } -} - -void KCMultiDialog::removeAllModules() -{ - kdDebug( 710 ) << k_funcinfo << endl; - ModuleList::Iterator end = m_modules.end(); - for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it ) - { - kdDebug( 710 ) << "remove 2" << endl; - TDECModuleProxy * kcm = ( *it ).kcm; - TQObject * page = TQT_TQOBJECT(kcm->parent()); - kcm->hide(); - if( page ) - { - // I hate this - kcm->reparent( 0, TQPoint( 0, 0 ), false ); - delete page; - } - m_orphanModules[ ( *it ).service ] = kcm; - kdDebug( 710 ) << "added TDECModule to the list of orphans: " << - kcm << endl; - } - m_modules.clear(); - // all modules are gone, none can be changed - clientChanged( false ); -} - -void KCMultiDialog::show() -{ /* KDE 4 Remove..? */ - KDialogBase::show(); -} - -void KCMultiDialog::slotAboutToShow(TQWidget *page) -{ - kdDebug(710) << k_funcinfo << endl; - - TQObject * obj = page->child( 0, "TDECModuleProxy" ); - if( ! obj ) - return; - - TDECModuleProxy * module = ::tqqt_cast<TDECModuleProxy*>(obj); - if( ! module ) - return; - d->currentModule = module; - - enableButton( KDialogBase::Help, - d->currentModule->buttons() & TDECModule::Help ); - enableButton( KDialogBase::Default, - d->currentModule->buttons() & TDECModule::Default ); - - disconnect( this, TQT_SIGNAL(user2Clicked()), 0, 0 ); - - if (d->currentModule->moduleInfo().needsRootPrivileges()) - { - if ( !d->currentModule->rootMode() ) - { /* Enable the Admin Mode button */ - enableButton( User2, true ); - connect( this, TQT_SIGNAL(user2Clicked()), d->currentModule, TQT_SLOT( runAsRoot() )); - connect( this, TQT_SIGNAL(user2Clicked()), TQT_SLOT( disableRModeButton() )); - } - else - enableButton( User2, false); - } -} - -void KCMultiDialog::rootExit() -{ - enableButton( User2, true); -} - -void KCMultiDialog::disableRModeButton() -{ - enableButton( User2, false ); - connect ( d->currentModule, TQT_SIGNAL( childClosed() ), TQT_SLOT( rootExit() )); -} - -void KCMultiDialog::dialogClosed() -{ - kdDebug(710) << k_funcinfo << endl; - - /* If we don't delete them, the DCOP registration stays, and trying to load the KCMs - * in other situations will lead to "module already loaded in Foo," while to the user - * doesn't appear so(the dialog is hidden) */ - ModuleList::Iterator end = m_modules.end(); - for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it ) - ( *it ).kcm->deleteClient(); -} - - -// vim: sw=4 et sts=4 diff --git a/kutils/kcmultidialog.h b/kutils/kcmultidialog.h deleted file mode 100644 index 46dde98fb..000000000 --- a/kutils/kcmultidialog.h +++ /dev/null @@ -1,288 +0,0 @@ -/* - Copyright (c) 2000 Matthias Elter <elter@kde.org> - Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> - Copyright (c) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KCMULTIDIALOG_H -#define KCMULTIDIALOG_H - -#include <tqptrdict.h> - -#include <kdialogbase.h> -#include <klocale.h> -#include <kservice.h> - -class TDECModuleProxy; -class TDECModuleInfo; - -/** - * @ingroup tdecmodule - * @short A method that offers a KDialogBase containing arbitrary - * KControl Modules. - * - * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org> - * @since 3.2 - */ -class KUTILS_EXPORT KCMultiDialog : public KDialogBase -{ - Q_OBJECT - -public: - /** - * Constructs a new KCMultiDialog - * - * @param parent The parent widget - * @param name The widget name - * @param modal If you pass true here, the dialog will be modal - **/ - KCMultiDialog( TQWidget *parent=0, const char *name=0, bool modal=false ); - - /** - * Construct a personalized KCMultiDialog. - * - * @param dialogFace You can use TreeList, Tabbed, Plain, Swallow or - * IconList. - * @param caption The dialog caption. Do not specify the application name - * here. The class will take care of that. - * @param parent Parent of the dialog. - * @param name Dialog name (for internal use only). - * @param modal Controls dialog modality. If @p false, the rest of the - * program interface (example: other dialogs) is accessible while - * the dialog is open. - */ - KCMultiDialog( int dialogFace, const TQString & caption, TQWidget * parent = 0, - const char * name = 0, bool modal = false ); - - - /** - * Constructor for the predefined layout mode where you specify the - * kind of layout (face) and also add buttons. Note that the User1 button - * of KDialogBase is already used to provide a "Reset" button so only - * two more buttons are available to users of KCMultiDialog. When clicked - * they trigger slotUser2() and slotUser3(). - * - * @note If any root modules are added to the dialog when this constructor is - * used, it will not be able to run them with root privileges. Since that will - * render them useless, it is a good idea to use another constructor. In KDE 4 - * the argument @p user3 will be removed. - * - * @param dialogFace You can use TreeList, Tabbed, Plain, Swallow or - * IconList. - * @param user2 User button2 text item. - * @param user3 User button3 text item. - * @param buttonMask Specifies which buttons will be visible. If zero - * (0) no extra buttons will be added. You can only use the User2 and - * User3 buttons. The User1 button is already used internally. See - * KDialogBase for more information on this. - * @param caption The dialog caption. Do not specify the application name - * here. The class will take care of that. - * @param parent Parent of the dialog. - * @param name Dialog name (for internal use only). - * @param modal Controls dialog modality. If @p false, the rest of the - * program interface (example: other dialogs) is accessible while - * the dialog is open. - */ - KCMultiDialog( int dialogFace, const KGuiItem &user2, - const KGuiItem &user3=KGuiItem(), int buttonMask=User2, - const TQString &caption=i18n("Configure"), TQWidget *parent=0, - const char *name=0, bool modal=false ) KDE_DEPRECATED; - // KDE4 remove the user3 argument, and instead initialize it to KStdGuiItem::adminMode. - - /** - * Destructor - **/ - virtual ~KCMultiDialog(); - - /** - * Add a module. - * - * @param module Specify the name of the module that is to be added - * to the list of modules the dialog will show. - * - * @param withfallback Try harder to load the module. Might result - * in the module appearing outside the dialog. - * - * @param args List of arguments to pass to the module. - **/ - void addModule(const TQString& module, bool withfallback=true, TQStringList args = TQStringList()); - - /** - * Add a module. - * - * @param moduleinfo Pass a TDECModuleInfo object which will be - * used for creating the module. It will be added - * to the list of modules the dialog will show. - * - * @param parentmodulenames The names of the modules that should appear as - * parents in the TreeList. Look at the - * KDialogBase::addPage documentation for more info - * on this. - * - * @param withfallback Try harder to load the module. Might result - * in the module appearing outside the dialog. - * - * @param args List of arguments to pass to the module. - **/ - void addModule(const TDECModuleInfo& moduleinfo, TQStringList - parentmodulenames = TQStringList(), bool withfallback=false, TQStringList args = TQStringList()); - - /** - * Remove all modules from the dialog. - */ - void removeAllModules(); - - /** - * @internal - * Re-implemented for internal reasons. - */ - void show(); - -signals: - /** - * Emitted after all TDECModules have been told to save their configuration. - * - * The applyClicked and okClicked signals are emitted before the - * configuration is saved. - */ - void configCommitted(); - - /** - * Emitted after the TDECModules have been told to save their configuration. - * It is emitted once for every instance the KCMs that were changed belong - * to. - * - * You can make use of this if you have more than one component in your - * application. instanceName tells you the instance that has to reload its - * configuration. - * - * The applyClicked and okClicked signals are emitted before the - * configuration is saved. - * - * @param instanceName The name of the instance that needs to reload its - * configuration. - */ - void configCommitted( const TQCString & instanceName ); - -protected slots: - /** - * This slot is called when the user presses the "Default" Button. - * You can reimplement it if needed. - * - * @note Make sure you call the original implementation. - **/ - virtual void slotDefault(); - - /** - * This slot is called when the user presses the "Reset" Button. - * You can reimplement it if needed. - * - * @note Make sure you call the original implementation. - */ - virtual void slotUser1(); - - /** - * This slot is called when the user presses the "Apply" Button. - * You can reimplement it if needed. - * - * @note Make sure you call the original implementation. - **/ - virtual void slotApply(); - - /** - * This slot is called when the user presses the "OK" Button. - * You can reimplement it if needed. - * - * @note Make sure you call the original implementation. - **/ - virtual void slotOk(); - - /** - * This slot is called when the user presses the "Help" Button. - * It reads the DocPath field of the currently selected KControl - * module's .desktop file to find the path to the documentation, - * which it then attempts to load. - * - * You can reimplement this slot if needed. - * - * @note Make sure you call the original implementation. - **/ - virtual void slotHelp(); - -private slots: - - void slotAboutToShow(TQWidget *); - - void clientChanged(bool state); - - /** - * Called when entering root mode, and disables - * the Admin Mode button such that the user doesn't do it - * twice. - * - * @since 3.4 - */ - void disableRModeButton(); - - /** - * Called when the current module exits from root - * mode. Enables the Administrator Mode button, again. - * - * @since 3.4 - */ - void rootExit(); - - /** - * - * Called when the dialog is hidden. It unregisters the modules, - * such that they don't hinder the same modules to be opened in - * another application. - * - * @since 3.4 - */ - void dialogClosed(); - -private: - - void init(); - void apply(); - - struct CreatedModule - { - TDECModuleProxy * kcm; - KService::Ptr service; - /* KDE 4 Move to Private class */ - }; - typedef TQValueList<CreatedModule> ModuleList; - ModuleList m_modules; - - typedef TQMap<KService::Ptr, TDECModuleProxy*> OrphanMap; - OrphanMap m_orphanModules; - - TQPtrDict<TQStringList> moduleParentComponents; - TQString _docPath; - int dialogface; - - class KCMultiDialogPrivate; - KCMultiDialogPrivate *d; -}; - -#endif //KCMULTIDIALOG_H - -// vim: sw=4 sts=4 et diff --git a/kutils/kdeglobals.kcfg b/kutils/kdeglobals.kcfg deleted file mode 100644 index 02b25f909..000000000 --- a/kutils/kdeglobals.kcfg +++ /dev/null @@ -1,564 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <kcfgfile name="kdeglobals" /> - <group name="DesktopIcons" > - <entry key="GridXSpacing" type="Int" > - <label>Distance between desktop icons</label> - <whatsthis>The distance between icons specified in pixels.</whatsthis> - <default>50</default> - </entry> - </group> - <group name="General" > - <entry key="alternateBackground" type="String" /> - <entry key="background" type="String" /> - <entry key="buttonBackground" type="String" /> - <entry key="buttonForeground" type="String" /> - <entry key="foreground" type="String" /> - <entry key="selectBackground" type="String" /> - <entry key="selectForeground" type="String" /> - <entry key="widgetStyle" type="String" > - <label>Widget style to use</label> - <whatsthis>The name of the widget style, for example "keramik" or "plastik". Without quotes.</whatsthis> - <default>keramik</default> - </entry> - <entry key="windowBackground" type="String" /> - <entry key="windowForeground" type="String" /> - <entry key="UseSystemBell" type="Bool" > - <label>Use the PC speaker</label> - <whatsthis>If the ordinary PC speaker should be used instead of TDE's own notifications system.</whatsthis> - <default>false</default> - </entry> - <entry key="TerminalApplication" type="String" > - <label>What terminal application to use</label> - <whatsthis>Whenever a terminal application is launched this terminal emulator program will be used. -</whatsthis> - <default>konsole</default> - </entry> - <entry key="fixed" type="Font" > - <label>Fixed width font</label> - <whatsthis>This font is used when a fixed font is needed. A fixed font has a constant width. -</whatsthis> - </entry> - <entry key="font" type="Font" > - <label>System wide font</label> - </entry> - <entry key="menuFont" type="Font" > - <label>Font for menus</label> - <whatsthis>What font to use for menus in applications.</whatsthis> - </entry> - <entry key="linkColor" type="Color" > - <label>Color for links</label> - <whatsthis>What color links which are yet not clicked on should have.</whatsthis> - </entry> - <entry key="visitedLinkColor" type="Color" > - <label>Color for visited links</label> - </entry> - <entry key="taskbarFont" type="Font" > - <label>Font for the taskbar</label> - <whatsthis>What font to use for the panel at the bottom of the screen, where the currently running applications are.</whatsthis> - </entry> - <entry key="toolBarFont" type="Font" > - <label>Fonts for toolbars</label> - </entry> - </group> - <group name="Global Shortcuts" > - <entry key="Activate Window Demanding Attention" type="String" name="Activate Window Demanding Attention" > - <default>Alt+Ctrl+A</default> - </entry> - - <entry key="Desktop Screenshot" type="String" name="Desktop Screenshot" > - <label>Shortcut for taking screenshot</label> - <default>Ctrl+Print</default> - </entry> - - <entry key="Enable/Disable Clipboard Actions" type="String" name="Enable/Disable Clipboard Actions" > - <label>Shortcut for toggling Clipboard Actions on and off</label> - <default>Alt+Ctrl+X</default> - </entry> - - <entry key="Halt without Confirmation" type="String" name="Halt without Confirmation" > - <label>Shortcut for shutting down the computer without confirmation</label> - <default>Alt+Ctrl+Shift+PageDown</default> - </entry> - - <entry key="Kill Window" type="String" name="Kill Window" > - <default>Alt+Ctrl+Escape</default> - </entry> - - <entry key="Lock Screen" type="String" > - <default>Alt+Ctrl+L</default> - </entry> - <entry key="Logout" type="String" > - <default>Alt+Ctrl+Delete</default> - </entry> - <entry key="Logout without Confirmation" type="String" > - <default>Alt+Ctrl+Shift+Delete</default> - </entry> - <entry key="Manually Invoke Action on Current Clipboard" type="String" > - <default>Alt+Ctrl+R</default> - </entry> - <entry key="Mouse Emulation" type="String" > - <default>Alt+F12</default> - </entry> - <entry key="Popup Launch Menu" type="String" > - <default>Alt+F1</default> - </entry> - <entry key="Reboot without Confirmation" type="String" name="Reboot without Confirmation" > - <default>Alt+Ctrl+Shift+PageUp</default> - </entry> - <entry key="Run Command" type="String" name="Run Command"> - <default>Alt+F2</default> - </entry> - <entry key="Show Klipper Popup-Menu" type="String" > - <default>Alt+Ctrl+V</default> - </entry> - <entry key="Show Taskmanager" type="String" > - <default>Ctrl+Escape</default> - </entry> - <entry key="Show Window List" type="String" > - <default>Alt+F5</default> - </entry> - <entry key="Switch One Desktop Down" type="String" > - <default></default> - </entry> - <entry key="Switch One Desktop Up" type="String" > - <default></default> - </entry> - <entry key="Switch One Desktop to the Left" type="String" > - <default></default> - </entry> - <entry key="Switch One Desktop to the Right" type="String" > - <default></default> - </entry> - <entry key="Switch to Desktop 1" type="String" > - <default>Ctrl+F1</default> - </entry> - <entry key="Switch to Desktop 10" type="String" > - <default>Ctrl+F10</default> - </entry> - <entry key="Switch to Desktop 11" type="String" > - <default>Ctrl+F11</default> - </entry> - <entry key="Switch to Desktop 12" type="String" > - <default>Ctrl+F12</default> - </entry> - <entry key="Switch to Desktop 13" type="String" > - <default>Ctrl+Shift+F1</default> - </entry> - <entry key="Switch to Desktop 14" type="String" > - <default>Ctrl+Shift+F2</default> - </entry> - <entry key="Switch to Desktop 15" type="String" > - <default>Ctrl+Shift+F3</default> - </entry> - <entry key="Switch to Desktop 16" type="String" > - <default>Ctrl+Shift+F4</default> - </entry> - <entry key="Switch to Desktop 2" type="String" > - <default>Ctrl+F2</default> - </entry> - <entry key="Switch to Desktop 3" type="String" > - <default>Ctrl+F3</default> - </entry> - <entry key="Switch to Desktop 4" type="String" > - <default>Ctrl+F4</default> - </entry> - <entry key="Switch to Desktop 5" type="String" > - <default>Ctrl+F5</default> - </entry> - <entry key="Switch to Desktop 6" type="String" > - <default>Ctrl+F6</default> - </entry> - <entry key="Switch to Desktop 7" type="String" > - <default>Ctrl+F7</default> - </entry> - <entry key="Switch to Desktop 8" type="String" > - <default>Ctrl+F8</default> - </entry> - <entry key="Switch to Desktop 9" type="String" > - <default>Ctrl+F9</default> - </entry> - <entry key="Switch to Next Desktop" type="String" > - <default></default> - </entry> - <entry key="Switch to Next Keyboard Layout" type="String" > - <default>Ctrl+Alt+K</default> - </entry> - <entry key="Switch to Previous Desktop" type="String" > - <default></default> - </entry> - <entry key="Toggle Showing Desktop" type="String" > - <default>Alt+Ctrl+D</default> - </entry> - <entry key="Toggle Window Raise/Lower" type="String" > - <default></default> - </entry> - <entry key="Walk Through Desktop List" type="String" > - <default>Ctrl+Tab</default> - </entry> - <entry key="Walk Through Desktop List (Reverse)" type="String" > - <default>Ctrl+Shift+Tab</default> - </entry> - <entry key="Walk Through Desktops" type="String" > - <default></default> - </entry> - <entry key="Walk Through Desktops (Reverse)" type="String" > - <default></default> - </entry> - <entry key="Walk Through Windows" type="String" > - <default>Alt+Tab</default> - </entry> - <entry key="Walk Through Windows (Reverse)" type="String" > - <default>Alt+Shift+Tab</default> - </entry> - <entry key="Window Above Other Windows" type="String" > - <default></default> - </entry> - <entry key="Window Below Other Windows" type="String" > - <default></default> - </entry> - <entry key="Window Close" type="String" > - <default>Alt+F4</default> - </entry> - <entry key="Window Fullscreen" type="String" > - <default></default> - </entry> - <entry key="Window Grow Horizontal" type="String" > - <default></default> - </entry> - <entry key="Window Grow Vertical" type="String" > - <default></default> - </entry> - <entry key="Window Lower" type="String" > - <default></default> - </entry> - <entry key="Window Maximize" type="String" > - <default></default> - </entry> - <entry key="Window Maximize Horizontal" type="String" > - <default></default> - </entry> - <entry key="Window Maximize Vertical" type="String" > - <default></default> - </entry> - <entry key="Window Minimize" type="String" > - <default></default> - </entry> - <entry key="Window Move" type="String" > - <default></default> - </entry> - <entry key="Window No Border" type="String" > - <default></default> - </entry> - <entry key="Window On All Desktops" type="String" > - <default></default> - </entry> - <entry key="Window Operations Menu" type="String" > - <default>Alt+F3</default> - </entry> - <entry key="Window Pack Down" type="String" > - <default></default> - </entry> - <entry key="Window Pack Left" type="String" > - <default></default> - </entry> - <entry key="Window Pack Right" type="String" > - <default></default> - </entry> - <entry key="Window Pack Up" type="String" > - <default></default> - </entry> - <entry key="Window Raise" type="String" > - <default></default> - </entry> - <entry key="Window Resize" type="String" > - <default></default> - </entry> - <entry key="Window Screenshot" type="String" > - <default>Alt+Print</default> - </entry> - <entry key="Window Shade" type="String" > - <default></default> - </entry> - <entry key="Window Shrink Horizontal" type="String" > - <default></default> - </entry> - <entry key="Window Shrink Vertical" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 1" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 10" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 11" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 12" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 13" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 14" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 15" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 16" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 2" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 3" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 4" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 5" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 6" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 7" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 8" type="String" > - <default></default> - </entry> - <entry key="Window to Desktop 9" type="String" > - <default></default> - </entry> - <entry key="Window to Next Desktop" type="String" > - <default></default> - </entry> - - <entry key="Window to Previous Desktop" type="String" > - <default></default> - </entry> - - </group> - <group name="KDE" > - <entry key="AutoSelectDelay" type="String" /> - <entry key="DoubleClickInterval" type="String" /> - <entry key="EffectAnimateCombo" type="String" /> - <entry key="EffectAnimateMenu" type="String" /> - <entry key="EffectAnimateTooltip" type="String" /> - <entry key="EffectFadeMenu" type="String" /> - <entry key="EffectFadeTooltip" type="String" /> - <entry key="EffectNoTooltip" type="String" /> - <entry key="EffectsEnabled" type="String" /> - <entry key="InsertTearOffHandle" type="String" /> - <entry key="ShowIconsOnPushButtons" type="String" /> - <entry key="SingleClick" type="String" /> - <entry key="StartDragDist" type="String" /> - <entry key="StartDragTime" type="String" /> - <entry key="VisualActivate" type="String" /> - <entry key="WheelScrollLines" type="String" /> - <entry key="colorScheme" type="String" /> - <entry key="contrast" type="String" /> - </group> - <group name="KFileDialog Settings" > - <entry key="Automatically select filename extension" type="String" name="Automatically select filename extension"> - <default>true</default> - </entry> - <entry key="Height 768" type="String" name="Height 768" /> - <entry key="LocationCombo Completionmode" type="String" name="LocationCombo Completionmode" /> - <entry key="PathCombo Completionmode" type="String" name="PathCombo Completionmode" /> - - <entry key="Separate Directories" type="Bool" name="Separate Directories" > - <default>false</default> - </entry> - - <entry key="Sort by" type="String" name="Sort by" /> - - <entry key="Sort case insensitively" type="Bool" name="Sort case insensitively"> - <default>true</default> - </entry> - - <entry key="Sort directories first" type="Bool" name="Sort directories first" > - <label>Show directories first</label> - <whatsthis>If directories should be placed at the top when displaying files</whatsthis> - <default>true</default> - </entry> - - <entry key="View Style" type="String" name="View Style" /> - <entry key="Width 1024" type="String" name="Width 1024" /> - - <entry key="Recent URLs" type="Path" name="Recent URLs" > - <label>The recent URLs recently visited</label> - <whatsthis>Used for auto completion in file dialogs for example.</whatsthis> - </entry> - - <entry key="Show Preview" type="Bool" name="Show Preview" > - <label>Show file preview in file dialog</label> - <default>false</default> - </entry> - - <entry key="Show hidden files" type="Bool" name="Show hidden files" > - <label>Show hidden files</label> - <whatsthis>Determines if files starting with a dot(convention for hidden files) should be shown</whatsthis> - <default>false</default> - </entry> - - <entry key="Show Speedbar" type="Bool" name="Show Speedbar" > - <label>Show speedbar</label> - <whatsthis>Whether the shortcut icons to the left in the file dialog should be shown</whatsthis> - <default>true</default> - </entry> - - <entry key="Sort reversed" type="Bool" name="Sort reversed" > - <default>false</default> - </entry> - - </group> - <group name="KSpell" > - <entry key="KSpell_Client" type="String" /> - <entry key="KSpell_DictFromList" type="String" /> - <entry key="KSpell_Dictionary" type="String" /> - <entry key="KSpell_Encoding" type="String" /> - <entry key="KSpell_NoRootAffix" type="String" /> - <entry key="KSpell_RunTogether" type="String" /> - </group> - <group name="Locale" > - <entry key="Country" type="String" > - <label>What country</label> - <whatsthis>Used to determine how to display numbers, currency and time/date for example</whatsthis> - <default>C</default> - </entry> - <entry key="Language" type="String" > - <label>What language to display text in</label> - </entry> - <entry key="PositiveSign" type="String" > - <label>Character used for indicating positive numbers</label> - <whatsthis>Most countries have no character for this</whatsthis> - </entry> - </group> - <group name="Paths" > - <entry key="Trash" type="Path" > - <label>Path for the trash can</label> - <default>$HOME/Desktop/Trash</default> - </entry> - <entry key="Autostart" type="Path" > - <label>Path to the autostart directory</label> - <whatsthis>Path to the directory containing executables to be run on session login</whatsthis> - <default>$TDEHOME/Autostart</default> - </entry> - <entry key="Desktop" type="Path" > - <label>Path to the desktop directory</label> - <whatsthis>In this directory the files on the dekstop are stored</whatsthis> - <default>$HOME/Desktop</default> - </entry> - <entry key="Documents" type="Path" > - <label>Path to documents folder</label> - <whatsthis></whatsthis> - <default>$HOME</default> - </entry> - </group> - <group name="PreviewSettings" > - <entry key="BoostSize" type="Bool" /> - <entry key="MaximumSize" type="Bool" /> - <entry key="UseFileThumbnails" type="Bool" /> - <entry key="ar" type="Bool" /> - <entry key="audiocd" type="Bool" /> - <entry key="devices" type="Bool" /> - <entry key="file" type="Bool" /> - <entry key="fish" type="Bool" /> - <entry key="floppy" type="Bool" /> - <entry key="fonts" type="Bool" /> - <entry key="ftp" type="Bool" /> - <entry key="imap" type="Bool" /> - <entry key="imaps" type="Bool" /> - <entry key="kdeapi" type="Bool" /> - <entry key="lan" type="Bool" /> - <entry key="mac" type="Bool" /> - <entry key="man" type="Bool" /> - <entry key="nfs" type="Bool" /> - <entry key="nntp" type="Bool" /> - <entry key="perldoc" type="Bool" /> - <entry key="pop3" type="Bool" /> - <entry key="pop3s" type="Bool" /> - <entry key="print" type="Bool" /> - <entry key="printdb" type="Bool" /> - <entry key="programs" type="Bool" /> - <entry key="pydoc" type="Bool" /> - <entry key="rlan" type="Bool" /> - <entry key="settings" type="Bool" /> - <entry key="sftp" type="Bool" /> - <entry key="sieve" type="Bool" /> - <entry key="smb" type="Bool" /> - <entry key="smtp" type="Bool" /> - <entry key="smtps" type="Bool" /> - <entry key="system" type="Bool" /> - <entry key="tar" type="Bool" /> - <entry key="webdav" type="Bool" /> - <entry key="webdavs" type="Bool" /> - <entry key="zip" type="Bool" /> - </group> - <group name="Socks" > - <entry key="SOCKS_enable" type="Bool" > - <label>Enable SOCKS support</label> - <whatsthis>Whether SOCKS version 4 and 5 should be enabled in TDE's sub systems</whatsthis> - <default>false</default> - </entry> - <entry key="SOCKS_lib" type="Path" > - <label>Path to custom SOCKS library</label> - </entry> - <entry key="SOCKS_method" type="String" /> - </group> - <group name="Toolbar style" > - <entry key="Highlighting" type="Bool"> - <label>Highlight toolbar buttons on mouse over</label> - <default>true</default> - </entry> - <entry key="IconText" type="Bool"> - <label>Show text on toolbar icons </label> - <whatsthis>Whether text should be shown in addition to icons on toolbar icons</whatsthis> - <default>false</default> - </entry> - <entry key="TransparentMoving" type="Bool" > - <label>Transparent toolbars when moved</label> - <whatsthis>Whether toolbars should be visible when moved</whatsthis> - <default>false</default> - </entry> - </group> - <group name="WM" > - <entry key="activeBackground" type="String" /> - <entry key="activeBlend" type="String" /> - <entry key="activeFont" type="String" /> - <entry key="activeForeground" type="String" /> - <entry key="activeTitleBtnBg" type="String" /> - <entry key="frame" type="String" /> - <entry key="handle" type="String" /> - <entry key="inactiveBackground" type="String" /> - <entry key="inactiveBlend" type="String" /> - <entry key="inactiveForeground" type="String" /> - <entry key="inactiveFrame" type="String" /> - <entry key="inactiveHandle" type="String" /> - <entry key="inactiveTitleBtnBg" type="String" /> - </group> - <group name="Passwords"> - <entry name="EchoMode" type="Enum"> - <label>Password echo type</label> - <choices> - <choice name="OneStar"/> - <choice name="ThreeStars"/> - <choice name="NoEcho"/> - </choices> - <default>OneStar</default> - </entry> - </group> - <group name="KKeyDialog Settings"> - <entry name="Dialog Size" type="IntList"><!-- Should this be taken care of globally, for dialogs? --> - <label>The size of the dialog</label> - </entry> - </group> -</kcfg> diff --git a/kutils/kdeglobals.kcfgc b/kutils/kdeglobals.kcfgc deleted file mode 100644 index fee74fc45..000000000 --- a/kutils/kdeglobals.kcfgc +++ /dev/null @@ -1,5 +0,0 @@ -File=kdeglobals.kcfg -ClassName=KDEGlobals -Singleton=true -Mutators=true - diff --git a/kutils/kfind.cpp b/kutils/kfind.cpp deleted file mode 100644 index 7b2da6899..000000000 --- a/kutils/kfind.cpp +++ /dev/null @@ -1,710 +0,0 @@ -/* - Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. - Copyright (C) 2002, David Faure <david@mandrakesoft.com> - Copyright (C) 2004, Arend van Beelen jr. <arend@auton.nl> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kfind.h" -#include "kfinddialog.h" -#include <kapplication.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <tqlabel.h> -#include <tqregexp.h> -#include <tqstylesheet.h> -#include <tqguardedptr.h> -#include <tqptrvector.h> -#include <kdebug.h> - -//#define DEBUG_FIND - -#define INDEX_NOMATCH -1 - -class KFindNextDialog : public KDialogBase -{ -public: - KFindNextDialog(const TQString &pattern, TQWidget *parent); -}; - -// Create the dialog. -KFindNextDialog::KFindNextDialog(const TQString &pattern, TQWidget *parent) : - KDialogBase(parent, 0, false, // non-modal! - i18n("Find Next"), - User1 | Close, - User1, - false, - KStdGuiItem::find()) -{ - setMainWidget( new TQLabel( i18n("<qt>Find next occurrence of '<b>%1</b>'?</qt>").arg(pattern), this ) ); -} - -//// - -struct KFind::Private -{ - Private() : - findDialog(0), - patternChanged(false), - matchedPattern(""), - incrementalPath(29, true), - emptyMatch(0), - currentId(0), - customIds(false) - { - incrementalPath.setAutoDelete(true); - data.setAutoDelete(true); - } - - ~Private() - { - delete emptyMatch; - emptyMatch = 0; - } - - struct Match - { - Match(int dataId, int index, int matchedLength) : - dataId(dataId), - index(index), - matchedLength(matchedLength) - { } - - int dataId; - int index; - int matchedLength; - }; - - struct Data - { - Data() : id(-1), dirty(false) { } - Data(int id, const TQString &text, bool dirty = false) : - id(id), - text(text), - dirty(dirty) - { } - - int id; - TQString text; - bool dirty; - }; - - TQGuardedPtr<TQWidget> findDialog; - bool patternChanged; - TQString matchedPattern; - TQDict<Match> incrementalPath; - Match * emptyMatch; - TQPtrVector<Data> data; - int currentId; - bool customIds; -}; - -//// - -KFind::KFind( const TQString &pattern, long options, TQWidget *parent ) - : TQObject( parent ) -{ - d = new KFind::Private; - m_options = options; - init( pattern ); -} - -KFind::KFind( const TQString &pattern, long options, TQWidget *parent, TQWidget *findDialog ) - : TQObject( parent ) -{ - d = new KFind::Private; - d->findDialog = findDialog; - m_options = options; - init( pattern ); -} - -void KFind::init( const TQString& pattern ) -{ - m_matches = 0; - m_pattern = pattern; - m_dialog = 0; - m_dialogClosed = false; - m_index = INDEX_NOMATCH; - m_lastResult = NoMatch; - if (m_options & KFindDialog::RegularExpression) - m_regExp = new TQRegExp(pattern, m_options & KFindDialog::CaseSensitive); - else { - m_regExp = 0; - } -} - -KFind::~KFind() -{ - delete m_dialog; - delete d; -} - -bool KFind::needData() const -{ - // always true when m_text is empty. - if (m_options & KFindDialog::FindBackwards) - // m_index==-1 and m_lastResult==Match means we haven't answered nomatch yet - // This is important in the "replace with a prompt" case. - return ( m_index < 0 && m_lastResult != Match ); - else - // "index over length" test removed: we want to get a nomatch before we set data again - // This is important in the "replace with a prompt" case. - return m_index == INDEX_NOMATCH; -} - -void KFind::setData( const TQString& data, int startPos ) -{ - setData( -1, data, startPos ); -} - -void KFind::setData( int id, const TQString& data, int startPos ) -{ - // cache the data for incremental find - if ( m_options & KFindDialog::FindIncremental ) - { - if ( id != -1 ) - d->customIds = true; - else - id = d->currentId + 1; - - if ( id >= (int) d->data.size() ) - d->data.resize( id + 100 ); - - d->data.insert( id, new Private::Data(id, data, true) ); - } - - if ( !(m_options & KFindDialog::FindIncremental) || needData() ) - { - m_text = data; - - if ( startPos != -1 ) - m_index = startPos; - else if (m_options & KFindDialog::FindBackwards) - m_index = m_text.length(); - else - m_index = 0; -#ifdef DEBUG_FIND - kdDebug() << "setData: '" << m_text << "' m_index=" << m_index << endl; -#endif - Q_ASSERT( m_index != INDEX_NOMATCH ); - m_lastResult = NoMatch; - - d->currentId = id; - } -} - -KDialogBase* KFind::findNextDialog( bool create ) -{ - if ( !m_dialog && create ) - { - m_dialog = new KFindNextDialog( m_pattern, parentWidget() ); - connect( m_dialog, TQT_SIGNAL( user1Clicked() ), this, TQT_SLOT( slotFindNext() ) ); - connect( m_dialog, TQT_SIGNAL( finished() ), this, TQT_SLOT( slotDialogClosed() ) ); - } - return m_dialog; -} - -KFind::Result KFind::find() -{ - Q_ASSERT( m_index != INDEX_NOMATCH || d->patternChanged ); - - if ( m_lastResult == Match && !d->patternChanged ) - { - // Move on before looking for the next match, _if_ we just found a match - if (m_options & KFindDialog::FindBackwards) { - m_index--; - if ( m_index == -1 ) // don't call KFind::find with -1, it has a special meaning - { - m_lastResult = NoMatch; - return NoMatch; - } - } else - m_index++; - } - d->patternChanged = false; - - if ( m_options & KFindDialog::FindIncremental ) - { - // if the current pattern is shorter than the matchedPattern we can - // probably look up the match in the incrementalPath - if ( m_pattern.length() < d->matchedPattern.length() ) - { - Private::Match *match = m_pattern.isEmpty() ? d->emptyMatch : d->incrementalPath[m_pattern]; - TQString previousPattern = d->matchedPattern; - d->matchedPattern = m_pattern; - if ( match != 0 ) - { - bool clean = true; - - // find the first result backwards on the path that isn't dirty - while ( d->data[match->dataId]->dirty == true && - !m_pattern.isEmpty() ) - { - m_pattern.truncate( m_pattern.length() - 1 ); - - match = d->incrementalPath[m_pattern]; - - clean = false; - } - - // remove all matches that lie after the current match - while ( m_pattern.length() < previousPattern.length() ) - { - d->incrementalPath.remove(previousPattern); - previousPattern.truncate(previousPattern.length() - 1); - } - - // set the current text, index, etc. to the found match - m_text = d->data[match->dataId]->text; - m_index = match->index; - m_matchedLength = match->matchedLength; - d->currentId = match->dataId; - - // if the result is clean we can return it now - if ( clean ) - { - if ( d->customIds ) - emit highlight(d->currentId, m_index, m_matchedLength); - else - emit highlight(m_text, m_index, m_matchedLength); - - m_lastResult = Match; - d->matchedPattern = m_pattern; - return Match; - } - } - // if we couldn't look up the match, the new pattern isn't a - // substring of the matchedPattern, so we start a new search - else - { - startNewIncrementalSearch(); - } - } - // if the new pattern is longer than the matchedPattern we might be - // able to proceed from the last search - else if ( m_pattern.length() > d->matchedPattern.length() ) - { - // continue from the previous pattern - if ( m_pattern.startsWith(d->matchedPattern) ) - { - // we can't proceed from the previous position if the previous - // position already failed - if ( m_index == INDEX_NOMATCH ) - return NoMatch; - - TQString temp = m_pattern; - m_pattern.truncate(d->matchedPattern.length() + 1); - d->matchedPattern = temp; - } - // start a new search - else - { - startNewIncrementalSearch(); - } - } - // if the new pattern is as long as the matchedPattern, we reset if - // they are not equal - else if ( m_pattern != d->matchedPattern ) - { - startNewIncrementalSearch(); - } - } - -#ifdef DEBUG_FIND - kdDebug() << k_funcinfo << "m_index=" << m_index << endl; -#endif - do - { - // if we have multiple data blocks in our cache, walk through these - // blocks till we either searched all blocks or we find a match - do - { - // Find the next candidate match. - if ( m_options & KFindDialog::RegularExpression ) - m_index = KFind::find(m_text, *m_regExp, m_index, m_options, &m_matchedLength); - else - m_index = KFind::find(m_text, m_pattern, m_index, m_options, &m_matchedLength); - - if ( m_options & KFindDialog::FindIncremental ) - d->data[d->currentId]->dirty = false; - - if ( m_index == -1 && d->currentId < (int) d->data.count() - 1 ) - { - m_text = d->data[++d->currentId]->text; - - if ( m_options & KFindDialog::FindBackwards ) - m_index = m_text.length(); - else - m_index = 0; - } - else - break; - } while ( !(m_options & KFindDialog::RegularExpression) ); - - if ( m_index != -1 ) - { - // Flexibility: the app can add more rules to validate a possible match - if ( validateMatch( m_text, m_index, m_matchedLength ) ) - { - bool done = true; - - if ( m_options & KFindDialog::FindIncremental ) - { - if ( m_pattern.isEmpty() ) { - delete d->emptyMatch; - d->emptyMatch = new Private::Match( d->currentId, m_index, m_matchedLength ); - } else - d->incrementalPath.replace(m_pattern, new Private::Match(d->currentId, m_index, m_matchedLength)); - - if ( m_pattern.length() < d->matchedPattern.length() ) - { - m_pattern += d->matchedPattern.mid(m_pattern.length(), 1); - done = false; - } - } - - if ( done ) - { - m_matches++; - // Tell the world about the match we found, in case someone wants to - // highlight it. - if ( d->customIds ) - emit highlight(d->currentId, m_index, m_matchedLength); - else - emit highlight(m_text, m_index, m_matchedLength); - - if ( !m_dialogClosed ) - findNextDialog(true)->show(); - -#ifdef DEBUG_FIND - kdDebug() << k_funcinfo << "Match. Next m_index=" << m_index << endl; -#endif - m_lastResult = Match; - return Match; - } - } - else // Skip match - { - if (m_options & KFindDialog::FindBackwards) - m_index--; - else - m_index++; - } - } - else - { - if ( m_options & KFindDialog::FindIncremental ) - { - TQString temp = m_pattern; - temp.truncate(temp.length() - 1); - m_pattern = d->matchedPattern; - d->matchedPattern = temp; - } - - m_index = INDEX_NOMATCH; - } - } - while (m_index != INDEX_NOMATCH); - -#ifdef DEBUG_FIND - kdDebug() << k_funcinfo << "NoMatch. m_index=" << m_index << endl; -#endif - m_lastResult = NoMatch; - return NoMatch; -} - -void KFind::startNewIncrementalSearch() -{ - Private::Match *match = d->emptyMatch; - if(match == 0) - { - m_text = TQString::null; - m_index = 0; - d->currentId = 0; - } - else - { - m_text = d->data[match->dataId]->text; - m_index = match->index; - d->currentId = match->dataId; - } - m_matchedLength = 0; - d->incrementalPath.clear(); - delete d->emptyMatch; - d->emptyMatch = 0; - d->matchedPattern = m_pattern; - m_pattern = TQString::null; -} - -// static -int KFind::find(const TQString &text, const TQString &pattern, int index, long options, int *matchedLength) -{ - // Handle regular expressions in the appropriate way. - if (options & KFindDialog::RegularExpression) - { - TQRegExp regExp(pattern, options & KFindDialog::CaseSensitive); - - return find(text, regExp, index, options, matchedLength); - } - - bool caseSensitive = (options & KFindDialog::CaseSensitive); - - if (options & KFindDialog::WholeWordsOnly) - { - if (options & KFindDialog::FindBackwards) - { - // Backward search, until the beginning of the line... - while (index >= 0) - { - // ...find the next match. - index = text.findRev(pattern, index, caseSensitive); - if (index == -1) - break; - - // Is the match delimited correctly? - *matchedLength = pattern.length(); - if (isWholeWords(text, index, *matchedLength)) - break; - index--; - } - } - else - { - // Forward search, until the end of the line... - while (index < (int)text.length()) - { - // ...find the next match. - index = text.find(pattern, index, caseSensitive); - if (index == -1) - break; - - // Is the match delimited correctly? - *matchedLength = pattern.length(); - if (isWholeWords(text, index, *matchedLength)) - break; - index++; - } - if (index >= (int)text.length()) // end of line - index = -1; // not found - } - } - else - { - // Non-whole-word search. - if (options & KFindDialog::FindBackwards) - { - index = text.findRev(pattern, index, caseSensitive); - } - else - { - index = text.find(pattern, index, caseSensitive); - } - if (index != -1) - { - *matchedLength = pattern.length(); - } - } - return index; -} - -// static -int KFind::find(const TQString &text, const TQRegExp &pattern, int index, long options, int *matchedLength) -{ - if (options & KFindDialog::WholeWordsOnly) - { - if (options & KFindDialog::FindBackwards) - { - // Backward search, until the beginning of the line... - while (index >= 0) - { - // ...find the next match. - index = text.findRev(pattern, index); - if (index == -1) - break; - - // Is the match delimited correctly? - //pattern.match(text, index, matchedLength, false); - /*int pos =*/ pattern.search( text.mid(index) ); - *matchedLength = pattern.matchedLength(); - if (isWholeWords(text, index, *matchedLength)) - break; - index--; - } - } - else - { - // Forward search, until the end of the line... - while (index < (int)text.length()) - { - // ...find the next match. - index = text.find(pattern, index); - if (index == -1) - break; - - // Is the match delimited correctly? - //pattern.match(text, index, matchedLength, false); - /*int pos =*/ pattern.search( text.mid(index) ); - *matchedLength = pattern.matchedLength(); - if (isWholeWords(text, index, *matchedLength)) - break; - index++; - } - if (index >= (int)text.length()) // end of line - index = -1; // not found - } - } - else - { - // Non-whole-word search. - if (options & KFindDialog::FindBackwards) - { - index = text.findRev(pattern, index); - } - else - { - index = text.find(pattern, index); - } - if (index != -1) - { - //pattern.match(text, index, matchedLength, false); - /*int pos =*/ pattern.search( text.mid(index) ); - *matchedLength = pattern.matchedLength(); - } - } - return index; -} - -bool KFind::isInWord(TQChar ch) -{ - return ch.isLetter() || ch.isDigit() || ch == '_'; -} - -bool KFind::isWholeWords(const TQString &text, int starts, int matchedLength) -{ - if ((starts == 0) || (!isInWord(text[starts - 1]))) - { - int ends = starts + matchedLength; - - if ((ends == (int)text.length()) || (!isInWord(text[ends]))) - return true; - } - return false; -} - -void KFind::slotFindNext() -{ - emit findNext(); -} - -void KFind::slotDialogClosed() -{ - emit dialogClosed(); - m_dialogClosed = true; -} - -void KFind::displayFinalDialog() const -{ - TQString message; - if ( numMatches() ) - message = i18n( "1 match found.", "%n matches found.", numMatches() ); - else - message = i18n("<qt>No matches found for '<b>%1</b>'.</qt>").arg(TQStyleSheet::escape(m_pattern)); - KMessageBox::information(dialogsParent(), message); -} - -bool KFind::shouldRestart( bool forceAsking, bool showNumMatches ) const -{ - // Only ask if we did a "find from cursor", otherwise it's pointless. - // Well, unless the user can modify the document during a search operation, - // hence the force boolean. - if ( !forceAsking && (m_options & KFindDialog::FromCursor) == 0 ) - { - displayFinalDialog(); - return false; - } - TQString message; - if ( showNumMatches ) - { - if ( numMatches() ) - message = i18n( "1 match found.", "%n matches found.", numMatches() ); - else - message = i18n("No matches found for '<b>%1</b>'.").arg(TQStyleSheet::escape(m_pattern)); - } - else - { - if ( m_options & KFindDialog::FindBackwards ) - message = i18n( "Beginning of document reached." ); - else - message = i18n( "End of document reached." ); - } - - message += "<br><br>"; // can't be in the i18n() of the first if() because of the plural form. - // Hope this word puzzle is ok, it's a different sentence - message += - ( m_options & KFindDialog::FindBackwards ) ? - i18n("Continue from the end?") - : i18n("Continue from the beginning?"); - - int ret = KMessageBox::questionYesNo( dialogsParent(), TQString("<qt>")+message+TQString("</qt>"), - TQString::null, KStdGuiItem::cont(), KStdGuiItem::stop() ); - bool yes = ( ret == KMessageBox::Yes ); - if ( yes ) - const_cast<KFind*>(this)->m_options &= ~KFindDialog::FromCursor; // clear FromCursor option - return yes; -} - -void KFind::setOptions( long options ) -{ - m_options = options; - - delete m_regExp; - if (m_options & KFindDialog::RegularExpression) - m_regExp = new TQRegExp(m_pattern, m_options & KFindDialog::CaseSensitive); - else - m_regExp = 0; -} - -void KFind::closeFindNextDialog() -{ - delete m_dialog; - m_dialog = 0L; - m_dialogClosed = true; -} - -int KFind::index() const -{ - return m_index; -} - -void KFind::setPattern( const TQString& pattern ) -{ - if ( m_options & KFindDialog::FindIncremental && m_pattern != pattern ) - d->patternChanged = true; - - m_pattern = pattern; - setOptions( options() ); // rebuild m_regExp if necessary -} - -TQWidget* KFind::dialogsParent() const -{ - // If the find dialog is still up, it should get the focus when closing a message box - // Otherwise, maybe the "find next?" dialog is up - // Otherwise, the "view" is the parent. - return d->findDialog ? (TQWidget*)d->findDialog : ( m_dialog ? m_dialog : parentWidget() ); -} - -#include "kfind.moc" diff --git a/kutils/kfind.h b/kutils/kfind.h deleted file mode 100644 index ab088ef33..000000000 --- a/kutils/kfind.h +++ /dev/null @@ -1,427 +0,0 @@ -/* - Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. - Copyright (C) 2002, David Faure <david@mandrakesoft.com> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KFIND_H -#define KFIND_H - -#include <kdialogbase.h> -#include <tqrect.h> - -/** - * @ingroup main - * @ingroup findreplace - * @brief A generic implementation of the "find" function. - * - * @author S.R.Haque <srhaque@iee.org>, David Faure <faure@kde.org>, - * Arend van Beelen jr. <arend@auton.nl> - * - * \b Detail: - * - * This class includes prompt handling etc. Also provides some - * static functions which can be used to create custom behavior - * instead of using the class directly. - * - * \b Example: - * - * To use the class to implement a complete find feature: - * - * In the slot connected to the find action, after using KFindDialog: - * \code - * - * // This creates a find-next-prompt dialog if needed. - * m_find = new KFind(pattern, options, this); - * - * // Connect highlight signal to code which handles highlighting - * // of found text. - * connect( m_find, TQT_SIGNAL( highlight( const TQString &, int, int ) ), - * this, TQT_SLOT( slotHighlight( const TQString &, int, int ) ) ); - * // Connect findNext signal - called when pressing the button in the dialog - * connect( m_find, TQT_SIGNAL( findNext() ), - * this, TQT_SLOT( slotFindNext() ) ); - * \endcode - * - * If you are using a non-modal find dialog (the recommended new way - * in KDE-3.2), you should call right away m_find->closeFindNextDialog(). - * - * Then initialize the variables determining the "current position" - * (to the cursor, if the option FromCursor is set, - * to the beginning of the selection if the option SelectedText is set, - * and to the beginning of the document otherwise). - * Initialize the "end of search" variables as well (end of doc or end of selection). - * Swap begin and end if FindBackwards. - * Finally, call slotFindNext(); - * - * \code - * void slotFindNext() - * { - * KFind::Result res = KFind::NoMatch; - * while ( res == KFind::NoMatch && <position not at end> ) { - * if ( m_find->needData() ) - * m_find->setData( <current text fragment> ); - * - * // Let KFind inspect the text fragment, and display a dialog if a match is found - * res = m_find->find(); - * - * if ( res == KFind::NoMatch ) { - * <Move to the next text fragment, honoring the FindBackwards setting for the direction> - * } - * } - * - * if ( res == KFind::NoMatch ) // i.e. at end - * <Call either m_find->displayFinalDialog(); delete m_find; m_find = 0L; - * or if ( m_find->shouldRestart() ) { reinit (w/o FromCursor) and call slotFindNext(); } - * else { m_find->closeFindNextDialog(); }> - * } - * \endcode - * - * Don't forget to delete m_find in the destructor of your class, - * unless you gave it a parent widget on construction. - * - * This implementation allows to have a "Find Next" action, which resumes the - * search, even if the user closed the "Find Next" dialog. - * - * A "Find Previous" action can simply switch temporarily the value of - * FindBackwards and call slotFindNext() - and reset the value afterwards. - */ -class KUTILS_EXPORT KFind : - public TQObject -{ - Q_OBJECT - - -public: - - /** - * Only use this constructor if you don't use KFindDialog, or if - * you use it as a modal dialog. - * @param pattern The pattern to look for. - * @param options Options for the find dialog. @see KFindDialog. - * @param parent The parent widget. - */ - KFind(const TQString &pattern, long options, TQWidget *parent); - - /** - * This is the recommended constructor if you also use KFindDialog (non-modal). - * You should pass the pointer to it here, so that when a message box - * appears it has the right parent. Don't worry about deletion, KFind - * will notice if the find dialog is closed. - * @param pattern The pattern to look for. - * @param options Options for the find dialog. @see KFindDialog. - * @param parent The parent widget. - * @param findDialog A pointer to the KFindDialog object. - */ - KFind(const TQString &pattern, long options, TQWidget *parent, TQWidget* findDialog); - - /** - * Destructor. - */ - virtual ~KFind(); - - /** - * Result enum. Holds information if the find was successful. - */ - enum Result { - NoMatch, ///< No match was found. - Match ///< A match was found. - }; - - /** - * @return @c true if the application must supply a new text fragment - * It also means the last call returned "NoMatch". But by storing this here - * the application doesn't have to store it in a member variable (between - * calls to slotFindNext()). - */ - bool needData() const; - - /** - * Call this when needData returns @c true, before calling find(). - * @param data the text fragment (line) - * @param startPos if set, the index at which the search should start. - * This is only necessary for the very first call to setData usually, - * for the 'find in selection' feature. A value of -1 (the default value) - * means "process all the data", i.e. either 0 or data.length()-1 depending - * on FindBackwards. - */ - void setData( const TQString& data, int startPos = -1 ); - - /** - * Call this when needData returns @c true, before calling find(). The use of - * ID's is especially useful if you're using the FindIncremental option. - * @param id the id of the text fragment - * @param data the text fragment (line) - * @param startPos if set, the index at which the search should start. - * This is only necessary for the very first call to setData usually, - * for the 'find in selection' feature. A value of -1 (the default value) - * means "process all the data", i.e. either 0 or data.length()-1 depending - * on FindBackwards. - * - * @since 3.3 - */ - void setData( int id, const TQString& data, int startPos = -1 ); - - /** - * Walk the text fragment (e.g. text-processor line, kspread cell) looking for matches. - * For each match, emits the highlight() signal and displays the find-again dialog - * proceeding. - * @return Whether or not there has been a match. - */ - Result find(); - - /** - * Return the current options. - * - * Warning: this is usually the same value as the one passed to the constructor, - * but options might change _during_ the replace operation: - * e.g. the "All" button resets the PromptOnReplace flag. - * - * @return The current options. @see KFindDialog. - */ - long options() const { return m_options; } - - /** - * Set new options. Usually this is used for setting or clearing the - * FindBackwards options. - * - * @see KFindDialog. - */ - virtual void setOptions( long options ); - - /** - * @return the pattern we're currently looking for - */ - TQString pattern() const { return m_pattern; } - - /** - * Change the pattern we're looking for - * @param pattern The new pattern. - */ - void setPattern( const TQString& pattern ); - - /** - * Return the number of matches found (i.e. the number of times - * the highlight signal was emitted). - * If 0, can be used in a dialog box to tell the user "no match was found". - * The final dialog does so already, unless you used setDisplayFinalDialog(false). - * @return The number of matches. - */ - int numMatches() const { return m_matches; } - - /** - * Call this to reset the numMatches count - * (and the numReplacements count for a KReplace). - * Can be useful if reusing the same KReplace for different operations, - * or when restarting from the beginning of the document. - */ - virtual void resetCounts() { m_matches = 0; } - - /** - * Virtual method, which allows applications to add extra checks for - * validating a candidate match. It's only necessary to reimplement this - * if the find dialog extension has been used to provide additional - * criterias. - * - * @param text The current text fragment - * @param index The starting index where the candidate match was found - * @param matchedlength The length of the candidate match - */ - virtual bool validateMatch( const TQString & text, int index, int matchedlength ) { - Q_UNUSED(text); Q_UNUSED(index); Q_UNUSED(matchedlength); return true; } - - /** - * Returns @c true if we should restart the search from scratch. - * Can ask the user, or return @c false (if we already searched the whole document). - * - * @param forceAsking set to @c true if the user modified the document during the - * search. In that case it makes sense to restart the search again. - * - * @param showNumMatches set to @c true if the dialog should show the number of - * matches. Set to @c false if the application provides a "find previous" action, - * in which case the match count will be erroneous when hitting the end, - * and we could even be hitting the beginning of the document (so not all - * matches have even been seen). - * - * @return @c true, if the search should be restarted. - */ - virtual bool shouldRestart( bool forceAsking = false, bool showNumMatches = true ) const; - - /** - * Search the given string, and returns whether a match was found. If one is, - * the length of the string matched is also returned. - * - * A performance optimised version of the function is provided for use - * with regular expressions. - * - * @param text The string to search. - * @param pattern The pattern to look for. - * @param index The starting index into the string. - * @param options The options to use. - * @param matchedlength The length of the string that was matched - * @return The index at which a match was found, or -1 if no match was found. - */ - static int find( const TQString &text, const TQString &pattern, int index, long options, int *matchedlength ); - - /** - * Search the given regular expression, and returns whether a match was found. If one is, - * the length of the matched string is also returned. - * - * Another version of the function is provided for use with strings. - * - * @param text The string to search. - * @param pattern The regular expression pattern to look for. - * @param index The starting index into the string. - * @param options The options to use. - * @param matchedlength The length of the string that was matched - * @return The index at which a match was found, or -1 if no match was found. - */ - static int find( const TQString &text, const TQRegExp &pattern, int index, long options, int *matchedlength ); - - /** - * Displays the final dialog saying "no match was found", if that was the case. - * Call either this or shouldRestart(). - */ - virtual void displayFinalDialog() const; - - /** - * Return (or create) the dialog that shows the "find next?" prompt. - * Usually you don't need to call this. - * One case where it can be useful, is when the user selects the "Find" - * menu item while a find operation is under way. In that case, the - * program may want to call setActiveWindow() on that dialog. - * @return The find next dialog. - */ - KDialogBase* findNextDialog( bool create = false ); - - /** - * Close the "find next?" dialog. The application should do this when - * the last match was hit. If the application deletes the KFind, then - * "find previous" won't be possible anymore. - * - * IMPORTANT: you should also call this if you are using a non-modal - * find dialog, to tell KFind not to pop up its own dialog. - */ - void closeFindNextDialog(); - - /** - * @return the current matching index ( or -1 ). - * Same as the matchingIndex parameter passed to highlight. - * You usually don't need to use this, except maybe when updating the current data, - * so you need to call setData( newData, index() ). - * @since 3.2 - */ - int index() const; - -signals: - - /** - * Connect to this signal to implement highlighting of found text during the find - * operation. - * - * If you've set data with setData(id, text), use the signal highlight(id, - * matchingIndex, matchedLength) - * - * @warning If you're using the FindIncremental option, the text argument - * passed by this signal is not necessarily the data last set through - * setData(), but can also be an earlier set data block. - * - * @param text The found text. - * @param matchingIndex The index of the found text's occurrence. - * @param matchedLength The length of the matched text. - * @see setData() - */ - void highlight(const TQString &text, int matchingIndex, int matchedLength); - - /** - * Connect to this signal to implement highlighting of found text during the find - * operation. - * - * Use this signal if you've set your data with setData(id, text), otherwise - * use the signal with highlight(text, matchingIndex, matchedLength). - * - * @warning If you're using the FindIncremental option, the id argument - * passed by this signal is not necessarily the id of the data last set - * through setData(), but can also be of an earlier set data block. - * - * @param id The ID of the text fragment, as used in setData(). - * @param matchingIndex The index of the found text's occurrence. - * @param matchedLength The length of the matched text. - * @see setData() - * - * @since 3.3 - */ - void highlight(int id, int matchingIndex, int matchedLength); - - // ## TODO docu - // findprevious will also emit findNext, after temporarily switching the value - // of FindBackwards - void findNext(); - - /** - * Emitted when the options have changed. - * This can happen e.g. with "Replace All", or if our 'find next' dialog - * gets a "find previous" one day. - */ - void optionsChanged(); - - /** - * Emitted when the 'find next' dialog is being closed. - * Some apps might want to remove the highlighted text when this happens. - * Apps without support for "Find Next" can also do m_find->deleteLater() - * to terminate the find operation. - */ - void dialogClosed(); - -protected: - - TQWidget* parentWidget() const { return (TQWidget *)parent(); } - TQWidget* dialogsParent() const; - -protected slots: - - void slotFindNext(); - void slotDialogClosed(); - -private: - void init( const TQString& pattern ); - void startNewIncrementalSearch(); - - static bool isInWord( TQChar ch ); - static bool isWholeWords( const TQString &text, int starts, int matchedLength ); - - friend class KReplace; - - - TQString m_pattern; - TQRegExp *m_regExp; - KDialogBase* m_dialog; - long m_options; - unsigned m_matches; - - TQString m_text; // the text set by setData - int m_index; - int m_matchedLength; - bool m_dialogClosed; - bool m_lastResult; - - // Binary compatible extensibility. - struct Private; - Private *d; -}; - -#endif diff --git a/kutils/kfinddialog.cpp b/kutils/kfinddialog.cpp deleted file mode 100644 index ef3c131cc..000000000 --- a/kutils/kfinddialog.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/* - Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. - Copyright (C) 2002, David Faure <david@mandrakesoft.com> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kfinddialog.h" -#include <tqcheckbox.h> -#include <tqcursor.h> -#include <tqgroupbox.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqpopupmenu.h> -#include <tqpushbutton.h> -#include <tqregexp.h> -#include <kcombobox.h> -#include <kdebug.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <assert.h> -#include <tqwhatsthis.h> - -#include <kregexpeditorinterface.h> -#include <kparts/componentfactory.h> - -class KFindDialog::KFindDialogPrivate -{ -public: - KFindDialogPrivate() : m_regexpDialog(0), - m_regexpDialogQueryDone(false), - m_enabled(WholeWordsOnly | FromCursor | SelectedText | CaseSensitive | FindBackwards | RegularExpression), m_initialShowDone(false) {} - TQDialog* m_regexpDialog; - bool m_regexpDialogQueryDone; - long m_enabled; // uses Options to define which search options are enabled - bool m_initialShowDone; - TQStringList findStrings; - TQString pattern; -}; - -KFindDialog::KFindDialog(TQWidget *parent, const char *name, long options, const TQStringList &findStrings, bool hasSelection) : - KDialogBase(parent, name, true, i18n("Find Text"), Ok | Cancel, Ok), - m_findExtension (0), - m_replaceExtension (0) -{ - d = new KFindDialogPrivate; - init(false, findStrings, hasSelection); - setOptions(options); - setButtonCancel( KStdGuiItem::close() ); -} - -KFindDialog::KFindDialog(bool modal, TQWidget *parent, const char *name, long options, const TQStringList &findStrings, bool hasSelection) : - KDialogBase(parent, name, modal, i18n("Find Text"), Ok | Cancel, Ok), - m_findExtension (0), - m_replaceExtension (0) -{ - d = new KFindDialogPrivate; - init(false, findStrings, hasSelection); - setOptions(options); - setButtonCancel( KStdGuiItem::close() ); -} - -KFindDialog::KFindDialog(TQWidget *parent, const char *name, bool /*forReplace*/) : - KDialogBase(parent, name, true, i18n("Replace Text"), Ok | Cancel, Ok), - m_findExtension (0), - m_replaceExtension (0) -{ - d = new KFindDialogPrivate; - setButtonCancel( KStdGuiItem::close() ); -} - -KFindDialog::~KFindDialog() -{ - delete d; -} - -TQWidget *KFindDialog::findExtension() -{ - if (!m_findExtension) - { - m_findExtension = new TQWidget(m_findGrp); - m_findLayout->addMultiCellWidget(m_findExtension, 3, 3, 0, 1); - } - - return m_findExtension; -} - -TQStringList KFindDialog::findHistory() const -{ - return m_find->historyItems(); -} - -void KFindDialog::init(bool forReplace, const TQStringList &findStrings, bool hasSelection) -{ - TQVBoxLayout *topLayout; - TQGridLayout *optionsLayout; - - // Create common parts of dialog. - TQWidget *page = new TQWidget(this); - setMainWidget(page); - - topLayout = new TQVBoxLayout(page); - topLayout->setSpacing( KDialog::spacingHint() ); - topLayout->setMargin( 0 ); - - m_findGrp = new TQGroupBox(0, Qt::Vertical, i18n("Find"), page); - m_findGrp->layout()->setSpacing( KDialog::spacingHint() ); - // m_findGrp->layout()->setMargin( KDialog::marginHint() ); - m_findLayout = new TQGridLayout(m_findGrp->layout()); - m_findLayout->setSpacing( KDialog::spacingHint() ); - // m_findLayout->setMargin( KDialog::marginHint() ); - - m_findLabel = new TQLabel(i18n("&Text to find:"), m_findGrp); - m_find = new KHistoryCombo(true, m_findGrp); - m_find->setMaxCount(10); - m_find->setDuplicatesEnabled(false); - m_regExp = new TQCheckBox(i18n("Regular e&xpression"), m_findGrp); - m_regExpItem = new TQPushButton(i18n("&Edit..."), m_findGrp); - m_regExpItem->setEnabled(false); - - m_findLayout->addWidget(m_findLabel, 0, 0); - m_findLayout->addMultiCellWidget(m_find, 1, 1, 0, 1); - m_findLayout->addWidget(m_regExp, 2, 0); - m_findLayout->addWidget(m_regExpItem, 2, 1); - topLayout->addWidget(m_findGrp); - - m_replaceGrp = new TQGroupBox(0, Qt::Vertical, i18n("Replace With"), page); - m_replaceGrp->layout()->setSpacing( KDialog::spacingHint() ); - // m_replaceGrp->layout()->setMargin( KDialog::marginHint() ); - m_replaceLayout = new TQGridLayout(m_replaceGrp->layout()); - m_replaceLayout->setSpacing( KDialog::spacingHint() ); -// m_replaceLayout->setMargin( KDialog::marginHint() ); - - m_replaceLabel = new TQLabel(i18n("Replace&ment text:"), m_replaceGrp); - m_replace = new KHistoryCombo(true, m_replaceGrp); - m_replace->setMaxCount(10); - m_replace->setDuplicatesEnabled(false); - m_backRef = new TQCheckBox(i18n("Use p&laceholders"), m_replaceGrp); - m_backRefItem = new TQPushButton(i18n("Insert Place&holder"), m_replaceGrp); - m_backRefItem->setEnabled(false); - - m_replaceLayout->addWidget(m_replaceLabel, 0, 0); - m_replaceLayout->addMultiCellWidget(m_replace, 1, 1, 0, 1); - m_replaceLayout->addWidget(m_backRef, 2, 0); - m_replaceLayout->addWidget(m_backRefItem, 2, 1); - topLayout->addWidget(m_replaceGrp); - - m_optionGrp = new TQGroupBox(0, Qt::Vertical, i18n("Options"), page); - m_optionGrp->layout()->setSpacing(KDialog::spacingHint()); - // m_optionGrp->layout()->setMargin(KDialog::marginHint()); - optionsLayout = new TQGridLayout(m_optionGrp->layout()); - optionsLayout->setSpacing( KDialog::spacingHint() ); - // optionsLayout->setMargin( KDialog::marginHint() ); - - m_caseSensitive = new TQCheckBox(i18n("C&ase sensitive"), m_optionGrp); - m_wholeWordsOnly = new TQCheckBox(i18n("&Whole words only"), m_optionGrp); - m_fromCursor = new TQCheckBox(i18n("From c&ursor"), m_optionGrp); - m_findBackwards = new TQCheckBox(i18n("Find &backwards"), m_optionGrp); - m_selectedText = new TQCheckBox(i18n("&Selected text"), m_optionGrp); - setHasSelection( hasSelection ); - // If we have a selection, we make 'find in selection' default - // and if we don't, then the option has to be unchecked, obviously. - m_selectedText->setChecked( hasSelection ); - slotSelectedTextToggled( hasSelection ); - - m_promptOnReplace = new TQCheckBox(i18n("&Prompt on replace"), m_optionGrp); - m_promptOnReplace->setChecked( true ); - - optionsLayout->addWidget(m_caseSensitive, 0, 0); - optionsLayout->addWidget(m_wholeWordsOnly, 1, 0); - optionsLayout->addWidget(m_fromCursor, 2, 0); - optionsLayout->addWidget(m_findBackwards, 0, 1); - optionsLayout->addWidget(m_selectedText, 1, 1); - optionsLayout->addWidget(m_promptOnReplace, 2, 1); - topLayout->addWidget(m_optionGrp); - - // We delay creation of these until needed. - m_patterns = 0L; - m_placeholders = 0L; - - // signals and slots connections - connect(m_selectedText, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSelectedTextToggled(bool))); - connect(m_regExp, TQT_SIGNAL(toggled(bool)), m_regExpItem, TQT_SLOT(setEnabled(bool))); - connect(m_backRef, TQT_SIGNAL(toggled(bool)), m_backRefItem, TQT_SLOT(setEnabled(bool))); - connect(m_regExpItem, TQT_SIGNAL(clicked()), this, TQT_SLOT(showPatterns())); - connect(m_backRefItem, TQT_SIGNAL(clicked()), this, TQT_SLOT(showPlaceholders())); - - connect(m_find, TQT_SIGNAL(textChanged ( const TQString & )),this, TQT_SLOT(textSearchChanged( const TQString & ))); - - // tab order - setTabOrder(m_find, m_regExp); - setTabOrder(m_regExp, m_regExpItem); - setTabOrder(m_regExpItem, m_replace); - setTabOrder(m_replace, m_backRef); - setTabOrder(m_backRef, m_backRefItem); - setTabOrder(m_backRefItem, m_caseSensitive); - setTabOrder(m_caseSensitive, m_wholeWordsOnly); - setTabOrder(m_wholeWordsOnly, m_fromCursor); - setTabOrder(m_fromCursor, m_findBackwards); - setTabOrder(m_findBackwards, m_selectedText); - setTabOrder(m_selectedText, m_promptOnReplace); - - // buddies - m_findLabel->setBuddy(m_find); - m_replaceLabel->setBuddy(m_replace); - - if (!forReplace) - { - m_promptOnReplace->hide(); - m_replaceGrp->hide(); - } - - d->findStrings = findStrings; - m_find->setFocus(); - enableButtonOK( !pattern().isEmpty() ); - if (forReplace) - { - setButtonOK(KGuiItem( i18n("&Replace"), TQString::null, - i18n("Start replace"), - i18n("<qt>If you press the <b>Replace</b> button, the text you entered " - "above is searched for within the document and any occurrence is " - "replaced with the replacement text.</qt>"))); - } - else - { - setButtonOK(KGuiItem( i18n("&Find"), "find", - i18n("Start searching"), - i18n("<qt>If you press the <b>Find</b> button, the text you entered " - "above is searched for within the document.</qt>"))); - } - - // QWhatsthis texts - TQWhatsThis::add ( m_find, i18n( - "Enter a pattern to search for, or select a previous pattern from " - "the list.") ); - TQWhatsThis::add ( m_regExp, i18n( - "If enabled, search for a regular expression.") ); - TQWhatsThis::add ( m_regExpItem, i18n( - "Click here to edit your regular expression using a graphical editor.") ); - TQWhatsThis::add ( m_replace, i18n( - "Enter a replacement string, or select a previous one from the list.") ); - TQWhatsThis::add( m_backRef, i18n( - "<qt>If enabled, any occurrence of <code><b>\\N</b></code>, where " - "<code><b>N</b></code> is a integer number, will be replaced with " - "the corresponding capture (\"parenthesized substring\") from the " - "pattern.<p>To include (a literal <code><b>\\N</b></code> in your " - "replacement, put an extra backslash in front of it, like " - "<code><b>\\\\N</b></code>.</qt>") ); - TQWhatsThis::add ( m_backRefItem, i18n( - "Click for a menu of available captures.") ); - TQWhatsThis::add ( m_wholeWordsOnly, i18n( - "Require word boundaries in both ends of a match to succeed.") ); - TQWhatsThis::add ( m_fromCursor, i18n( - "Start searching at the current cursor location rather than at the top.") ); - TQWhatsThis::add ( m_selectedText, i18n( - "Only search within the current selection.") ); - TQWhatsThis::add ( m_caseSensitive, i18n( - "Perform a case sensitive search: entering the pattern " - "'Joe' will not match 'joe' or 'JOE', only 'Joe'.") ); - TQWhatsThis::add ( m_findBackwards, i18n( - "Search backwards.") ); - TQWhatsThis::add ( m_promptOnReplace, i18n( - "Ask before replacing each match found.") ); -} - -void KFindDialog::textSearchChanged( const TQString & text) -{ - enableButtonOK( !text.isEmpty() ); -} - -void KFindDialog::showEvent( TQShowEvent *e ) -{ - if ( !d->m_initialShowDone ) - { - d->m_initialShowDone = true; // only once - kdDebug() << "showEvent\n"; - if (!d->findStrings.isEmpty()) - setFindHistory(d->findStrings); - d->findStrings = TQStringList(); - if (!d->pattern.isEmpty()) { - m_find->lineEdit()->setText( d->pattern ); - m_find->lineEdit()->selectAll(); - d->pattern = TQString::null; - } - } - KDialogBase::showEvent(e); -} - -long KFindDialog::options() const -{ - long options = 0; - - if (m_caseSensitive->isChecked()) - options |= CaseSensitive; - if (m_wholeWordsOnly->isChecked()) - options |= WholeWordsOnly; - if (m_fromCursor->isChecked()) - options |= FromCursor; - if (m_findBackwards->isChecked()) - options |= FindBackwards; - if (m_selectedText->isChecked()) - options |= SelectedText; - if (m_regExp->isChecked()) - options |= RegularExpression; - return options; -} - -TQString KFindDialog::pattern() const -{ - return m_find->currentText(); -} - -void KFindDialog::setPattern (const TQString &pattern) -{ - m_find->lineEdit()->setText( pattern ); - m_find->lineEdit()->selectAll(); - d->pattern = pattern; - kdDebug() << "setPattern " << pattern<<endl; -} - -void KFindDialog::setFindHistory(const TQStringList &strings) -{ - if (strings.count() > 0) - { - m_find->setHistoryItems(strings, true); - m_find->lineEdit()->setText( strings.first() ); - m_find->lineEdit()->selectAll(); - } - else - m_find->clearHistory(); -} - -void KFindDialog::setHasSelection(bool hasSelection) -{ - if (hasSelection) d->m_enabled |= SelectedText; - else d->m_enabled &= ~SelectedText; - m_selectedText->setEnabled( hasSelection ); - if ( !hasSelection ) - { - m_selectedText->setChecked( false ); - slotSelectedTextToggled( hasSelection ); - } -} - -void KFindDialog::slotSelectedTextToggled(bool selec) -{ - // From cursor doesn't make sense if we have a selection - m_fromCursor->setEnabled( !selec && (d->m_enabled & FromCursor) ); - if ( selec ) // uncheck if disabled - m_fromCursor->setChecked( false ); -} - -void KFindDialog::setHasCursor(bool hasCursor) -{ - if (hasCursor) d->m_enabled |= FromCursor; - else d->m_enabled &= ~FromCursor; - m_fromCursor->setEnabled( hasCursor ); - m_fromCursor->setChecked( hasCursor && (options() & FromCursor) ); -} - -void KFindDialog::setSupportsBackwardsFind( bool supports ) -{ - // ########## Shouldn't this hide the checkbox instead? - if (supports) d->m_enabled |= FindBackwards; - else d->m_enabled &= ~FindBackwards; - m_findBackwards->setEnabled( supports ); - m_findBackwards->setChecked( supports && (options() & FindBackwards) ); -} - -void KFindDialog::setSupportsCaseSensitiveFind( bool supports ) -{ - // ########## This should hide the checkbox instead - if (supports) d->m_enabled |= CaseSensitive; - else d->m_enabled &= ~CaseSensitive; - m_caseSensitive->setEnabled( supports ); - m_caseSensitive->setChecked( supports && (options() & CaseSensitive) ); -} - -void KFindDialog::setSupportsWholeWordsFind( bool supports ) -{ - // ########## This should hide the checkbox instead - if (supports) d->m_enabled |= WholeWordsOnly; - else d->m_enabled &= ~WholeWordsOnly; - m_wholeWordsOnly->setEnabled( supports ); - m_wholeWordsOnly->setChecked( supports && (options() & WholeWordsOnly) ); -} - -void KFindDialog::setSupportsRegularExpressionFind( bool supports ) -{ - // ########## This should hide the checkbox instead - if (supports) d->m_enabled |= RegularExpression; - else d->m_enabled &= ~RegularExpression; - m_regExp->setEnabled( supports ); - m_regExp->setChecked( supports && (options() & RegularExpression) ); -} - -void KFindDialog::setOptions(long options) -{ - m_caseSensitive->setChecked((d->m_enabled & CaseSensitive) && (options & CaseSensitive)); - m_wholeWordsOnly->setChecked((d->m_enabled & WholeWordsOnly) && (options & WholeWordsOnly)); - m_fromCursor->setChecked((d->m_enabled & FromCursor) && (options & FromCursor)); - m_findBackwards->setChecked((d->m_enabled & FindBackwards) && (options & FindBackwards)); - m_selectedText->setChecked((d->m_enabled & SelectedText) && (options & SelectedText)); - m_regExp->setChecked((d->m_enabled & RegularExpression) && (options & RegularExpression)); -} - -// Create a popup menu with a list of regular expression terms, to help the user -// compose a regular expression search pattern. -void KFindDialog::showPatterns() -{ - if ( !d->m_regexpDialogQueryDone ) - { - d->m_regexpDialog = KParts::ComponentFactory::createInstanceFromQuery<TQDialog>( "KRegExpEditor/KRegExpEditor", TQString(), TQT_TQOBJECT(this) ); - d->m_regexpDialogQueryDone = true; - } - - if ( d->m_regexpDialog ) - { - KRegExpEditorInterface *iface = tqt_dynamic_cast<KRegExpEditorInterface *>( d->m_regexpDialog ); - assert( iface ); - - iface->setRegExp( pattern() ); - if ( d->m_regexpDialog->exec() == TQDialog::Accepted ) - setPattern( iface->regExp() ); - } - else // No complete regexp-editor available, bring up the old popupmenu - { - typedef struct - { - const char *description; - const char *regExp; - int cursorAdjustment; - } term; - static const term items[] = - { - { I18N_NOOP("Any Character"), ".", 0 }, - { I18N_NOOP("Start of Line"), "^", 0 }, - { I18N_NOOP("End of Line"), "$", 0 }, - { I18N_NOOP("Set of Characters"), "[]", -1 }, - { I18N_NOOP("Repeats, Zero or More Times"), "*", 0 }, - { I18N_NOOP("Repeats, One or More Times"), "+", 0 }, - { I18N_NOOP("Optional"), "?", 0 }, - { I18N_NOOP("Escape"), "\\", 0 }, - { I18N_NOOP("TAB"), "\\t", 0 }, - { I18N_NOOP("Newline"), "\\n", 0 }, - { I18N_NOOP("Carriage Return"), "\\r", 0 }, - { I18N_NOOP("White Space"), "\\s", 0 }, - { I18N_NOOP("Digit"), "\\d", 0 }, - }; - int i; - - // Populate the popup menu. - if (!m_patterns) - { - m_patterns = new TQPopupMenu(this); - for (i = 0; (unsigned)i < sizeof(items) / sizeof(items[0]); i++) - { - m_patterns->insertItem(i18n(items[i].description), i, i); - } - } - - // Insert the selection into the edit control. - i = m_patterns->exec(m_regExpItem->mapToGlobal(m_regExpItem->rect().bottomLeft())); - if (i != -1) - { - TQLineEdit *editor = m_find->lineEdit(); - - editor->insert(items[i].regExp); - editor->setCursorPosition(editor->cursorPosition() + items[i].cursorAdjustment); - } - } -} - -// Create a popup menu with a list of backreference terms, to help the user -// compose a regular expression replacement pattern. -void KFindDialog::showPlaceholders() -{ - // Populate the popup menu. - if (!m_placeholders) - { - m_placeholders = new TQPopupMenu(this); - connect( m_placeholders, TQT_SIGNAL(aboutToShow()), this, TQT_SLOT(slotPlaceholdersAboutToShow()) ); - } - - // Insert the selection into the edit control. - int i = m_placeholders->exec(m_backRefItem->mapToGlobal(m_backRefItem->rect().bottomLeft())); - if (i != -1) - { - TQLineEdit *editor = m_replace->lineEdit(); - editor->insert( TQString("\\%1").arg( i ) ); - } -} - -void KFindDialog::slotPlaceholdersAboutToShow() -{ - m_placeholders->clear(); - m_placeholders->insertItem( i18n("Complete Match"), 0 ); - - TQRegExp r( pattern() ); - uint n = r.numCaptures(); - for ( uint i=0; i < n; i++ ) - m_placeholders->insertItem( i18n("Captured Text (%1)").arg( i+1 ), i+1 ); -} - -void KFindDialog::slotOk() -{ - // Nothing to find? - if (pattern().isEmpty()) - { - KMessageBox::error(this, i18n("You must enter some text to search for.")); - return; - } - - if (m_regExp->isChecked()) - { - // Check for a valid regular expression. - TQRegExp regExp(pattern()); - - if (!regExp.isValid()) - { - KMessageBox::error(this, i18n("Invalid regular expression.")); - return; - } - } - m_find->addToHistory(pattern()); - emit okClicked(); - if ( testWFlags( WShowModal ) ) - accept(); -} -// kate: space-indent on; indent-width 4; replace-tabs on; -#include "kfinddialog.moc" diff --git a/kutils/kfinddialog.h b/kutils/kfinddialog.h deleted file mode 100644 index fcf870836..000000000 --- a/kutils/kfinddialog.h +++ /dev/null @@ -1,315 +0,0 @@ -/* - Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. - Copyright (C) 2002, David Faure <david@mandrakesoft.com> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KFINDDIALOG_H -#define KFINDDIALOG_H - -#include <kdialogbase.h> -class KHistoryCombo; -class TQPushButton; -class TQPopupMenu; -class TQGridLayout; -class TQLabel; -class TQGroupBox; -class TQCheckBox; - -/** - * @ingroup main - * @ingroup findreplace - * @brief A generic "find" dialog. - * - * @author S.R.Haque <srhaque@iee.org> - * - * \b Detail: - * - * This widget inherits from KDialogBase and implements - * the following additional functionalities: a find string - * object and an area for a user-defined widget to extend the dialog. - * - * \b Example: - * - * To use the basic modal find dialog, and then run the search: - * - * \code - * KFindDialog dlg(....) - * if ( dlg.exec() != TQDialog::Accepted ) - * return; - * - * // proceed with KFind from here - * \endcode - * - * To create a non-modal find dialog: - * \code - * if ( m_findDia ) - * KWin::setActiveWindow( m_findDia->winId() ); - * else - * { - * m_findDia = new KFindDialog(false,...); - * connect( m_findDia, TQT_SIGNAL(okClicked()), this, TQT_SLOT(findTextNext()) ); - * } - * \endcode - * Don't forget to delete and reset m_findDia when closed. - * (But do NOT delete your KFind object at that point, it's needed for "Find Next") - * - * To use your own extensions: see findExtension(). - * - */ -class KUTILS_EXPORT KFindDialog: - public KDialogBase -{ - Q_OBJECT - -public: - - // Options. - - // KDE4: move to KFind - /** - * Options for the search - */ - enum Options - { - WholeWordsOnly = 1, ///< Match whole words only. - FromCursor = 2, ///< Start from current cursor position. - SelectedText = 4, ///< Only search selected area. - CaseSensitive = 8, ///< Consider case when matching. - FindBackwards = 16, ///< Go backwards. - RegularExpression = 32, ///< Interpret the pattern as a regular expression. - FindIncremental = 64, ///< Find incremental. - // Note that KReplaceDialog uses 256 and 512 - // User extensions can use boolean options above this value. - MinimumUserOption = 65536 ///< The first flag which can be used by extensions. - }; - - /** - * Construct a modal find dialog - * - * @param parent The parent object of this widget. - * @param name The name of this widget. - * @param options A bitfield of the Options to be checked. - * @param findStrings The find history, see findHistory() - * @param hasSelection Whether a selection exists - */ - KFindDialog( TQWidget *parent = 0, const char *name = 0, long options = 0, - const TQStringList &findStrings = TQStringList(), bool hasSelection = false ); - // KDE4: fix ambiguity with private constructor - // Maybe remove options (there's setOptions) and findStrings (setFindHistory) and hasSelection (setHasSelection) - - /** - * Construct a non-modal find dialog - * - * @param modal set to @c false to get a non-modal dialog - * @param parent The parent object of this widget. - * @param name The name of this widget. - * @param options A bitfield of the Options to be checked. - * @param findStrings The find history, see findHistory() - * @param hasSelection Whether a selection exists - */ - KFindDialog( bool modal, TQWidget *parent = 0, const char *name = 0, long options = 0, - const TQStringList &findStrings = TQStringList(), bool hasSelection = false ); - // KDE4: consider simplifying - - /** - * Destructor. - */ - virtual ~KFindDialog(); - - /** - * Provide the list of @p strings to be displayed as the history - * of find strings. @p strings might get truncated if it is - * too long. - * - * @param history The find history. - * @see findHistory - */ - void setFindHistory( const TQStringList &history ); - - /** - * Returns the list of history items. - * - * @return The find history. - * @see setFindHistory - */ - TQStringList findHistory() const; - - /** - * Enable/disable the 'search in selection' option, depending - * on whether there actually is a selection. - * - * @param hasSelection @c true if a selection exists - */ - void setHasSelection( bool hasSelection ); - - /** - * Hide/show the 'from cursor' option, depending - * on whether the application implements a cursor. - * - * @param hasCursor @c true if the application features a cursor - * This is assumed to be the case by default. - */ - void setHasCursor( bool hasCursor ); - - /** - * Enable/disable the 'Find backwards' option, depending - * on whether the application supports it. - * - * @param supports @c true if the application supports backwards find - * This is assumed to be the case by default. - * @since 3.4 - */ - void setSupportsBackwardsFind( bool supports ); - - /** - * Enable/disable the 'Case sensitive' option, depending - * on whether the application supports it. - * - * @param supports @c true if the application supports case sensitive find - * This is assumed to be the case by default. - * @since 3.4 - */ - void setSupportsCaseSensitiveFind( bool supports ); - - /** - * Enable/disable the 'Whole words only' option, depending - * on whether the application supports it. - * - * @param supports @c true if the application supports whole words only find - * This is assumed to be the case by default. - * @since 3.4 - */ - void setSupportsWholeWordsFind( bool supports ); - - /** - * Enable/disable the 'Regular expression' option, depending - * on whether the application supports it. - * - * @param supports @c true if the application supports regular expression find - * This is assumed to be the case by default. - * @since 3.4 - */ - void setSupportsRegularExpressionFind( bool supports ); - - /** - * Set the options which are checked. - * - * @param options The setting of the Options. - * @see Options - */ - void setOptions( long options ); - - /** - * Returns the state of the options. Disabled options may be returned in - * an indeterminate state. - * - * @return The options. - * @see Options, setOptions - */ - long options() const; - - /** - * Returns the pattern to find. - * @return The search text. - */ - TQString pattern() const; - - /** - * Sets the pattern to find. - * @param pattern The new search pattern. - */ - void setPattern ( const TQString &pattern ); - - /** - * Returns an empty widget which the user may fill with additional UI - * elements as required. The widget occupies the width of the dialog, - * and is positioned immediately below the regular expression support - * widgets for the pattern string. - * @return An extensible TQWidget. - */ - TQWidget *findExtension(); - -protected slots: - - void slotOk(); - void slotSelectedTextToggled(bool); - void showPatterns(); - void showPlaceholders(); - void textSearchChanged( const TQString &); - -protected: - virtual void showEvent ( TQShowEvent * ); - -private slots: - /** - * connected to the aboutToShow of the placeholders menu, - * updates it according to the text in the pattern. - */ - void slotPlaceholdersAboutToShow(); - -private: - - TQGroupBox *m_findGrp; - TQLabel *m_findLabel; - KHistoryCombo *m_find; - TQCheckBox *m_regExp; - TQPushButton *m_regExpItem; - TQGridLayout *m_findLayout; - TQWidget *m_findExtension; - - TQGroupBox *m_optionGrp; - TQCheckBox *m_wholeWordsOnly; - TQCheckBox *m_fromCursor; - TQCheckBox *m_selectedText; - TQCheckBox *m_caseSensitive; - TQCheckBox *m_findBackwards; - - TQPopupMenu *m_patterns; - - // Our dirty little secret is that we also implement the "replace" dialog. But we - // keep that fact hidden from all but our friends. - - friend class KReplaceDialog; - - /** - * Construct a find dialog with a parent object and a name. This version of the - * constructor is for use by friends only! - * - * @param forReplace Is this a replace dialog? - */ - KFindDialog( TQWidget *parent, const char *name, bool forReplace ); - void init( bool forReplace, const TQStringList &findStrings, bool hasSelection ); - - TQGroupBox *m_replaceGrp; - TQLabel *m_replaceLabel; - KHistoryCombo *m_replace; - TQCheckBox* m_backRef; - TQPushButton* m_backRefItem; - TQGridLayout *m_replaceLayout; - TQWidget *m_replaceExtension; - - TQCheckBox* m_promptOnReplace; - - TQPopupMenu *m_placeholders; - - // Binary compatible extensibility. - class KFindDialogPrivate; - KFindDialogPrivate *d; -}; - -#endif // KFINDDIALOG_H diff --git a/kutils/kmultitabbar.cpp b/kutils/kmultitabbar.cpp deleted file mode 100644 index 082470538..000000000 --- a/kutils/kmultitabbar.cpp +++ /dev/null @@ -1,997 +0,0 @@ -/*************************************************************************** - kmultitabbar.cpp - description - ------------------- - begin : 2001 - copyright : (C) 2001,2002,2003 by Joseph Wenninger <jowenn@kde.org> - ***************************************************************************/ - -/*************************************************************************** - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - ***************************************************************************/ - -#include "kmultitabbar.h" -#include "kmultitabbar.moc" -#include "kmultitabbar_p.h" -#include "kmultitabbar_p.moc" -#include <tqbutton.h> -#include <tqpopupmenu.h> -#include <tqlayout.h> -#include <tqpainter.h> -#include <tqtooltip.h> -#include <tqfontmetrics.h> -#include <tqstyle.h> - -#include <kiconloader.h> -#include <kdebug.h> -#include <tqapplication.h> -#include <math.h> - -#define NEARBYINT(i) ((int(float(i) + 0.5))) - -class KMultiTabBarTabPrivate { -public: - TQPixmap pix; -}; - - -KMultiTabBarInternal::KMultiTabBarInternal(TQWidget *parent, KMultiTabBar::KMultiTabBarMode bm):TQScrollView(parent) -{ - m_expandedTabSize=-1; - m_showActiveTabTexts=false; - m_tabs.setAutoDelete(true); - m_barMode=bm; - setHScrollBarMode(AlwaysOff); - setVScrollBarMode(AlwaysOff); - if (bm==KMultiTabBar::Vertical) - { - box=new TQWidget(viewport()); - mainLayout=new TQVBoxLayout(box); - mainLayout->setAutoAdd(true); - box->setFixedWidth(24); - setFixedWidth(24); - } - else - { - box=new TQWidget(viewport()); - mainLayout=new TQHBoxLayout(box); - mainLayout->setAutoAdd(true); - box->setFixedHeight(24); - setFixedHeight(24); - } - addChild(box); - setFrameStyle(NoFrame); - viewport()->setBackgroundMode(TQt::PaletteBackground); -/* box->setPaletteBackgroundColor(Qt::red); - setPaletteBackgroundColor(Qt::green);*/ -} - -void KMultiTabBarInternal::setStyle(enum KMultiTabBar::KMultiTabBarStyle style) -{ - m_style=style; - for (uint i=0;i<m_tabs.count();i++) - m_tabs.at(i)->setStyle(m_style); - - if ( (m_style==KMultiTabBar::KDEV3) || - (m_style==KMultiTabBar::KDEV3ICON ) ) { - delete mainLayout; - mainLayout=0; - resizeEvent(0); - } else if (mainLayout==0) { - if (m_barMode==KMultiTabBar::Vertical) - { - box=new TQWidget(viewport()); - mainLayout=new TQVBoxLayout(box); - box->setFixedWidth(24); - setFixedWidth(24); - } - else - { - box=new TQWidget(viewport()); - mainLayout=new TQHBoxLayout(box); - box->setFixedHeight(24); - setFixedHeight(24); - } - addChild(box); - for (uint i=0;i<m_tabs.count();i++) - mainLayout->add(m_tabs.at(i)); - mainLayout->setAutoAdd(true); - - } - viewport()->repaint(); -} - -void KMultiTabBarInternal::drawContents ( TQPainter * paint, int clipx, int clipy, int clipw, int cliph ) -{ - TQScrollView::drawContents (paint , clipx, clipy, clipw, cliph ); - - if (m_position==KMultiTabBar::Right) - { - - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,0,viewport()->height()); - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(1,0,1,viewport()->height()); - - - } - else - if (m_position==KMultiTabBar::Left) - { - paint->setPen(colorGroup().light()); - paint->drawLine(23,0,23,viewport()->height()); - paint->drawLine(22,0,22,viewport()->height()); - - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,0,viewport()->height()); - } - else - if (m_position==KMultiTabBar::Bottom) - { - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,viewport()->width(),0); - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(0,1,viewport()->width(),1); - } - else - { - paint->setPen(colorGroup().light()); - paint->drawLine(0,23,viewport()->width(),23); - paint->drawLine(0,22,viewport()->width(),22); - -/* paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,0,viewport()->height());*/ - - } - - -} - -void KMultiTabBarInternal::contentsMousePressEvent(TQMouseEvent *ev) -{ - ev->ignore(); -} - -void KMultiTabBarInternal::mousePressEvent(TQMouseEvent *ev) -{ - ev->ignore(); -} - - -#define CALCDIFF(m_tabs,diff,i) if (m_lines>(int)lines) {\ - /*kdDebug()<<"i="<<i<<" tabCount="<<tabCount<<" space="<<space<<endl;*/ \ - uint ulen=0;\ - diff=0; \ - for (uint i2=i;i2<tabCount;i2++) {\ - uint l1=m_tabs.at(i2)->neededSize();\ - if ((ulen+l1)>space){\ - if (ulen==0) diff=0;\ - else diff=((float)(space-ulen))/(i2-i);\ - break;\ - }\ - ulen+=l1;\ - }\ - } else {diff=0; } - - -void KMultiTabBarInternal::resizeEvent(TQResizeEvent *ev) { -/* kdDebug()<<"KMultiTabBarInternal::resizeEvent"<<endl; - kdDebug()<<"KMultiTabBarInternal::resizeEvent - box geometry"<<box->geometry()<<endl; - kdDebug()<<"KMultiTabBarInternal::resizeEvent - geometry"<<geometry()<<endl;*/ - if (ev) TQScrollView::resizeEvent(ev); - - if ( (m_style==KMultiTabBar::KDEV3) || - (m_style==KMultiTabBar::KDEV3ICON) ){ - box->setGeometry(0,0,width(),height()); - int lines=1; - uint space; - float tmp=0; - if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) - space=width(); - else - space=height(); - - int cnt=0; -//CALCULATE LINES - const uint tabCount=m_tabs.count(); - for (uint i=0;i<tabCount;i++) { - cnt++; - tmp+=m_tabs.at(i)->neededSize(); - if (tmp>space) { - if (cnt>1)i--; - else if (i==(tabCount-1)) break; - cnt=0; - tmp=0; - lines++; - } - } -//SET SIZE & PLACE - float diff=0; - cnt=0; - - if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) { - - setFixedHeight(lines*24); - box->setFixedHeight(lines*24); - m_lines=height()/24-1; - lines=0; - CALCDIFF(m_tabs,diff,0) - tmp=-diff; - - //kdDebug()<<"m_lines recalculated="<<m_lines<<endl; - for (uint i=0;i<tabCount;i++) { - KMultiTabBarTab *tab=m_tabs.at(i); - cnt++; - tmp+=tab->neededSize()+diff; - if (tmp>space) { - //kdDebug()<<"about to start new line"<<endl; - if (cnt>1) { - CALCDIFF(m_tabs,diff,i) - i--; - } - else { - //kdDebug()<<"placing line on old line"<<endl; - kdDebug()<<"diff="<<diff<<endl; - tab->removeEventFilter(this); - tab->move(NEARBYINT(tmp-tab->neededSize()),lines*24); -// tab->setFixedWidth(tab->neededSize()+diff); - tab->setFixedWidth(NEARBYINT(tmp+diff)-tab->x());; - tab->installEventFilter(this); - CALCDIFF(m_tabs,diff,(i+1)) - - } - tmp=-diff; - cnt=0; - lines++; - //kdDebug()<<"starting new line:"<<lines<<endl; - - } else { - //kdDebug()<<"Placing line on line:"<<lines<<" pos: (x/y)=("<<tmp-m_tabs.at(i)->neededSize()<<"/"<<lines*24<<")"<<endl; - //kdDebug()<<"diff="<<diff<<endl; - tab->removeEventFilter(this); - tab->move(NEARBYINT(tmp-tab->neededSize()),lines*24); - tab->setFixedWidth(NEARBYINT(tmp+diff)-tab->x());; - - //tab->setFixedWidth(tab->neededSize()+diff); - tab->installEventFilter(this); - - } - } - } - else { - setFixedWidth(lines*24); - box->setFixedWidth(lines*24); - m_lines=lines=width()/24; - lines=0; - CALCDIFF(m_tabs,diff,0) - tmp=-diff; - - for (uint i=0;i<tabCount;i++) { - KMultiTabBarTab *tab=m_tabs.at(i); - cnt++; - tmp+=tab->neededSize()+diff; - if (tmp>space) { - if (cnt>1) { - CALCDIFF(m_tabs,diff,i); - tmp=-diff; - i--; - } - else { - tab->removeEventFilter(this); - tab->move(lines*24,NEARBYINT(tmp-tab->neededSize())); - tab->setFixedHeight(NEARBYINT(tmp+diff)-tab->y());; - tab->installEventFilter(this); - } - cnt=0; - tmp=-diff; - lines++; - } else { - tab->removeEventFilter(this); - tab->move(lines*24,NEARBYINT(tmp-tab->neededSize())); - tab->setFixedHeight(NEARBYINT(tmp+diff)-tab->y());; - tab->installEventFilter(this); - } - } - } - - - //kdDebug()<<"needed lines:"<<m_lines<<endl; - } else { - int size=0; /*move the calculation into another function and call it only on add tab and tab click events*/ - for (int i=0;i<(int)m_tabs.count();i++) - size+=(m_barMode==KMultiTabBar::Vertical?m_tabs.at(i)->height():m_tabs.at(i)->width()); - if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) - box->setGeometry(0,0,size,height()); - else box->setGeometry(0,0,width(),size); - - } -} - - -void KMultiTabBarInternal::showActiveTabTexts(bool show) -{ - m_showActiveTabTexts=show; -} - - -KMultiTabBarTab* KMultiTabBarInternal::tab(int id) const -{ - for (TQPtrListIterator<KMultiTabBarTab> it(m_tabs);it.current();++it){ - if (it.current()->id()==id) return it.current(); - } - return 0; -} - -bool KMultiTabBarInternal::eventFilter(TQObject *, TQEvent *e) { - if (e->type()==TQEvent::Resize) resizeEvent(0); - return false; -} - -int KMultiTabBarInternal::appendTab(const TQPixmap &pic ,int id,const TQString& text) -{ - KMultiTabBarTab *tab; - m_tabs.append(tab= new KMultiTabBarTab(pic,text,id,box,m_position,m_style)); - tab->installEventFilter(this); - tab->showActiveTabText(m_showActiveTabTexts); - - if (m_style==KMultiTabBar::KONQSBC) - { - if (m_expandedTabSize<tab->neededSize()) { - m_expandedTabSize=tab->neededSize(); - for (uint i=0;i<m_tabs.count();i++) - m_tabs.at(i)->setSize(m_expandedTabSize); - - } else tab->setSize(m_expandedTabSize); - } else tab->updateState(); - tab->show(); - resizeEvent(0); - return 0; -} - -void KMultiTabBarInternal::removeTab(int id) -{ - for (uint pos=0;pos<m_tabs.count();pos++) - { - if (m_tabs.at(pos)->id()==id) - { - m_tabs.remove(pos); - resizeEvent(0); - break; - } - } -} - -void KMultiTabBarInternal::setPosition(enum KMultiTabBar::KMultiTabBarPosition pos) -{ - m_position=pos; - for (uint i=0;i<m_tabs.count();i++) - m_tabs.at(i)->setTabsPosition(m_position); - viewport()->repaint(); -} - -KMultiTabBarButton::KMultiTabBarButton(const TQPixmap& pic,const TQString& text, TQPopupMenu *popup, - int id,TQWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style) - :TQPushButton(TQIconSet(),text,parent),m_style(style) -{ - setIconSet(pic); - setText(text); - m_position=pos; - if (popup) setPopup(popup); - setFlat(true); - setFixedHeight(24); - setFixedWidth(24); - m_id=id; - TQToolTip::add(this,text); - connect(this,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotClicked())); -} - -KMultiTabBarButton::KMultiTabBarButton(const TQString& text, TQPopupMenu *popup, - int id,TQWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style) - :TQPushButton(TQIconSet(),text,parent),m_style(style) -{ - setText(text); - m_position=pos; - if (popup) setPopup(popup); - setFlat(true); - setFixedHeight(24); - setFixedWidth(24); - m_id=id; - TQToolTip::add(this,text); - connect(this,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotClicked())); -} - -KMultiTabBarButton::~KMultiTabBarButton() { -} - -int KMultiTabBarButton::id() const{ - return m_id; -} - -void KMultiTabBarButton::setText(const TQString& text) -{ - TQPushButton::setText(text); - m_text=text; - TQToolTip::add(this,text); -} - -void KMultiTabBarButton::slotClicked() -{ - emit clicked(m_id); -} - -void KMultiTabBarButton::setPosition(KMultiTabBar::KMultiTabBarPosition pos) -{ - m_position=pos; - repaint(); -} - -void KMultiTabBarButton::setStyle(KMultiTabBar::KMultiTabBarStyle style) -{ - m_style=style; - repaint(); -} - -void KMultiTabBarButton::hideEvent( TQHideEvent* he) { - TQPushButton::hideEvent(he); - KMultiTabBar *tb=tqt_dynamic_cast<KMultiTabBar*>(parentWidget()); - if (tb) tb->updateSeparator(); -} - -void KMultiTabBarButton::showEvent( TQShowEvent* he) { - TQPushButton::showEvent(he); - KMultiTabBar *tb=tqt_dynamic_cast<KMultiTabBar*>(parentWidget()); - if (tb) tb->updateSeparator(); -} - - -TQSize KMultiTabBarButton::sizeHint() const -{ - constPolish(); - - int w = 0, h = 0; - - // calculate contents size... -#ifndef QT_NO_ICONSET - if ( iconSet() && !iconSet()->isNull() ) { - int iw = iconSet()->pixmap( TQIconSet::Small, TQIconSet::Normal ).width() + 4; - int ih = iconSet()->pixmap( TQIconSet::Small, TQIconSet::Normal ).height(); - w += iw; - h = QMAX( h, ih ); - } -#endif - if ( isMenuButton() ) - w += style().pixelMetric(TQStyle::PM_MenuButtonIndicator, this); - - if ( pixmap() ) { - TQPixmap *pm = (TQPixmap *)pixmap(); - w += pm->width(); - h += pm->height(); - } else { - TQString s( text() ); - bool empty = s.isEmpty(); - if ( empty ) - s = TQString::fromLatin1("XXXX"); - TQFontMetrics fm = fontMetrics(); - TQSize sz = fm.size( ShowPrefix, s ); - if(!empty || !w) - w += sz.width(); - if(!empty || !h) - h = QMAX(h, sz.height()); - } - - return (style().tqsizeFromContents(TQStyle::CT_ToolButton, this, TQSize(w, h)). - expandedTo(TQApplication::globalStrut())); -} - - -KMultiTabBarTab::KMultiTabBarTab(const TQPixmap& pic, const TQString& text, - int id,TQWidget *parent,KMultiTabBar::KMultiTabBarPosition pos, - KMultiTabBar::KMultiTabBarStyle style) - :KMultiTabBarButton(text,0,id,parent,pos,style), - m_showActiveTabText(false) -{ - d=new KMultiTabBarTabPrivate(); - setIcon(pic); - m_expandedSize=24; - setToggleButton(true); -} - -KMultiTabBarTab::~KMultiTabBarTab() { - delete d; -} - - -void KMultiTabBarTab::setTabsPosition(KMultiTabBar::KMultiTabBarPosition pos) -{ - if ((pos!=m_position) && ((pos==KMultiTabBar::Left) || (pos==KMultiTabBar::Right))) { - if (!d->pix.isNull()) { - TQWMatrix temp;// (1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); - temp.rotate(180); - d->pix=d->pix.xForm(temp); - setIconSet(d->pix); - } - } - - setPosition(pos); -// repaint(); -} - -void KMultiTabBarTab::setIcon(const TQString& icon) -{ - TQPixmap pic=SmallIcon(icon); - setIcon(pic); -} - -void KMultiTabBarTab::setIcon(const TQPixmap& icon) -{ - - if (m_style!=KMultiTabBar::KDEV3) { - if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) { - TQWMatrix rotateMatrix; - if (m_position==KMultiTabBar::Left) - rotateMatrix.rotate(90); - else - rotateMatrix.rotate(-90); - TQPixmap pic=icon.xForm(rotateMatrix); //TODO FIX THIS, THIS SHOWS WINDOW - d->pix=pic; - setIconSet(pic); - } else setIconSet(icon); - } -} - -void KMultiTabBarTab::slotClicked() -{ - updateState(); - KMultiTabBarButton::slotClicked(); -} - -void KMultiTabBarTab::setState(bool b) -{ - setOn(b); - updateState(); -} - -void KMultiTabBarTab::updateState() -{ - - if (m_style!=KMultiTabBar::KONQSBC) { - if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isOn())) { - TQPushButton::setText(m_text); - } else { - kdDebug()<<"KMultiTabBarTab::updateState(): setting text to an empty TQString***************"<<endl; - TQPushButton::setText(TQString::null); - } - - if ((m_position==KMultiTabBar::Right || m_position==KMultiTabBar::Left)) { - setFixedWidth(24); - if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isOn())) { - setFixedHeight(KMultiTabBarButton::sizeHint().width()); - } else setFixedHeight(36); - } else { - setFixedHeight(24); - if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isOn())) { - setFixedWidth(KMultiTabBarButton::sizeHint().width()); - } else setFixedWidth(36); - } - } else { - if ((!isOn()) || (!m_showActiveTabText)) - { - setFixedWidth(24); - setFixedHeight(24); - return; - } - if ((m_position==KMultiTabBar::Right || m_position==KMultiTabBar::Left)) - setFixedHeight(m_expandedSize); - else - setFixedWidth(m_expandedSize); - } - TQApplication::sendPostedEvents(0,TQEvent::Paint | TQEvent::Move | TQEvent::Resize | TQEvent::LayoutHint); - TQApplication::flush(); -} - -int KMultiTabBarTab::neededSize() -{ - return (((m_style!=KMultiTabBar::KDEV3)?24:0)+TQFontMetrics(TQFont()).width(m_text)+6); -} - -void KMultiTabBarTab::setSize(int size) -{ - m_expandedSize=size; - updateState(); -} - -void KMultiTabBarTab::showActiveTabText(bool show) -{ - m_showActiveTabText=show; -} - -void KMultiTabBarTab::drawButtonLabel(TQPainter *p) { - drawButton(p); -} -void KMultiTabBarTab::drawButton(TQPainter *paint) -{ - if (m_style!=KMultiTabBar::KONQSBC) drawButtonStyled(paint); - else drawButtonClassic(paint); -} - -void KMultiTabBarTab::drawButtonStyled(TQPainter *paint) { - - TQSize sh; - const int width = 36; // rotated - const int height = 24; - if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isOn())) { - if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) - sh=TQSize(this->height(),this->width());//KMultiTabBarButton::sizeHint(); - else sh=TQSize(this->width(),this->height()); - } - else - sh=TQSize(width,height); - - TQPixmap pixmap( sh.width(),height); ///,sh.height()); - pixmap.fill(eraseColor()); - TQPainter painter(&pixmap); - - - TQStyle::SFlags st=TQStyle::Style_Default; - - st|=TQStyle::Style_Enabled; - - if (isOn()) st|=TQStyle::Style_On; - - style().drawControl(TQStyle::CE_PushButton,&painter,this, TQRect(0,0,pixmap.width(),pixmap.height()), colorGroup(),st); - style().drawControl(TQStyle::CE_PushButtonLabel,&painter,this, TQRect(0,0,pixmap.width(),pixmap.height()), colorGroup(),st); - - switch (m_position) { - case KMultiTabBar::Left: - paint->rotate(-90); - paint->drawPixmap(1-pixmap.width(),0,pixmap); - break; - case KMultiTabBar::Right: - paint->rotate(90); - paint->drawPixmap(0,1-pixmap.height(),pixmap); - break; - - default: - paint->drawPixmap(0,0,pixmap); - break; - } -// style().drawControl(TQStyle::CE_PushButtonLabel,painter,this, TQRect(0,0,pixmap.width(),pixmap.height()), -// colorGroup(),TQStyle::Style_Enabled); - - -} - -void KMultiTabBarTab::drawButtonClassic(TQPainter *paint) -{ - TQPixmap pixmap; - if ( iconSet()) - pixmap = iconSet()->pixmap( TQIconSet::Small, TQIconSet::Normal ); - paint->fillRect(0, 0, 24, 24, colorGroup().background()); - - if (!isOn()) - { - - if (m_position==KMultiTabBar::Right) - { - paint->fillRect(0,0,21,21,TQBrush(colorGroup().background())); - - paint->setPen(colorGroup().background().dark(150)); - paint->drawLine(0,22,23,22); - - paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,0,23); - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(1,0,1,23); - - } - else - if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) - { - paint->fillRect(0,1,23,22,TQBrush(colorGroup().background())); - - paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(23,0,23,23); - - - paint->setPen(colorGroup().light()); - paint->drawLine(0,22,23,22); - paint->drawLine(0,23,23,23); - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,23,0); - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(0,1,23,1); - - } - else - { - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(0,23,23,23); - paint->fillRect(0,0,23,21,TQBrush(colorGroup().background())); - paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - - paint->setPen(colorGroup().light()); - paint->drawLine(23,0,23,23); - paint->drawLine(22,0,22,23); - - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,0,23); - - } - - - } - else - { - if (m_position==KMultiTabBar::Right) - { - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,height()-1,23,height()-1); - paint->drawLine(0,height()-2,23,height()-2); - paint->drawLine(23,0,23,height()-1); - paint->drawLine(22,0,22,height()-1); - paint->fillRect(0,0,21,height()-3,TQBrush(colorGroup().light())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - - if (m_showActiveTabText) - { - if (height()<25+4) return; - - TQPixmap tpixmap(height()-25-3, width()-2); - TQPainter painter(&tpixmap); - - painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),TQBrush(colorGroup().light())); - - painter.setPen(colorGroup().text()); - painter.drawText(0,+width()/2+TQFontMetrics(TQFont()).height()/2,m_text); - - paint->rotate(90); - kdDebug()<<"tpixmap.width:"<<tpixmap.width()<<endl; - paint->drawPixmap(25,-tpixmap.height()+1,tpixmap); - } - - } - else - if (m_position==KMultiTabBar::Top) - { - paint->fillRect(0,0,width()-1,23,TQBrush(colorGroup().light())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - if (m_showActiveTabText) - { - paint->setPen(colorGroup().text()); - paint->drawText(25,height()/2+TQFontMetrics(TQFont()).height()/2,m_text); - } - } - else - if (m_position==KMultiTabBar::Bottom) - { - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,23,width()-1,23); - paint->drawLine(0,22,width()-1,22); - paint->fillRect(0,0,width()-1,21,TQBrush(colorGroup().light())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - if (m_showActiveTabText) - { - paint->setPen(colorGroup().text()); - paint->drawText(25,height()/2+TQFontMetrics(TQFont()).height()/2,m_text); - } - - } - else - { - - - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,height()-1,23,height()-1); - paint->drawLine(0,height()-2,23,height()-2); - paint->fillRect(0,0,23,height()-3,TQBrush(colorGroup().light())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - if (m_showActiveTabText) - { - - if (height()<25+4) return; - - TQPixmap tpixmap(height()-25-3, width()-2); - TQPainter painter(&tpixmap); - - painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),TQBrush(colorGroup().light())); - - painter.setPen(colorGroup().text()); - painter.drawText(tpixmap.width()-TQFontMetrics(TQFont()).width(m_text),+width()/2+TQFontMetrics(TQFont()).height()/2,m_text); - - paint->rotate(-90); - kdDebug()<<"tpixmap.width:"<<tpixmap.width()<<endl; - - paint->drawPixmap(-24-tpixmap.width(),2,tpixmap); - - } - - } - - } -} - - - - - - - -KMultiTabBar::KMultiTabBar(KMultiTabBarMode bm, TQWidget *parent,const char *name):TQWidget(parent,name) -{ - m_buttons.setAutoDelete(false); - if (bm==Vertical) - { - m_l=new TQVBoxLayout(this); - setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Expanding, true); -// setFixedWidth(24); - } - else - { - m_l=new TQHBoxLayout(this); - setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Fixed, true); -// setFixedHeight(24); - } - m_l->setMargin(0); - m_l->setAutoAdd(false); - - m_internal=new KMultiTabBarInternal(this,bm); - setPosition((bm==KMultiTabBar::Vertical)?KMultiTabBar::Right:KMultiTabBar::Bottom); - setStyle(VSNET); - // setStyle(KDEV3); - //setStyle(KONQSBC); - m_l->insertWidget(0,m_internal); - m_l->insertWidget(0,m_btnTabSep=new TQFrame(this)); - m_btnTabSep->setFixedHeight(4); - m_btnTabSep->setFrameStyle(TQFrame::Panel | TQFrame::Sunken); - m_btnTabSep->setLineWidth(2); - m_btnTabSep->hide(); - - updateGeometry(); -} - -KMultiTabBar::~KMultiTabBar() { -} - -/*int KMultiTabBar::insertButton(TQPixmap pic,int id ,const TQString&) -{ - (new KToolbarButton(pic,id,m_internal))->show(); - return 0; -}*/ - -int KMultiTabBar::appendButton(const TQPixmap &pic ,int id,TQPopupMenu *popup,const TQString&) -{ - KMultiTabBarButton *btn; - m_buttons.append(btn= new KMultiTabBarButton(pic,TQString::null, - popup,id,this,m_position,m_internal->m_style)); - m_l->insertWidget(0,btn); - btn->show(); - m_btnTabSep->show(); - return 0; -} - -void KMultiTabBar::updateSeparator() { - bool hideSep=true; - for (TQPtrListIterator<KMultiTabBarButton> it(m_buttons);it.current();++it){ - if (it.current()->isVisibleTo(this)) { - hideSep=false; - break; - } - } - if (hideSep) m_btnTabSep->hide(); - else m_btnTabSep->show(); - -} - -int KMultiTabBar::appendTab(const TQPixmap &pic ,int id ,const TQString& text) -{ - m_internal->appendTab(pic,id,text); - return 0; -} - -KMultiTabBarButton* KMultiTabBar::button(int id) const -{ - for (TQPtrListIterator<KMultiTabBarButton> it(m_buttons);it.current();++it){ - if (it.current()->id()==id) return it.current(); - } - return 0; -} - -KMultiTabBarTab* KMultiTabBar::tab(int id) const -{ - return m_internal->tab(id); -} - - - -void KMultiTabBar::removeButton(int id) -{ - for (uint pos=0;pos<m_buttons.count();pos++) - { - if (m_buttons.at(pos)->id()==id) - { - m_buttons.take(pos)->deleteLater(); - break; - } - } - if (m_buttons.count()==0) m_btnTabSep->hide(); -} - -void KMultiTabBar::removeTab(int id) -{ - m_internal->removeTab(id); -} - -void KMultiTabBar::setTab(int id,bool state) -{ - KMultiTabBarTab *ttab=tab(id); - if (ttab) - { - ttab->setState(state); - } -} - -bool KMultiTabBar::isTabRaised(int id) const -{ - KMultiTabBarTab *ttab=tab(id); - if (ttab) - { - return ttab->isOn(); - } - - return false; -} - - -void KMultiTabBar::showActiveTabTexts(bool show) -{ - m_internal->showActiveTabTexts(show); -} - -void KMultiTabBar::setStyle(KMultiTabBarStyle style) -{ - m_internal->setStyle(style); -} - -KMultiTabBar::KMultiTabBarStyle KMultiTabBar::tabStyle() const -{ - return m_internal->m_style; -} - -void KMultiTabBar::setPosition(KMultiTabBarPosition pos) -{ - m_position=pos; - m_internal->setPosition(pos); - for (uint i=0;i<m_buttons.count();i++) - m_buttons.at(i)->setPosition(pos); -} - -KMultiTabBar::KMultiTabBarPosition KMultiTabBar::position() const -{ - return m_position; -} -void KMultiTabBar::fontChange(const TQFont& /* oldFont */) -{ - for (uint i=0;i<tabs()->count();i++) - tabs()->at(i)->resize(); - repaint(); -} - -TQPtrList<KMultiTabBarTab>* KMultiTabBar::tabs() {return m_internal->tabs();} -TQPtrList<KMultiTabBarButton>* KMultiTabBar::buttons() {return &m_buttons;} - diff --git a/kutils/kmultitabbar.h b/kutils/kmultitabbar.h deleted file mode 100644 index ffc3fca5f..000000000 --- a/kutils/kmultitabbar.h +++ /dev/null @@ -1,316 +0,0 @@ -/*************************************************************************** - kmultitabbar.h - description - ------------------- - begin : 2001 - copyright : (C) 2001,2002,2003 by Joseph Wenninger <jowenn@kde.org> - ***************************************************************************/ - -/*************************************************************************** - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - ***************************************************************************/ - -#ifndef _KMultitabbar_h_ -#define _KMultitabbar_h_ - -#include <tqscrollview.h> -#include <tqvbox.h> -#include <tqhbox.h> -#include <tqlayout.h> -#include <tqstring.h> -#include <tqptrlist.h> -#include <tqpushbutton.h> - -#include <tdelibs_export.h> - -class TQPixmap; -class TQPainter; -class TQFrame; - -class KMultiTabBarPrivate; -class KMultiTabBarTabPrivate; -class KMultiTabBarButtonPrivate; -class KMultiTabBarInternal; - -/** - * @ingroup main - * @ingroup multitabbar - * A Widget for horizontal and vertical tabs. - * It is possible to add normal buttons to the top/left - * The handling if only one tab at a time or multiple tabs - * should be raisable is left to the "user". - *@author Joseph Wenninger - */ -class KUTILS_EXPORT KMultiTabBar: public TQWidget -{ - Q_OBJECT -public: - /** - * The tab bar's orientation. Also constraints the bar's position. - */ - enum KMultiTabBarMode { - Horizontal, ///< Horizontal orientation (i.e. on top or bottom) - Vertical ///< Vertical orientation (i.e. on the left or right hand side) - }; - - /** - * The tab bar's position - */ - enum KMultiTabBarPosition { - Left, ///< Left hand side - Right, ///< Right hand side - Top, ///< On top - Bottom ///< On bottom - }; - - /** - * The list of available styles for KMultiTabBar - */ - enum KMultiTabBarStyle { - VSNET=0, ///< Visual Studio .Net like (only show the text of active tabs) - KDEV3=1, ///< KDevelop 3 like (always show the text) - KONQSBC=2, ///< Konqueror's classic sidebar style (unthemed) (currently disabled) - KDEV3ICON=3, ///< KDevelop 3 like with icons - STYLELAST=0xffff ///< Last style - }; - - /** - * Constructor. - * @param bm The tab bar's orientation - * @param parent The parent widget - * @param name The widget's name - */ - KMultiTabBar(KMultiTabBarMode bm,TQWidget *parent=0,const char *name=0); - - /** - * Destructor. - */ - virtual ~KMultiTabBar(); - - /** - * append a new button to the button area. The button can later on be accessed with button(ID) - * eg for connecting signals to it - * @param pic a pixmap for the button - * @param id an arbitraty ID value. It will be emitted in the clicked signal for identifying the button - * if more than one button is connected to a signals. - * @param popup A popup menu which should be displayed if the button is clicked - * @param not_used_yet will be used for a popup text in the future - */ - int appendButton(const TQPixmap &pic,int id=-1,TQPopupMenu* popup=0,const TQString& not_used_yet=TQString::null); - /** - * remove a button with the given ID - */ - void removeButton(int id); - /** - * append a new tab to the tab area. It can be accessed lateron with tabb(id); - * @param pic a bitmap for the tab - * @param id an arbitrary ID which can be used later on to identify the tab - * @param text if a mode with text is used it will be the tab text, otherwise a mouse over hint - * @return Always zero. Can be safely ignored. - */ - int appendTab(const TQPixmap &pic,int id=-1,const TQString& text=TQString::null); - /** - * remove a tab with a given ID - * @param id The ID of the tab to remove - */ - void removeTab(int id); - /** - * set a tab to "raised" - * @param id The ID of the tab to manipulate - * @param state true == activated/raised, false == not active - */ - void setTab(int id ,bool state); - /** - * return the state of a tab, identified by it's ID - * @param id The ID of the tab to raise - */ - bool isTabRaised(int id) const; - /** - * get a pointer to a button within the button area identified by its ID - * @param id The id of the tab - */ - class KMultiTabBarButton *button(int id) const; - - /** - * get a pointer to a tab within the tab area, identified by its ID - */ - class KMultiTabBarTab *tab(int id) const; - /** - * set the real position of the widget. - * @param pos if the mode is horizontal, only use top, bottom, if it is vertical use left or right - */ - void setPosition(KMultiTabBarPosition pos); - /** - * get the tabbar position. - * @return The tab bar's position - */ - KMultiTabBarPosition position() const; - /** - * set the display style of the tabs - * @param style The new display style - */ - void setStyle(KMultiTabBarStyle style); - /** - * get the display style of the tabs - * @return display style - */ - KMultiTabBarStyle tabStyle() const; - /** - * Returns the list of pointers to the tabs of type KMultiTabBarTab. - * @return The list of tabs. - * @warning be careful, don't delete tabs yourself and don't delete the list itself - */ - TQPtrList<KMultiTabBarTab>* tabs(); - /** - * Returns the list of pointers to the tab buttons of type KMultiTabBarButton. - * @return The list of tab buttons. - * @warning be careful, don't delete buttons yourself and don't delete the list itself - */ - TQPtrList<KMultiTabBarButton>* buttons(); - - /** - * might vanish, not sure yet - */ - void showActiveTabTexts(bool show=true); -protected: - friend class KMultiTabBarButton; - virtual void fontChange( const TQFont& ); - void updateSeparator(); -private: - class KMultiTabBarInternal *m_internal; - TQBoxLayout *m_l; - TQFrame *m_btnTabSep; - TQPtrList<KMultiTabBarButton> m_buttons; - KMultiTabBarPosition m_position; - KMultiTabBarPrivate *d; -}; - -/** - * @ingroup multitabbar - * This class represents a tab bar button in a KMultiTabBarWidget. - * This class should never be created except with the appendButton call of KMultiTabBar - */ -class KUTILS_EXPORT KMultiTabBarButton: public TQPushButton -{ - Q_OBJECT -public: - /** @internal */ - KMultiTabBarButton(const TQPixmap& pic,const TQString&, TQPopupMenu *popup, - int id,TQWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style); - /** @internal */ - KMultiTabBarButton(const TQString&, TQPopupMenu *popup, - int id,TQWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style); - /** - * Destructor - */ - virtual ~KMultiTabBarButton(); - /** - * Returns the tab's ID - * @return The tab's ID - */ - int id() const; - -public slots: - /** - * this is used internaly, but can be used by the user, if (s)he wants to - * It the according call of KMultiTabBar is invoked though this modifications will be overwritten - */ - void setPosition(KMultiTabBar::KMultiTabBarPosition); - /** - * this is used internaly, but can be used by the user, if (s)he wants to - * It the according call of KMultiTabBar is invoked though this modifications will be overwritten - */ - void setStyle(KMultiTabBar::KMultiTabBarStyle); - - /** - * modify the text of the button - */ - void setText(const TQString &); - - TQSize sizeHint() const; - -protected: - KMultiTabBar::KMultiTabBarPosition m_position; - KMultiTabBar::KMultiTabBarStyle m_style; - TQString m_text; - virtual void hideEvent( class TQHideEvent*); - virtual void showEvent( class TQShowEvent*); -private: - int m_id; - KMultiTabBarButtonPrivate *d; -signals: - /** - * this is emitted if the button is clicked - * @param id the ID identifying the button - */ - void clicked(int id); -protected slots: - virtual void slotClicked(); -}; - -/** - * @ingroup multitabbar - * This class represents a tab bar's tab in a KMultiTabBarWidget. - * This class should never be created except with the appendTab call of KMultiTabBar - */ -class KUTILS_EXPORT KMultiTabBarTab: public KMultiTabBarButton -{ - Q_OBJECT -public: - /** @internal */ - KMultiTabBarTab(const TQPixmap& pic,const TQString&,int id,TQWidget *parent, - KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style); - /** - * Destructor. - */ - virtual ~KMultiTabBarTab(); - /** - * set the active state of the tab - * @param state @c true if the tab should become active, @c false otherwise - */ - void setState(bool state); - /** - * choose if the text should always be displayed - * this is only used in classic mode if at all - * @param show Whether or not to show the text - */ - void showActiveTabText(bool show); - /** - * Resized the tab to the needed size. - */ - void resize(){ setSize( neededSize() ); } -private: - bool m_showActiveTabText; - int m_expandedSize; - KMultiTabBarTabPrivate *d; -protected: - friend class KMultiTabBarInternal; - void setSize(int); - int neededSize(); - void updateState(); - virtual void drawButton(TQPainter *); - virtual void drawButtonLabel(TQPainter *); - void drawButtonStyled(TQPainter *); - void drawButtonClassic(TQPainter *); -protected slots: - virtual void slotClicked(); - void setTabsPosition(KMultiTabBar::KMultiTabBarPosition); - -public slots: - virtual void setIcon(const TQString&); - virtual void setIcon(const TQPixmap&); -}; - -#endif diff --git a/kutils/kmultitabbar_p.h b/kutils/kmultitabbar_p.h deleted file mode 100644 index f8d552b40..000000000 --- a/kutils/kmultitabbar_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - kmultitabbar_p.h - description - ------------------- - begin : 2003 - copyright : (C) 2003 by Joseph Wenninger <jowenn@kde.org> - ***************************************************************************/ - -/*************************************************************************** - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - ***************************************************************************/ - -#ifndef K_MULTI_TAB_BAR_P_H -#define K_MULTI_TAB_BAR_P_H -#include <tqscrollview.h> -#include <kmultitabbar.h> - -class KMultiTabBarInternal: public TQScrollView -{ - Q_OBJECT -public: - KMultiTabBarInternal(TQWidget *parent,KMultiTabBar::KMultiTabBarMode bm); - int appendTab(const TQPixmap &,int=-1,const TQString& =TQString::null); - KMultiTabBarTab *tab(int) const; - void removeTab(int); - void setPosition(enum KMultiTabBar::KMultiTabBarPosition pos); - void setStyle(enum KMultiTabBar::KMultiTabBarStyle style); - void showActiveTabTexts(bool show); - TQPtrList<KMultiTabBarTab>* tabs(){return &m_tabs;} -private: - friend class KMultiTabBar; - TQWidget *box; - TQBoxLayout *mainLayout; - TQPtrList<KMultiTabBarTab> m_tabs; - enum KMultiTabBar::KMultiTabBarPosition m_position; - bool m_showActiveTabTexts; - enum KMultiTabBar::KMultiTabBarStyle m_style; - int m_expandedTabSize; - int m_lines; - KMultiTabBar::KMultiTabBarMode m_barMode; -protected: - virtual bool eventFilter(TQObject *,TQEvent*); - virtual void drawContents ( TQPainter *, int, int, int, int); - - /** - * [contentsM|m]ousePressEvent are reimplemented from QScrollView - * in order to ignore all mouseEvents on the viewport, so that the - * parent can handle them. - */ - virtual void contentsMousePressEvent(TQMouseEvent *); - virtual void mousePressEvent(TQMouseEvent *); - virtual void resizeEvent(TQResizeEvent *); -}; -#endif - diff --git a/kutils/kplugininfo.cpp b/kutils/kplugininfo.cpp deleted file mode 100644 index aec0a095c..000000000 --- a/kutils/kplugininfo.cpp +++ /dev/null @@ -1,359 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "kplugininfo.h" -#include <ksimpleconfig.h> -#include <ktrader.h> -#include <kdebug.h> -#include <kconfigbase.h> -#include <kglobal.h> -#include <kstandarddirs.h> -#include <kdesktopfile.h> -#include <kservice.h> - -class KPluginInfo::KPluginInfoPrivate -{ - public: - KPluginInfoPrivate() - : hidden( false ) - , enabledbydefault( false ) - , pluginenabled( false ) - , config( 0 ) - , kcmservicesCached( false ) - {} - - ~KPluginInfoPrivate() - { - delete config; - } - - TQString specfile; // the filename of the file containing all the info - TQString name; - TQString comment; - TQString icon; - TQString author; - TQString email; - TQString pluginName; // the name attribute in the .rc file - TQString version; - TQString website; // URL to the website of the plugin/author - TQString category; - TQString license; - TQStringList dependencies; - - bool hidden; - bool enabledbydefault; - bool pluginenabled; - - TDEConfig * config; - TQString configgroup; - KService::Ptr service; - TQValueList<KService::Ptr> kcmservices; - bool kcmservicesCached; -}; - -KPluginInfo::KPluginInfo( const TQString & filename, const char* resource ) -: d( new KPluginInfoPrivate ) -{ - KDesktopFile file( filename, true, resource ); - - d->specfile = filename; - - if( filename.endsWith( TQString::fromAscii( ".desktop" ) ) ) - { - file.setDesktopGroup(); - d->hidden = file.readBoolEntry( "Hidden", false ); - if( d->hidden ) - return; - - d->name = file.readName(); - d->comment = file.readComment(); - d->icon = file.readEntry( "Icon" ); - d->author = file.readEntry( "X-TDE-PluginInfo-Author" ); - d->email = file.readEntry( "X-TDE-PluginInfo-Email" ); - d->pluginName = file.readEntry( "X-TDE-PluginInfo-Name" ); - d->version = file.readEntry( "X-TDE-PluginInfo-Version" ); - d->website = file.readEntry( "X-TDE-PluginInfo-Website" ); - d->category = file.readEntry( "X-TDE-PluginInfo-Category" ); - d->license = file.readEntry( "X-TDE-PluginInfo-License" ); - d->dependencies = file.readListEntry( "X-TDE-PluginInfo-Depends" ); - d->enabledbydefault = file.readBoolEntry( - "X-TDE-PluginInfo-EnabledByDefault", false ); - } - else if( filename.endsWith( TQString::fromAscii( ".plugin" ) ) ) - { // provided for noatun style .plugin files compatibility - - d->name = file.readName(); - d->comment = file.readComment(); - d->icon = file.readEntry( "Icon" ); - d->author = file.readEntry( "Author" ); - d->email = file.readEntry( "Email" ); - d->pluginName = file.readPathEntry( "Filename" ); - // no version - d->website = file.readEntry( "Site" ); - d->category = file.readEntry( "Type" ); - d->license = file.readEntry( "License" ); - d->dependencies = file.readListEntry( "Require" ); - } -} - -KPluginInfo::KPluginInfo( const KService::Ptr service ) -: d( new KPluginInfoPrivate ) -{ - d->service = service; - d->specfile = service->desktopEntryPath(); - - if ( service->isDeleted() ) - { - d->hidden = true; - return; - } - - d->name = service->name(); - d->comment = service->comment(); - d->icon = service->icon(); - d->author = service->property( "X-TDE-PluginInfo-Author" ).toString(); - d->email = service->property( "X-TDE-PluginInfo-Email" ).toString(); - d->pluginName = service->property( "X-TDE-PluginInfo-Name" ).toString(); - d->version = service->property( "X-TDE-PluginInfo-Version" ).toString(); - d->website = service->property( "X-TDE-PluginInfo-Website" ).toString(); - d->category = service->property( "X-TDE-PluginInfo-Category" ).toString(); - d->license = service->property( "X-TDE-PluginInfo-License" ).toString(); - d->dependencies = - service->property( "X-TDE-PluginInfo-Depends" ).toStringList(); - TQVariant tmp = service->property( "X-TDE-PluginInfo-EnabledByDefault" ); - d->enabledbydefault = tmp.isValid() ? tmp.toBool() : false; -} - -//X KPluginInfo::KPluginInfo() -//X : d( new KPluginInfoPrivate ) -//X { -//X d->hidden = true; -//X } - -KPluginInfo::~KPluginInfo() -{ - delete d; -} - -TQValueList<KPluginInfo*> KPluginInfo::fromServices( const KService::List & services, TDEConfig * config, const TQString & group ) -{ - TQValueList<KPluginInfo*> infolist; - KPluginInfo * info; - for( KService::List::ConstIterator it = services.begin(); - it != services.end(); ++it ) - { - info = new KPluginInfo( *it ); - info->setConfig( config, group ); - infolist += info; - } - return infolist; -} - -TQValueList<KPluginInfo*> KPluginInfo::fromFiles( const TQStringList & files, TDEConfig * config, const TQString & group ) -{ - TQValueList<KPluginInfo*> infolist; - for( TQStringList::ConstIterator it = files.begin(); it != files.end(); ++it ) - { - KPluginInfo * info = new KPluginInfo( *it ); - info->setConfig( config, group ); - infolist += info; - } - return infolist; -} - -TQValueList<KPluginInfo*> KPluginInfo::fromKPartsInstanceName( const TQString & name, TDEConfig * config, const TQString & group ) -{ - TQStringList files = TDEGlobal::dirs()->findAllResources( "data", name + - "/kpartplugins/*.desktop", true, false ); - return fromFiles( files, config, group ); -} - -bool KPluginInfo::isHidden() const -{ - return d->hidden; -} - -void KPluginInfo::setPluginEnabled( bool enabled ) -{ - kdDebug( 703 ) << k_funcinfo << endl; - d->pluginenabled = enabled; -} - -bool KPluginInfo::isPluginEnabled() const -{ - kdDebug( 703 ) << k_funcinfo << endl; - return d->pluginenabled; -} - -bool KPluginInfo::isPluginEnabledByDefault() const -{ - kdDebug( 703 ) << k_funcinfo << endl; - return d->enabledbydefault; -} - -const TQString & KPluginInfo::name() const -{ - return d->name; -} - -const TQString & KPluginInfo::comment() const -{ - return d->comment; -} - -const TQString & KPluginInfo::icon() const -{ - return d->icon; -} - -const TQString & KPluginInfo::specfile() const -{ - return d->specfile; -} - -const TQString & KPluginInfo::author() const -{ - return d->author; -} - -const TQString & KPluginInfo::email() const -{ - return d->email; -} - -const TQString & KPluginInfo::category() const -{ - return d->category; -} - -const TQString & KPluginInfo::pluginName() const -{ - return d->pluginName; -} - -const TQString & KPluginInfo::version() const -{ - return d->version; -} - -const TQString & KPluginInfo::website() const -{ - return d->website; -} - -const TQString & KPluginInfo::license() const -{ - return d->license; -} - -const TQStringList & KPluginInfo::dependencies() const -{ - return d->dependencies; -} - -KService::Ptr KPluginInfo::service() const -{ - return d->service; -} - -const TQValueList<KService::Ptr> & KPluginInfo::kcmServices() const -{ - if ( !d->kcmservicesCached ) - { - d->kcmservices = KTrader::self()->query( "TDECModule", "'" + d->pluginName + - "' in [X-TDE-ParentComponents]" ); - kdDebug( 703 ) << "found " << d->kcmservices.count() << " offers for " << - d->pluginName << endl; - - d->kcmservicesCached = true; - } - - return d->kcmservices; -} - -void KPluginInfo::setConfig( TDEConfig * config, const TQString & group ) -{ - d->config = config; - d->configgroup = group; -} - -TDEConfig * KPluginInfo::config() const -{ - return d->config; -} - -const TQString & KPluginInfo::configgroup() const -{ - return d->configgroup; -} - -TQVariant KPluginInfo::property( const TQString & key ) const -{ - if( d->service ) - return d->service->property( key ); - else - return TQVariant(); -} - -TQVariant KPluginInfo::operator[]( const TQString & key ) const -{ - return property( key ); -} - -void KPluginInfo::save( TDEConfigGroup * config ) -{ - kdDebug( 703 ) << k_funcinfo << endl; - if( 0 == config ) - { - if( 0 == d->config ) - { - kdWarning( 703 ) << "no TDEConfigGroup, cannot save" << endl; - return; - } - d->config->setGroup( d->configgroup ); - d->config->writeEntry( d->pluginName + "Enabled", isPluginEnabled() ); - } - else - config->writeEntry( d->pluginName + "Enabled", isPluginEnabled() ); -} - -void KPluginInfo::load( TDEConfigGroup * config ) -{ - kdDebug( 703 ) << k_funcinfo << endl; - if( 0 == config ) - { - if( 0 == d->config ) - { - kdWarning( 703 ) << "no TDEConfigGroup, cannot load" << endl; - return; - } - d->config->setGroup( d->configgroup ); - setPluginEnabled( d->config->readBoolEntry( d->pluginName + "Enabled", isPluginEnabledByDefault() ) ); - } - else - setPluginEnabled( config->readBoolEntry( d->pluginName + "Enabled", isPluginEnabledByDefault() ) ); -} - -void KPluginInfo::defaults() -{ - kdDebug( 703 ) << k_funcinfo << endl; - setPluginEnabled( isPluginEnabledByDefault() ); -} - -// vim: sw=4 sts=4 et diff --git a/kutils/kplugininfo.desktop b/kutils/kplugininfo.desktop deleted file mode 100644 index d88712b9d..000000000 --- a/kutils/kplugininfo.desktop +++ /dev/null @@ -1,107 +0,0 @@ -[Desktop Entry] -Type=ServiceType -X-TDE-ServiceType=KPluginInfo -Name=TDE Plugin Information -Name[af]=TDE Inprop module Informasie -Name[ar]=معلومات ملحقات كيدي -Name[az]=TDE Əlavə Mə'lumatı -Name[be]=Звесткі аб дадатках TDE -Name[bg]=Информация за приставките в TDE -Name[bn]=কে.ডি.ই. প্লাগ-ইন তথ্য -Name[br]=Titouroù al lugent TDE -Name[bs]=TDE informacije o dodatku -Name[ca]=Connector informatiu de TDE -Name[cs]=Informace o pluginu TDE -Name[csb]=Wëdowiédzô ò pluginsach TDE -Name[cy]=Gwybodaeth Ategynnau TDE -Name[da]=TDE's plugin-information -Name[de]=TDE-Modul-Information -Name[el]=Πληροφορίες πρόσθετου TDE -Name[eo]=TDEa kromaĵinformo -Name[es]=Información de los plugin de TDE -Name[et]=TDE plugina info -Name[eu]=TDEren plugin-en informazioa -Name[fa]=اطلاعات وصلۀ TDE -Name[fi]=TDE:n lisäosatiedot -Name[fr]=Information sur le module TDE -Name[fy]=TDE Plugin ynformaasje -Name[ga]=Eolas Bhreiseán TDE -Name[gl]=Información de Plugin de TDE -Name[he]=מידע על תוספים של TDE -Name[hi]=केडीई प्लगिन जानकारी -Name[hr]=Podaci o TDE dodatku -Name[hu]=A TDE bővítőmodulok áttekintése -Name[id]=Informasi Plugin TDE -Name[is]=TDE íforritsupplýsingar -Name[it]=Informazioni plugin TDE -Name[ja]=TDE プラグイン情報 -Name[ka]=TDE მოდულის ინფორმაცია -Name[kk]=TDE модулі туралы мәлімет -Name[km]=ព័ត៌មានកម្មវិធីជំនួយខាងក្នុង TDE -Name[ko]=TDE 플러그인 정보 -Name[lb]=TDE-Plugininformatioun -Name[lt]=TDE priedų informacija -Name[lv]=TDE spraudņa informācija -Name[mk]=TDE Информација за приклучок -Name[mn]=КДЭ плугин мэдээлэл -Name[ms]=Maklumat Plugmasuk TDE -Name[nb]=TDEs informasjon om programtillegg -Name[nds]=Plugin-Informatschoon -Name[ne]=TDE प्लगइन सूचना -Name[nl]=TDE-plugininformatie -Name[nn]=Informasjon om TDE-programtillegg -Name[pa]=TDE ਪਲੱਗਿੰਨ ਜਾਣਕਾਰੀ -Name[pl]=Informacja o wtyczkach TDE -Name[pt]=Informação do 'Plugin' do TDE -Name[pt_BR]=Informações do Plug-in do TDE -Name[ro]=Informaţii modul TDE -Name[ru]=Сведения о модуле TDE -Name[rw]=Ibisobanuro by'Icomeka TDE -Name[se]=Dieđut TDE-moduvlla birra -Name[sk]=Informácia o module TDE -Name[sl]=Informacija o vstavkih v TDE -Name[sq]=Informata për Shtojca të TDE -Name[sr]=Информација о TDE dodatku -Name[sr@Latn]=Informacija o TDE dodatku -Name[sv]=TDE-insticksinformation -Name[ta]=TDE சொருகுப்பொருள் தகவல் -Name[te]=కెడిఈ ప్లగిన్ సమాచారం -Name[tg]=TDE барномаҳои чоп кунӣ -Name[th]=ข้อมูลปลั้กอินของ TDE -Name[tr]=TDE Eklenti Bilgisi -Name[tt]=TDE Östämäse Turında -Name[uk]=Інформація про втулок TDE -Name[uz]=TDE plagin haqida maʼlumot -Name[uz@cyrillic]=TDE плагин ҳақида маълумот -Name[vi]=Thông tin bộ cầm phít TDE -Name[wa]=Informåcion sol tchôke-divins di TDE -Name[zh_CN]=TDE 打印信息 -Name[zh_HK]=TDE 外掛資訊 -Name[zh_TW]=TDE 外掛資訊 - -[PropertyDef::X-TDE-PluginInfo-Author] -Type=TQString - -[PropertyDef::X-TDE-PluginInfo-Email] -Type=TQString - -[PropertyDef::X-TDE-PluginInfo-Name] -Type=TQString - -[PropertyDef::X-TDE-PluginInfo-Version] -Type=TQString - -[PropertyDef::X-TDE-PluginInfo-Website] -Type=TQString - -[PropertyDef::X-TDE-PluginInfo-Category] -Type=TQString - -[PropertyDef::X-TDE-PluginInfo-Depends] -Type=TQStringList - -[PropertyDef::X-TDE-PluginInfo-License] -Type=TQString - -[PropertyDef::X-TDE-PluginInfo-EnabledByDefault] -Type=bool diff --git a/kutils/kplugininfo.h b/kutils/kplugininfo.h deleted file mode 100644 index 0ba051d2c..000000000 --- a/kutils/kplugininfo.h +++ /dev/null @@ -1,319 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KPLUGININFO_H -#define KPLUGININFO_H - -#include <tqstring.h> -#include <tqmap.h> -#include <tqstringlist.h> -#include <tqvaluelist.h> -#include <kservice.h> - -class TDEConfigGroup; - -/** - * @ingroup main - * @ingroup plugin - * Information about a plugin. - * - * This holds all the information about a plugin there is. It's used for the - * user to decide whether he wants to use this plugin or not. - * - * @author Matthias Kretz <kretz@kde.org> - * @since 3.2 - */ -class KUTILS_EXPORT KPluginInfo -{ - public: - typedef TQValueList<KPluginInfo*> List; - - /** - * Read plugin info from @p filename. - * - * The file should be of the following form: - * \verbatim - [Desktop Entry] - Name=User Visible Name - Comment=Description of what the plugin does - - [X-TDE Plugin Info] - Author=Author's Name - Email=author@foo.bar - PluginName=internalname - Version=1.1 - Website=http://www.plugin.org/ - Category=playlist - Depends=plugin1,plugin3 - License=GPL - EnabledByDefault=true - \endverbatim - * The first two entries in the "Desktop Entry" group always need to - * be present. - * - * The "X-TDE-PluginInfo" keys you may add further entries which - * will be available using property(). The Website,Category,Require - * keys are optional. - * For EnabledByDefault look at isPluginEnabledByDefault. - * - * @param filename The filename of the .desktop file. - * @param resource If filename is relative, you need to specify a resource type - * (e.g. "service", "apps"... KStandardDirs). Otherwise, - * resource isn't used. - */ - KPluginInfo( const TQString & filename, const char* resource = 0 ); - - /** - * Read plugin info from a KService object. - * - * The .desktop file should look like this: - * \verbatim - [Desktop Entry] - Encoding=UTF-8 - Icon=mypluginicon - Type=Service - ServiceTypes=KPluginInfo - - X-TDE-PluginInfo-Author=Author's Name - X-TDE-PluginInfo-Email=author@foo.bar - X-TDE-PluginInfo-Name=internalname - X-TDE-PluginInfo-Version=1.1 - X-TDE-PluginInfo-Website=http://www.plugin.org/ - X-TDE-PluginInfo-Category=playlist - X-TDE-PluginInfo-Depends=plugin1,plugin3 - X-TDE-PluginInfo-License=GPL - X-TDE-PluginInfo-EnabledByDefault=true - - Name=User Visible Name - Comment=Description of what the plugin does - \endverbatim - * In the first three entries the Icon entry is optional. - */ - KPluginInfo( const KService::Ptr service ); - -//X /** -//X * Create an empty hidden plugin. -//X * @internal -//X */ -//X KPluginInfo(); - - virtual ~KPluginInfo(); - - /** - * @return A list of KPluginInfo objects constructed from a list of - * KService objects. If you get a trader offer of the plugins you want - * to use you can just pass them to this function. - */ - static KPluginInfo::List fromServices( const KService::List & services, TDEConfig * config = 0, const TQString & group = TQString::null ); - - /** - * @return A list of KPluginInfo objects constructed from a list of - * filenames. If you make a lookup using, for example, - * KStandardDirs::findAllResources() you pass the list of files to this - * function. - */ - static KPluginInfo::List fromFiles( const TQStringList & files, TDEConfig * config = 0, const TQString & group = TQString::null ); - - /** - * @return A list of KPluginInfo objects for the KParts plugins of an - * instance. You only need the name of the instance not a pointer to the - * TDEInstance object. - */ - static KPluginInfo::List fromKPartsInstanceName( const TQString &, TDEConfig * config = 0, const TQString & group = TQString::null ); - - /** - * @return Whether the plugin should be hidden. - */ - bool isHidden() const; - - /** - * Set whether the plugin is currently loaded. - * - * You might need to reimplement this method for special needs. - * - * @see isPluginEnabled() - * @see save() - */ - virtual void setPluginEnabled( bool enabled ); - - /** - * @return Whether the plugin is currently loaded. - * - * You might need to reimplement this method for special needs. - * - * @see setPluginEnabled() - * @see load() - */ - virtual bool isPluginEnabled() const; - - /** - * @return The default value whether the plugin is enabled or not. - * Defaults to the value set in the desktop file, or if that isn't set - * to false. - */ - bool isPluginEnabledByDefault() const; - - /** - * @return The value associated the the @p key. You can use it if you - * want to read custom values. To do this you need to define - * your own servicetype and add it to the ServiceTypes keys. - * - * @see operator[] - */ - TQVariant property( const TQString & key ) const; - - /** - * This is the same as property(). It is provided for convenience. - * - * @return The value associated with the @p key. - * - * @see property() - */ - TQVariant operator[]( const TQString & key ) const; - - /** - * @return The user visible name of the plugin. - */ - const TQString & name() const; - - /** - * @return A comment describing the plugin. - */ - const TQString & comment() const; - - /** - * @return The iconname for this plugin - */ - const TQString & icon() const; - - /** - * @return The file containing the information about the plugin. - */ - const TQString & specfile() const; - - /** - * @return The author of this plugin. - */ - const TQString & author() const; - - /** - * @return The email address of the author. - */ - const TQString & email() const; - - /** - * @return The category of this plugin (e.g. playlist/skin). - */ - const TQString & category() const; - - /** - * @return The internal name of the plugin (for KParts Plugins this is - * the same name as set in the .rc file). - */ - const TQString & pluginName() const; - - /** - * @return The version of the plugin. - */ - const TQString & version() const; - - /** - * @return The website of the plugin/author. - */ - const TQString & website() const; - - - /** - * @return The license of this plugin. - */ - const TQString & license() const; - - /** - * @return A list of plugins required for this plugin to be enabled. Use - * the pluginName in this list. - */ - const TQStringList & dependencies() const; - - /** - * @return The KService object for this plugin. You might need it if you - * want to read custom values. To do this you need to define - * your own servicetype and add it to the ServiceTypes keys. - * Then you can use the KService::property() method to read your - * keys. - * - * @see property() - */ - KService::Ptr service() const; - - /** - * @return A list of Service pointers if the plugin installs one or more - * TDECModule - */ - const TQValueList<KService::Ptr> & kcmServices() const; - - /** - * Set the TDEConfigGroup to use for load()ing and save()ing the - * configuration. This will be overridden by the TDEConfigGroup passed to - * save() or load() (if one is passed). - */ - void setConfig( TDEConfig * config, const TQString & group ); - - /** - * @return If the KPluginInfo object has a TDEConfig object set return - * it, else return 0. - */ - TDEConfig * config() const; - - /** - * @return The groupname used in the TDEConfig object for load()ing and - * save()ing whether the plugin is enabled. - */ - const TQString & configgroup() const; - - /** - * Save state of the plugin - enabled or not. This function is provided - * for reimplementation if you need to save somewhere else. - * @param config The TDEConfigGroup holding the information whether - * plugin is enabled. - */ - virtual void save( TDEConfigGroup * config = 0 ); - - /** - * Load the state of the plugin - enabled or not. This function is provided - * for reimplementation if you need to save somewhere else. - * @param config The TDEConfigGroup holding the information whether - * plugin is enabled. - */ - virtual void load( TDEConfigGroup * config = 0 ); - - /** - * Restore defaults (enabled or not). - */ - virtual void defaults(); - - private: - KPluginInfo( const KPluginInfo & ); - const KPluginInfo & operator=( const KPluginInfo & ); - - class KPluginInfoPrivate; - KPluginInfoPrivate * d; -}; - -// vim: sw=4 sts=4 et tw=80 -#endif // KPLUGININFO_H diff --git a/kutils/kpluginselector.cpp b/kutils/kpluginselector.cpp deleted file mode 100644 index fb1386106..000000000 --- a/kutils/kpluginselector.cpp +++ /dev/null @@ -1,726 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2002-2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "kpluginselector.h" -#include "kpluginselector_p.h" - -#include <tqtooltip.h> -#include <tqvbox.h> -#include <tqlabel.h> -#include <tqstrlist.h> -#include <tqfile.h> -#include <tqstring.h> -#include <tqlayout.h> -#include <tqptrlist.h> -#include <tqwidgetstack.h> -#include <tqcursor.h> -#include <tqapplication.h> -#include <tqobjectlist.h> -#include <tqcstring.h> - -#include <kdebug.h> -#include <klocale.h> -#include <klistview.h> -#include <ksimpleconfig.h> -#include <kdialog.h> -#include <kglobal.h> -#include <kglobalsettings.h> -#include <kstandarddirs.h> -#include <ktabctl.h> -#include <tdecmoduleinfo.h> -#include <tqvaluelist.h> -#include <kservice.h> -#include <ktrader.h> -#include <ktabwidget.h> -#include <kiconloader.h> -#include <tdecmodule.h> -#include "tdecmoduleinfo.h" -#include "tdecmoduleloader.h" -#include <tqsplitter.h> -#include <tqframe.h> -#include "kplugininfo.h" -#include <kinstance.h> -#include <tqptrdict.h> -#include <tqstringlist.h> -#include "tdecmoduleproxy.h" - -/* - QCheckListViewItem that holds a pointer to the KPluginInfo object. - Used in the tooltip code to access additional fields -*/ -class KPluginInfoLVI : public TQCheckListItem -{ -public: - KPluginInfoLVI( KPluginInfo *pluginInfo, KListView *parent ) - : TQCheckListItem( parent, pluginInfo->name(), TQCheckListItem::CheckBox ), m_pluginInfo( pluginInfo ) - { - } - - KPluginInfo * pluginInfo() { return m_pluginInfo; } - -private: - KPluginInfo *m_pluginInfo; -}; - -/* - Custom TQToolTip for the list view. - The decision whether or not to show tooltips is taken in - maybeTip(). See also the TQListView sources from Qt itself. -*/ -class KPluginListViewToolTip : public TQToolTip -{ -public: - KPluginListViewToolTip( TQWidget *parent, KListView *lv ); - - void maybeTip( const TQPoint &pos ); - -private: - KListView *m_listView; -}; - -KPluginListViewToolTip::KPluginListViewToolTip( TQWidget *parent, KListView *lv ) -: TQToolTip( parent ), m_listView( lv ) -{ -} - -void KPluginListViewToolTip::maybeTip( const TQPoint &pos ) -{ - if ( !parentWidget() || !m_listView ) - return; - - KPluginInfoLVI *item = dynamic_cast<KPluginInfoLVI *>( m_listView->itemAt( pos ) ); - if ( !item ) - return; - - TQString toolTip = i18n( "<qt><table>" - "<tr><td><b>Description:</b></td><td>%1</td></tr>" - "<tr><td><b>Author:</b></td><td>%2</td></tr>" - "<tr><td><b>Version:</b></td><td>%3</td></tr>" - "<tr><td><b>License:</b></td><td>%4</td></tr></table></qt>" ).arg( item->pluginInfo()->comment(), - item->pluginInfo()->author(), item->pluginInfo()->version(), item->pluginInfo()->license() ); - - //kdDebug( 702 ) << k_funcinfo << "Adding tooltip: itemRect: " << itemRect << ", tooltip: " << toolTip << endl; - tip( m_listView->itemRect( item ), toolTip ); -} - -struct KPluginSelectionWidget::KPluginSelectionWidgetPrivate -{ - KPluginSelectionWidgetPrivate( KPluginSelector * _kps, - const TQString & _cat, - TDEConfigGroup * _config ) - : widgetstack( 0 ) - , kps( _kps ) - , config( _config ) - , tooltip( 0 ) - , catname( _cat ) - , currentplugininfo( 0 ) - , visible( true ) - , currentchecked( false ) - , changed( 0 ) - { - moduleParentComponents.setAutoDelete( true ); - } - - ~KPluginSelectionWidgetPrivate() - { - delete config; - } - - TQMap<TQCheckListItem*, KPluginInfo*> pluginInfoMap; - - TQWidgetStack * widgetstack; - KPluginSelector * kps; - TDEConfigGroup * config; - KPluginListViewToolTip *tooltip; - - TQDict<TDECModuleInfo> pluginconfigmodules; - TQMap<TQString, int> widgetIDs; - TQMap<KPluginInfo*, bool> plugincheckedchanged; - TQString catname; - TQValueList<TDECModuleProxy*> modulelist; - TQPtrDict<TQStringList> moduleParentComponents; - - KPluginInfo * currentplugininfo; - bool visible; - bool currentchecked; - int changed; -}; - -KPluginSelectionWidget::KPluginSelectionWidget( - const TQValueList<KPluginInfo*> & plugininfos, KPluginSelector * kps, - TQWidget * parent, const TQString & catname, const TQString & category, - TDEConfigGroup * config, const char * name ) - : TQWidget( parent, name ) - , d( new KPluginSelectionWidgetPrivate( kps, catname, config ) ) -{ - init( plugininfos, category ); -} - -inline TQString KPluginSelectionWidget::catName() const -{ - return d->catname; -} - -void KPluginSelectionWidget::init( const TQValueList<KPluginInfo*> & plugininfos, - const TQString & category ) -{ - // setup Widgets - ( new TQVBoxLayout( this, 0, KDialog::spacingHint() ) )->setAutoAdd( true ); - KListView * listview = new KListView( this ); - d->tooltip = new KPluginListViewToolTip( listview->viewport(), listview ); - connect( listview, TQT_SIGNAL( pressed( TQListViewItem * ) ), this, - TQT_SLOT( executed( TQListViewItem * ) ) ); - connect( listview, TQT_SIGNAL( spacePressed( TQListViewItem * ) ), this, - TQT_SLOT( executed( TQListViewItem * ) ) ); - connect( listview, TQT_SIGNAL( returnPressed( TQListViewItem * ) ), this, - TQT_SLOT( executed( TQListViewItem * ) ) ); - connect( listview, TQT_SIGNAL( selectionChanged( TQListViewItem * ) ), this, - TQT_SLOT( executed( TQListViewItem * ) ) ); - listview->setSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Preferred ); - listview->setAcceptDrops( false ); - listview->setFullWidth( true ); - listview->setSelectionModeExt( KListView::Single ); - listview->setAllColumnsShowFocus( true ); - listview->addColumn( i18n( "Name" ) ); - for( TQValueList<KPluginInfo*>::ConstIterator it = plugininfos.begin(); - it != plugininfos.end(); ++it ) - { - d->plugincheckedchanged[ *it ] = false; - if( !( *it )->isHidden() && - ( category.isNull() || ( *it )->category() == category ) ) - { - TQCheckListItem * item = new KPluginInfoLVI( *it, listview ); - if( ! ( *it )->icon().isEmpty() ) - item->setPixmap( 0, SmallIcon( ( *it )->icon(), IconSize( KIcon::Small ) ) ); - item->setOn( ( *it )->isPluginEnabled() ); - d->pluginInfoMap.insert( item, *it ); - } - } - - // widgetstack - d->widgetstack = d->kps->widgetStack(); - load(); - // select and highlight the first item in the plugin list - if( listview->firstChild() ) - listview->setSelected( listview->firstChild(), true ); -} - -KPluginSelectionWidget::~KPluginSelectionWidget() -{ - delete d->tooltip; - delete d; -} - -bool KPluginSelectionWidget::pluginIsLoaded( const TQString & pluginName ) const -{ - for( TQMap<TQCheckListItem*, KPluginInfo*>::ConstIterator it = - d->pluginInfoMap.begin(); it != d->pluginInfoMap.end(); ++it ) - if( it.data()->pluginName() == pluginName ) - return it.data()->isPluginEnabled(); - return false; -} - - -TQWidget * KPluginSelectionWidget::insertKCM( TQWidget * parent, - const TDECModuleInfo & moduleinfo ) -{ - TDECModuleProxy * module = new TDECModuleProxy( moduleinfo, false, - parent ); - if( !module->realModule() ) - { - //FIXME: not very verbose - TQLabel * label = new TQLabel( i18n( "Error" ), parent ); - label->setAlignment( Qt::AlignCenter ); - - return label; - } - // add the KCM to the list so that we can call load/save/defaults on it - d->modulelist.append( module ); - TQStringList * parentComponents = new TQStringList( - moduleinfo.service()->property( - "X-TDE-ParentComponents" ).toStringList() ); - d->moduleParentComponents.insert( module, parentComponents ); - connect( module, TQT_SIGNAL( changed( bool ) ), TQT_SLOT( clientChanged( bool ) ) ); - return module; -} - -void KPluginSelectionWidget::embeddPluginKCMs( KPluginInfo * plugininfo, bool checked ) -{ - //if we have Services for the plugin we should be able to - //create KCM(s) - TQApplication::setOverrideCursor( Qt::WaitCursor ); - if( plugininfo->kcmServices().size() > 1 ) - { - // we need a tabwidget - KTabWidget * tabwidget = new KTabWidget( d->widgetstack ); - tabwidget->setEnabled( checked ); - - int id = d->widgetstack->addWidget( tabwidget ); - d->kps->configPage( id ); - d->widgetIDs[ plugininfo->pluginName() ] = id; - - for( TQValueList<KService::Ptr>::ConstIterator it = - plugininfo->kcmServices().begin(); - it != plugininfo->kcmServices().end(); ++it ) - { - if( !( *it )->noDisplay() ) - { - TDECModuleInfo moduleinfo( *it ); - TQWidget * module = insertKCM( tabwidget, moduleinfo ); - tabwidget->addTab( module, moduleinfo.moduleName() ); - } - } - } - else - { - if( !plugininfo->kcmServices().front()->noDisplay() ) - { - TDECModuleInfo moduleinfo( - plugininfo->kcmServices().front() ); - TQWidget * module = insertKCM( d->widgetstack, moduleinfo ); - module->setEnabled( checked ); - - int id = d->widgetstack->addWidget( module ); - d->kps->configPage( id ); - d->widgetIDs[ plugininfo->pluginName() ] = id; - } - } - TQApplication::restoreOverrideCursor(); -} - -inline void KPluginSelectionWidget::updateConfigPage() -{ - updateConfigPage( d->currentplugininfo, d->currentchecked ); -} - -void KPluginSelectionWidget::updateConfigPage( KPluginInfo * plugininfo, - bool checked ) -{ - //kdDebug( 702 ) << k_funcinfo << endl; - d->currentplugininfo = plugininfo; - d->currentchecked = checked; - - // if this widget is not currently visible (meaning that it's in a tabwidget - // and another tab is currently opened) it's not allowed to change the - // widgetstack - if( ! d->visible ) - return; - - if( 0 == plugininfo ) - { - d->kps->configPage( 1 ); - return; - } - - if( plugininfo->kcmServices().empty() ) - d->kps->configPage( 1 ); - else - { - if( !d->widgetIDs.contains( plugininfo->pluginName() ) ) - // if no widget exists for the plugin create it - embeddPluginKCMs( plugininfo, checked ); - else - { - // the page already exists - int id = d->widgetIDs[ plugininfo->pluginName() ]; - d->kps->configPage( id ); - d->widgetstack->widget( id )->setEnabled( checked ); - } - } -} - -void KPluginSelectionWidget::clientChanged( bool didchange ) -{ - kdDebug( 702 ) << k_funcinfo << endl; - d->changed += didchange ? 1 : -1; - if( d->changed == 1 ) - emit changed( true ); - else if( d->changed == 0 ) - emit changed( false ); - else if( d->changed < 0 ) - kdError( 702 ) << "negative changed value: " << d->changed << endl; -} - -void KPluginSelectionWidget::tabWidgetChanged( TQWidget * widget ) -{ - if( widget == this ) - { - d->visible = true; - updateConfigPage(); - } - else - d->visible = false; -} - -void KPluginSelectionWidget::executed( TQListViewItem * item ) -{ - kdDebug( 702 ) << k_funcinfo << endl; - if( item == 0 ) - return; - - // Why not a dynamic_cast? - Martijn - // because this is what the Qt API suggests; and since gcc 3.x I don't - // trust dynamic_cast anymore - mkretz - if( item->rtti() != 1 ) //check for a QCheckListItem - return; - - TQCheckListItem * citem = static_cast<TQCheckListItem *>( item ); - bool checked = citem->isOn(); - //kdDebug( 702 ) << "it's a " << ( checked ? "checked" : "unchecked" ) - // << " TQCheckListItem" << endl; - - KPluginInfo * info = d->pluginInfoMap[ citem ]; - Q_ASSERT( !info->isHidden() ); - - if ( info->isPluginEnabled() != checked ) - { - kdDebug( 702 ) << "Item changed state, emitting changed()" << endl; - - if( ! d->plugincheckedchanged[ info ] ) - { - ++d->changed; - if ( d->changed == 1 ) - emit changed( true ); - } - d->plugincheckedchanged[ info ] = true; - - checkDependencies( info ); - } - else - { - if( d->plugincheckedchanged[ info ] ) - { - --d->changed; - if ( d->changed == 0 ) - emit changed( false ); - } - d->plugincheckedchanged[ info ] = false; - // FIXME: plugins that depend on this plugin need to be disabled, too - } - - updateConfigPage( info, checked ); -} - -void KPluginSelectionWidget::load() -{ - //kdDebug( 702 ) << k_funcinfo << endl; - - for( TQMap<TQCheckListItem*, KPluginInfo*>::Iterator it = - d->pluginInfoMap.begin(); it != d->pluginInfoMap.end(); ++it ) - { - KPluginInfo * info = it.data(); - info->load( d->config ); - it.key()->setOn( info->isPluginEnabled() ); - if( d->visible && info == d->currentplugininfo ) - d->currentchecked = info->isPluginEnabled(); - } - - for( TQValueList<TDECModuleProxy*>::Iterator it = d->modulelist.begin(); - it != d->modulelist.end(); ++it ) - if( ( *it )->changed() ) - ( *it )->load(); - - updateConfigPage(); - // TODO: update changed state -} - -void KPluginSelectionWidget::save() -{ - kdDebug( 702 ) << k_funcinfo << endl; - - for( TQMap<TQCheckListItem*, KPluginInfo*>::Iterator it = - d->pluginInfoMap.begin(); it != d->pluginInfoMap.end(); ++it ) - { - KPluginInfo * info = it.data(); - bool checked = it.key()->isOn(); - info->setPluginEnabled( checked ); - info->save( d->config ); - d->plugincheckedchanged[ info ] = false; - } - TQStringList updatedModules; - for( TQValueList<TDECModuleProxy*>::Iterator it = d->modulelist.begin(); - it != d->modulelist.end(); ++it ) - if( ( *it )->changed() ) - { - ( *it )->save(); - TQStringList * names = d->moduleParentComponents[ *it ]; - if( names->size() == 0 ) - names->append( TQString::null ); - for( TQStringList::ConstIterator nameit = names->begin(); - nameit != names->end(); ++nameit ) - if( updatedModules.find( *nameit ) == updatedModules.end() ) - updatedModules.append( *nameit ); - } - for( TQStringList::ConstIterator it = updatedModules.begin(); it != updatedModules.end(); ++it ) - emit configCommitted( ( *it ).latin1() ); - - updateConfigPage(); - kdDebug( 702 ) << "syncing config file" << endl; - d->config->sync(); - d->changed = 0; - emit changed( false ); -} - -void KPluginSelectionWidget::checkDependencies( const KPluginInfo * info ) -{ - if( info->dependencies().isEmpty() ) - return; - - for( TQStringList::ConstIterator it = info->dependencies().begin(); - it != info->dependencies().end(); ++it ) - for( TQMap<TQCheckListItem*, - KPluginInfo*>::Iterator infoIt = d->pluginInfoMap.begin(); - infoIt != d->pluginInfoMap.end(); ++infoIt ) - if( infoIt.data()->pluginName() == *it ) - { - if( !infoIt.key()->isOn() ) - { - infoIt.key()->setOn( true ); - checkDependencies( infoIt.data() ); - } - continue; - } -} - -class KPluginSelector::KPluginSelectorPrivate -{ - public: - KPluginSelectorPrivate() - : frame( 0 ) - , tabwidget( 0 ) - , widgetstack( 0 ) - , hideconfigpage( false ) - { - } - - TQFrame * frame; - KTabWidget * tabwidget; - TQWidgetStack * widgetstack; - TQValueList<KPluginSelectionWidget *> pswidgets; - bool hideconfigpage; -}; - -KPluginSelector::KPluginSelector( TQWidget * parent, const char * name ) -: TQWidget( parent, name ) -, d( new KPluginSelectorPrivate ) -{ - TQBoxLayout * hbox = new TQHBoxLayout( this, 0, KDialog::spacingHint() ); - hbox->setAutoAdd( true ); - - TQSplitter* splitter = new TQSplitter( Qt::Horizontal, this ); - d->frame = new TQFrame( splitter, "KPluginSelector left frame" ); - d->frame->setFrameStyle( TQFrame::NoFrame ); - ( new TQVBoxLayout( d->frame, 0, KDialog::spacingHint() ) )->setAutoAdd( true ); - - // widgetstack - d->widgetstack = new TQWidgetStack( splitter, "KPluginSelector Config Pages" ); - d->widgetstack->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); - d->widgetstack->setMinimumSize( 200, 200 ); - - TQLabel * label = new TQLabel( i18n( "(This plugin is not configurable)" ), - d->widgetstack ); - ( new TQVBoxLayout( label, 0, KDialog::spacingHint() ) )->setAutoAdd( true ); - label->setAlignment( Qt::AlignCenter ); - label->setMinimumSize( 200, 200 ); - - d->widgetstack->addWidget( label, 1 ); - - configPage( 1 ); -} - -KPluginSelector::~KPluginSelector() -{ - delete d; -} - -void KPluginSelector::checkNeedForTabWidget() -{ - kdDebug( 702 ) << k_funcinfo << endl; - if( ! d->tabwidget && d->pswidgets.size() == 1 ) - { - kdDebug( 702 ) << "no TabWidget and one KPluginSelectionWidget" << endl; - // there's only one KPluginSelectionWidget yet, we need a TabWidget - KPluginSelectionWidget * w = d->pswidgets.first(); - if( w ) - { - kdDebug( 702 ) << "create TabWidget" << endl; - d->tabwidget = new KTabWidget( d->frame, - "KPluginSelector TabWidget" ); - w->reparent( d->tabwidget, TQPoint( 0, 0 ) ); - d->tabwidget->addTab( w, w->catName() ); - connect( d->tabwidget, TQT_SIGNAL( currentChanged( TQWidget * ) ), w, - TQT_SLOT( tabWidgetChanged( TQWidget * ) ) ); - } - } -} - -static TQValueList<KPluginInfo*> kpartsPluginInfos( const TQString& instanceName ) -{ - if( instanceName.isNull() ) - return TQValueList<KPluginInfo*>(); //nothing - - const TQStringList desktopfilenames = TDEGlobal::dirs()->findAllResources( "data", - instanceName + "/kpartplugins/*.desktop", true, false ); - return KPluginInfo::fromFiles( desktopfilenames ); -} - -void KPluginSelector::addPlugins( const TQString & instanceName, - const TQString & catname, const TQString & category, TDEConfig * config ) -{ - const TQValueList<KPluginInfo*> plugininfos = kpartsPluginInfos( instanceName ); - if ( plugininfos.isEmpty() ) - return; - checkNeedForTabWidget(); - Q_ASSERT( config ); // please set config, or use addPlugins( instance, ... ) which takes care of it - if ( !config ) // KDE4: ensure that config is always set; make it second in the arg list? - config = new KSimpleConfig( instanceName ); // memleak! - TDEConfigGroup * cfgGroup = new TDEConfigGroup( config, "KParts Plugins" ); - kdDebug( 702 ) << k_funcinfo << "cfgGroup = " << cfgGroup << endl; - addPluginsInternal( plugininfos, catname, category, cfgGroup ); -} - -void KPluginSelector::addPluginsInternal( const TQValueList<KPluginInfo*> plugininfos, - const TQString & catname, const TQString & category, - TDEConfigGroup* cfgGroup ) -{ - KPluginSelectionWidget * w; - if( d->tabwidget ) - { - w = new KPluginSelectionWidget( plugininfos, this, - d->tabwidget, catname, category, cfgGroup ); - d->tabwidget->addTab( w, catname ); - connect( d->tabwidget, TQT_SIGNAL( currentChanged( TQWidget * ) ), w, - TQT_SLOT( tabWidgetChanged( TQWidget * ) ) ); - } - else - w = new KPluginSelectionWidget( plugininfos, this, d->frame, - catname, category, cfgGroup ); - w->setMinimumSize( 200, 200 ); - connect( w, TQT_SIGNAL( changed( bool ) ), this, TQT_SIGNAL( changed( bool ) ) ); - connect( w, TQT_SIGNAL( configCommitted( const TQCString & ) ), this, - TQT_SIGNAL( configCommitted( const TQCString & ) ) ); - d->pswidgets += w; -} - -void KPluginSelector::addPlugins( const TDEInstance * instance, const TQString & - catname, const TQString & category, TDEConfig * config ) -{ - if ( !config ) - config = instance->config(); - addPlugins( instance->instanceName(), catname, category, config ); -} - -void KPluginSelector::addPlugins( const TQValueList<KPluginInfo*> & plugininfos, - const TQString & catname, const TQString & category, TDEConfig * config ) -{ - checkNeedForTabWidget(); - // the TDEConfigGroup becomes owned by KPluginSelectionWidget - TDEConfigGroup * cfgGroup = new TDEConfigGroup( config ? config : TDEGlobal::config(), "Plugins" ); - kdDebug( 702 ) << k_funcinfo << "cfgGroup = " << cfgGroup << endl; - addPluginsInternal( plugininfos, catname, category, cfgGroup ); -} - -TQWidgetStack * KPluginSelector::widgetStack() -{ - return d->widgetstack; -} - -inline void KPluginSelector::configPage( int id ) -{ - if( id == 1 ) - { - // no config page - if( d->hideconfigpage ) - { - d->widgetstack->hide(); - return; - } - } - else - d->widgetstack->show(); - - d->widgetstack->raiseWidget( id ); -} - -void KPluginSelector::setShowEmptyConfigPage( bool show ) -{ - d->hideconfigpage = !show; - if( d->hideconfigpage ) - if( d->widgetstack->id( d->widgetstack->visibleWidget() ) == 1 ) - d->widgetstack->hide(); -} - -void KPluginSelector::load() -{ - for( TQValueList<KPluginSelectionWidget *>::Iterator it = - d->pswidgets.begin(); it != d->pswidgets.end(); ++it ) - { - ( *it )->load(); - } -} - -void KPluginSelector::save() -{ - for( TQValueList<KPluginSelectionWidget *>::Iterator it = - d->pswidgets.begin(); it != d->pswidgets.end(); ++it ) - { - ( *it )->save(); - } -} - -void KPluginSelector::defaults() -{ - kdDebug( 702 ) << k_funcinfo << endl; - - // what should defaults do? here's what I think: - // Pressing a button in the dialog should not change any widgets that are - // not visible for the user. Therefor we may only change the currently - // visible plugin's KCM. Restoring the default plugin selections is therefor - // not possible. (if the plugin has multiple KCMs they will be shown in a - // tabwidget - defaults() will be called for all of them) - - TQWidget * pluginconfig = d->widgetstack->visibleWidget(); - TDECModuleProxy * kcm = ::tqqt_cast<TDECModuleProxy*>(pluginconfig); - if( kcm ) - { - kdDebug( 702 ) << "call TDECModule::defaults() for the plugins KCM" - << endl; - kcm->defaults(); - return; - } - - // if we get here the visible Widget must be a tabwidget holding more than - // one KCM - TQObjectList * kcms = pluginconfig->queryList( "TDECModuleProxy", - 0, false, false ); - TQObjectListIt it( *kcms ); - TQObject * obj; - while( ( obj = it.current() ) != 0 ) - { - ++it; - ( ( TDECModule* )obj )->defaults(); - } - delete kcms; - // FIXME: update changed state -} - -// vim: sw=4 sts=4 et - -#include "kpluginselector.moc" -#include "kpluginselector_p.moc" diff --git a/kutils/kpluginselector.h b/kutils/kpluginselector.h deleted file mode 100644 index 4316f4880..000000000 --- a/kutils/kpluginselector.h +++ /dev/null @@ -1,218 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2002-2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KPLUGINSELECTOR_H -#define KPLUGINSELECTOR_H - -#include <tqwidget.h> -#include <tqstring.h> - -#include <tdelibs_export.h> - -class TDEInstance; -class KPluginInfo; -class TQWidgetStack; -class TDEConfig; -class TDEConfigGroup; - -/** - * @ingroup main - * @ingroup plugin - * @short A widget to select what plugins to load and configure the plugins. - * - * It shows the list of available plugins on top (if there's more than one - * category this is a TabWidget) and the configuration of the selected plugin - * below that. - * - * Since the user needs a way to know what a specific plugin does every plugin - * sould install a desktop file containing a name, comment and category field. - * The category is usefull for applications that can use different kinds of - * plugins like a playlist, skin or visualization. - * - * The location of these desktop files is the - * share/apps/<instancename>/<plugindir> directory. But if you need - * you may use a different directory. - * - * Often a program has more than one kind of plugin. In that case you want to - * make a visible distinction between those plugins. All you have to do is to - * create a KPluginSelectionWidget for every category and then add them all - * to the KPluginSelector. - * - * @author Matthias Kretz <kretz@kde.org> - * @since 3.2 - */ -class KUTILS_EXPORT KPluginSelector : public TQWidget -{ - friend class KPluginSelectionWidget; - - Q_OBJECT - public: - /** - * Create a new KPluginSelector. - */ - KPluginSelector( TQWidget * parent, const char * name = 0 ); - ~KPluginSelector(); - - /** - * Add a list of KParts plugins - * - * If you want to support non-KParts plugins use the following - * function. - * - * The information about the plugins will be loaded from the - * share/apps/<instancename>/kpartplugins directory. - * - * @param instanceName The name of the TDEInstance of the plugin's parent. - * @param catname The translated name of the category. This is the - * name that is shown in the TabWidget if there is - * more than one category. - * @param category When you have different categories of KParts - * plugins you distinguish between the plugins using - * the Category key in the .desktop file. Use this - * parameter to select only those KParts plugins - * with the Category key == @p category. If @p - * category is not set the Category key is ignored - * and all plugins are shown. - * @param config The TDEConfig object that holds the state of the - * plugins being enabled or not. By default it should - * be instance->config(). It is recommended to - * always pass a TDEConfig object if you use - * KSettings::PluginPage since you never know from where the - * page will be called (think global config app). - * For example KViewCanvas passes KSimpleConfig( - * "kviewcanvas" ). - */ - void addPlugins( const TQString & instanceName, - const TQString & catname = TQString::null, - const TQString & category = TQString::null, - TDEConfig * config = 0 ); - - /** - * Add a list of KParts plugins. Convenience method for the one above. - * If not set explicitely, @p config is set to instance->config(). - */ - void addPlugins( const TDEInstance * instance, - const TQString & catname = TQString::null, - const TQString & category = TQString::null, - TDEConfig * config = 0 ); - - /** - * Add a list of non-KParts plugins - * - * @param plugininfos A list of KPluginInfo objects containing the - * necessary information for the plugins you want to - * add to the list. - * @param catname The translated name of the category. This is the - * name that is shown in the TabWidget if there is - * more than one category. - * @param category When you have different categories of KParts - * plugins you distinguish between the plugins using - * the Category key in the .desktop file. Use this - * parameter to select only those KParts plugins - * with the Category key == @p category. If @p - * category is not set the Category key is ignored - * and all plugins are shown. - * @param config The TDEConfig object that holds the state of the - * plugins being enabled or not. By default it will - * use TDEGlobal::config(). It is recommended to - * always pass a TDEConfig object if you use - * KSettings::PluginPage since you never know from where the - * page will be called (think global config app). - * For example KViewCanvas passes KSimpleConfig( - * "kviewcanvas" ). - */ - void addPlugins( const TQValueList<KPluginInfo*> & plugininfos, - const TQString & catname = TQString::null, - const TQString & category = TQString::null, - TDEConfig * config = 0 ); - - /** - * Set whether the area for showing the KCMs of the plugins should be - * hidden if the plugin doesn't have a KCM or whether the layout should - * rather stay static and only an message should be shown. - * - * By default the config page is not hidden. - */ - void setShowEmptyConfigPage( bool ); - - /** - * Load the state of the plugins (selected or not) from the KPluginInfo - * objects. For KParts plugins everything should work automatically. For - * your own type of plugins you might need to reimplement the - * KPluginInfo::isPluginEnabled() method. If that doesn't fit your needs - * you can also reimplement this method. - */ - void load(); - - /** - * Save the configuration - */ - void save(); - - /** - * Change to applications defaults - */ - void defaults(); - - signals: - /** - * Tells you whether the configuration is changed or not. - */ - void changed( bool ); - - /** - * Emitted after the config of an embedded KCM has been saved. The - * argument is the name of the parent component that needs to reload - * its config - */ - void configCommitted( const TQCString & instanceName ); - - private: - /** - * return the KCM widgetstack - * - * @internal - */ - TQWidgetStack * widgetStack(); - - /** - * Show an info page in the widgetstack. - * - * @internal - */ - void configPage( int id ); - - /** - * @internal - */ - void checkNeedForTabWidget(); - - /** - * @internal - */ - void addPluginsInternal( const TQValueList<KPluginInfo*> plugininfos, - const TQString & catname, const TQString & category, - TDEConfigGroup* cfgGroup ); - - class KPluginSelectorPrivate; - KPluginSelectorPrivate * d; -}; - -// vim: sw=4 sts=4 et tw=80 -#endif // KPLUGINSELECTOR_H diff --git a/kutils/kpluginselector_p.h b/kutils/kpluginselector_p.h deleted file mode 100644 index c287ce555..000000000 --- a/kutils/kpluginselector_p.h +++ /dev/null @@ -1,188 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KPLUGINSELECTOR_P_H -#define KPLUGINSELECTOR_P_H - -#include <tqwidget.h> - -#include <tdelibs_export.h> - -class TDEConfigGroup; -class TQListViewItem; -class KPluginInfo; -class TDECModuleInfo; - -/** - * This is a widget to configure what Plugins should be loaded. This widget is - * used by KPluginSelector and has no direct use. - * - * @internal - * @see KPluginSelector - * - * @author Matthias Kretz <kretz@kde.org> - * @since 3.2 - */ -class KPluginSelectionWidget : public TQWidget -{ - Q_OBJECT - public: - /** - * Create a new Plugin Selector widget. - * - * @param plugininfos A list of KPluginInfo objects containing the - * necessary information for the plugins you want to - * add the selector's list. - * @param kps A KPluginSelector object. - * @param parent The parent widget. - * @param catname The translated name of the category. - * @param category The unstranslated category key name. - * @param config Set the TDEConfigGroup object that holds the - * state of the plugins being enabled or not. - * @param name The name of the widget (passed to TQWidget) - * - * @internal - */ - KPluginSelectionWidget( const TQValueList<KPluginInfo*> & plugininfos, - KPluginSelector * kps, TQWidget * parent, const TQString & catname, - const TQString & category, TDEConfigGroup * config = 0, - const char * name = 0 ); - - virtual ~KPluginSelectionWidget(); - - - /** - * Returns the translated category name - * - * @internal - */ - TQString catName() const; - - /** - * Tell the KPluginInfo objects to load their state (enabled/disabled). - */ - virtual void load(); - - /** - * It tells the KPluginInfo objects to save their current state - * (enabled/disabled). - */ - virtual void save(); - - /** - * @return whether the plugin is enabled in the ListView or not. - */ - bool pluginChecked( const TQString & pluginName ) const; - - signals: - /** - * Emits true when at least one embedded KCM is changed, or the plugin - * selection was changed. - * Emits false when the configuration is back to what it was. - */ - void changed( bool ); - - /** - * Emitted after the config of an embedded KCM has been saved. The - * argument is the name of the parent component that needs to reload - * its config - */ - void configCommitted( const TQCString & instanceName ); - - protected: - /** - * Reimplement in your subclass if you have special needs: The standard - * implementation looks at the KPluginInfo objects to find the - * needed information. But if, for some reason, your program doesn't - * work with that here's your chance to get it working. - * - * @return Whether the plugin is loaded. - */ - virtual bool pluginIsLoaded( const TQString & pluginName ) const; - - private slots: - /** - * Called when a TQCheckListItem is checked or unchecked. It calls - * checkDependencies on the Plugin and then updateConfigPage. - * - * @internal - */ - void executed( TQListViewItem * ); - - /** - * Called whenever the visible config page should change (plugin - * selection changed, plugin checked changed) - * - * First it checks for a widget for the plugin - if there is one, great: - * show it. - * If there is none, check whether there should be one and try to load - * the KCM. If there are more than one KCM create a TabWidget and put - * all of them inside, else just use the "bare" KCM. If there is no KCM - * us the infoPage( NoKCM ). If there should be one but it can't be - * loaded us the infoPage( LoadError ). - * Depending on whether the currently selected Plugin is checked or not - * disable or enable the "page" (which is the TabWidget or the KCM). - * - * @internal - */ - void updateConfigPage( KPluginInfo * plugininfo, bool checked ); - void updateConfigPage(); - - /** - * Whenever an embedded KCM emits the changed signal we count the number - * of changed KCMs. If it becomes one we emit changed( true ), if it - * becomes zero we emit changed( false ). - * - * @internal - */ - void clientChanged( bool ); - - /** - * Called whenever the tabWidget changes. It checks whether this - * KPluginSelectionWidget is shown and sets the currentplugininfo - * accordingly. - */ - void tabWidgetChanged( TQWidget * ); - - private: - /** - * Load a KCM from a TDECModuleInfo. If successfull connect changed - * signal and return the module. If not, create a label showing "Error", - * show the loaderError and return the label. - * - * @internal - */ - TQWidget * insertKCM( TQWidget * parent, const TDECModuleInfo & ); - - /** - * Embed the KCMs for the plugin into the widgetstack - * - * @internal - */ - void embeddPluginKCMs( KPluginInfo *, bool ); - - void init( const TQValueList<KPluginInfo*> & plugininfos, const TQString & ); - void checkDependencies( const KPluginInfo * ); - - struct KPluginSelectionWidgetPrivate; - KPluginSelectionWidgetPrivate * d; -}; - -// vim: sw=4 sts=4 et -#endif // KPLUGINSELECTOR_P_H diff --git a/kutils/kreplace.cpp b/kutils/kreplace.cpp deleted file mode 100644 index f825e93cc..000000000 --- a/kutils/kreplace.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/* - Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. - Copyright (C) 2002, David Faure <david@mandrakesoft.com> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <tqlabel.h> -#include <kapplication.h> -#include <kdebug.h> - -#include <klocale.h> -#include <kmessagebox.h> -#include "kreplace.h" -#include "kreplacedialog.h" -#include <tqregexp.h> - -//#define DEBUG_REPLACE -#define INDEX_NOMATCH -1 - -class KReplaceNextDialog : public KDialogBase -{ -public: - KReplaceNextDialog( TQWidget *parent ); - void setLabel( const TQString& pattern, const TQString& replacement ); -private: - TQLabel* m_mainLabel; -}; - -KReplaceNextDialog::KReplaceNextDialog(TQWidget *parent) : - KDialogBase(parent, 0, false, // non-modal! - i18n("Replace"), - User3 | User2 | User1 | Close, - User3, - false, - i18n("&All"), i18n("&Skip"), i18n("Replace")) -{ - m_mainLabel = new TQLabel( this ); - setMainWidget( m_mainLabel ); - resize(minimumSize()); -} - -void KReplaceNextDialog::setLabel( const TQString& pattern, const TQString& replacement ) -{ - m_mainLabel->setText( i18n("Replace '%1' with '%2'?").arg(pattern).arg(replacement) ); -} - -//// - -KReplace::KReplace(const TQString &pattern, const TQString &replacement, long options, TQWidget *parent) : - KFind( pattern, options, parent ) -{ - m_replacements = 0; - m_replacement = replacement; -} - -KReplace::KReplace(const TQString &pattern, const TQString &replacement, long options, TQWidget *parent, TQWidget *dlg) : - KFind( pattern, options, parent, dlg ) -{ - m_replacements = 0; - m_replacement = replacement; -} - -KReplace::~KReplace() -{ - // KFind::~KFind will delete m_dialog -} - -KDialogBase* KReplace::replaceNextDialog( bool create ) -{ - if ( m_dialog || create ) - return dialog(); - return 0L; -} - -KReplaceNextDialog* KReplace::dialog() -{ - if ( !m_dialog ) - { - m_dialog = new KReplaceNextDialog( parentWidget() ); - connect( m_dialog, TQT_SIGNAL( user1Clicked() ), this, TQT_SLOT( slotReplaceAll() ) ); - connect( m_dialog, TQT_SIGNAL( user2Clicked() ), this, TQT_SLOT( slotSkip() ) ); - connect( m_dialog, TQT_SIGNAL( user3Clicked() ), this, TQT_SLOT( slotReplace() ) ); - connect( m_dialog, TQT_SIGNAL( finished() ), this, TQT_SLOT( slotDialogClosed() ) ); - } - return static_cast<KReplaceNextDialog *>(m_dialog); -} - -void KReplace::displayFinalDialog() const -{ - if ( !m_replacements ) - KMessageBox::information(parentWidget(), i18n("No text was replaced.")); - else - KMessageBox::information(parentWidget(), i18n("1 replacement done.", "%n replacements done.", m_replacements ) ); -} - -KFind::Result KReplace::replace() -{ -#ifdef DEBUG_REPLACE - kdDebug() << k_funcinfo << "m_index=" << m_index << endl; -#endif - if ( m_index == INDEX_NOMATCH && m_lastResult == Match ) - { - m_lastResult = NoMatch; - return NoMatch; - } - - do // this loop is only because validateMatch can fail - { -#ifdef DEBUG_REPLACE - kdDebug() << k_funcinfo << "beginning of loop: m_index=" << m_index << endl; -#endif - // Find the next match. - if ( m_options & KReplaceDialog::RegularExpression ) - m_index = KFind::find(m_text, *m_regExp, m_index, m_options, &m_matchedLength); - else - m_index = KFind::find(m_text, m_pattern, m_index, m_options, &m_matchedLength); -#ifdef DEBUG_REPLACE - kdDebug() << k_funcinfo << "KFind::find returned m_index=" << m_index << endl; -#endif - if ( m_index != -1 ) - { - // Flexibility: the app can add more rules to validate a possible match - if ( validateMatch( m_text, m_index, m_matchedLength ) ) - { - if ( m_options & KReplaceDialog::PromptOnReplace ) - { -#ifdef DEBUG_REPLACE - kdDebug() << k_funcinfo << "PromptOnReplace" << endl; -#endif - // Display accurate initial string and replacement string, they can vary - TQString matchedText = m_text.mid( m_index, m_matchedLength ); - TQString rep = matchedText; - KReplace::replace(rep, m_replacement, 0, m_options, m_matchedLength); - dialog()->setLabel( matchedText, rep ); - dialog()->show(); - - // Tell the world about the match we found, in case someone wants to - // highlight it. - emit highlight(m_text, m_index, m_matchedLength); - - m_lastResult = Match; - return Match; - } - else - { - doReplace(); // this moves on too - } - } - else - { - // not validated -> move on - if (m_options & KFindDialog::FindBackwards) - m_index--; - else - m_index++; - } - } else - m_index = INDEX_NOMATCH; // will exit the loop - } - while (m_index != INDEX_NOMATCH); - - m_lastResult = NoMatch; - return NoMatch; -} - -int KReplace::replace(TQString &text, const TQString &pattern, const TQString &replacement, int index, long options, int *replacedLength) -{ - int matchedLength; - - index = KFind::find(text, pattern, index, options, &matchedLength); - if (index != -1) - { - *replacedLength = replace(text, replacement, index, options, matchedLength); - if (options & KReplaceDialog::FindBackwards) - index--; - else - index += *replacedLength; - } - return index; -} - -int KReplace::replace(TQString &text, const TQRegExp &pattern, const TQString &replacement, int index, long options, int *replacedLength) -{ - int matchedLength; - - index = KFind::find(text, pattern, index, options, &matchedLength); - if (index != -1) - { - *replacedLength = replace(text, replacement, index, options, matchedLength); - if (options & KReplaceDialog::FindBackwards) - index--; - else - index += *replacedLength; - } - return index; -} - -int KReplace::replace(TQString &text, const TQString &replacement, int index, long options, int length) -{ - TQString rep = replacement; - // Backreferences: replace \0 with the right portion of 'text' - if ( options & KReplaceDialog::BackReference ) - rep.replace( "\\0", text.mid( index, length ) ); - // Then replace rep into the text - text.replace(index, length, rep); - return rep.length(); -} - -void KReplace::slotReplaceAll() -{ - doReplace(); - m_options &= ~KReplaceDialog::PromptOnReplace; - emit optionsChanged(); - emit findNext(); -} - -void KReplace::slotSkip() -{ - if (m_options & KReplaceDialog::FindBackwards) - m_index--; - else - m_index++; - if ( m_dialogClosed ) { - delete m_dialog; // hide it again - m_dialog = 0L; - } else - emit findNext(); -} - -void KReplace::slotReplace() -{ - doReplace(); - if ( m_dialogClosed ) { - delete m_dialog; // hide it again - m_dialog = 0L; - } else - emit findNext(); -} - -void KReplace::doReplace() -{ - int replacedLength = KReplace::replace(m_text, m_replacement, m_index, m_options, m_matchedLength); - - // Tell the world about the replacement we made, in case someone wants to - // highlight it. - emit replace(m_text, m_index, replacedLength, m_matchedLength); -#ifdef DEBUG_REPLACE - kdDebug() << k_funcinfo << "after replace() signal: m_index=" << m_index << " replacedLength=" << replacedLength << endl; -#endif - m_replacements++; - if (m_options & KReplaceDialog::FindBackwards) - m_index--; - else { - m_index += replacedLength; - // when replacing the empty pattern, move on. See also kjs/regexp.cpp for how this should be done for regexps. - if ( m_pattern.isEmpty() ) - ++m_index; - } -#ifdef DEBUG_REPLACE - kdDebug() << k_funcinfo << "after adjustement: m_index=" << m_index << endl; -#endif -} - -void KReplace::resetCounts() -{ - KFind::resetCounts(); - m_replacements = 0; -} - -bool KReplace::shouldRestart( bool forceAsking, bool showNumMatches ) const -{ - // Only ask if we did a "find from cursor", otherwise it's pointless. - // ... Or if the prompt-on-replace option was set. - // Well, unless the user can modify the document during a search operation, - // hence the force boolean. - if ( !forceAsking && (m_options & KFindDialog::FromCursor) == 0 - && (m_options & KReplaceDialog::PromptOnReplace) == 0 ) - { - displayFinalDialog(); - return false; - } - TQString message; - if ( showNumMatches ) - { - if ( !m_replacements ) - message = i18n("No text was replaced."); - else - message = i18n("1 replacement done.", "%n replacements done.", m_replacements ); - } - else - { - if ( m_options & KFindDialog::FindBackwards ) - message = i18n( "Beginning of document reached." ); - else - message = i18n( "End of document reached." ); - } - - message += "\n"; - // Hope this word puzzle is ok, it's a different sentence - message += - ( m_options & KFindDialog::FindBackwards ) ? - i18n("Do you want to restart search from the end?") - : i18n("Do you want to restart search at the beginning?"); - - int ret = KMessageBox::questionYesNo( parentWidget(), message, TQString::null, i18n("Restart"), i18n("Stop") ); - return( ret == KMessageBox::Yes ); -} - -void KReplace::closeReplaceNextDialog() -{ - closeFindNextDialog(); -} - -#include "kreplace.moc" diff --git a/kutils/kreplace.h b/kutils/kreplace.h deleted file mode 100644 index ea385189b..000000000 --- a/kutils/kreplace.h +++ /dev/null @@ -1,269 +0,0 @@ -/* - Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. - Copyright (C) 2002, David Faure <david@mandrakesoft.com> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KREPLACE_H -#define KREPLACE_H - -#include "kfind.h" - -class KReplaceNextDialog; - -/** - * @ingroup main - * @ingroup findreplace - * @brief A generic implementation of the "replace" function. - * - * @author S.R.Haque <srhaque@iee.org>, David Faure <faure@kde.org> - * - * \b Detail: - * - * This class includes prompt handling etc. Also provides some - * static functions which can be used to create custom behavior - * instead of using the class directly. - * - * \b Example: - * - * To use the class to implement a complete replace feature: - * - * In the slot connect to the replace action, after using KReplaceDialog: - * \code - * - * // This creates a replace-on-prompt dialog if needed. - * m_replace = new KReplace(pattern, replacement, options, this); - * - * // Connect signals to code which handles highlighting - * // of found text, and on-the-fly replacement. - * connect( m_replace, TQT_SIGNAL( highlight( const TQString &, int, int ) ), - * this, TQT_SLOT( slotHighlight( const TQString &, int, int ) ) ); - * // Connect findNext signal - called when pressing the button in the dialog - * connect( m_replace, TQT_SIGNAL( findNext() ), - * this, TQT_SLOT( slotReplaceNext() ) ); - * // Connect replace signal - called when doing a replacement - * connect( m_replace, TQT_SIGNAL( replace(const TQString &, int, int, int) ), - * this, TQT_SLOT( slotReplace(const TQString &, int, int, int) ) ); - * \endcode - * Then initialize the variables determining the "current position" - * (to the cursor, if the option FromCursor is set, - * to the beginning of the selection if the option SelectedText is set, - * and to the beginning of the document otherwise). - * Initialize the "end of search" variables as well (end of doc or end of selection). - * Swap begin and end if FindBackwards. - * Finally, call slotReplaceNext(); - * - * \code - * void slotReplaceNext() - * { - * KFind::Result res = KFind::NoMatch; - * while ( res == KFind::NoMatch && <position not at end> ) { - * if ( m_replace->needData() ) - * m_replace->setData( <current text fragment> ); - * - * // Let KReplace inspect the text fragment, and display a dialog if a match is found - * res = m_replace->replace(); - * - * if ( res == KFind::NoMatch ) { - * <Move to the next text fragment, honoring the FindBackwards setting for the direction> - * } - * } - * - * if ( res == KFind::NoMatch ) // i.e. at end - * <Call either m_replace->displayFinalDialog(); delete m_replace; m_replace = 0L; - * or if ( m_replace->shouldRestart() ) { reinit (w/o FromCursor) and call slotReplaceNext(); } - * else { m_replace->closeReplaceNextDialog(); }> - * } - * \endcode - * - * Don't forget delete m_find in the destructor of your class, - * unless you gave it a parent widget on construction. - * - */ -class KUTILS_EXPORT KReplace : - public KFind -{ - Q_OBJECT - -public: - - /** - * Only use this constructor if you don't use KFindDialog, or if - * you use it as a modal dialog. - * @param pattern The pattern to look for. - * @param replacement The replacement string. - * @param options Options for the find dialog. @see KFindDialog and KReplaceDialog. - * @param parent The parent widget. - */ - KReplace(const TQString &pattern, const TQString &replacement, long options, TQWidget *parent = 0); - /** - * This is the recommended constructor if you also use KReplaceDialog (non-modal). - * You should pass the pointer to it here, so that when a message box - * appears it has the right parent. Don't worry about deletion, KReplace - * will notice if the find dialog is closed. - * @param pattern The pattern to look for. - * @param replacement The replacement string. - * @param options Options for the find dialog. @see KFindDialog and KReplaceDialog. - * @param parent The parent widget. - * @param replaceDialog A pointer to the KReplaceDialog object. - */ - KReplace(const TQString &pattern, const TQString &replacement, long options, TQWidget *parent, TQWidget* replaceDialog); - - /** - * Destructor. - */ - virtual ~KReplace(); - - /** - * Return the number of replacements made (i.e. the number of times - * the replace signal was emitted). - * Can be used in a dialog box to tell the user how many replacements were made. - * The final dialog does so already, unless you used setDisplayFinalDialog(false). - * @return The number of replacements. - */ - int numReplacements() const { return m_replacements; } - - /** - * Call this to reset the numMatches & numReplacements counts. - * Can be useful if reusing the same KReplace for different operations, - * or when restarting from the beginning of the document. - */ - virtual void resetCounts(); - - /** - * Walk the text fragment (e.g. kwrite line, kspread cell) looking for matches. - * For each match, if prompt-on-replace is specified, emits the highlight() signal - * and displays the prompt-for-replace dialog before doing the replace. - * @return Whether or not there has been a match. - */ - Result replace(); - - /** - * Return (or create) the dialog that shows the "find next?" prompt. - * Usually you don't need to call this. - * One case where it can be useful, is when the user selects the "Find" - * menu item while a find operation is under way. In that case, the - * program may want to call setActiveWindow() on that dialog. - * @return The replace next dialog. - */ - KDialogBase* replaceNextDialog( bool create = false ); - - /** - * Close the "replace next?" dialog. The application should do this when - * the last match was hit. If the application deletes the KReplace, then - * "find previous" won't be possible anymore. - */ - void closeReplaceNextDialog(); - - /** - * Searches the given string, replaces with the given replacement string, - * and returns whether a match was found. If one is, - * the replacement string length is also returned. - * - * A performance optimised version of the function is provided for use - * with regular expressions. - * - * @param text The string to search. - * @param pattern The pattern to look for. - * @param replacement The replacement string to insert into the text. - * @param index The starting index into the string. - * @param options The options to use. - * @param replacedLength Output parameter, contains the length of the replaced string. - * Not always the same as replacement.length(), when backreferences are used. - * @return The index at which a match was found, or -1 if no match was found. - */ - static int replace( TQString &text, const TQString &pattern, const TQString &replacement, int index, long options, int *replacedLength ); - - /** - * Searches the given regular expression, replaces with the given replacement string, - * and returns whether a match was found. If one is, - * the replacement string length is also returned. - * - * Another version of the function is provided for use with strings. - * - * @param text The string to search. - * @param pattern The regular expression pattern to look for. - * @param replacement The replacement string to insert into the text. - * @param index The starting index into the string. - * @param options The options to use. - * @param replacedLength Output parameter, contains the length of the replaced string. - * Not always the same as replacement.length(), when backreferences are used. - * @return The index at which a match was found, or -1 if no match was found. - */ - static int replace( TQString &text, const TQRegExp &pattern, const TQString &replacement, int index, long options, int *replacedLength ); - - /** - * Returns @c true if we should restart the search from scratch. - * Can ask the user, or return @c false (if we already searched/replaced the - * whole document without the PromptOnReplace option). - * - * @param forceAsking set to @c true if the user modified the document during the - * search. In that case it makes sense to restart the search again. - * - * @param showNumMatches set to @c true if the dialog should show the number of - * matches. Set to @c false if the application provides a "find previous" action, - * in which case the match count will be erroneous when hitting the end, - * and we could even be hitting the beginning of the document (so not all - * matches have even been seen). - * - * @return @c true, if the search should be restarted. - */ - virtual bool shouldRestart( bool forceAsking = false, bool showNumMatches = true ) const; - - /** - * Displays the final dialog telling the user how many replacements were made. - * Call either this or shouldRestart(). - */ - virtual void displayFinalDialog() const; - -signals: - - /** - * Connect to this slot to implement updating of replaced text during the replace - * operation. - * - * Extra care must be taken to properly implement the "no prompt-on-replace" case. - * For instance highlight isn't emitted in that case (some code might rely on it), - * and for performance reasons one should repaint after replace() ONLY if - * prompt-on-replace was selected. - * - * @param text The text, in which the replacement has already been done. - * @param replacementIndex Starting index of the matched substring - * @param replacedLength Length of the replacement string - * @param matchedLength Length of the matched string - */ - void replace(const TQString &text, int replacementIndex, int replacedLength, int matchedLength); - -protected slots: - - void slotSkip(); - void slotReplace(); - void slotReplaceAll(); - -private: - KReplaceNextDialog* dialog(); - void doReplace(); - static int replace( TQString &text, const TQString &replacement, int index, long options, int length ); - - TQString m_replacement; - unsigned m_replacements; - - // Binary compatible extensibility. - class KReplacePrivate; - KReplacePrivate *d; -}; -#endif diff --git a/kutils/kreplacedialog.cpp b/kutils/kreplacedialog.cpp deleted file mode 100644 index 88c006b4d..000000000 --- a/kutils/kreplacedialog.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. - Copyright (C) 2002, David Faure <david@mandrakesoft.com> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kreplacedialog.h" - -#include <tqcheckbox.h> -#include <tqgroupbox.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqregexp.h> -#include <kcombobox.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <kdebug.h> - -/** - * we need to insert the strings after the dialog is set - * up, otherwise TQComboBox will deliver an aweful big sizeHint - * for long replacement texts. - */ -class KReplaceDialog::KReplaceDialogPrivate { - public: - KReplaceDialogPrivate() : m_initialShowDone(false) {} - TQStringList replaceStrings; - bool m_initialShowDone; -}; - -KReplaceDialog::KReplaceDialog(TQWidget *parent, const char *name, long options, const TQStringList &findStrings, const TQStringList &replaceStrings, bool hasSelection) : - KFindDialog(parent, name, true) -{ - d = new KReplaceDialogPrivate; - d->replaceStrings = replaceStrings; - init(true, findStrings, hasSelection); - setOptions(options); -} - -KReplaceDialog::~KReplaceDialog() -{ - delete d; -} - -void KReplaceDialog::showEvent( TQShowEvent *e ) -{ - if ( !d->m_initialShowDone ) - { - d->m_initialShowDone = true; // only once - - if (!d->replaceStrings.isEmpty()) - { - setReplacementHistory(d->replaceStrings); - m_replace->lineEdit()->setText( d->replaceStrings[0] ); - } - } - - KFindDialog::showEvent(e); -} - -long KReplaceDialog::options() const -{ - long options = 0; - - options = KFindDialog::options(); - if (m_promptOnReplace->isChecked()) - options |= PromptOnReplace; - if (m_backRef->isChecked()) - options |= BackReference; - return options; -} - -TQWidget *KReplaceDialog::replaceExtension() -{ - if (!m_replaceExtension) - { - m_replaceExtension = new TQWidget(m_replaceGrp); - m_replaceLayout->addMultiCellWidget(m_replaceExtension, 3, 3, 0, 1); - } - - return m_replaceExtension; -} - -TQString KReplaceDialog::replacement() const -{ - return m_replace->currentText(); -} - -TQStringList KReplaceDialog::replacementHistory() const -{ - TQStringList lst = m_replace->historyItems(); - // historyItems() doesn't tell us about the case of replacing with an empty string - if ( m_replace->lineEdit()->text().isEmpty() ) - lst.prepend( TQString::null ); - return lst; -} - -void KReplaceDialog::setOptions(long options) -{ - KFindDialog::setOptions(options); - m_promptOnReplace->setChecked(options & PromptOnReplace); - m_backRef->setChecked(options & BackReference); -} - -void KReplaceDialog::setReplacementHistory(const TQStringList &strings) -{ - if (strings.count() > 0) - m_replace->setHistoryItems(strings, true); - else - m_replace->clearHistory(); -} - -void KReplaceDialog::slotOk() -{ - // If regex and backrefs are enabled, do a sanity check. - if ( m_regExp->isChecked() && m_backRef->isChecked() ) - { - TQRegExp r ( pattern() ); - int caps = r.numCaptures(); - TQRegExp check(TQString("((?:\\\\)+)(\\d+)")); - int p = 0; - TQString rep = replacement(); - while ( (p = check.search( rep, p ) ) > -1 ) - { - if ( check.cap(1).length()%2 && check.cap(2).toInt() > caps ) - { - KMessageBox::information( this, i18n( - "Your replacement string is referencing a capture greater than '\\%1', ").arg( caps ) + - ( caps ? - i18n("but your pattern only defines 1 capture.", - "but your pattern only defines %n captures.", caps ) : - i18n("but your pattern defines no captures.") ) + - i18n("\nPlease correct.") ); - return; // abort OKing - } - p += check.matchedLength(); - } - - } - - KFindDialog::slotOk(); - m_replace->addToHistory(replacement()); -} - -// kate: space-indent on; indent-width 4; replace-tabs on; -#include "kreplacedialog.moc" diff --git a/kutils/kreplacedialog.h b/kutils/kreplacedialog.h deleted file mode 100644 index 409666dbd..000000000 --- a/kutils/kreplacedialog.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. - Copyright (C) 2002, David Faure <david@mandrakesoft.com> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KREPLACEDIALOG_H -#define KREPLACEDIALOG_H - -#include "kfinddialog.h" - -class KHistoryCombo; -class TQCheckBox; -class TQGroupBox; -class TQLabel; -class TQPopupMenu; -class TQPushButton; -class TQRect; - -/** - * @ingroup main - * @ingroup findreplace - * @short A generic "replace" dialog. - * - * @author S.R.Haque <srhaque@iee.org> - * - * \b Detail: - * - * This widget inherits from KFindDialog and implements - * the following additional functionalities: a replacement string - * object and an area for a user-defined widget to extend the dialog. - * - * \b Example: - * - * To use the basic replace dialog: - * - * \code - * \endcode - * - * To use your own extensions: - * - * \code - * \endcode - */ -class KUTILS_EXPORT KReplaceDialog: - public KFindDialog -{ - Q_OBJECT - -public: - - /** - * Options. - */ - enum Options - { - PromptOnReplace = 256, ///< Should the user be prompted before the replace operation? - BackReference = 512 - }; - - /** - * Construct a replace dialog.read-only or rather select-only combo box with a - * parent object and a name. - * - * @param parent The parent object of this widget - * @param name The name of this widget - * @param options A bitfield of the Options to be enabled. - * @param findStrings A TQStringList to insert in the combo box of text to find - * @param replaceStrings A TQStringList to insert in the combo box of text to - * replace with - * @param hasSelection Whether a selection exists - */ - KReplaceDialog( TQWidget *parent = 0, const char *name = 0, long options = 0, - const TQStringList &findStrings = TQStringList(), - const TQStringList &replaceStrings = TQStringList(), - bool hasSelection = true ); - - /** - * Destructor. - */ - virtual ~KReplaceDialog(); - - /** - * Provide the list of @p strings to be displayed as the history - * of replacement strings. @p strings might get truncated if it is - * too long. - * - * @param history The replacement history. - * @see replacementHistory - */ - void setReplacementHistory( const TQStringList &history ); - - /** - * Returns the list of history items. - * - * @return The replacement history. - * @see setReplacementHistory - */ - TQStringList replacementHistory() const; - - /** - * Set the options which are enabled. - * - * @param options The setting of the Options. - * @see Options, KFindDialog::Options - */ - void setOptions( long options ); - - /** - * Returns the state of the options. Disabled options may be returned in - * an indeterminate state. - * - * @return The options. - * @see setOptions, Options, KFindDialog::Options - */ - long options() const; - - /** - * Returns the replacement string. - * @return The replacement string. - */ - TQString replacement() const; - - /** - * Returns an empty widget which the user may fill with additional UI - * elements as required. The widget occupies the width of the dialog, - * and is positioned immediately the regular expression support widgets - * for the replacement string. - * @return An extensible TQWidget. - */ - TQWidget *replaceExtension(); - -protected slots: - - void slotOk(); - virtual void showEvent ( TQShowEvent * ); - -private: - - // Binary compatible extensibility. - class KReplaceDialogPrivate; - KReplaceDialogPrivate *d; -}; - - -#endif // KREPLACEDIALOG_H diff --git a/kutils/ksettings/CMakeLists.txt b/kutils/ksettings/CMakeLists.txt deleted file mode 100644 index 3e4744bd8..000000000 --- a/kutils/ksettings/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/kutils - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio/kio -) - -##### headers ################################### - -install( FILES - dispatcher.h dialog.h pluginpage.h componentsdialog.h - DESTINATION ${INCLUDE_INSTALL_DIR}/ksettings ) - - -##### ksettings ################################# - -set( target ksettings ) - -set( ${target}_SRCS - dispatcher.cpp dialog.cpp pluginpage.cpp componentsdialog.cpp -) - -tde_add_library( ${target} STATIC_PIC AUTOMOC - SOURCES ${${target}_SRCS} -) diff --git a/kutils/ksettings/Makefile.am b/kutils/ksettings/Makefile.am deleted file mode 100644 index 39e7183b2..000000000 --- a/kutils/ksettings/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -INCLUDES=-I$(srcdir)/.. $(all_includes) -noinst_LTLIBRARIES = libksettings.la - -libksettings_la_SOURCES = dispatcher.cpp dialog.cpp pluginpage.cpp componentsdialog.cpp - -ksettingsincludedir = $(includedir)/ksettings -ksettingsinclude_HEADERS = dispatcher.h dialog.h pluginpage.h componentsdialog.h - -METASOURCES = AUTO diff --git a/kutils/ksettings/README.dox b/kutils/ksettings/README.dox deleted file mode 100644 index 88268f671..000000000 --- a/kutils/ksettings/README.dox +++ /dev/null @@ -1,276 +0,0 @@ -/** - -\namespace KSettings - -\short A collection of classes to create configuration dialogs that work over -component boundaries - -<h2>How to use KSettings::Dialog in your application.</h2> - -<hr> -<h3>1. Open the dialog from your app</h3> - -All you need to do is instanciate KSettings::Dialog and show() it. I recommend -the following: - -create the 'Configure MyApp' StdAction like this: -\code -KStdAction::preferences( this, SLOT( showConfigDialog() ), actionCollection ); -\endcode - -and the slot looks like this: -\code -if( m_dlg == 0 ) - m_dlg = new KSettings::Dialog( this ); -m_dlg->show(); -\endcode - -Of course you need to have the 'KSettings::Dialog * m_dlg' member var and -initialize it to 0 in the ctor. - -If your application uses KParts that don't set 'X-TDE-ParentApp=<the instance -name of your application>' then you need to use the second ctor of -KSettings::Dialog: -\code -m_dlg = new KSettings::Dialog( QStringList::split( ';', "component1;component2" ) ); -\endcode - -The KSettings::Dialog object will be destructed automatically by the QObject -mechanisms. - - -<hr> -<h3>2. Create pages for your dialog</h3> - -Every page is a KCM. This is what you need for creating a page: - -\code -class MyAppConfig : public TDECModule -{ - Q_OBJECT -public: - MyAppConfig( QWidget *parent, const char *name = 0, const QStringList &args = - QStringList() ); - ~MyAppConfig(); - - void load(); - void save(); - void defaults(); -} -\endcode - -and in the cpp file: - -\code -typedef KGenericFactory<MyAppConfig, QWidget> MyAppConfigFactory; -K_EXPORT_COMPONENT_FACTORY( kcm_myappconfig, MyAppConfigFactory( - "kcm_myappconfig" ) ); - -MyAppConfig::MyAppConfig( QWidget *parent, const char *, const QStringList &args ) - : TDECModule( MyAppConfigFactory::instance(), parent, args ) -{ - // create the pages GUI - load(); -} - -// implementations for the other methods -\endcode - -For the TDEConfig object you can either use -TDEGlobal::config() (I don't recommend it) or KSimpleConfig( "myapprc" ). -I added a method to KSettings::Dispatcher that gives you the TDEConfig -object for every registered instance name: \ref KSettings::Dispatcher::configForInstanceName - - -<hr> -<h3>3. The .desktop file for the page</h3> - -The .desktop file holds all the information for the dialog to find the page and -insert it at the right place (with the right icon, name and comment). - -An example file: -\verbatim -[Desktop Entry] -Encoding=UTF-8 -Icon=myapp -Type=Service -ServiceTypes=TDECModule - -X-TDE-ModuleType=Library -X-TDE-Library=myappconfig -X-TDE-FactoryName=MyAppConfigFactory -X-TDE-ParentApp=myapp -X-TDE-ParentComponents=myapp -X-TDE-Weight=10 - -Name=General -Comment=General configuration of my app -\endverbatim - - -Some explanation for those keys: -- You just keep 'Encoding', 'Type', 'ServiceTypes' and 'X-TDE-ModuleType' like - in the example. For very special needs you might add another ServiceType to - the list... -- Icon is the icon that will be used in the listview/iconview for your page. -- X-TDE-Library is the name of the library where the page is in. The library - always needs to be prefixed with kcm_ but you don't write the prefix in the - desktop file. For more docu on this look for the TDECModule docu. -- X-TDE-FactoryName is either the name of the Factory you used in the - KGenericFactory call or the suffix of the create_ function that you created. - Again for more info look for the TDECModule docu. -- X-TDE-ParentApp is the name of the application this config page belongs to. It - is used by the first two \ref KSettings::Dialog constructors. The Dialog will - use all modules that set X-TDE-ParentApp to - TDEGlobal::instance()->instanceName(). It - should be pretty easy to find out what name that is: look at the first - argument to the TDEAboutData ctor. -- X-TDE-ParentComponents is a list of the components (plugin/KPart/whatever) - this config page belongs to. Normally there is only one component. - It is used for two things: - -# If you use KSettings::Dispatcher the dispatcher will notify all components - in this list after the save() method of your KCM has been called. The - components then can reload the configuration and apply the changes the user - did to the config. - -# If your component is used by another application (that is not = - X-TDE-ParentApp) then it may add the name of the component to the ctor of - KSettings::Dialog and the dialog will automatically include all config - pages that have the components name in their ParentComponents list. -- X-TDE-Weight sets the order for the modules to be inserted into the dialog. - The higher the number (heavier) the lower the module will appear in the list. - (the default value is 100) -- Name is the string that is shown in the listview/iconview right below the - icon. -- Comment is the string that is shown on top of the config page for a short - description what you can do on this page. - - -<hr> -<h3>4. The .setdlg file for hierarchical (TreeList) page layouts</h3> - -If your config dialog should show a tree of pages in the config dialog you need -to define that hierarchy with a .setdlg file. - -The file should be installed in apps/<appname>/<appname>.setdlg. If third party -plugins need to merge in they will install their file to -apps/<appname>/ksettingsdialog/<pluginname>.setdlg. - -A .setdlg file contains one or more blocks like the following: - -\verbatim -[id] -Name= -Comment= -Icon= -Weight= -Parent= -\endverbatim - -- The group name (id) is the name you use in the .desktop file of the page: - If your page's .desktop file says "X-TDE-CfgDlgHierarchy=id" then it will be - inserted as a child of this entry. -- \p Name: The name of the section. It will appear in the listview. -- \p Comment: A description of what the modules in this section are. It will - appear in the place where the KCMs are placed when the user clicks on the item - in the listview. -- \p Icon: An icon for the item. -- \p Weight: Defines the position in the listview. See X-TDE-Weight above. -- \p Parent: If this group should be a child of another group write the parent's - group id here. - -<hr> -<h3>5. The Pluginselector</h3> - -There are two ways to use the KPluginSelector widget. One is to use the class -directly and the second to use KSettings::PluginPage as baseclass for a config -page that shows the KPluginSelector widget. - -I'll cover the second usage here and the calls to addPlugins are just the same -for the first. - -To create a plugin page you need the following code: - -\code -typedef KGenericFactory<MyAppPluginConfig, QWidget> MyAppPluginConfigFactory; -K_EXPORT_COMPONENT_FACTORY( kcm_myapppluginconfig, MyAppPluginConfigFactory( "kcm_myapppluginconfig" ) ); - -MyAppPluginConfig( QWidget * parent, const char *, const QStringList & args ) - : PluginPage( MyAppPluginConfigFactory::instance(), parent, args ) -{ - pluginSelector()->addPlugins( ... ); - pluginSelector()->addPlugins( ... ); - . - . - . -} -\endcode - -pluginSelector() returns a pointer to the KPluginSelector widget of the page. -There are three addPlugins methods available, two for adding KParts plugins and -one for the rest. - - -<hr> -<h3>6. The .desktop files of plugin config pages</h3> - -this is the entry for the Makefile.am: - -\verbatim -myappconfigpagedir = $(kde_servicesdir)/<appname> -myappconfigpage_DATA = myappconfigpage.desktop -\endverbatim - - -And this is what the .desktop file looks like: - -\verbatim -[Desktop Entry] -Encoding=UTF-8 -Type=Service -Icon=<iconname> -ServiceTypes=KPluginInfo - -Name=MyPlugin -Comment=My plugin is cool and does foo and bar. - -X-TDE-PluginInfo-Name=myplugin - -X-TDE-PluginInfo-Author=<your name> -X-TDE-PluginInfo-Email=<your email> -X-TDE-PluginInfo-Website=http://www.myplugin.org/ -X-TDE-PluginInfo-Category=CoolPlugins -X-TDE-PluginInfo-Version=0.1 -X-TDE-PluginInfo-License=GPL -X-TDE-PluginInfo-EnabledByDefault=true -X-TDE-PluginInfo-Depends=myotherplugin -X-TDE-CfgDlgHierarchy=GroupID -\endverbatim - -Explanation: -mandatory entries: -- leave \p Type and \p Encoding like in the example -- \p Name -- \p Comment -- \p X-TDE-PluginInfo-Name is the "internal name" of the plugin. -- You need to have \p KPluginInfo in \p ServiceTypes but of course you may have more - entries in there. - -optional entries: -- \p Icon is the icon used for your plugin (it's shown in the pluginselector if you - set one). -- \p X-TDE-PluginInfo-Author and \p X-TDE-PluginInfo-Email is some information about the author of the plugin. -- \p X-TDE-PluginInfo-Website is the address for a webpage for this plugin. -- \p X-TDE-PluginInfo-Category is used if your application has different categories of plugins. -- \p X-TDE-PluginInfo-Version is the version of this plugin. -- \p X-TDE-PluginInfo-License is the license of this plugin. -- \p X-TDE-PluginInfo-EnabledByDefault tells the program whether the plugin - should be enabled on first startup or not. -- \p X-TDE-PluginInfo-Depends can be used to tell the application that you need to have - myotherplugin enabled for your plugin to work. -- \p X-TDE-CfgDlgHierarchy is used if you use a \p KSettings::Dialog::ConfigurableInline - KSettings::Dialog to put the plugin checkbox into the group with the GroupID - you set here. - -If you have questions contact Matthias Kretz <kretz@kde.org>. -*/ -// vim: tw=80 diff --git a/kutils/ksettings/TODO b/kutils/ksettings/TODO deleted file mode 100644 index 9950ddfd9..000000000 --- a/kutils/ksettings/TODO +++ /dev/null @@ -1,13 +0,0 @@ -- KPluginSelct.. listview should only show the name and comment, the rest is - shown in a tooltip (I don't know how to get the tooltip working in the - listview.) -- Handle unsaved changes in KCMs that are hidden if the user deselects some - plugin KCMs (in KSettings::Dialog::Configurable mode). Ideas: - - don't allow changes to the plugin selection if there are unsaved changes in - the main dlg ("You have unsaved changes in the configuration dialog, please - save them first before changing the components selection.") - - automatically save changes of hidden modules when the dialog is deleted - - ask as soon as KCMultiDialog can detect that there are unsaved changes to - hidden KCMs (it might even be possible to show the KCMs for that) - -# vim: tw=80 diff --git a/kutils/ksettings/componentsdialog.cpp b/kutils/ksettings/componentsdialog.cpp deleted file mode 100644 index 097d1f6d7..000000000 --- a/kutils/ksettings/componentsdialog.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "ksettings/componentsdialog.h" -#include <klocale.h> -#include <tqlayout.h> -#include <klistview.h> -#include <tqlabel.h> -#include <tqheader.h> -#include <kplugininfo.h> -#include <kiconloader.h> -#include <kdebug.h> -#include <kconfig.h> -#include <kseparator.h> - -namespace KSettings -{ - -class ComponentsDialog::ComponentsDialogPrivate -{ - public: - KListView * listview; - TQFrame * infowidget; - TQLabel * iconwidget; - TQLabel * commentwidget; - TQLabel * descriptionwidget; - TQMap<TQCheckListItem*, KPluginInfo*> plugininfomap; - TQValueList<KPluginInfo*> plugininfolist; -}; - -ComponentsDialog::ComponentsDialog( TQWidget * parent, const char * name ) - : KDialogBase( parent, name, false, i18n( "Select Components" ) ) -, d( new ComponentsDialogPrivate ) -{ - TQWidget * page = new TQWidget( this ); - setMainWidget( page ); - ( new TQHBoxLayout( page, 0, KDialog::spacingHint() ) )->setAutoAdd( true ); - d->listview = new KListView( page ); - d->listview->setMinimumSize( 200, 200 ); - d->infowidget = new TQFrame( page ); - d->infowidget->setMinimumSize( 200, 200 ); - ( new TQVBoxLayout( d->infowidget, 0, KDialog::spacingHint() ) )->setAutoAdd( true ); - d->iconwidget = new TQLabel( d->infowidget ); - ( void )new KSeparator( d->infowidget ); - d->commentwidget = new TQLabel( d->infowidget ); - d->commentwidget->setAlignment( TQt::WordBreak ); - d->descriptionwidget = new TQLabel( d->infowidget ); - d->descriptionwidget->setAlignment( TQt::WordBreak ); - - d->listview->addColumn( TQString::null ); - d->listview->header()->hide(); - d->listview->setRootIsDecorated( true ); - d->listview->setSorting( -1 ); - d->listview->setAcceptDrops( false ); - d->listview->setSelectionModeExt( KListView::Single ); - d->listview->setAllColumnsShowFocus( true ); - - connect( d->listview, TQT_SIGNAL( pressed( TQListViewItem * ) ), this, - TQT_SLOT( executed( TQListViewItem * ) ) ); - connect( d->listview, TQT_SIGNAL( spacePressed( TQListViewItem * ) ), this, - TQT_SLOT( executed( TQListViewItem * ) ) ); - connect( d->listview, TQT_SIGNAL( returnPressed( TQListViewItem * ) ), this, - TQT_SLOT( executed( TQListViewItem * ) ) ); - connect( d->listview, TQT_SIGNAL( selectionChanged( TQListViewItem * ) ), this, - TQT_SLOT( executed( TQListViewItem * ) ) ); -} - -ComponentsDialog::~ComponentsDialog() -{ -} - -void ComponentsDialog::addPluginInfo( KPluginInfo * info ) -{ - d->plugininfolist.append( info ); -} - -void ComponentsDialog::setPluginInfos( const TQMap<TQString, KPluginInfo*> & - plugininfos ) -{ - for( TQMap<TQString, KPluginInfo*>::ConstIterator it = plugininfos.begin(); - it != plugininfos.end(); ++it ) - { - d->plugininfolist.append( it.data() ); - } -} - -void ComponentsDialog::setPluginInfos( const TQValueList<KPluginInfo *> &plugins ) -{ - d->plugininfolist = plugins; -} - -void ComponentsDialog::show() -{ - // clear the treelist - d->listview->clear(); - d->plugininfomap.clear(); - - // construct the treelist - for( TQValueList<KPluginInfo*>::ConstIterator it = d->plugininfolist.begin(); - it != d->plugininfolist.end(); ++it ) - { - ( *it )->load(); - TQCheckListItem * item = new TQCheckListItem( d->listview, ( *it )->name(), - TQCheckListItem::CheckBox ); - if( ! ( *it )->icon().isEmpty() ) - item->setPixmap( 0, SmallIcon( ( *it )->icon(), IconSize( KIcon::Small ) ) ); - item->setOn( ( *it )->isPluginEnabled() ); - d->plugininfomap[ item ] = ( *it ); - } - KDialogBase::show(); -} - -void ComponentsDialog::executed( TQListViewItem * item ) -{ - kdDebug( 704 ) << k_funcinfo << endl; - if( item == 0 ) - return; - if( item->rtti() != 1 ) // check for QCheckListItem - return; - - TQCheckListItem * citem = static_cast<TQCheckListItem *>( item ); - bool checked = citem->isOn(); - - kdDebug( 704 ) << "it's a " << ( checked ? "checked" : "unchecked" ) - << " TQCheckListItem" << endl; - - KPluginInfo * info = d->plugininfomap[ citem ]; - info->setPluginEnabled( checked ); - //checkDependencies( info ); - // show info about the component on the right - d->iconwidget->setPixmap( SmallIcon( info->icon(), KIcon::SizeLarge ) ); - d->commentwidget->setText( info->comment() ); - //d->descriptionwidget->setText( info->description() ); -} - -void ComponentsDialog::savePluginInfos() -{ - for( TQValueList<KPluginInfo*>::ConstIterator it = d->plugininfolist.begin(); - it != d->plugininfolist.end(); ++it ) - { - if( ( *it )->config() ) - { - ( *it )->save(); - ( *it )->config()->sync(); - } - } -} - -void ComponentsDialog::slotOk() -{ - savePluginInfos(); - KDialogBase::slotOk(); -} - -void ComponentsDialog::slotApply() -{ - savePluginInfos(); - KDialogBase::slotApply(); -} - -} //namespace - -#include "componentsdialog.moc" -// vim: sw=4 sts=4 et diff --git a/kutils/ksettings/componentsdialog.h b/kutils/ksettings/componentsdialog.h deleted file mode 100644 index e3f8b60a0..000000000 --- a/kutils/ksettings/componentsdialog.h +++ /dev/null @@ -1,88 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KSETTINGS_COMPONENTSDIALOG_H -#define KSETTINGS_COMPONENTSDIALOG_H - -#include <kdialogbase.h> - -class TQString; -class KPluginInfo; - -namespace KSettings -{ - -/** - @ingroup plugin - @ingroup settings - Dialog for selecting which plugins should be active for an application. Set - the list of available plugins with \ref setPluginInfos. The dialog will save the - configuration on clicking ok or apply to the applications config file. Connect - to the okClicked() and applyClicked() signals to be notified about - configuration changes. -*/ -class KUTILS_EXPORT ComponentsDialog : public KDialogBase -{ - Q_OBJECT - public: - /** - Create Dialog. - - @param parent parent widget - @param name name - */ - ComponentsDialog( TQWidget * parent = 0, const char * name = 0 ); - ~ComponentsDialog(); - - /** - Add a plugin that the dialog offers for selection. - */ - void addPluginInfo( KPluginInfo * ); - /** - Set list of plugins the dialog offers for selection. (Overwrites a previous list) - */ - void setPluginInfos( const TQMap<TQString, KPluginInfo*> & plugininfos ); - /** - Set list of plugins the dialog offers for selection. (Overwrites a previous list) - */ - void setPluginInfos( const TQValueList<KPluginInfo *> &plugins ); - - /** - * reimplemented - */ - void show(); - - protected slots: - void slotOk(); - void slotApply(); - - private slots: - void executed( TQListViewItem * ); - - private: - void savePluginInfos(); - - class ComponentsDialogPrivate; - ComponentsDialogPrivate * d; -}; - -} - -// vim: sw=4 sts=4 et -#endif // KSETTINGS_COMPONENTSDIALOG_H diff --git a/kutils/ksettings/dialog.cpp b/kutils/ksettings/dialog.cpp deleted file mode 100644 index e3bfa579f..000000000 --- a/kutils/ksettings/dialog.cpp +++ /dev/null @@ -1,642 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "ksettings/dialog.h" - - -#include <kcmultidialog.h> -#include <klocale.h> -#include <kservicegroup.h> -#include <kdebug.h> -#include <ktrader.h> -#include <kplugininfo.h> -#include "ksettings/dispatcher.h" -#include "ksettings/componentsdialog.h" -#include <ksimpleconfig.h> -#include <kstandarddirs.h> -#include <kiconloader.h> -#include <tqvbox.h> -#include <tqlabel.h> -#include "tdecmoduleinfo.h" - -namespace KSettings -{ - -struct GroupInfo -{ - TQString id; - TQString name; - TQString comment; - TQString icon; - int weight; - TQString parentid; - TQWidget * page; -}; - -// The TreeList can get really complicated. That's why a tree data structure -// is necessary to make it suck less -class PageNode -{ - private: - typedef TQValueList<PageNode*> List; - enum Type { KCM, Group, Root }; - union Value - { - TDECModuleInfo * kcm; - GroupInfo * group; - }; - Type m_type; - Value m_value; - - Dialog * m_dialog; - List m_children; - PageNode * m_parent; - bool m_visible; - bool m_dirty; - - protected: - PageNode( TDECModuleInfo * info, PageNode * parent ) - : m_type( KCM ) - , m_parent( parent ) - , m_visible( true ) - , m_dirty( true ) - { - m_value.kcm = info; - m_dialog = parent->m_dialog; - } - - PageNode( GroupInfo & group, PageNode * parent ) - : m_type( Group ) - , m_parent( parent ) - , m_visible( true ) - , m_dirty( true ) - { - m_value.group = new GroupInfo( group ); - m_value.group->page = 0; - m_dialog = parent->m_dialog; - } - - void bubbleSort( List::Iterator begin, List::Iterator end ) - { - --end; - bool finished; - List::Iterator lastswapped = begin; - List::Iterator i; - List::Iterator j; - while( begin != end ) - { - finished = true; - i = j = end; - do { - --j; - if( **i < **j ) - { - finished = false; - tqSwap( *i, *j ); - lastswapped = j; - } - --i; - } while( j != begin ); - if( finished ) - return; - ++lastswapped; - begin = lastswapped; - } - } - - public: - PageNode( Dialog * dialog ) - : m_type( Root ) - , m_dialog( dialog ) - , m_parent( 0 ) - , m_visible( true ) - , m_dirty( true ) - {} - - ~PageNode() - { - if( KCM == m_type ) - delete m_value.kcm; - else if( Group == m_type ) - delete m_value.group; - List::Iterator end = m_children.end(); - for( List::Iterator it = m_children.begin(); it != end; ++it ) - delete ( *it ); - } - - int weight() const - { - int w = ( KCM == m_type ) ? m_value.kcm->weight() - : m_value.group->weight; - kdDebug( 700 ) << k_funcinfo << name() << " " << w << endl; - return w; - } - - bool operator<( const PageNode & rhs ) const - { - return weight() < rhs.weight(); - } - - bool isVisible() - { - if( m_dirty ) - { - if( KCM == m_type ) - m_visible = m_dialog->isPluginForKCMEnabled( m_value.kcm ); - else - { - m_visible = false; - List::Iterator end = m_children.end(); - for( List::Iterator it = m_children.begin(); it != end; - ++it ) - if( ( *it )->isVisible() ) - { - m_visible = true; - break; - } - } - m_dirty = false; - } - kdDebug( 700 ) << k_funcinfo << "returns " << m_visible << endl; - return m_visible; - } - - void makeDirty() - { - m_dirty = true; - List::Iterator end = m_children.end(); - for( List::Iterator it = m_children.begin(); it != end; ++it ) - ( *it )->makeDirty(); - } - - TQString name() const - { - if( Root == m_type ) - return TQString::fromAscii( "root node" ); - return ( KCM == m_type ) ? m_value.kcm->moduleName() - : m_value.group->name; - } - - TQStringList parentNames() const - { - TQStringList ret; - PageNode * node = m_parent; - while( node && node->m_type != Root ) - { - ret.prepend( node->name() ); - node = node->m_parent; - } - return ret; - } - - void addToDialog( KCMultiDialog * dlg ) - { - kdDebug( 700 ) << k_funcinfo << "for " << name() << endl; - if( ! isVisible() ) - return; - - if( KCM == m_type ) - { - dlg->addModule( *m_value.kcm, parentNames() ); - return; - } - if( Group == m_type && 0 == m_value.group->page ) - { - TQPixmap icon; - if( ! m_value.group->icon.isNull() ) - icon = SmallIcon( m_value.group->icon, - IconSize( KIcon::Small ) ); - TQVBox * page = dlg->addVBoxPage( m_value.group->name, - TQString::null, icon ); - TQLabel * comment = new TQLabel( m_value.group->comment, page ); - comment->setTextFormat( TQt::RichText ); - m_value.group->page = page; - } - List::Iterator end = m_children.end(); - for( List::Iterator it = m_children.begin(); it != end; ++it ) - ( *it )->addToDialog( dlg ); - } - - void removeFromDialog( KCMultiDialog * dlg ) - { - kdDebug( 700 ) << k_funcinfo << "for " << name() << endl; - if( KCM == m_type ) - return; - if( Root == m_type ) - dlg->removeAllModules(); - List::Iterator end = m_children.end(); - for( List::Iterator it = m_children.begin(); it != end; ++it ) - ( *it )->removeFromDialog( dlg ); - if( Group == m_type ) - { - delete m_value.group->page; - m_value.group->page = 0; - } - } - - void sort() - { - kdDebug( 700 ) << k_funcinfo << name() << endl; - List::Iterator begin = m_children.begin(); - List::Iterator end = m_children.end(); - bubbleSort( begin, end ); - for( List::Iterator it = begin ; it != end; ++it ) - ( *it )->sort(); - } - - bool insert( GroupInfo & group ) - { - if( group.parentid.isNull() ) - { - if( Root == m_type ) - { - m_children.append( new PageNode( group, this ) ); - return true; - } - else - kdFatal( 700 ) << "wrong PageNode insertion" - << kdBacktrace() << endl; - } - if( Group == m_type && group.parentid == m_value.group->id ) - { - m_children.append( new PageNode( group, this ) ); - return true; - } - List::Iterator end = m_children.end(); - for( List::Iterator it = m_children.begin(); it != end; ++it ) - if( ( *it )->insert( group ) ) - return true; - // no parent with the right parentid - if( Root == m_type ) - { - m_children.append( new PageNode( group, this ) ); - return true; - } - return false; - } - - bool insert( TDECModuleInfo * info, const TQString & parentid ) - { - if( parentid.isNull() ) - { - if( Root == m_type ) - { - m_children.append( new PageNode( info, this ) ); - return true; - } - else - kdFatal( 700 ) << "wrong PageNode insertion" - << kdBacktrace() << endl; - } - if( Group == m_type && parentid == m_value.group->id ) - { - m_children.append( new PageNode( info, this ) ); - return true; - } - List::Iterator end = m_children.end(); - for( List::Iterator it = m_children.begin(); it != end; ++it ) - if( ( *it )->insert( info, parentid ) ) - return true; - // no parent with the right parentid - if( Root == m_type ) - { - m_children.append( new PageNode( info, this ) ); - return true; - } - return false; - } - - bool needTree() - { - List::ConstIterator end = m_children.end(); - for( List::ConstIterator it = m_children.begin(); it != end; ++it ) - if( ( *it )->m_children.count() > 0 ) - return true; - return false; - } - - bool singleChild() - { - return ( m_children.count() == 1 ); - } -}; - -class Dialog::DialogPrivate -{ - public: - DialogPrivate( Dialog * parent ) - : dlg( 0 ) - , pagetree( parent ) - { - } - - bool staticlistview; - KCMultiDialog * dlg; - PageNode pagetree; - TQWidget * parentwidget; - TQStringList registeredComponents; - TQValueList<KService::Ptr> services; - TQMap<TQString, KPluginInfo*> plugininfomap; -}; - -Dialog::Dialog( TQWidget * parent, const char * name ) - : TQObject( parent, name ) - , d( new DialogPrivate( this ) ) -{ - d->parentwidget = parent; - d->staticlistview = true; - d->services = instanceServices(); -} - -Dialog::Dialog( ContentInListView content, - TQWidget * parent, const char * name ) - : TQObject( parent, name ) - , d( new DialogPrivate( this ) ) -{ - d->parentwidget = parent; - d->staticlistview = ( content == Static ); - d->services = instanceServices(); -} - -Dialog::Dialog( const TQStringList & components, - TQWidget * parent, const char * name ) - : TQObject( parent, name ) - , d( new DialogPrivate( this ) ) -{ - d->parentwidget = parent; - d->staticlistview = true; - d->services = instanceServices() + parentComponentsServices( components ); -} - -Dialog::Dialog( const TQStringList & components, - ContentInListView content, TQWidget * parent, const char * name ) - : TQObject( parent, name ) - , d( new DialogPrivate( this ) ) -{ - d->parentwidget = parent; - d->staticlistview = ( content == Static ); - d->services = instanceServices() + parentComponentsServices( components ); -} - -Dialog::~Dialog() -{ - delete d; -} - -void Dialog::addPluginInfos( const TQValueList<KPluginInfo*> & plugininfos ) -{ - for( TQValueList<KPluginInfo*>::ConstIterator it = plugininfos.begin(); - it != plugininfos.end(); ++it ) - { - d->registeredComponents.append( ( *it )->pluginName() ); - d->services += ( *it )->kcmServices(); - d->plugininfomap[ ( *it )->pluginName() ] = *it; - } -} - -void Dialog::show() -{ - if( 0 == d->dlg ) - createDialogFromServices(); - Dispatcher::self()->syncConfiguration(); - return d->dlg->show(); -} - -KCMultiDialog * Dialog::dialog() -{ - if( 0 == d->dlg ) - createDialogFromServices(); - return d->dlg; -} - -TQValueList<KService::Ptr> Dialog::instanceServices() const -{ - kdDebug( 700 ) << k_funcinfo << endl; - TQString instanceName = TDEGlobal::instance()->instanceName(); - d->registeredComponents.append( instanceName ); - kdDebug( 700 ) << "calling KServiceGroup::childGroup( " << instanceName - << " )" << endl; - KServiceGroup::Ptr service = KServiceGroup::childGroup( instanceName ); - - TQValueList<KService::Ptr> ret; - - if( service && service->isValid() ) - { - kdDebug( 700 ) << "call was successfull" << endl; - KServiceGroup::List list = service->entries(); - for( KServiceGroup::List::ConstIterator it = list.begin(); - it != list.end(); ++it ) - { - KSycocaEntry * p = *it; - if( p->isType( KST_KService ) ) - { - kdDebug( 700 ) << "found service" << endl; - ret << static_cast<KService *>( p ); - } - else - kdWarning( 700 ) << "KServiceGroup::childGroup returned" - " something else than a KService (kinda)" << endl; - } - } - - return ret; -} - -TQValueList<KService::Ptr> Dialog::parentComponentsServices( - const TQStringList & kcdparents ) const -{ - d->registeredComponents += kcdparents; - TQString constraint = kcdparents.join( - "' in [X-TDE-ParentComponents]) or ('" ); - constraint = "('" + constraint + "' in [X-TDE-ParentComponents])"; - - kdDebug( 700 ) << "constraint = " << constraint << endl; - return KTrader::self()->query( "TDECModule", constraint ); -} - -bool Dialog::isPluginForKCMEnabled( TDECModuleInfo * moduleinfo ) const -{ - // if the user of this class requested to hide disabled modules - // we check whether it should be enabled or not - bool enabled = true; - kdDebug( 700 ) << "check whether the " << moduleinfo->moduleName() - << " KCM should be shown" << endl; - // for all parent components - TQStringList parentComponents = moduleinfo->service()->property( - "X-TDE-ParentComponents" ).toStringList(); - for( TQStringList::ConstIterator pcit = parentComponents.begin(); - pcit != parentComponents.end(); ++pcit ) - { - // if the parentComponent is not registered ignore it - if( d->registeredComponents.find( *pcit ) == - d->registeredComponents.end() ) - continue; - - // we check if the parent component is a plugin - if( ! d->plugininfomap.contains( *pcit ) ) - { - // if not the TDECModule must be enabled - enabled = true; - // we're done for this TDECModuleInfo - break; - } - // if it is a plugin we check whether the plugin is enabled - KPluginInfo * pinfo = d->plugininfomap[ *pcit ]; - pinfo->load(); - enabled = pinfo->isPluginEnabled(); - kdDebug( 700 ) << "parent " << *pcit << " is " - << ( enabled ? "enabled" : "disabled" ) << endl; - // if it is enabled we're done for this TDECModuleInfo - if( enabled ) - break; - } - return enabled; -} - -void Dialog::parseGroupFile( const TQString & filename ) -{ - KSimpleConfig file( filename ); - TQStringList groups = file.groupList(); - for( TQStringList::ConstIterator it = groups.begin(); it != groups.end(); - ++it ) - { - GroupInfo group; - TQString id = *it; - file.setGroup( id.utf8() ); - group.id = id; - group.name = file.readEntry( "Name" ); - group.comment = file.readEntry( "Comment" ); - group.weight = file.readNumEntry( "Weight", 100 ); - group.parentid = file.readEntry( "Parent" ); - group.icon = file.readEntry( "Icon" ); - d->pagetree.insert( group ); - } -} - -void Dialog::createDialogFromServices() -{ - // read .setdlg files - TQString setdlgpath = locate( "appdata", - TDEGlobal::instance()->instanceName() + ".setdlg" ); - TQStringList setdlgaddon = TDEGlobal::dirs()->findAllResources( "appdata", - "ksettingsdialog/*.setdlg" ); - if( ! setdlgpath.isNull() ) - parseGroupFile( setdlgpath ); - if( setdlgaddon.size() > 0 ) - for( TQStringList::ConstIterator it = setdlgaddon.begin(); - it != setdlgaddon.end(); ++it ) - parseGroupFile( *it ); - - // now we process the TDECModule services - for( TQValueList<KService::Ptr>::ConstIterator it = d->services.begin(); - it != d->services.end(); ++it ) - { - // we create the TDECModuleInfo - TDECModuleInfo * info = new TDECModuleInfo( *it ); - TQString parentid; - TQVariant tmp = info->service()->property( "X-TDE-CfgDlgHierarchy", - TQVariant::String ); - if( tmp.isValid() ) - parentid = tmp.toString(); - d->pagetree.insert( info, parentid ); - } - - // At this point d->pagetree holds a nice structure of the pages we want - // to show. It's not going to change anymore so we can sort it now. - d->pagetree.sort(); - - int dialogface = KJanusWidget::IconList; - if( d->pagetree.needTree() ) - dialogface = KJanusWidget::TreeList; - else if( d->pagetree.singleChild() ) - dialogface = KJanusWidget::Plain; - - kdDebug( 700 ) << "creating KCMultiDialog" << endl; - d->dlg = new KCMultiDialog( dialogface, i18n( "Configure" ), - d->parentwidget ); - - if( dialogface == KJanusWidget::TreeList ) - d->dlg->setShowIconsInTreeList( true ); - - // TODO: Don't show the reset button until the issue with the - // KPluginSelector::load() method is solved. - // Problem: - // KCMultiDialog::show() call TDECModule::load() to reset all KCMs - // (KPluginSelector::load() resets all plugin selections and all plugin - // KCMs). - // The reset button calls TDECModule::load(), too but in this case we want the - // KPluginSelector to only reset the current visible plugin KCM and not - // touch the plugin selections. - // I have no idea how to check that in KPluginSelector::load()... - //d->dlg->showButton( KDialogBase::User1, true ); - - if( ! d->staticlistview ) - d->dlg->addButtonBelowList( i18n( "Select Components..." ), this, - TQT_SLOT( configureTree() ) ); - - connect( d->dlg, TQT_SIGNAL( okClicked() ), Dispatcher::self(), - TQT_SLOT( syncConfiguration() ) ); - connect( d->dlg, TQT_SIGNAL( applyClicked() ), Dispatcher::self(), - TQT_SLOT( syncConfiguration() ) ); - connect( d->dlg, TQT_SIGNAL( configCommitted( const TQCString & ) ), - Dispatcher::self(), TQT_SLOT( reparseConfiguration( const TQCString & ) ) ); - - d->pagetree.addToDialog( d->dlg ); - - if( dialogface == KJanusWidget::TreeList ) - d->dlg->unfoldTreeList(); -} - -void Dialog::configureTree() -{ - kdDebug( 700 ) << k_funcinfo << endl; - ComponentsDialog * subdlg = new ComponentsDialog( d->dlg ); - subdlg->setPluginInfos( d->plugininfomap ); - subdlg->show(); - connect( subdlg, TQT_SIGNAL( okClicked() ), this, TQT_SLOT( updateTreeList() ) ); - connect( subdlg, TQT_SIGNAL( applyClicked() ), this, TQT_SLOT( updateTreeList() ) ); - connect( subdlg, TQT_SIGNAL( okClicked() ), this, - TQT_SIGNAL( pluginSelectionChanged() ) ); - connect( subdlg, TQT_SIGNAL( applyClicked() ), this, - TQT_SIGNAL( pluginSelectionChanged() ) ); - connect( subdlg, TQT_SIGNAL( finished() ), subdlg, TQT_SLOT( delayedDestruct() ) ); -} - -void Dialog::updateTreeList() -{ - kdDebug( 700 ) << k_funcinfo << endl; - - d->pagetree.makeDirty(); - - // remove all pages from the dialog and then add them again. This is needed - // because KDialogBase/KJanusWidget can only append to the end of the list - // and we need to have a predefined order. - - d->pagetree.removeFromDialog( d->dlg ); - d->pagetree.addToDialog( d->dlg ); - - if( d->pagetree.needTree() ) - d->dlg->unfoldTreeList( true ); -} - -} //namespace - -#include "dialog.moc" - -// vim: sw=4 ts=4 noet diff --git a/kutils/ksettings/dialog.h b/kutils/ksettings/dialog.h deleted file mode 100644 index 58115426c..000000000 --- a/kutils/ksettings/dialog.h +++ /dev/null @@ -1,224 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KSETTINGS_DIALOG_H -#define KSETTINGS_DIALOG_H - -#include <tqobject.h> -#include <kservice.h> - -template<class T> class TQValueList; -class KPluginInfo; -class KCMultiDialog; -class TDECModuleInfo; - -namespace KSettings -{ - -/** - * @ingroup main - * @ingroup settings - * @short Generic configuration dialog that even works over component boundaries - * - * For more information see \ref KSettings. - * - * This class aims to standardize the use of configuration dialogs in KDE - * applications. Especially when using KParts and/or Plugins you face problems - * creating a consistent config dialog. - * - * To show a configuration dialog you only have to call the show method and be - * done with it. A code example: - * - * You initialize \p m_cfgdlg with - * \code - * m_cfgdlg = new Dialog( Dialog::Static, this ); - * \endcode - * If you use a KPart that was not especially designed for your app you can use - * the second constructor: - * \code - * TQStringList kpartslist; - * for( all my kparts ) - * kpartslist += m_mypart->instance().instanceName(); - * m_cfgdlg = new Dialog( kpartslist, this ); - * \endcode - * and the action for the config dialog is connected to the show slot: - * \code - * KStdAction::preferences( m_cfgdlg, TQT_SLOT( show() ), actionCollection() ); - * \endcode - * - * If you need to be informed when the config was changed and applied in the - * dialog you might want to take a look at Dispatcher. - * - * For more information see \ref KSettings. - * - * @author Matthias Kretz <kretz@kde.org> - * @since 3.2 - */ -class KUTILS_EXPORT Dialog : public TQObject -{ - friend class PageNode; - Q_OBJECT - public: - /** - * Tells the dialog whether the entries in the listview are all static - * or whether it should add a Configure... button to select which parts - * of the optional functionality should be active or not. - */ - enum ContentInListView - { - /** - * Static listview, while running no entries are added or deleted - */ - Static, - /** - * Configurable listview. The user can select what functionality he - * wants. - */ - Configurable - }; - - /** - * Construct a new Preferences Dialog for the application. It uses all - * KCMs with X-TDE-ParentApp set to TDEGlobal::instance()->instanceName(). - * - * @param parent The parent is only used as the parent for the - * dialog - centering the dialog over the parent - * widget. - * @param name name - */ - Dialog( TQWidget * parent = 0, const char * name = 0 ); - - /** - * Construct a new Preferences Dialog for the application. It uses all - * KCMs with X-TDE-ParentApp set to TDEGlobal::instance()->instanceName(). - * - * @param content Select whether you want a static or configurable - * config dialog. - * @param parent The parent is only used as the parent for the - * dialog - centering the dialog over the parent - * widget. - * @param name name - */ - Dialog( ContentInListView content = Static, TQWidget * parent = 0, - const char * name = 0 ); - - /** - * Construct a new Preferences Dialog with the pages for the selected - * instance names. For example if you want to have the configuration - * pages for the kviewviewer KPart you would pass a - * TQStringList consisting of only the name of the part "kviewviewer". - * - * @param components A list of the names of the components that your - * config dialog should merge the config pages in. - * @param parent The parent is only used as the parent for the - * dialog - centering the dialog over the parent - * widget. - * @param name name - */ - Dialog( const TQStringList & components, TQWidget * parent = 0, - const char * name = 0 ); - - /** - * Construct a new Preferences Dialog with the pages for the selected - * instance names. For example if you want to have the configuration - * pages for the kviewviewer KPart you would pass a - * TQStringList consisting of only the name of the part "kviewviewer". - * - * @param components A list of the names of the components that your - * config dialog should merge the config pages in. - * @param content Select whether you want a static or configurable - * config dialog. - * @param parent The parent is only used as the parent for the - * dialog - centering the dialog over the parent - * widget. - * @param name name - */ - Dialog( const TQStringList & components, ContentInListView - content, TQWidget * parent = 0, const char * name = 0 ); - - ~Dialog(); - - /** - * If you use a Configurable dialog you need to pass KPluginInfo - * objects that the dialog should configure. - */ - void addPluginInfos( const TQValueList<KPluginInfo*> & plugininfos ); - - KCMultiDialog * dialog(); - - public slots: - /** - * Show the config dialog. The slot immediatly returns since the dialog - * is non-modal. - */ - void show(); - - signals: - /** - * If you use the dialog in Configurable mode and want to be notified - * when the user changes the plugin selections use this signal. It's - * emitted if the selection has changed and the user pressed Apply or - * Ok. In the slot you would then load and unload the plugins as - * requested. - */ - void pluginSelectionChanged(); - - protected slots: - void configureTree(); - void updateTreeList(); - - private: - /** - * @internal - * Check whether the plugin associated with this KCM is enabled. - */ - bool isPluginForKCMEnabled( TDECModuleInfo * ) const; - - TQValueList<KService::Ptr> instanceServices() const; - TQValueList<KService::Ptr> parentComponentsServices( - const TQStringList & ) const; - /** - * @internal - * Read the .setdlg file and add it to the groupmap - */ - void parseGroupFile( const TQString & ); - - /** - * @internal - * If this module is put into a TreeList hierarchy this will return a - * list of the names of the parent modules. - */ - TQStringList parentModuleNames( TDECModuleInfo * ); - - /** - * @internal - * This method is called only once. The KCMultiDialog is not created - * until it's really needed. So if some method needs to access d->dlg it - * checks for 0 and if it's not created this method will do it. - */ - void createDialogFromServices(); - - class DialogPrivate; - DialogPrivate * d; -}; - -} - -// vim: sw=4 sts=4 et -#endif // KSETTINGS_DIALOG_H diff --git a/kutils/ksettings/dispatcher.cpp b/kutils/ksettings/dispatcher.cpp deleted file mode 100644 index 590ca7e3c..000000000 --- a/kutils/ksettings/dispatcher.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "ksettings/dispatcher.h" - -#include <tqsignal.h> - -#include <kstaticdeleter.h> -#include <kdebug.h> -#include <kconfig.h> -#include <assert.h> - -namespace KSettings -{ - -//class Dispatcher::DispatcherPrivate -//{ -//}; - -static KStaticDeleter<Dispatcher> ksd_kpd; - -Dispatcher * Dispatcher::m_self = 0; - -Dispatcher * Dispatcher::self() -{ - kdDebug( 701 ) << k_funcinfo << endl; - if( m_self == 0 ) - ksd_kpd.setObject( m_self, new Dispatcher() ); - return m_self; -} - -Dispatcher::Dispatcher( TQObject * parent, const char * name ) - : TQObject( parent, name ) - //, d( 0 ) -{ - kdDebug( 701 ) << k_funcinfo << endl; -} - -Dispatcher::~Dispatcher() -{ - kdDebug( 701 ) << k_funcinfo << endl; - //delete d; -} - -void Dispatcher::registerInstance( TDEInstance * instance, TQObject * recv, const char * slot ) -{ - assert( instance != 0 ); - // keep the TDEInstance around and call - // instance->config()->reparseConfiguration when the app should reparse - TQCString instanceName = instance->instanceName(); - kdDebug( 701 ) << k_funcinfo << instanceName << endl; - m_instanceName[ recv ] = instanceName; - TQSignal * sig; - if( m_instanceInfo.contains( instanceName ) ) - { - sig = m_instanceInfo[ instanceName ].signal; - } - else - { - sig = new TQSignal( this, "signal dispatcher" ); - m_instanceInfo[ instanceName ].signal = sig; - m_instanceInfo[ instanceName ].instance = instance; - } - sig->connect( recv, slot ); - - ++m_instanceInfo[ instanceName ].count; - connect( recv, TQT_SIGNAL( destroyed( TQObject * ) ), this, TQT_SLOT( unregisterInstance( TQObject * ) ) ); -} - -TDEConfig * Dispatcher::configForInstanceName( const TQCString & instanceName ) -{ - kdDebug( 701 ) << k_funcinfo << endl; - if( m_instanceInfo.contains( instanceName ) ) - { - TDEInstance * inst = m_instanceInfo[ instanceName ].instance; - if( inst ) - return inst->config(); - } - //if( fallback ) - //return new KSimpleConfig( instanceName ); - return 0; -} - -TQStrList Dispatcher::instanceNames() const -{ - kdDebug( 701 ) << k_funcinfo << endl; - TQStrList names; - for( TQMap<TQCString, InstanceInfo>::ConstIterator it = m_instanceInfo.begin(); it != m_instanceInfo.end(); ++it ) - if( ( *it ).count > 0 ) - names.append( it.key() ); - return names; -} - -void Dispatcher::reparseConfiguration( const TQCString & instanceName ) -{ - kdDebug( 701 ) << k_funcinfo << instanceName << endl; - // check if the instanceName is valid: - if( ! m_instanceInfo.contains( instanceName ) ) - return; - // first we reparse the config of the instance so that the TDEConfig object - // will be up to date - m_instanceInfo[ instanceName ].instance->config()->reparseConfiguration(); - TQSignal * sig = m_instanceInfo[ instanceName ].signal; - if( sig ) - { - kdDebug( 701 ) << "emit signal to instance" << endl; - sig->activate(); - } -} - -void Dispatcher::syncConfiguration() -{ - for( TQMap<TQCString, InstanceInfo>::ConstIterator it = m_instanceInfo.begin(); it != m_instanceInfo.end(); ++it ) - { - ( *it ).instance->config()->sync(); - } -} - -void Dispatcher::unregisterInstance( TQObject * obj ) -{ - kdDebug( 701 ) << k_funcinfo << endl; - TQCString name = m_instanceName[ obj ]; - m_instanceName.remove( obj ); //obj will be destroyed when we return, so we better remove this entry - --m_instanceInfo[ name ].count; - if( m_instanceInfo[ name ].count == 0 ) - { - delete m_instanceInfo[ name ].signal; - m_instanceInfo.remove( name ); - } -} - -//X TDEInstance * Dispatcher::instanceForName( const TQCString & instanceName ) -//X { -//X return m_instanceInfo[ instanceName ].instance; -//X } - -} //namespace - -#include "dispatcher.moc" - -// vim: sw=4 sts=4 et diff --git a/kutils/ksettings/dispatcher.h b/kutils/ksettings/dispatcher.h deleted file mode 100644 index fa0c9e6c9..000000000 --- a/kutils/ksettings/dispatcher.h +++ /dev/null @@ -1,133 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KSETTINGS_DISPATCHER_H -#define KSETTINGS_DISPATCHER_H - -#include <tqobject.h> -#include <tqmap.h> -#include <tdelibs_export.h> - -class TQCString; -class TQSignal; -class TQStrList; -template<class T> class KStaticDeleter; -class TDEInstance; -class TDEConfig; - -namespace KSettings -{ - -/** - * @ingroup settings - * @short Dispatch change notifications from the KCMs to the program. - * - * Since your program does not have direct control over the KCMs that get loaded - * into the TDEConfigureDialog you need a way to get notified. This is what you - * do: - * \code - * Dispatcher::self()->registerInstance( instance(), this, TQT_SLOT( loadSettings() ) ); - * \endcode - * - * @author Matthias Kretz <kretz@kde.org> - * @since 3.2 - */ -class KUTILS_EXPORT Dispatcher : public TQObject -{ - friend class KStaticDeleter<Dispatcher>; - - Q_OBJECT - public: - /** - * Get a reference the the Dispatcher object. - */ - static Dispatcher * self(); - - /** - * Register a slot to be called when the configuration for the instance - * has changed. @p instance is the TDEInstance object - * that is passed to KGenericFactory (if it is used). You can query - * it with KGenericFactory<YourClassName>::instance(). - * instance->instanceName() is also the same name that is put into the - * .desktop file of the KCMs for the X-TDE-ParentComponents. - * - * @param instance The TDEInstance object - * @param recv The object that should receive the signal - * @param slot The slot to be called: TQT_SLOT( slotName() ) - */ - void registerInstance( TDEInstance * instance, TQObject * recv, const char * slot ); - - /** - * @return the TDEConfig object that belongs to the instanceName - */ - TDEConfig * configForInstanceName( const TQCString & instanceName ); - - /** - * @return a list of all the instance names that are currently - * registered - */ - TQStrList instanceNames() const; - -//X /** -//X * @return The TDEInstance object belonging to the instance name you pass -//X * (only works for registered instances of course). -//X */ -//X TDEInstance * instanceForName( const TQCString & instanceName ); - - public slots: - /** - * Call this slot when the configuration belonging to the associated - * instance name has changed. The registered slot will be called. - * - * @param instanceName The value of X-TDE-ParentComponents. - */ - void reparseConfiguration( const TQCString & instanceName ); - - /** - * When this slot is called the TDEConfig objects of all the registered - * instances are sync()ed. This is usefull when some other TDEConfig - * objects will read/write from/to the same config file, so that you - * can first write out the current state of the TDEConfig objects. - */ - void syncConfiguration(); - - private slots: - void unregisterInstance( TQObject * ); - - private: - Dispatcher( TQObject * parent = 0, const char * name = 0 ); - ~Dispatcher(); - static Dispatcher * m_self; - - struct InstanceInfo { - TDEInstance * instance; - TQSignal * signal; - int count; - }; - TQMap<TQCString, InstanceInfo> m_instanceInfo; - TQMap<TQObject *, TQCString> m_instanceName; - - class DispatcherPrivate; - DispatcherPrivate * d; -}; - -} - -// vim: sw=4 sts=4 et -#endif // KSETTINGS_DISPATCHER_H diff --git a/kutils/ksettings/pluginpage.cpp b/kutils/ksettings/pluginpage.cpp deleted file mode 100644 index c7208dc69..000000000 --- a/kutils/ksettings/pluginpage.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "ksettings/pluginpage.h" -#include "kpluginselector.h" -#include <tqlayout.h> -#include <kdialog.h> -#include "ksettings/dispatcher.h" - -namespace KSettings -{ - -class PluginPage::PluginPagePrivate -{ - public: - PluginPagePrivate() - : selwid( 0 ) - { - } - - KPluginSelector * selwid; -}; - - PluginPage::PluginPage( TQWidget * parent, const char * name, const TQStringList & args ) - : TDECModule( parent, name, args ) - , d( new PluginPagePrivate ) -{ - ( new TQVBoxLayout( this, 0, KDialog::spacingHint() ) )->setAutoAdd( true ); - d->selwid = new KPluginSelector( this ); - connect( d->selwid, TQT_SIGNAL( changed( bool ) ), this, TQT_SIGNAL( changed( bool ) ) ); -} - - PluginPage::PluginPage( TDEInstance * instance, TQWidget * parent, const TQStringList & args ) - : TDECModule( instance, parent, args ) - , d( new PluginPagePrivate ) -{ - ( new TQVBoxLayout( this, 0, KDialog::spacingHint() ) )->setAutoAdd( true ); - d->selwid = new KPluginSelector( this ); - connect( d->selwid, TQT_SIGNAL( changed( bool ) ), this, TQT_SIGNAL( changed( bool ) ) ); - connect( d->selwid, TQT_SIGNAL( configCommitted( const TQCString & ) ), - Dispatcher::self(), TQT_SLOT( reparseConfiguration( const TQCString & ) ) ); -} - -PluginPage::~PluginPage() -{ - delete d; -} - -KPluginSelector * PluginPage::pluginSelector() -{ - return d->selwid; -} - -void PluginPage::load() -{ - d->selwid->load(); -} - -void PluginPage::save() -{ - d->selwid->save(); -} - -void PluginPage::defaults() -{ - d->selwid->defaults(); -} - -} //namespace - -#include "pluginpage.moc" -// vim: sw=4 sts=4 et diff --git a/kutils/ksettings/pluginpage.h b/kutils/ksettings/pluginpage.h deleted file mode 100644 index 7f5c7e952..000000000 --- a/kutils/ksettings/pluginpage.h +++ /dev/null @@ -1,120 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KSETTINGS_PLUGINPAGE_H -#define KSETTINGS_PLUGINPAGE_H - -#include <tdecmodule.h> -#include <tdelibs_export.h> - -class KPluginSelector; - -namespace KSettings -{ - -/** - * @ingroup settings - * @ingroup plugin - * @short Convenience TDECModule for creating a plugins config page. - * - * This class makes it very easy to create a plugins configuration page to your - * program. All you need to do is create a class that is derived from - * PluginPage and add the appropriate plugin infos to the KPluginSelector. - * This is done using the pluginSelector() method: - * \code - * typedef KGenericFactory<MyAppPluginConfig, TQWidget> MyAppPluginConfigFactory; - * K_EXPORT_COMPONENT_FACTORY( kcm_myapppluginconfig, MyAppPluginConfigFactory( "kcm_myapppluginconfig" ) ); - * - * MyAppPluginConfig( TQWidget * parent, const char *, const TQStringList & args ) - * : PluginPage( MyAppPluginConfigFactory::instance(), parent, args ) - * { - * pluginSelector()->addPlugins( TDEGlobal::instance()->instanceName(), i18n( "General Plugins" ), "General" ); - * pluginSelector()->addPlugins( TDEGlobal::instance()->instanceName(), i18n( "Effects" ), "Effects" ); - * } - * \endcode - * - * All that remains to be done is to create the appropriate .desktop file - * \verbatim - [Desktop Entry] - Encoding=UTF-8 - Icon=plugin - Type=Service - ServiceTypes=TDECModule - - X-TDE-ModuleType=Library - X-TDE-Library=myapppluginconfig - X-TDE-FactoryName=MyAppPluginConfigFactory - X-TDE-ParentApp=myapp - X-TDE-ParentComponents=myapp - - Name=Plugins - Comment=Select and configure your plugins: - \endverbatim - * - * @author Matthias Kretz <kretz@kde.org> - * @since 3.2 - */ -class KUTILS_EXPORT PluginPage : public TDECModule -{ - Q_OBJECT - public: - /** - * Standart TDECModule constructor. Automatically creates the the - * KPluginSelector widget. - */ - PluginPage( TQWidget * parent = 0, const char * name = 0, const TQStringList & args = TQStringList() ); - - /** - * Standart TDECModule constructor. Automatically creates the the - * KPluginSelector widget. - */ - PluginPage( TDEInstance * instance, TQWidget * parent = 0, const TQStringList & args = TQStringList() ); - - ~PluginPage(); - - /** - * @return a reference to the KPluginSelector. - */ - KPluginSelector * pluginSelector(); - - /** - * Load the state of the plugins (selected or not) from the KPluginInfo - * objects. For KParts plugins everything should work automatically. For - * your own type of plugins you might need to reimplement the - * KPluginInfo::pluginLoaded() method. If that doesn't fit your needs - * you can also reimplement this method. - */ - virtual void load(); - - /** - * Save the state of the plugins to TDEConfig objects - */ - virtual void save(); - virtual void defaults(); - - private: - class PluginPagePrivate; - PluginPagePrivate * d; -}; - -} - -// vim: sw=4 sts=4 et - -#endif // KSETTINGS_PLUGINPAGE_H diff --git a/kutils/tdecmodulecontainer.cpp b/kutils/tdecmodulecontainer.cpp deleted file mode 100644 index 04cbf6751..000000000 --- a/kutils/tdecmodulecontainer.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2004 Frans Englich <frans.englich@telia.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <tqlayout.h> -#include <tqpixmap.h> -#include <tqstringlist.h> -#include <tqtabwidget.h> -#include <tqtooltip.h> -#include <tqvaluelist.h> - -#include <tdecmodule.h> -#include <tdecmoduleinfo.h> -#include <tdecmoduleloader.h> -#include <tdecmoduleproxy.h> -#include <kdebug.h> -#include <kdialog.h> -#include <kglobal.h> -#include <kiconloader.h> -#include <kpushbutton.h> -#include <kservice.h> -#include <kstdguiitem.h> - -#include "tdecmodulecontainer.h" -#include "tdecmodulecontainer.moc" - -/***********************************************************************/ -class TDECModuleContainer::TDECModuleContainerPrivate -{ - public: - TDECModuleContainerPrivate( const TQStringList& mods ) - : modules( mods ) - , tabWidget( 0 ) - , buttons( 0 ) - , hasRootKCM( false ) - , btnRootMode( 0 ) - , btnLayout( 0 ) - , topLayout( 0 ) - {} - - TQStringList modules; - TQTabWidget *tabWidget; - int buttons; - bool hasRootKCM: 1; - KPushButton *btnRootMode; - TQHBoxLayout *btnLayout; - TQVBoxLayout *topLayout; - - -}; -/***********************************************************************/ - - - - - -/***********************************************************************/ -TDECModuleContainer::TDECModuleContainer( TQWidget* parent, const char* name, - const TQString& mods ) - : TDECModule( parent, name ) -{ - d = new TDECModuleContainerPrivate( TQStringList::split( ",", TQString(mods).remove( " " )) ); - init(); -} - -TDECModuleContainer::TDECModuleContainer( TQWidget* parent, const char* name, - const TQStringList& mods ) - : TDECModule( parent, name ), d( new TDECModuleContainerPrivate( mods ) ) -{ - init(); -} - -void TDECModuleContainer::init() -{ - d->topLayout = new TQVBoxLayout( this, 0, KDialog::spacingHint(), "topLayout" ); - d->tabWidget = new TQTabWidget(this, "tabWidget"); - d->tabWidget->setMargin(KDialog::marginHint()); - connect( d->tabWidget, TQT_SIGNAL( currentChanged( TQWidget* ) ), TQT_SLOT( tabSwitched( TQWidget* ) )); - d->topLayout->addWidget( d->tabWidget ); - - if ( !d->modules.isEmpty() ) - { - /* Add our modules */ - for ( TQStringList::Iterator it = d->modules.begin(); it != d->modules.end(); ++it ) - addModule( (*it) ); - - finalize(); - } - -} - -void TDECModuleContainer::finalize() -{ - setButtons( d->buttons ); - if ( d->hasRootKCM ) /* Add a root mode button */ - { - if(!d->btnLayout) /* It could already be added */ - { - d->btnLayout = new TQHBoxLayout(this, 0, 0, "btnLayout"); - d->btnRootMode = new KPushButton(KStdGuiItem::adminMode(), this, "btnRootMode"); - - d->btnLayout->addWidget( d->btnRootMode ); - d->btnLayout->addStretch(); - d->topLayout->addLayout( d->btnLayout ); - } - } -} - -void TDECModuleContainer::addModule( const TQString& module ) -{ - /* In case it doesn't exist we just silently drop it. - * This allows people to easily extend containers. - * For example, KCM monitor gamma can be in tdegraphics. - */ - if ( !KService::serviceByDesktopName( module ) ) - { - kdDebug(713) << "TDECModuleContainer: module '" << - module << "' was not found and thus not loaded" << endl; - return; - } - - if( !TDECModuleLoader::testModule( module )) - return; - - TDECModuleProxy* proxy = new TDECModuleProxy( module, false, d->tabWidget, module.latin1()); - allModules.append( proxy ); - - d->tabWidget->addTab( proxy, TQIconSet(TDEGlobal::iconLoader()->loadIcon( - proxy->moduleInfo().icon(), KIcon::Desktop)), - /* QT eats ampersands for dinner. But not this time. */ - proxy->moduleInfo().moduleName().replace( "&", "&&" )); - - d->tabWidget->setTabToolTip( proxy, proxy->moduleInfo().comment() ); - - connect( proxy, TQT_SIGNAL(changed(TDECModuleProxy *)), TQT_SLOT(moduleChanged(TDECModuleProxy *))); - - /* Collect our buttons - we go for the common deliminator */ - d->buttons = d->buttons | proxy->realModule()->buttons(); - - /* If we should add an Administrator Mode button */ - if ( proxy->moduleInfo().needsRootPrivileges() ) - d->hasRootKCM=true; - - -} - -void TDECModuleContainer::tabSwitched( TQWidget * module ) -{ - if ( !d->hasRootKCM ) - return; - - /* Not like this. Not like this. */ - disconnect( d->btnRootMode, 0, 0, 0 ); - /* Welcome to the real world huh baby? */ - - TDECModuleProxy* mod = (TDECModuleProxy *) module; - - if ( mod->moduleInfo().needsRootPrivileges() && !mod->rootMode() ) - { - d->btnRootMode->setEnabled( true ); - connect( d->btnRootMode, TQT_SIGNAL( clicked() ), - TQT_SLOT( runAsRoot() )); - connect( mod, TQT_SIGNAL( childClosed() ), - TQT_SLOT ( rootExited() )); - } - else - d->btnRootMode->setEnabled( false ); - - setQuickHelp( mod->quickHelp() ); - setAboutData( const_cast<TDEAboutData*>(mod->aboutData()) ); - -} - -void TDECModuleContainer::runAsRoot() -{ - if ( d->tabWidget->currentPage() ) - ( (TDECModuleProxy *) d->tabWidget->currentPage() )->runAsRoot(); - d->btnRootMode->setEnabled( false ); -} - -void TDECModuleContainer::rootExited() -{ - connect( d->btnRootMode, TQT_SIGNAL( clicked() ), TQT_SLOT( runAsRoot() )); - d->btnRootMode->setEnabled( true ); -} - -void TDECModuleContainer::save() -{ - ModuleList list = changedModules; - ModuleList::iterator it; - for ( it = list.begin() ; it !=list.end() ; ++it ) - { - (*it)->save(); - } - - emit changed( false ); - -} - -void TDECModuleContainer::load() -{ - ModuleList list = allModules; - ModuleList::iterator it; - for ( it = list.begin() ; it !=list.end() ; ++it ) - { - (*it)->load(); - } - - emit changed( false ); -} - -void TDECModuleContainer::defaults() -{ - ModuleList list = allModules; - ModuleList::iterator it; - for ( it = list.begin() ; it !=list.end() ; ++it ) - { - (*it)->defaults(); - } - - emit changed( true ); -} - - -void TDECModuleContainer::moduleChanged(TDECModuleProxy * proxy) -{ - changedModules.append( proxy ); - if( changedModules.isEmpty() ) - return; - - emit changed(true); -} - -TDECModuleContainer::~TDECModuleContainer() -{ - delete d; -} - -/***********************************************************************/ - - - - diff --git a/kutils/tdecmodulecontainer.h b/kutils/tdecmodulecontainer.h deleted file mode 100644 index 5708f80cf..000000000 --- a/kutils/tdecmodulecontainer.h +++ /dev/null @@ -1,207 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2004 Frans Englich <frans.englich@telia.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KCMODULECONTAINER_H -#define KCMODULECONTAINER_H - -#include <tqvaluelist.h> -#include <tqstring.h> -#include <tqstringlist.h> - -#include <tdecmodule.h> -#include <tdecmoduleloader.h> - -class TQTabWidget; -class TQWidget; -class TQVBoxLayout; - -class TDECModuleProxy; - -/** - * @ingroup tdecmodule - * @brief TDECModuleContainer is a convenience class encapsulating several TDECModules. - * - * The TDECModuleContainer class is a convenience class for organizing a multiple set - * of TDECModule. TDECModuleContainer is a sub class of TDECModule and builds an interface mainly - * consisting of a tab widget where each tab contains one of the modules specified via one of the - * constructors. TDECModuleContainer can handle modules which requires root permissions. What you - * most likely want is the KCMODULECONTAINER macro. \n - * Sometimes it is of interest to detect in runtime whether a module should be loaded or not. This - * can be achieved by sub classing TDECModuleContainer, doing the probing/testing checks and then manually - * call addModule for each module which should be displayed. When all calls to addModule is done, call - * finalize() which performs some necessary final steps. - * - * @author Frans Englich <frans.englich@telia.com> - * @since 3.4 - */ -class KUTILS_EXPORT TDECModuleContainer : public TDECModule -{ - Q_OBJECT - public: - /** - * Creates a TDECModuleContainer with tabs, each one containing one of the - * specified modules in @p mods. - * - * @param parent the parent TQWidget. - * @param name the module's name. - * @param mods The list of TDECModules to be loaded. The name of each - * TDECModule is its service name, that is the name of the desktop file without - * the ".desktop" part - * - */ - TDECModuleContainer( TQWidget* parent, const char* name, const TQStringList& mods ); - - /** - * This is a convenience function, instead of building a TQStringList you - * can specify the modules in a comma separated TQString. For example; - * \code - * TDECModuleContainer* cont = TDECModuleContainer( this, "kcm_misc", TQString("kcm_energy, kcm_keyboard ,kcm_useraccount, kcm_mouse") ); - * \endcode - * The other constructor takes its modules in a QStringlist which also can be constructed from a - * string and thus you will have to be explicit on the data type. - * - * What you probably want is the KCMODULECONTAINER macro which builds an TDECModule - * for you, taking the modules you want as argument. - * - * @param parent The parent widget - * @param name The service name - * @param mods The modules to load - * @return The TDECModule containing the requested modules. - */ - TDECModuleContainer( TQWidget *parent, const char* name, const TQString& mods = TQString() ); - - /** - * Adds the specified module to the tab widget. Setting the tab icon, text, - * tool tip, connecting the signals is what it does. - * - * @param module the name of the module to add. The name is the desktop file's name - * without the ".desktop" part. - */ - void addModule( const TQString& module ); - - /** - * Default destructor. - */ - virtual ~TDECModuleContainer(); - - /** - * Reimplemented for internal purposes. - * @internal - */ - void save(); - - /** - * Reimplemented for internal purposes. - * @internal - */ - void load(); - - /** - * Reimplemented for internal purposes. - * @internal - */ - void defaults(); - - protected: - - /** - * Sets this KCM's buttons and adds a AdminMode button - * if necessary. If TDECModuleContainer is subclassed finalize() - * should be called in the constructor after all calls to addModule - * have been done. Call it once. - */ - void finalize(); - - typedef TQValueList<TDECModuleProxy*> ModuleList; - - /** - * A list containing TDECModuleProxy objects which - * have changed and must be saved. - */ - ModuleList changedModules; - - /** - * A list of all modules which are encapsulated. - */ - ModuleList allModules; // KDE 4 put in the Private class and abstract with getter - - private slots: - - /** - * Enables/disables the Admin Mode button, as appropriate. - */ - void tabSwitched( TQWidget * module ); - - void moduleChanged(TDECModuleProxy *proxy); - - /** - * Called when the user clicks our custom root button. - */ - void runAsRoot(); - - /** - * Enables the admin mode button - */ - void rootExited(); - - private: - - void init(); - - class TDECModuleContainerPrivate; - TDECModuleContainerPrivate *d; - -}; - -/** - * @ingroup tdecmodule - * This macro creates an factory declaration which when run creates an TDECModule with specified - * modules. For example: - * \code - * KCMODULECONTAINER( "kcm_fonts, kcm_keyboard,kcm_fonts", misc_modules) - * \endcode - * would create a TDECModule with three tabs, each containing one of the specified KCMs. Each - * use of the macro must be accompanied by a desktop file where the factory name equals - * the second argument in the macro(in this example, misc_modules). \n - * The module container takes care of testing the contained modules when being shown, as well - * as when the module itself is asked whether it should be shown. - * - * @param modules the modules to put in the container - * @param factoryName what factory name the module should have - */ -#define KCMODULECONTAINER( modules, factoryName ) \ -extern "C" \ -{ \ - TDECModule *create_## factoryName(TQWidget *parent, const char *name) \ - { \ - return new TDECModuleContainer( parent, name, TQString( modules ) ); \ - } \ - \ - bool test_## factoryName() \ - { \ - TQStringList modList = TQStringList::split( ",", TQString(modules).remove( " " )); \ - for ( TQStringList::Iterator it = modList.begin(); it != modList.end(); ++it ) \ - if ( TDECModuleLoader::testModule( *it ) ) \ - return true; \ - return false; \ - } \ -} - -#endif // KCMODULECONTAINER_H - diff --git a/kutils/tdecmoduleinfo.cpp b/kutils/tdecmoduleinfo.cpp deleted file mode 100644 index 3a7fdfd63..000000000 --- a/kutils/tdecmoduleinfo.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> - Copyright (c) 2000 Matthias Elter <elter@kde.org> - Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> - Copyright (c) 2003 Matthias Kretz <kretz@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <tqvariant.h> - -#include <kdesktopfile.h> -#include <kdebug.h> -#include <kglobal.h> -#include <kstandarddirs.h> -#include <klocale.h> - -#include "tdecmoduleinfo.h" - -class TDECModuleInfo::TDECModuleInfoPrivate -{ - public: - TDECModuleInfoPrivate() : - testModule( false ) - {} - ~TDECModuleInfoPrivate() - { } - - TQString factoryName; - bool testModule; - -}; - -TDECModuleInfo::TDECModuleInfo() -{ - _allLoaded = false; - d = new TDECModuleInfoPrivate; -} - -TDECModuleInfo::TDECModuleInfo(const TQString& desktopFile) -{ - KService::Ptr service = KService::serviceByStorageId(desktopFile); - if(!service) setName(desktopFile); - init(service); -} - -TDECModuleInfo::TDECModuleInfo( KService::Ptr moduleInfo ) -{ - init(moduleInfo); -} - -TDECModuleInfo::TDECModuleInfo( const TDECModuleInfo &rhs ) -{ - d = new TDECModuleInfoPrivate; - ( *this ) = rhs; -} - -// this re-implementation exists to ensure that other code always calls -// our re-implementation, so in case we add data to the d pointer in the future -// we can be sure that we get called when we are copied. -TDECModuleInfo &TDECModuleInfo::operator=( const TDECModuleInfo &rhs ) -{ - _keywords = rhs._keywords; - _name = rhs._name; - _icon = rhs._icon; - _lib = rhs._lib; - _handle = rhs._handle; - _fileName = rhs._fileName; - _doc = rhs._doc; - _comment = rhs._comment; - _needsRootPrivileges = rhs._needsRootPrivileges; - _isHiddenByDefault = rhs._isHiddenByDefault; - _allLoaded = rhs._allLoaded; - _service = rhs._service; - - *d = *(rhs.d); - - return *this; -} - -TQString TDECModuleInfo::factoryName() const -{ - if( d->factoryName.isEmpty() ) - { - d->factoryName = _service->property("X-TDE-FactoryName", TQVariant::String).toString(); - if ( d->factoryName.isEmpty() ) - d->factoryName = library(); - } - - return d->factoryName; -} - -bool TDECModuleInfo::operator==( const TDECModuleInfo & rhs ) const -{ - return ( ( _name == rhs._name ) && ( _lib == rhs._lib ) && ( _fileName == rhs._fileName ) ); -} - -bool TDECModuleInfo::operator!=( const TDECModuleInfo & rhs ) const -{ - return ! operator==( rhs ); -} - -TDECModuleInfo::~TDECModuleInfo() -{ - delete d; -} - -void TDECModuleInfo::init(KService::Ptr s) -{ - _allLoaded = false; - d = new TDECModuleInfoPrivate; - - if ( s ) - _service = s; - else - { - kdDebug(712) << "Could not find the service." << endl; - return; - } - - // set the modules simple attributes - setName(_service->name()); - setComment(_service->comment()); - setIcon(_service->icon()); - - _fileName = ( _service->desktopEntryPath() ); - - // library and factory - setLibrary(_service->library()); - - // get the keyword list - setKeywords(_service->keywords()); -} - -void -TDECModuleInfo::loadAll() -{ - if( !_service ) /* We have a bogus service. All get functions will return empty/zero values */ - return; - - _allLoaded = true; - - // library and factory - setHandle(_service->property("X-TDE-FactoryName", TQVariant::String).toString()); - - TQVariant tmp; - - // read weight - tmp = _service->property( "X-TDE-Weight", TQVariant::Int ); - setWeight( tmp.isValid() ? tmp.toInt() : 100 ); - - // does the module need super user privileges? - tmp = _service->property( "X-TDE-RootOnly", TQVariant::Bool ); - setNeedsRootPrivileges( tmp.isValid() ? tmp.toBool() : false ); - - // does the module need to be shown to root only? - // Deprecated ! KDE 4 - tmp = _service->property( "X-TDE-IsHiddenByDefault", TQVariant::Bool ); - setIsHiddenByDefault( tmp.isValid() ? tmp.toBool() : false ); - - // get the documentation path - setDocPath( _service->property( "DocPath", TQVariant::String ).toString() ); - - tmp = _service->property( "X-TDE-Test-Module", TQVariant::Bool ); - setNeedsTest( tmp.isValid() ? tmp.asBool() : false ); -} - -TQString -TDECModuleInfo::docPath() const -{ - if (!_allLoaded) - const_cast<TDECModuleInfo*>(this)->loadAll(); - - return _doc; -} - -TQString -TDECModuleInfo::handle() const -{ - if (!_allLoaded) - const_cast<TDECModuleInfo*>(this)->loadAll(); - - if (_handle.isEmpty()) - return _lib; - - return _handle; -} - -int -TDECModuleInfo::weight() const -{ - if (!_allLoaded) - const_cast<TDECModuleInfo*>(this)->loadAll(); - - return _weight; -} - -bool -TDECModuleInfo::needsRootPrivileges() const -{ - if (!_allLoaded) - const_cast<TDECModuleInfo*>(this)->loadAll(); - - return _needsRootPrivileges; -} - -bool -TDECModuleInfo::isHiddenByDefault() const -{ - if (!_allLoaded) - const_cast<TDECModuleInfo*>(this)->loadAll(); - - return _isHiddenByDefault; -} - -bool TDECModuleInfo::needsTest() const -{ - return d->testModule; -} - -void TDECModuleInfo::setNeedsTest( bool val ) -{ - d->testModule = val; -} - - - -// vim: ts=2 sw=2 et diff --git a/kutils/tdecmoduleinfo.h b/kutils/tdecmoduleinfo.h deleted file mode 100644 index 0bd7c44e3..000000000 --- a/kutils/tdecmoduleinfo.h +++ /dev/null @@ -1,296 +0,0 @@ -/* - Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> - Copyright (c) 2000 Matthias Elter <elter@kde.org> - Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> - Copyright (c) 2003 Matthias Kretz <kretz@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KCMODULEINFO_H -#define KCMODULEINFO_H - -#include <kservice.h> - -class TQPixmap; -class TQString; -class TQStringList; - -/** - * @ingroup tdecmodule - * A class that provides information about a TDECModule - * - * TDECModuleInfo provides various technical information, such as icon, library - * etc. about a TDECModule.n - * @note Any values set with the set* functions is not - * written back with TDECModuleInfo it only reads value from the desktop file. - * - * @internal - * @author Matthias Hoelzer-Kluepfel <mhk@kde.org> - * @author Matthias Elter <elter@kde.org> - * @author Daniel Molkentin <molkentin@kde.org> - * @since 3.2 - * - */ -class KUTILS_EXPORT TDECModuleInfo -{ - -public: - - /** - * Constructs a TDECModuleInfo. - * @note a TDECModuleInfo object will have to be manually deleted, it is not - * done automatically for you. - * @param desktopFile the desktop file representing the module, or - * the name of the module. - */ - TDECModuleInfo(const TQString& desktopFile); - - /** - * Same as above but takes a KService::Ptr as argument. - * - * @note @p moduleInfo must be a valid pointer. - * - * @param moduleInfo specifies the module - */ - TDECModuleInfo( KService::Ptr moduleInfo ); - - - /** - * Same as above but takes a TDECModuleInfo as argument. - * - * @param rhs specifies the module - */ - TDECModuleInfo( const TDECModuleInfo &rhs ); - - /** - * Same as above but creates an empty TDECModuleInfo. - * You should not normally call this. - * @since 3.4 - */ - TDECModuleInfo(); - - /** - * Assignment operator - */ - TDECModuleInfo &operator=( const TDECModuleInfo &rhs ); - - /** - * Equal operator - * - * @return true if @p rhs equals itself - */ - - bool operator==( const TDECModuleInfo &rhs ) const; - - /** - * @return true if @p rhs is not equal itself - */ - bool operator!=( const TDECModuleInfo &rhs ) const; - - /** - * Default destructor. - */ - ~TDECModuleInfo(); - - /** - * @return the filename of the .desktop file that describes the KCM - */ - TQString fileName() const { return _fileName; } - - /** - * @return the keywords associated with this KCM. - */ - const TQStringList &keywords() const { return _keywords; } - - /** - * Returns the module's factory name, if it's set. If not, the library - * name is returned. - * @returns the module's factory name - * @since 3.4 - */ - TQString factoryName() const; - - /** - * @return the module\'s (translated) name - */ - TQString moduleName() const { return _name; } - // changed from name() to avoid ambiguity with TQObject::name() on multiple inheritance - - /** - * @return a KSharedPtr to KService created from the modules .desktop file - */ - KService::Ptr service() const { return _service; } - - /** - * @return the module's (translated) comment field - */ - TQString comment() const { return _comment; } - - /** - * @return the module's icon name - */ - TQString icon() const { return _icon; } - - /** - * @return the path of the module's documentation - */ - TQString docPath() const; - - /** - * @return the library name - */ - TQString library() const { return _lib; } - - /** - * @return a handle (usually the contents of the FactoryName field) - */ - TQString handle() const; - - /** - * @return the weight of the module which determines the order of the pages in - * the KCMultiDialog. It's set by the X-TDE-Weight field. - */ - int weight() const; - - /** - * @return whether the module might require root permissions - */ - bool needsRootPrivileges() const; - - /** - * @deprecated - * @return the isHiddenByDefault attribute. - */ - bool isHiddenByDefault() const KDE_DEPRECATED; - - - /** - * @returns true if the module should be conditionally - * loaded. - * @since 3.4 - */ - bool needsTest() const; - - -protected: - - /** - * Sets the object's keywords. - * @param keyword the new keywords - */ - void setKeywords(const TQStringList &keyword) { _keywords = keyword; } - - /** - * Sets the object's name. - * @param name the new name - */ - void setName(const TQString &name) { _name = name; } - - /** - * Sets the object's name. - * @param comment the new comment - */ - void setComment(const TQString &comment) { _comment = comment; } - - /** - * Sets the object's icon. - * @param icon the name of the new icon - */ - void setIcon(const TQString &icon) { _icon = icon; } - - /** - * Set the object's library - * @param lib the name of the new library without any extensions or prefixs. - */ - void setLibrary(const TQString &lib) { _lib = lib; } - - /** - * Sets the factory name - * @param handle The new factory name - */ - void setHandle(const TQString &handle) { _handle = handle; } - - /** - * Sets the object's weight property which determines in what - * order modules will be displayed. Default is 100. - * - * @param weight the new weight - */ - void setWeight(int weight) { _weight = weight; } - - - /** - * Sets if the module should be tested for loading. - * @param val the value to set - * @since 3.4 - */ - void setNeedsTest( bool val ); - - /** - * Toggles whether the represented module needs root privileges. - * Use with caution. - * @param needsRootPrivileges if module needs root privilges - */ - void setNeedsRootPrivileges(bool needsRootPrivileges) - { _needsRootPrivileges = needsRootPrivileges; } - - /** - * @deprecated - */ - void setIsHiddenByDefault(bool isHiddenByDefault) - { _isHiddenByDefault = isHiddenByDefault; } - - /** - * Sets the object's documentation path - * @param p the new documentation path - */ - void setDocPath(const TQString &p) { _doc = p; } - - /** - * Reads the service entries specific for TDECModule from the desktop file. - * The usual desktop entries are read in init. - */ - void loadAll(); - -private: - - /** - * Reads the service entries. Called by the constructors. - */ - void init(KService::Ptr s); - -private: - - // KDE4 These needs to be moved to TDECModuleInfoPrivate - TQStringList _keywords; - TQString _name, _icon, _lib, _handle, _fileName, _doc, _comment; - bool _needsRootPrivileges : 1; - bool _isHiddenByDefault : 1; - bool _allLoaded : 1; - int _weight; - - KService::Ptr _service; - - class TDECModuleInfoPrivate; - TDECModuleInfoPrivate *d; - -}; - -#endif // KCMODULEINFO_H - -// vim: ts=2 sw=2 et diff --git a/kutils/tdecmoduleloader.cpp b/kutils/tdecmoduleloader.cpp deleted file mode 100644 index c661ac22f..000000000 --- a/kutils/tdecmoduleloader.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/* - Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> - Copyright (c) 2000 Matthias Elter <elter@kde.org> - Copyright (c) 2003,2004 Matthias Kretz <kretz@kde.org> - Copyright (c) 2004 Frans Englich <frans.englich@telia.com> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <tqfile.h> -#include <tqlabel.h> -#include <tqlayout.h> - -#include <kapplication.h> -#include <kdebug.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <kparts/componentfactory.h> - -#include "tdecmoduleloader.h" - - -/***************************************************************/ -/** - * When something goes wrong in loading the module, this one - * jumps in as a "dummy" module. - */ -class KCMError : public TDECModule -{ - public: - KCMError( const TQString& msg, const TQString& details, TQWidget* parent ) - : TDECModule( parent, "KCMError" ) - { - TQVBoxLayout* topLayout = new TQVBoxLayout( this ); - topLayout->addWidget( new TQLabel( msg, this ) ); - topLayout->addWidget( new TQLabel( details, this ) ); - } -}; -/***************************************************************/ - - - - -TDECModule* TDECModuleLoader::load(const TDECModuleInfo &mod, const TQString &libname, - KLibLoader *loader, ErrorReporting report, TQWidget * parent, - const char * name, const TQStringList & args ) -{ - // attempt to load modules with ComponentFactory, only if the symbol init_<lib> exists - // (this is because some modules, e.g. kcmkio with multiple modules in the library, - // cannot be ported to KGenericFactory) - KLibrary *lib = loader->library(TQFile::encodeName(libname.arg(mod.library()))); - if (lib) { - TQString initSym("init_"); - initSym += libname.arg(mod.library()); - - if ( lib->hasSymbol(TQFile::encodeName(initSym)) ) - { - KLibFactory *factory = lib->factory(); - if ( factory ) - { - TDECModule *module = KParts::ComponentFactory::createInstanceFromFactory<TDECModule>( factory, TQT_TQOBJECT(parent), name ? name : mod.handle().latin1(), args ); - if (module) - return module; - } - // else do a fallback - kdDebug(1208) << "Unable to load module using ComponentFactory. Falling back to old loader." << endl; - } - - // get the create_ function - TQString factory("create_%1"); - void *create = lib->symbol(TQFile::encodeName(factory.arg(mod.handle()))); - - if (create) - { - // create the module - TDECModule* (*func)(TQWidget *, const char *); - func = (TDECModule* (*)(TQWidget *, const char *)) create; - return func( parent, name ? name : mod.handle().latin1() ); - } - else - { - TQString libFileName = lib->fileName(); - lib->unload(); - return reportError( report, i18n("<qt>There was an error when loading the module '%1'.<br><br>" - "The desktop file (%2) as well as the library (%3) was found but " - "yet the module could not be loaded properly. Most likely " - "the factory declaration was wrong, or the " - "create_* function was missing.</qt>") - .arg( mod.moduleName() ) - .arg( mod.fileName() ) - .arg( libFileName ), - TQString::null, parent ); - } - - lib->unload(); - } - return reportError( report, i18n("The specified library %1 could not be found.") - .arg( mod.library() ), TQString::null, parent ); - return 0; -} - -TDECModule* TDECModuleLoader::loadModule(const TDECModuleInfo &mod, bool withfallback, TQWidget * parent, const char * name, const TQStringList & args ) -{ - return loadModule( mod, None, withfallback, parent, name, args ); -} - -TDECModule* TDECModuleLoader::loadModule(const TDECModuleInfo &mod, ErrorReporting report, bool withfallback, TQWidget * parent, const char * name, const TQStringList & args ) -{ - /* - * Simple libraries as modules are the easiest case: - * We just have to load the library and get the module - * from the factory. - */ - - if ( !mod.service() ) - { - if ( mod.moduleName() == "kcmlisa" || mod.moduleName() == "kcmkiolan" ) - { - return reportError( report, - i18n("The module %1 could not be found.") - .arg( mod.moduleName() ), - i18n("<qt><p>The Lisa and lan:/ ioslave modules " - "are not installed by default in Kubuntu, because they are obsolete " - "and replaced by zeroconf.<br> If you still wish to use them, you " - "should install the lisa package from the Universe repository.</p></qt>"), - parent ); - } else { - return reportError( report, - i18n("The module %1 could not be found.") - .arg( mod.moduleName() ), - i18n("<qt><p>The diagnostics is:<br>The desktop file %1 could not be found.</p></qt>").arg(mod.fileName()), - parent ); - } - } - - if (!mod.library().isEmpty()) - { - // get the library loader instance - - KLibLoader *loader = KLibLoader::self(); - - TDECModule *module = load(mod, "kcm_%1", loader, report, parent, name, args ); - /* - * Only try to load libkcm_* if it exists, otherwise KLibLoader::lastErrorMessage would say - * "libkcm_foo not found" instead of the real problem with loading kcm_foo. - */ - if (!KLibLoader::findLibrary( TQCString( "libkcm_" ) + TQFile::encodeName( mod.library() ) ).isEmpty() ) - module = load(mod, "libkcm_%1", loader, report, parent, name, args ); - if (module) - return module; - return reportError( report, - i18n("The module %1 could not be loaded.") - .arg( mod.moduleName() ), TQString::null, parent ); - } - - /* - * Ok, we could not load the library. - * Try to run it as an executable. - * This must not be done when calling from kcmshell, or you'll - * have infinite recursion - * (startService calls kcmshell which calls modloader which calls startService...) - * - */ - if(withfallback) - { - TDEApplication::startServiceByDesktopPath(mod.fileName(), TQString::null); - } - else - { - return reportError( report, - i18n("The module %1 is not a valid configuration module.") - .arg( mod.moduleName() ), i18n("<qt><p>The diagnostics is:<br>The desktop file %1 does not specify a library.</qt>").arg(mod.fileName()), parent ); - } - - return 0; -} - -TDECModule* TDECModuleLoader::loadModule(const TQString &module, TQWidget *parent, - const char *name, const TQStringList & args) -{ - return loadModule(TDECModuleInfo(module), None, false, parent, name, args); -} - -TDECModule* TDECModuleLoader::loadModule(const TQString &module, ErrorReporting - report, TQWidget *parent, const char *name, const TQStringList & args) -{ - return loadModule(TDECModuleInfo(module), report, false, parent, name, args); -} - -void TDECModuleLoader::unloadModule(const TDECModuleInfo &mod) -{ - // get the library loader instance - KLibLoader *loader = KLibLoader::self(); - - // try to unload the library - TQString libname("libkcm_%1"); - loader->unloadLibrary(TQFile::encodeName(libname.arg(mod.library()))); - - libname = "kcm_%1"; - loader->unloadLibrary(TQFile::encodeName(libname.arg(mod.library()))); -} - -void TDECModuleLoader::showLastLoaderError(TQWidget *parent) -{ - KMessageBox::detailedError(parent, - i18n("There was an error loading the module."),i18n("<qt><p>The diagnostics is:<br>%1" - "<p>Possible reasons:</p><ul><li>An error occurred during your last " - "TDE upgrade leaving an orphaned control module<li>You have old third party " - "modules lying around.</ul><p>Check these points carefully and try to remove " - "the module mentioned in the error message. If this fails, consider contacting " - "your distributor or packager.</p></qt>") - .arg(KLibLoader::self()->lastErrorMessage())); - -} - -bool TDECModuleLoader::testModule( const TQString& module ) -{ - return testModule( TDECModuleInfo( module ) ); -} - -bool TDECModuleLoader::testModule( const TDECModuleInfo& module ) -{ - if (!module.service()) - { - kdDebug(1208) << "Module '" << module.fileName() << "' not found." << endl; - return true; - } - - bool doLoad = module.service()->property( "X-TDE-Test-Module", TQVariant::Bool ).toBool(); - if( !doLoad ) - { - return true; - } - else - { - /** - * If something fails we return true - we can't risk functionality becoming - * unavailable because of a buggy test. Furthermore, the error needs to - * show so it is discovered. TDECModuleProxy will detect the error and load - * a corresponding KCMError. - * */ - KLibLoader* loader = KLibLoader::self(); - KLibrary* library = loader->library( TQFile::encodeName((TQString("kcm_%1").arg(module.library()))) ); - if( library ) - { - void *test_func = library->symbol( TQString(TQString("test_%1").arg(module.factoryName())).utf8() ); - if( test_func ) - { - bool (*func)() = (bool(*)())test_func; - if( func() ) - { - return true; - } - else - { - return false; - } - } - else - { - kdDebug(1208) << "The test function for module '" << module.fileName() << "' could not be found." << endl; - return true; - } - } - kdDebug(1208) << "The library '" << module.library() << "' could not be found." << endl; - return true; - } -} - -TDECModule* TDECModuleLoader::reportError( ErrorReporting report, const TQString & text, - TQString details, TQWidget * parent ) -{ - if( details.isNull() ) - details = i18n("<qt><p>The diagnostics is:<br>%1" - "<p>Possible reasons:</p><ul><li>An error occurred during your last " - "TDE upgrade leaving an orphaned control module<li>You have old third party " - "modules lying around.</ul><p>Check these points carefully and try to remove " - "the module mentioned in the error message. If this fails, consider contacting " - "your distributor or packager.</p></qt>").arg(KLibLoader::self()->lastErrorMessage()); - if( report & Dialog ) - KMessageBox::detailedError( parent, text, details ); - if( report & Inline ) - return new KCMError( text, details, parent ); - return 0; -} - -// vim: ts=2 sw=2 et - diff --git a/kutils/tdecmoduleloader.h b/kutils/tdecmoduleloader.h deleted file mode 100644 index 1ae9f6b9f..000000000 --- a/kutils/tdecmoduleloader.h +++ /dev/null @@ -1,220 +0,0 @@ -/* - Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> - Copyright (c) 2002-2003 Daniel Molkentin <molkentin@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -#ifndef MODLOADER_H -#define MODLOADER_H - -#include <tdecmodule.h> -#include <tdecmoduleinfo.h> - -class TQWidget; -class KLibLoader; - -/** - * @ingroup tdecmodule - * @brief Loads a KControl Module. - * - * TDECModuleLoader tries in several ways - * to locate and load a TDECModule. If loading fails a - * zero pointer is returned. \n - * It is very unlikely TDECModuleLoader is what you want - * and @ref TDECModuleProxy suits your needs. - * - * @author Matthias Hoelzer-Kluepfel <mhk@kde.org> - * @author Frans Englich <frans.englich@telia.com> - * @since 3.2 - * @internal -**/ -class KUTILS_EXPORT TDECModuleLoader -{ - public: - - /** - * Loads a @ref TDECModule. If loading fails a zero pointer is returned. - * @param module what module to load - * @param withFallback if true and loading failed a separate window - * with the module may appear and a zero pointer is a returned - * @param parent The parent widget - * @param name The widget's name - * @param args A list of arguments for the module to load - * - * @return a pointer to the loaded @ref TDECModule - * - * @deprecated use the function which explicitly states the error reporting - * method - */ - static TDECModule *loadModule(const TDECModuleInfo &module, bool withFallback=true, - TQWidget * parent = 0, const char * name = 0, - const TQStringList & args = TQStringList() ) KDE_DEPRECATED; - - /** - * Loads a @ref TDECModule. If loading fails a zero pointer is returned. - * @param module what module to load - * with the module may appear and a zero pointer is a returned - * @param parent The parent widget - * @param name The widget's name - * @param args A list of arguments for the module to load - * - * @deprecated use the function which explicitly states the error reporting - * method - */ - static TDECModule *loadModule(const TQString &module, TQWidget *parent = 0, - const char *name = 0, const TQStringList & args = TQStringList()) KDE_DEPRECATED; - - /** - * Determines the way errors are reported - */ - enum ErrorReporting { - /** - * no error reporting is done - * */ - None = 0, - /** - * the error report is shown instead of the - * TDECModule that should have * been loaded - */ - Inline = 1, - /** - * shows a dialog with the error report - */ - Dialog = 2, - /** - * does both Inline and Dialog - */ - Both = 3 - }; - - /** - * Loads a @ref TDECModule. If loading fails a zero pointer is returned. - * @param module what module to load - * @param report see ErrorReporting - * @param withFallback if true and loading failed a separate window - * with the module may appear and a zero pointer is a returned - * @param parent The parent widget - * @param name The widget's name - * @param args A list of arguments for the module to load - * - * @return a pointer to the loaded @ref TDECModule - * @since 3.4 - */ - static TDECModule *loadModule(const TDECModuleInfo &module, ErrorReporting - report, bool withFallback=true, TQWidget * parent = 0, - const char * name = 0, const TQStringList & args = TQStringList() ); - - /** - * Loads a @ref TDECModule. If loading fails a zero pointer is returned. - * @param module what module to load - * @param report see ErrorReporting - * with the module may appear and a zero pointer is a returned - * @param parent The parent widget - * @param name The widget's name - * @param args A list of arguments for the module to load - * - * @return a pointer to the loaded @ref TDECModule - * @since 3.4 - */ - static TDECModule *loadModule(const TQString &module, ErrorReporting - report, TQWidget *parent = 0, const char *name = 0, - const TQStringList & args = TQStringList()); - - /** - * Unloads the module's library - * @param mod What module to unload for - */ - static void unloadModule(const TDECModuleInfo &mod); - - /** - * Display a message box explaining an error occured and possible - * reasons to why. - * - * @deprecated Use a constructor with ErrorReporting set to Dialog to show a - * message box like this function did. - */ - static void showLastLoaderError(TQWidget *parent) KDE_DEPRECATED; - - - /** - * Checks whether an TDECModule should be shown by running its - * test function. If it is unsure whether a module should be shown, it should - * be made available, leaving the decision to the user. - * If false is returned, the module should not be loaded in any interface. - * - * A module declares it needs to be tested by having "X-TDE-Test-Module=true" in - * its desktop file. When that line exists, the following code must be available - * in the module's library: - * - * \code - * extern "C" - * { - * bool test_moduleName() - * { - * // Code testing for hardware/software presence. - * return true; // and the modue will be loaded. - * } - * - * } - * \endcode - * - * where moduleName is the library name for the module. - * - * @param module the module to check - * @returns true if the module should be loaded - * @since 3.4 - */ - static bool testModule( const TQString& module ); - - /** - * Convenience function, essentially the same as above. - * - * @param module the module to check - * @returns true if the module should be loaded - * @since 3.4 - */ - static bool testModule( const TDECModuleInfo& module ); - - /** - * Returns a TDECModule containing the messages @p report and @p text. - * - * @param report the type of error reporting, see ErrorReporting - * @param text the main message - * @param details any additional details - * @param parent The parent widget - * - * @since 3.4 - * @internal - */ - static TDECModule* reportError( ErrorReporting report, const TQString & text, - TQString details, TQWidget * parent ); - - private: - - /** - * Internal loader called by the public loaders. - * @internal - */ - static TDECModule* load(const TDECModuleInfo &mod, const TQString &libname, - KLibLoader *loader, ErrorReporting report, TQWidget * parent = 0, - const char * name = 0, const TQStringList & args = TQStringList() ); - -}; - -// vim: ts=2 sw=2 et -#endif // MODLOADER_H - diff --git a/kutils/tdecmoduleproxy.cpp b/kutils/tdecmoduleproxy.cpp deleted file mode 100644 index 673074c16..000000000 --- a/kutils/tdecmoduleproxy.cpp +++ /dev/null @@ -1,650 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2004 Frans Englich <frans.englich@telia.com> - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <tqapplication.h> -#include <tqcursor.h> -#include <tqdatastream.h> -#include <tqevent.h> -#include <tqfileinfo.h> -#include <tqframe.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqpoint.h> -#include <tqscrollview.h> -#include <tqtextstream.h> -#include <tqvbox.h> -#include <tqwhatsthis.h> -#include <tqwidget.h> - -#include <dcopclient.h> -#include <qxembed.h> - -#include <kapplication.h> -#include <kaboutdata.h> -#include <tdecmodule.h> -#include <tdecmoduleinfo.h> -#include <tdecmoduleloader.h> -#include <kdebug.h> -#include <kdialog.h> -#include <klocale.h> -#include <kprocess.h> -#include <kservice.h> -#include <kstandarddirs.h> -#include <kuser.h> - -#include <X11/Xlib.h> - -#include "tdecmoduleproxy.h" -#include "tdecmoduleproxyIface.h" -#include "tdecmoduleproxyIfaceImpl.h" - -/***************************************************************/ -class TDECModuleProxy::TDECModuleProxyPrivate -{ - public: - TDECModuleProxyPrivate( const TDECModuleInfo & info ) - : args( 0 ) - , kcm( 0 ) - //, view( 0 ) - , embedWidget( 0 ) - , rootProcess ( 0 ) - , embedFrame ( 0 ) - , dcopObject( 0 ) - , dcopClient( 0 ) - , topLayout( 0 ) - , rootCommunicator( 0 ) - , rootInfo( 0 ) - , modInfo( info ) - , withFallback( false ) - , changed( false ) - , rootMode( false ) - , bogusOccupier( false ) - , isInitialized( false ) - {} - - ~TDECModuleProxyPrivate() - { - delete rootInfo; // Delete before embedWidget! - delete embedWidget; // Delete before embedFrame! - delete embedFrame; - delete dcopClient; - delete dcopObject; - delete rootCommunicator; - delete rootProcess; - delete kcm; - } - - TQStringList args; - TDECModule *kcm; - QXEmbed *embedWidget; - TDEProcess *rootProcess; - TQVBox *embedFrame; - TDECModuleProxyIfaceImpl *dcopObject; - DCOPClient *dcopClient; - TQVBoxLayout *topLayout; /* Contains TQScrollView view, and root stuff */ - TDECModuleProxyRootCommunicatorImpl *rootCommunicator; - TQLabel *rootInfo; - TQCString dcopName; - TDECModuleInfo modInfo; - bool withFallback; - bool changed; - bool rootMode; - bool bogusOccupier; - bool isInitialized; -}; -/***************************************************************/ - - - -/* - TODO: - - - How TDECModuleProxy behaves wrt memory leaks and behavior, when exiting - from root mode is not tested, because no code make use of it. It needs - work, if it should be used. - - - Should write a document which outlines test cases, to avoid - regressions. This class is a hazard. - - - Two Layout problems in runAsRoot: - * lblBusy doesn't show - * d->kcm/d->rootInfo doesn't get it right when the user - presses cancel in the tdesu dialog - - - Resizing horizontally is contrained; minimum size is set somewhere. - It appears to be somehow derived from the module's size. - - - Prettify: set icon in KCMultiDialog. - - - Perhaps it's possible to link against tdesu such that - the dialog is in process? - - */ -/***************************************************************/ -TDECModule * TDECModuleProxy::realModule() const -{ - - /* - * Note, don't call any function that calls realModule() since - * that leads to an infinite loop. - */ - - kdDebug(711) << k_funcinfo << endl; - - /* Already loaded */ - if( d->kcm ) - return d->kcm; - - /* /We/ have no kcm, but kcmshell running with root prevs does.. */ - if( d->rootMode ) - return 0; - - TQApplication::setOverrideCursor( Qt::WaitCursor ); - - TDECModuleProxy * that = const_cast<TDECModuleProxy*>( this ); - - if( !d->isInitialized ) - { - d->dcopName = TQString(moduleInfo().handle().prepend("TDECModuleProxy-")).utf8(); - d->topLayout = new TQVBoxLayout( that, 0, 0, "topLayout" ); - - d->isInitialized = true; - } - - if( !d->dcopClient ) - d->dcopClient = new DCOPClient(); - - if( !d->dcopClient->isRegistered() ) - d->dcopClient->registerAs( d->dcopName, false ); - - d->dcopClient->setAcceptCalls( true ); - - if( d->dcopClient->appId() == d->dcopName || d->bogusOccupier ) - { /* We got the name we requested, because no one was before us, - * or, it was an random application which had picked that name */ - kdDebug(711) << "Module not already loaded, loading module" << endl; - - d->dcopObject = new TDECModuleProxyIfaceImpl( d->dcopName, that ); - - d->kcm = TDECModuleLoader::loadModule( moduleInfo(), TDECModuleLoader::Inline, d->withFallback, - that, name(), d->args ); - - connect( d->kcm, TQT_SIGNAL( changed( bool ) ), - TQT_SLOT(moduleChanged(bool)) ); - connect( d->kcm, TQT_SIGNAL( destroyed() ), - TQT_SLOT( moduleDestroyed() ) ); - connect( d->kcm, TQT_SIGNAL(quickHelpChanged()), - TQT_SIGNAL(quickHelpChanged())); - TQWhatsThis::add( that, d->kcm->quickHelp() ); - - d->topLayout->addWidget( d->kcm ); - - if ( !d->rootInfo && /* If the message was not yet created */ - d->kcm->useRootOnlyMsg() /* and the module requests the message */ && - moduleInfo().needsRootPrivileges() /* and the module wants root access */ && - !KUser().isSuperUser() ) /* and we are not currently root */ - { - - d->rootInfo = new TQLabel( that, "rootInfo" ); - d->topLayout->insertWidget( 0, d->rootInfo ); - - d->rootInfo->setFrameShape(TQFrame::Box); - d->rootInfo->setFrameShadow(TQFrame::Raised); - - const TQString msg = d->kcm->rootOnlyMsg(); - if( msg.isEmpty() ) - d->rootInfo->setText(i18n( - "<b>Changes in this section requires root access.</b><br />" - "Click the \"Administrator Mode\" button to " - "allow modifications.")); - else - d->rootInfo->setText(msg); - - TQWhatsThis::add( d->rootInfo, i18n( - "This section requires special permissions, probably " - "for system-wide changes; therefore, it is " - "required that you provide the root password to be " - "able to change the module's properties. If " - "you do not provide the password, the module will be " - "disabled.")); - } - } - else - { - kdDebug(711) << "Module already loaded, loading KCMError" << endl; - - d->dcopClient->detach(); - /* Re-register as anonymous */ - d->dcopClient->attach(); - - d->dcopClient->setNotifications( true ); - connect( d->dcopClient, TQT_SIGNAL( applicationRemoved( const TQCString& )), - TQT_SLOT( applicationRemoved( const TQCString& ))); - - /* Figure out the name of where the module is already loaded */ - TQByteArray replyData, data; - TQCString replyType; - TQString result; - TQDataStream arg, stream( replyData, IO_ReadOnly ); - - if( d->dcopClient->call( d->dcopName, d->dcopName, "applicationName()", - data, replyType, replyData )) - { - stream >> result; - - d->kcm = TDECModuleLoader::reportError( TDECModuleLoader::Inline, - i18n( "Argument is application name", "This configuration section is " - "already opened in %1" ).arg( result ), " ", that ); - - d->topLayout->addWidget( d->kcm ); - } - else - { - kdDebug(711) << "Calling TDECModuleProxy's DCOP interface for fetching the name failed." << endl; - d->bogusOccupier = true; - TQApplication::restoreOverrideCursor(); - return realModule(); - } - } - - TQApplication::restoreOverrideCursor(); - - return d->kcm; -} - -void TDECModuleProxy::applicationRemoved( const TQCString& app ) -{ - if( app == d->dcopName ) - { - /* Violence: Get rid of KCMError & CO, so that - * realModule() attempts to reload the module */ - delete d->kcm; - d->kcm = 0; - d->dcopClient->setNotifications( false ); - realModule(); - d->kcm->show(); - } -} - -void TDECModuleProxy::showEvent( TQShowEvent * ev ) -{ - - kdDebug(711) << k_funcinfo << endl; - ( void )realModule(); - - /* We have no kcm, if we're in root mode */ - if( d->kcm ) - d->kcm->show(); - - TQWidget::showEvent( ev ); - -} - -void TDECModuleProxy::runAsRoot() -{ - if ( !moduleInfo().needsRootPrivileges() ) - return; - - TQApplication::setOverrideCursor( Qt::WaitCursor ); - - delete d->rootProcess; - delete d->embedWidget; - delete d->embedFrame; - - d->embedFrame = new TQVBox( this, "embedFrame" ); - d->embedFrame->setFrameStyle( TQFrame::Box | TQFrame::Raised ); - - TQPalette pal( red ); - pal.setColor( TQColorGroup::Background, - colorGroup().background() ); - d->embedFrame->setPalette( pal ); - d->embedFrame->setLineWidth( 2 ); - d->embedFrame->setMidLineWidth( 2 ); - d->topLayout->addWidget(d->embedFrame,1); - - d->embedWidget = new QXEmbed( d->embedFrame, "embedWidget" ); - - d->embedFrame->show(); - - TQLabel *lblBusy = new TQLabel(i18n("<big>Loading...</big>"), d->embedWidget, "lblBusy" ); - lblBusy->setTextFormat(RichText); - lblBusy->setAlignment(AlignCenter); - lblBusy->setGeometry(0,0, d->kcm->width(), d->kcm->height()); - lblBusy->show(); - - deleteClient(); - /* The DCOP registration is now gone, and it will occur again when kcmshell soon - * registers. Here's a race condition in other words, but how likely is that? - * - * - It's a user initiated action, which means the user have to do weird stuff, very - * quick. - * - If the user _do_ manage to fsck up, the code will recover gracefully, see realModule(). - * - * So no worry. At the end of this function, communication with - * the DCOP object is established. - */ - - /* Prepare the process to run the kcmshell */ - TQString cmd = moduleInfo().service()->exec().stripWhiteSpace(); - if (cmd.left(5) == "tdesu") - { - cmd = TQString(cmd.remove(0,5)).stripWhiteSpace(); - - /* Remove all tdesu switches */ - while( cmd.length() > 1 && cmd[ 0 ] == '-' ) - cmd = TQString(cmd.remove( 0, cmd.find( ' ' ) )).stripWhiteSpace(); - } - - if (cmd.left(8) == "kcmshell") - cmd = TQString(cmd.remove(0,8)).stripWhiteSpace(); - - /* Run the process */ - TQString tdesu = KStandardDirs::findExe("tdesu"); - if (!tdesu.isEmpty()) - { - - d->rootProcess = new TDEProcess; - - *d->rootProcess << tdesu; - *d->rootProcess << "--nonewdcop" << "-n" << "-d" << TQString( "-i%1" ).arg(moduleInfo().icon()); - - *d->rootProcess << TQString("%1 %2 --embed-proxy %3 --lang %4").arg(locate("exe", "kcmshell")) - .arg(cmd).arg(d->embedWidget->winId()).arg(TDEGlobal::locale()->language()); - - connect(d->rootProcess, TQT_SIGNAL(processExited(TDEProcess*)), TQT_SLOT(rootExited())); - - if ( !d->rootProcess->start( TDEProcess::NotifyOnExit )) - { - d->rootMode = false; - rootExited(); - } - else - { - d->rootMode = true; - kapp->dcopClient(); - d->rootCommunicator = new TDECModuleProxyRootCommunicatorImpl( d->dcopName + "-RootCommunicator", this ); - } - - delete lblBusy; - TQApplication::restoreOverrideCursor(); - return; - } - - /* Clean up in case of failure */ - delete d->embedWidget; - d->embedWidget = 0; - delete d->embedFrame; - d->embedFrame = 0; - - TQApplication::restoreOverrideCursor(); -} - -void TDECModuleProxy::rootExited() -{ - kdDebug(711) << k_funcinfo << endl; - - if ( d->embedWidget->embeddedWinId() ) - XDestroyWindow(tqt_xdisplay(), d->embedWidget->embeddedWinId()); - - delete d->embedWidget; - d->embedWidget = 0; - - delete d->rootProcess; - d->rootProcess = 0; - - delete d->embedFrame; - d->embedFrame=0; - - delete d->rootCommunicator; - d->rootCommunicator = 0; - - /* Such that the "ordinary" module loads again */ - d->rootMode = false; - - d->topLayout->invalidate(); - - TQShowEvent ev; - showEvent( &ev ); - - moduleChanged( false ); - emit childClosed(); -} - -TDECModuleProxy::~TDECModuleProxy() -{ - deleteClient(); - TDECModuleLoader::unloadModule(moduleInfo()); - - delete d; -} - -void TDECModuleProxy::deleteClient() -{ - if( d->embedWidget ) - XKillClient(tqt_xdisplay(), d->embedWidget->embeddedWinId()); - - - delete d->kcm; - d->kcm = 0; - - delete d->dcopObject; - d->dcopObject = 0; - - if( d->dcopClient && !d->dcopClient->detach() ) - kdDebug(711) << "Unregistering from DCOP failed." << endl; - - delete d->dcopClient; - d->dcopClient = 0; - - kapp->syncX(); - -} - -void TDECModuleProxy::moduleChanged( bool c ) -{ - if( d->changed == c ) - return; - - d->changed = c; - emit changed( c ); - emit changed( this ); -} - -void TDECModuleProxy::moduleDestroyed() -{ - d->kcm = 0; -} - -TDECModuleProxy::TDECModuleProxy( const KService::Ptr & service, bool withFallback, - TQWidget * parent, const char * name, const TQStringList & args) - : TQWidget( parent, name ) -{ - init( TDECModuleInfo( service )); - d->args = args; - d->withFallback = withFallback; -} - -TDECModuleProxy::TDECModuleProxy( const TDECModuleInfo & info, bool withFallback, - TQWidget * parent, const char * name, const TQStringList & args ) - : TQWidget( parent, name ) -{ - init( info ); - d->args = args; - d->withFallback = withFallback; -} - -TDECModuleProxy::TDECModuleProxy( const TQString& serviceName, bool withFallback, - TQWidget * parent, const char * name, - const TQStringList & args) - : TQWidget( parent, name ) -{ - init( TDECModuleInfo( serviceName )); - d->args = args; - d->withFallback = withFallback; -} - -void TDECModuleProxy::init( const TDECModuleInfo& info ) -{ - kdDebug(711) << k_funcinfo << endl; - - d = new TDECModuleProxyPrivate( info ); - - /* This is all we do for now; all the heavy work is - * done in realModule(). It's called when the module - * _actually_ is needed, in for example showEvent(). - * The module is loaded "on demand" -- lazy loading. - */ - -} - -void TDECModuleProxy::load() -{ - - if( d->rootMode ) - callRootModule( "load()" ); - else if( realModule() ) - { - d->kcm->load(); - moduleChanged( false ); - } -} - -void TDECModuleProxy::save() -{ - if( d->rootMode ) - callRootModule( "save()" ); - else if( d->changed && realModule() ) - { - d->kcm->save(); - moduleChanged( false ); - } -} - -void TDECModuleProxy::callRootModule( const TQCString& function ) -{ - TQByteArray sendData, replyData; - TQCString replyType; - - /* Note, we don't use d->dcopClient here, because it's used for - * the loaded module(and it's not "us" when this function is called) */ - if( !kapp->dcopClient()->call( d->dcopName, d->dcopName, function, sendData, - replyType, replyData, true, -1 )) - kdDebug(711) << "Calling function '" << function << "' failed." << endl; - -} - -void TDECModuleProxy::defaults() -{ - if( d->rootMode ) - callRootModule( "defaults()" ); - if( realModule() ) - d->kcm->defaults(); -} - -TQString TDECModuleProxy::quickHelp() const -{ - - if( !d->rootMode ) - return realModule() ? realModule()->quickHelp() : TQString::null; - else - { - TQByteArray data, replyData; - TQCString replyType; - - if (kapp->dcopClient()->call(d->dcopName, d->dcopName, "quickHelp()", - data, replyType, replyData)) - kdDebug(711) << "Calling DCOP function bool changed() failed." << endl; - else - { - TQDataStream reply(replyData, IO_ReadOnly); - if (replyType == "TQString") - { - TQString result; - reply >> result; - return result; - } - else - kdDebug(711) << "DCOP function changed() returned mumbo jumbo." << endl; - } - return TQString::null; - } -} - -const TDEAboutData * TDECModuleProxy::aboutData() const -{ - if( !d->rootMode ) - return realModule() ? realModule()->aboutData() : 0; - else - /* This needs fixing, perhaps cache a TDEAboutData copy - * while in root mode? */ - return 0; - - -} - -int TDECModuleProxy::buttons() const -{ - return realModule() ? realModule()->buttons() : - TDECModule::Help | TDECModule::Default | TDECModule::Apply ; -} - -TQString TDECModuleProxy::rootOnlyMsg() const -{ - return realModule() ? realModule()->rootOnlyMsg() : TQString::null; -} - -bool TDECModuleProxy::useRootOnlyMsg() const -{ - return realModule() ? realModule()->useRootOnlyMsg() : true; -} - -TDEInstance * TDECModuleProxy::instance() const -{ - return realModule() ? realModule()->instance() : 0; -} - -bool TDECModuleProxy::changed() const -{ - return d->changed; -} - -const TDECModuleInfo& TDECModuleProxy::moduleInfo() const -{ - return d->modInfo; -} - -bool TDECModuleProxy::rootMode() const -{ - return d->rootMode; -} - -TQCString TDECModuleProxy::dcopName() const -{ - return d->dcopName; -} - -void TDECModuleProxy::emitQuickHelpChanged() -{ - emit quickHelpChanged(); -} - -/***************************************************************/ -#include "tdecmoduleproxy.moc" - -// vim: sw=4 ts=4 noet diff --git a/kutils/tdecmoduleproxy.h b/kutils/tdecmoduleproxy.h deleted file mode 100644 index 9fc559d97..000000000 --- a/kutils/tdecmoduleproxy.h +++ /dev/null @@ -1,358 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Matthias Kretz <kretz@kde.org> - Copyright (C) 2004 Frans Englich <frans.englich@telia.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KCMODULEPROXY_H -#define KCMODULEPROXY_H - -#include <tqwidget.h> -#include <tqstringlist.h> - -#include <kservice.h> -#include <tdelibs_export.h> - -class TDEAboutData; -class TDECModule; -class TDECModuleInfo; -class TDEInstance; -class TDEProcess; - -/** - * @ingroup tdecmodule - * - * @brief Encapsulates a TDECModule for embedding. - * - * TDECModuleProxy is a wrapper for TDECModule intended for cases where - * modules are to be displayed. It ensures layout is consistent, handles - * root/administrator modules and in general takes care of the details - * needed for making a module available in an interface. A TDECModuleProxy - * can be treated as a TQWidget, without worrying about the details specific - * for modules such as library loading. TDECModuleProxy is not a sub class of TDECModule - * but its API closely resembles TDECModule's.\n - * Usually, an instance is created by passing one of the constructors a KService::Ptr, - * TDECModuleInfo or simply the name of the module and then added to the layout as any - * other widget. \n - * When the user have changed the module, changed( bool ) as well as changed ( TDECModuleProxy * ) - * is emitted. TDECModuleProxy does not take care of prompting for saving - if the object is deleted while - * changes is not saved the changes will be lost. changed() returns true if changes are unsaved. \n - * \n - * TDECModuleProxy does not take care of authorization of TDECModules. \n - * TDECModuleProxy do lazy loading, meaning the library will not be loaded or - * any other initialization done before its show() function is called. This means - * modules will only be loaded when they are actually needed as well as it is possible to - * load many TDECModuleProxy without any speed penalty. - * - * TDECModuleProxy should be used in all cases where modules are embedded in order to - * promote code efficiency and usability consistency. - * - * @author Frans Englich <frans.englich@telia.com> - * @author Matthias Kretz <kretz@kde.org> - * - */ -class KUTILS_EXPORT TDECModuleProxy : public TQWidget -{ -Q_OBJECT - - - friend class TDECModuleProxyRootCommunicatorImpl; - -public: - - /** - * Constructs a TDECModuleProxy from a TDECModuleInfo class. - * - * @param info The TDECModuleInfo to construct the module from. - * @param withFallback If set to true and loading of the module fails, - * a alternative will be tried, resulting in the module appearing in its - * own window, if at all. - * The embedded module will be load()ed. - * @param parent the parent TQWidget. - * @param name the module's name. - * @param args This is used in the implementation and is internal. - * Use the default. - */ - TDECModuleProxy( const TDECModuleInfo & info, bool withFallback = true, - TQWidget * parent = 0, const char * name = 0, - const TQStringList & args = TQStringList() ); - - /** - * Constructs a TDECModuleProxy from a module's service name, which is - * equivalent to the desktop file for the kcm without the ".desktop" part. - * Otherwise equal to the one above. - * - * @param serviceName The module's service name to construct from. - * @param withFallback If set to true and loading of the module fails, - * a alternative will be tried, resulting in the module appearing in its - * own window, if at all. - * The embedded module will be load()ed. - * @param parent the parent TQWidget. - * @param name the module's name. - * @param args This is used in the implementation and is internal. - * Use the default. - */ - TDECModuleProxy( const TQString& serviceName, bool withFallback = true, - TQWidget * parent = 0, const char * name = 0, - const TQStringList & args = TQStringList() ); - - /** - * Constructs a TDECModuleProxy from KService. Otherwise equal to the one above. - * - * @param service The KService to construct from. - * @param withFallback If set to true and loading of the module fails, - * a alternative will be tried, resulting in the module appearing in its - * own window, if at all. - * The embedded module will be load()ed. - * @param parent the parent TQWidget. - * @param name the module's name. - * @param args This is used in the implementation and is internal. - * Use the default. - */ - TDECModuleProxy( const KService::Ptr& service, bool withFallback = true, - TQWidget * parent = 0, const char * name = 0, - const TQStringList & args = TQStringList() ); - - /** - * Default destructor - */ - ~TDECModuleProxy(); - - /** - * Calling it will cause the contained module to - * run its load() routine. - */ - void load(); - - /** - * Calling it will cause the contained module to - * run its save() routine. - * - * If the module was not modified, it will not be asked - * to save. - */ - void save(); - - /** - * @return the module's quickHelp(); - */ - TQString quickHelp() const; - - /** - * @return the module's aboutData() - */ - const TDEAboutData * aboutData() const; - - /** - * @return what buttons the module - * needs - */ - int buttons() const; - - /** - * @return The module's custom root - * message, if it has one - * @deprecated - */ - TQString rootOnlyMsg() const; - //KDE4 remove. There's a limit for convenience functions, - // this one's available via moduleInfo()-> and realModule()-> - - /** - * @return If the module is a root module. - * @deprecated - */ - bool useRootOnlyMsg() const; - //KDE4 remove. There's a limit for convenience functions, - // this one's available via moduleInfo()-> and realModule()-> - - /** - * Returns the embedded TDECModule's TDEInstance. - * @return The module's TDEInstance. - * @deprecated - */ - TDEInstance * instance() const; - //KDE4 remove. There's a limit for convenience functions, - // this one's available via realModule() - - /** - * @return true if the module is modified - * and needs to be saved. - */ - bool changed() const; - - /** - * Returns whether the module is running in root mode. A module is in root mode - * when runAsRoot() has been called. A session under root user will never reach - * root mode. - * - * @note realModule() will return null when the module is running in root mode. - * - * @return true if the module is running with root privileges - * @since 3.4 - */ - bool rootMode() const; - - /** - * Access to the actual module. However, if the module is - * running in root mode, see rootMode(), this function returns - * a NULL pointer, since the module is in another process. It may also - * return NULL if anything goes wrong. - * - * @return the encapsulated module. - */ - TDECModule* realModule() const; - - /** - * @return a TDECModuleInfo for the encapsulated - * module - */ - const TDECModuleInfo& moduleInfo() const; - - /** - * Returns the DCOP the module's DCOPClient - * and DCOPObject has(they are identical). - * - * @since 3.4 - */ - TQCString dcopName() const; - -public slots: - - /** - * Calling this will cause the module to be run in - * "administrator mode". - * - * @since 3.4 - */ - void runAsRoot(); - - /** - * Calling it will cause the contained module to - * load its default values. - */ - void defaults(); - - /** - * Calling this, results in deleting the contained - * module, and unregistering from DCOP. A similar result is achieved - * by deleting the TDECModuleProxy itself. - * - * @since 3.4 - */ - void deleteClient(); - -signals: - - /* - * This signal is emitted when the contained module is changed. - */ - void changed( bool state ); - - /** - * This is emitted in the same situations as in the one above. Practical - * when several TDECModuleProxys are loaded. - * - * @since 3.4 - */ - void changed( TDECModuleProxy* mod ); - - /** - * When a module running with root privileges and exits, returns to normal mode, the - * childClosed() signal is emitted. - * - * @since 3.4 - */ - void childClosed(); - - /* - * This signal is relayed from the encapsulated module, and - * is equivalent to the module's own quickHelpChanged() signal. - * - * @since 3.4 - */ - void quickHelpChanged(); - -protected: - - /** - * Reimplemented for internal purposes. Makes sure the encapsulated - * module is loaded before the show event is taken care of. - */ - void showEvent( TQShowEvent * ); - - /** - * Internal intialization function, called by the constructors. - * - * @internal - * @since 3.4 - */ - void init( const TDECModuleInfo& info ); - - - /** - * Emits the quickHelpChanged signal. - * @since 3.4 - */ - void emitQuickHelpChanged(); - -private slots: - - /** - * Calls the function @p function of the root module's TDECModuleProxy - * DCOP interface. - * - * @param function the function signature of the function to call. - * @since 3.4 - */ - void callRootModule( const TQCString& function ); - - /** - * This is called when the module exits from root mode. It zeroes - * pointers, deletes the embed window, and so forth. - * - * @since 3.4 - */ - void rootExited(); - - /** - * Makes sure the proper variables is set and signals are emitted. - */ - void moduleChanged( bool ); - - /** - * Zeroes d->kcm - */ - void moduleDestroyed(); - - /** - * Gets called by DCOP when an application closes. - * Is used to (try to) reload a KCM which previously - * was loaded. - * - * @since 3.4 - */ - void applicationRemoved( const TQCString& app ); - -private: - - class TDECModuleProxyPrivate; - TDECModuleProxyPrivate * d; -}; - -#endif // KCMODULEPROXY_H -// vim: sw=4 ts=4 noet diff --git a/kutils/tdecmoduleproxyIface.h b/kutils/tdecmoduleproxyIface.h deleted file mode 100644 index 22bfa8e52..000000000 --- a/kutils/tdecmoduleproxyIface.h +++ /dev/null @@ -1,121 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2004 Frans Englich <frans.englich@telia.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef __KCMODULEPROXYIFACE_H__ -#define __KCMODULEPROXYIFACE_H__ - -#include <dcopobject.h> - -/** - * @ingroup tdecmodule - * @brief DCOP Interface for TDECModule. - * - * A module (which is loaded via TDECModuleProxy) does always have - * this DCOP interface, whether it's in root mode or not. - * - * @since 3.4 - * @internal - * @author Frans Englich <frans.englich@telia.com> - */ -class TDECModuleProxyIface : virtual public DCOPObject -{ - K_DCOP - -k_dcop: - - /** - * Return the caption of the host application which the module - * is part in. This is the application name, or similar. - * - * @returns the host's name - */ - virtual TQString applicationName() = 0; - - /** - * Save settings. - */ - virtual void save() = 0; - - /** - * Load settings. - */ - virtual void load() = 0; - - /** - * Load defaults. - */ - virtual void defaults() = 0; - - /** - * Returns the module's quick help. - */ - virtual TQString quickHelp() = 0; - - /** - * @returns true if the module has unsaved - * data, typically. - */ - virtual bool changed() = 0; - -k_dcop_signals: - - /** - * Emitted when the state of the module changes. @p c - * is true when the content is changed, otherwise false. - * - * @param c true if the module is modified, false if its not. - * @param module a string identifying the module which was changed. This - * is typically "TDECModuleProx-X" where X is the module's name. - */ - virtual void changed( bool c ); - - virtual void quickHelpChanged(); - -}; - -/** - * @ingroup tdecmodule - * @brief DCOP interface for communicating with the real module running in root mode. - * - * When a TDECModuleProxy tells kcmshell to load "itself" and embed into the - * TDECModuleProxy, this DCOP interface is used to communicate to the real TDECModuleProxy, since - * the TDECModuleProxy which told kcmshell to load itself, is nothing but a shell. - * - * Currently is only the changed signal routed, but it's possible to proxy - * the rest of the TDECModuleProxy API, if it turns out necessary. - * - * @since 3.4 - * @internal - * @author Frans Englich <frans.englich@telia.com> - */ -class TDECModuleProxyRootDispatcher : virtual public DCOPObject -{ - K_DCOP - -k_dcop: - - /** - * TDECModuleProxyIface::changed() gets connected to this. - */ - virtual void changed( bool c ) = 0; - - virtual void quickHelpChanged() = 0; -}; - -#endif // __KCMODULEPROXYIFACE_H__ diff --git a/kutils/tdecmoduleproxyIfaceImpl.cpp b/kutils/tdecmoduleproxyIfaceImpl.cpp deleted file mode 100644 index 53019f72f..000000000 --- a/kutils/tdecmoduleproxyIfaceImpl.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2004 Frans Englich <frans.englich@telia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <tqcstring.h> -#include <tqdatastream.h> - -#include <dcopclient.h> - -#include <kapplication.h> -#include <tdecmoduleproxy.h> -#include <kdebug.h> - -#include "tdecmoduleproxyIfaceImpl.h" - - -#include <tqmessagebox.h> - -TDECModuleProxyIfaceImpl::TDECModuleProxyIfaceImpl( const TQCString& name, - TDECModuleProxy* const client ) - : DCOPObject( name ), TQObject( 0, name ), - p( const_cast<TDECModuleProxy *>( client )) -{ - connect( p, TQT_SIGNAL( changed(bool)), - TQT_SLOT( changedRelay(bool))); - connect( p, TQT_SIGNAL( quickHelpChanged()), - TQT_SLOT( quickHelpRelay())); -} - -void TDECModuleProxyIfaceImpl::save() -{ - kdDebug(711) << k_funcinfo << endl; - p->save(); -} - -void TDECModuleProxyIfaceImpl::load() -{ - kdDebug(711) << k_funcinfo << endl; - p->load(); -} - -void TDECModuleProxyIfaceImpl::defaults() -{ - kdDebug(711) << k_funcinfo << endl; - p->defaults(); -} - -TQString TDECModuleProxyIfaceImpl::applicationName() -{ - return kapp->caption(); -} - -TQString TDECModuleProxyIfaceImpl::quickHelp() -{ - return p->quickHelp(); -} - -bool TDECModuleProxyIfaceImpl::changed() -{ - return p->changed(); -} - -void TDECModuleProxyIfaceImpl::changedRelay( bool c ) -{ - TQByteArray data; - TQDataStream stream(data, IO_WriteOnly); - stream << c; - emitDCOPSignal( "changed(bool)", data ); -} - -void TDECModuleProxyIfaceImpl::quickHelpRelay() -{ - TQByteArray data; - emitDCOPSignal( "quickHelpChanged()", data ); -} - -/***************************************************************/ - - - - -/***************************************************************/ -TDECModuleProxyRootCommunicatorImpl::TDECModuleProxyRootCommunicatorImpl - ( const TQCString& name, TDECModuleProxy* const client ) - : DCOPObject( name ), TQObject( 0, name ), - p( const_cast<TDECModuleProxy *>( client )) -{ - /* - * Connect kcmshell's TDECModuleProxy's change signal - * to us, such that we act as a proxy for - * TDECModuleProxy's API. - */ - - /* Note, we don't use TDECModuleProxy::d->dcopClient */ - kapp->dcopClient()->connectDCOPSignal( 0, p->dcopName(), - "changed(bool)", objId(), "changed(bool)", false ); - - kapp->dcopClient()->connectDCOPSignal( 0, p->dcopName(), - "quickHelpChanged()", objId(), "quickHelpChanged()", false ); -} - -/* Reimplementations of DCOP members */ -void TDECModuleProxyRootCommunicatorImpl::changed( bool c ) -{ - kdDebug(711) << k_funcinfo << endl; - p->moduleChanged( c ); -} - -void TDECModuleProxyRootCommunicatorImpl::quickHelpChanged() -{ - kdDebug(711) << k_funcinfo << endl; - p->emitQuickHelpChanged(); -} - -#include "tdecmoduleproxyIfaceImpl.moc" diff --git a/kutils/tdecmoduleproxyIfaceImpl.h b/kutils/tdecmoduleproxyIfaceImpl.h deleted file mode 100644 index fec8c6e5c..000000000 --- a/kutils/tdecmoduleproxyIfaceImpl.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2004 Frans Englich <frans.englich@telia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __KCMODULEPROXYIFACEIMPL_H__ -#define __KCMODULEPROXYIFACEIMPL_H__ - -#include "tdecmoduleproxyIface.h" - -class TDECModuleProxy; - -/***************************************************************/ -/** @internal - @ingroup internal */ -class TDECModuleProxyIfaceImpl: public TQObject, virtual public TDECModuleProxyIface -{ - /* KDE4 Merge TDECModuleProxyIfaceImpl with TDECModuleProxy(MI) - * if it doesn't break what DCOPClient it binds to. - * Update: This is probably not possible, since we don't want the DCOPObject when - * we're running in root mode. */ - - Q_OBJECT - -public: - - /* Reimplementations of DCOP members */ - TDECModuleProxyIfaceImpl( const TQCString& name, TDECModuleProxy* const client ); - - virtual void save(); - - virtual void load(); - - virtual void defaults(); - - virtual TQString applicationName(); - - virtual TQString quickHelp(); - - virtual bool changed(); -public slots: - - /** - * Emits the changed(bool) DCOP signal. - */ - void changedRelay( bool c ); - - /** - * Simply relays TDECModuleProxy's signal with the same name. - */ - void quickHelpRelay(); - - -private: - - TDECModuleProxy* p; -}; -/***************************************************************/ - - - - -/***************************************************************/ -/** @internal - @ingroup internal */ -class TDECModuleProxyRootCommunicatorImpl: public TQObject, - virtual public TDECModuleProxyRootDispatcher -{ - Q_OBJECT - -public: - TDECModuleProxyRootCommunicatorImpl( const TQCString& name, TDECModuleProxy* const client ); - - /* Reimplementations of DCOP members */ - virtual void changed( bool c ); - - virtual void quickHelpChanged(); - -TDECModuleProxy* p; -}; -/***************************************************************/ - -#endif // __KCMODULEPROXYIFACEIMPL_H__ - diff --git a/kutils/tests/Makefile.am b/kutils/tests/Makefile.am deleted file mode 100644 index 3bde7a9a2..000000000 --- a/kutils/tests/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -INCLUDES = $(all_includes) - -check_PROGRAMS = kfindtest kreplacetest - -TESTS = kfindtest kreplacetest - -kfindtest_SOURCES = kfindtest.cpp -kfindtest_LDADD = ../libkutils.la -kfindtest_LDFLAGS = $(all_libraries) - -kreplacetest_SOURCES = kreplacetest.cpp -kreplacetest_LDADD = ../libkutils.la -kreplacetest_LDFLAGS = $(all_libraries) - -METASOURCES = AUTO - diff --git a/kutils/tests/kfindtest.cpp b/kutils/tests/kfindtest.cpp deleted file mode 100644 index 6c64245dc..000000000 --- a/kutils/tests/kfindtest.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - Copyright (C) 2004, Arend van Beelen jr. <arend@auton.nl> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "../kfind.h" -#include "../kfinddialog.h" -#include "kfindtest.h" - -#include <kapplication.h> -#include <kcmdlineargs.h> -#include <kdebug.h> - -#include <stdlib.h> -#include <assert.h> - -static bool check(TQString txt, TQString a, TQString b) // from kurltest -{ - if (a.isEmpty()) - a = TQString::null; - if (b.isEmpty()) - b = TQString::null; - if (a == b) { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; - } - else { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; - exit(1); - } - return true; -} - -void KFindTest::changeText(uint line, const TQString &text) -{ - Q_ASSERT(line < m_text.count()); - Q_ASSERT(m_find != 0); - - m_line = line; - m_text[line] = text; - m_find->setData(line, text); -} - -void KFindTest::find(const TQString &pattern, long options) -{ - delete m_find; - m_find = new KFind(pattern, options, 0); - - connect(m_find, TQT_SIGNAL(highlight(const TQString &, int, int)), - TQT_SLOT(slotHighlight(const TQString &, int, int))); - connect(m_find, TQT_SIGNAL(highlight(int, int, int)), - TQT_SLOT(slotHighlight(int, int, int))); - - m_line = 0; - KFind::Result result = KFind::NoMatch; - do - { - if(options & KFindDialog::FindIncremental) - m_find->setData(m_line, m_text[m_line]); - else - m_find->setData(m_text[m_line]); - - m_line++; - - result = m_find->find(); - } while(result == KFind::NoMatch && m_line < m_text.count()); -} - -void KFindTest::findNext(const TQString &pattern) -{ - Q_ASSERT(m_find != 0); - - if(!pattern.isNull()) - { - m_find->setPattern(pattern); - } - - KFind::Result result = KFind::NoMatch; - do - { - //kdDebug() << "m_line: " << m_line << endl; - - result = m_find->find(); - - if(result == KFind::NoMatch && m_line < m_text.count()) - { - //kdDebug() << "incrementing m_line..." << endl; - if(m_find->options() & KFindDialog::FindIncremental) - m_find->setData(m_line, m_text[m_line]); - else - m_find->setData(m_text[m_line]); - - m_line++; - } - } while(result == KFind::NoMatch && m_line < m_text.count()); - //kdDebug() << "find next completed" << m_line << endl; -} - -void KFindTest::slotHighlight(const TQString &text, int index, int matchedLength) -{ - m_hits.append("line: \"" + text + "\", index: " + TQString::number(index) + - ", length: " + TQString::number(matchedLength) + "\n"); -} - -void KFindTest::slotHighlight(int id, int index, int matchedLength) -{ - m_hits.append("line: \"" + m_text[id] + "\", index: " + TQString::number(index) + - ", length: " + TQString::number(matchedLength) + "\n"); -} - -int main(int argc, char **argv) -{ - TDECmdLineArgs::init(argc, argv, "kfindtest", "KFindTest", 0, 0, false); - TDEApplication app; - - TQString text = "This file is part of the KDE project.\n" - "This library is free software; you can redistribute it and/or\n" - "modify it under the terms of the GNU Library General Public\n" - "License version 2, as published by the Free Software Foundation.\n" - "\n" - " This library is distributed in the hope that it will be useful,\n" - " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" - " Library General Public License for more details.\n" - "\n" - " You should have received a copy of the GNU Library General Public License\n" - " along with this library; see the file COPYING.LIB. If not, write to\n" - " the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,\n" - " Boston, MA 02110-1301, USA.\n"; - - TQString output1 = "line: \"This file is part of the KDE project.\", index: 0, length: 4\n" - "line: \"This library is free software; you can redistribute it and/or\", index: 0, length: 4\n" - "line: \" This library is distributed in the hope that it will be useful,\", index: 4, length: 4\n" - "line: \" along with this library; see the file COPYING.LIB. If not, write to\", index: 15, length: 4\n"; - - TQString output2 = "line: \"This file is part of the KDE project.\", index: 0, length: 0\n" - "line: \"This file is part of the KDE project.\", index: 2, length: 1\n" - "line: \"This file is part of the KDE project.\", index: 2, length: 2\n" - "line: \"This library is free software; you can redistribute it and/or\", index: 42, length: 3\n" - "line: \" This library is distributed in the hope that it will be useful,\", index: 21, length: 3\n" - "line: \" This library is distributed in the hope that it will be useful,\", index: 21, length: 5\n" - "line: \" This library is distributed in the hope that it will be useful,\", index: 21, length: 4\n" - "line: \" This library is distributed in the hope that it will be useful,\", index: 21, length: 3\n" - "line: \"This file is part of the KDE project.\", index: 2, length: 2\n" - "line: \"This library is free software; you can redistribute it and/or\", index: 25, length: 1\n" - "line: \"This library is free software; you can redistribute it and/or\", index: 25, length: 2\n" - "line: \" but WITHOUT ANY WARRANTY; without even the implied warranty of\", index: 20, length: 8\n" - "line: \"This library is free software; you can redistribute it and/or\", index: 16, length: 4\n" - "line: \"License version 2, as published by the Free Software Foundation.\", index: 44, length: 19\n"; - - TQString output3 = "line: \"This file is part of the KDE project.\", index: 0, length: 0\n" - "line: \"This file is part of the KDE project.\", index: 2, length: 1\n" - "line: \"This file is part of the KDE project.\", index: 2, length: 2\n" - "line: \"This library is free software; you can redistribute it and/or\", index: 42, length: 3\n" - "line: \"This library is free software; you can redistribute it and/or\", index: 42, length: 4\n" - "line: \" This library is distributed in the hope that it will be useful,\", index: 21, length: 4\n" - "line: \" This library is distributed in the hope that it will be useful,\", index: 21, length: 5\n" - "line: \" This library is distributed in the hope that it will be useful,\", index: 21, length: 4\n" - "line: \" This library is distributed in the hope that it will be useful,\", index: 21, length: 3\n" - "line: \"This file is part of the KDE project.\", index: 2, length: 2\n" - "line: \"This file is part of the KDE project.\", index: 2, length: 1\n" - "line: \"The second line now looks a whole lot different.\", index: 18, length: 1\n" - "line: \"License version 2, as published by the Free Software Foundation.\", index: 48, length: 2\n" - "line: \" but WITHOUT ANY WARRANTY; without even the implied warranty of\", index: 20, length: 8\n" - "line: \" but WITHOUT ANY xxxx; without even the implied warranty of\", index: 51, length: 6\n" - "line: \"License version 2, as published by the Free Software Foundation.\", index: 39, length: 4\n" - "line: \"License version 2, as published by the Free Software Foundation.\", index: 44, length: 19\n"; - - KFindTest *test = new KFindTest(TQStringList::split('\n', text, true)); - - kdDebug() << "Plain static search..." << endl; - - // first we do a simple text searching the text and doing a few find nexts - test->find("This", 0); - test->findNext(); - test->findNext(); - test->findNext(); - test->findNext(); - test->findNext(); - - check("result", test->hits().join(""), output1); - test->clearHits(); - kdDebug() << "PASSED" << endl; - - kdDebug() << "FindIncremental with static contents..." << endl; - - // now we'll do some searches using FindIncremental - test->find("", KFindDialog::FindIncremental); - test->findNext("i"); - test->findNext("is"); - test->findNext("ist"); - test->findNext(); - test->findNext("istri"); - test->findNext("istr"); - test->findNext("ist"); - test->findNext("is"); - test->findNext("W"); - test->findNext("WA"); - test->findNext("WARRANTY"); - test->findNext("Free"); - test->findNext("Software Foundation"); - - check("result", test->hits().join(""), output2); - test->clearHits(); - kdDebug() << "PASSED" << endl; - - kdDebug() << "FindIncremental with dynamic contents..." << endl; - - // now do that again but with pages that change between searches - test->find("", KFindDialog::FindIncremental); - test->findNext("i"); - test->findNext("is"); - test->findNext("ist"); - test->findNext("istr"); - test->findNext(); - test->changeText(1, "The second line now looks a whole lot different."); - test->findNext("istri"); - test->findNext("istr"); - test->findNext("ist"); - test->findNext("is"); - test->findNext("i"); - test->findNext("W"); - test->findNext("WA"); - test->findNext("WARRANTY"); - test->changeText(6, " but WITHOUT ANY xxxx; without even the implied warranty of"); - test->findNext("WARRAN"); - test->findNext("Free"); - test->findNext("Software Foundation"); - - check("result", test->hits().join(""), output3); - test->clearHits(); - kdDebug() << "PASSED" << endl; - - //return app.exec(); - delete test; - return 0; -} - -#include "kfindtest.moc" diff --git a/kutils/tests/kfindtest.h b/kutils/tests/kfindtest.h deleted file mode 100644 index 847d9579c..000000000 --- a/kutils/tests/kfindtest.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2004, Arend van Beelen jr. <arend@auton.nl> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KFINDTEST_H -#define KFINDTEST_H - -#include <tqobject.h> -#include <tqstringlist.h> - -class KFind; - -class KFindTest : public TQObject -{ - Q_OBJECT - - public: - KFindTest(const TQStringList &text) : - TQObject(0), - m_find(0), - m_text(text), - m_line(0) - {} - - void find(const TQString &pattern, long options = 0); - void findNext(const TQString &pattern = TQString::null); - - void changeText(uint line, const TQString &text); - - const TQStringList &hits() const { return m_hits; } - void clearHits() { m_hits.clear(); } - - public slots: - void slotHighlight(const TQString &text, int index, int matchedLength); - void slotHighlight(int id, int index, int matchedLengthlength); - - private: - KFind *m_find; - TQStringList m_text; - uint m_line; - TQStringList m_hits; -}; - -#endif diff --git a/kutils/tests/kreplacetest.cpp b/kutils/tests/kreplacetest.cpp deleted file mode 100644 index 26b0f7c9e..000000000 --- a/kutils/tests/kreplacetest.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/* - Copyright (C) 2002, David Faure <david@mandrakesoft.com> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <assert.h> - -#include <kcmdlineargs.h> -#include <kapplication.h> -#include <tqeventloop.h> -#include <kpushbutton.h> -#include "../kreplace.h" -#include "../kreplacedialog.h" - -#include "kreplacetest.h" -#include <kdebug.h> -#include <stdlib.h> - -void KReplaceTest::replace( const TQString &pattern, const TQString &replacement, long options ) -{ - m_needEventLoop = false; - // This creates a replace-next-prompt dialog if needed. - m_replace = new KReplace(pattern, replacement, options); - - // Connect highlight signal to code which handles highlighting - // of found text. - connect(m_replace, TQT_SIGNAL( highlight( const TQString &, int, int ) ), - this, TQT_SLOT( slotHighlight( const TQString &, int, int ) ) ); - // Connect findNext signal - called when pressing the button in the dialog - connect(m_replace, TQT_SIGNAL( findNext() ), - this, TQT_SLOT( slotReplaceNext() ) ); - // Connect replace signal - called when doing a replacement - connect(m_replace, TQT_SIGNAL( replace(const TQString &, int, int, int) ), - this, TQT_SLOT( slotReplace(const TQString &, int, int, int) ) ); - - // Go to initial position - if ( (options & KReplaceDialog::FromCursor) == 0 ) - { - if ( m_replace->options() & KFindDialog::FindBackwards ) - m_currentPos = m_text.fromLast(); - else - m_currentPos = m_text.begin(); - } - - // Launch first replacement - slotReplaceNext(); - - if ( m_needEventLoop ) - tqApp->eventLoop()->enterLoop(); -} - -void KReplaceTest::slotHighlight( const TQString &str, int matchingIndex, int matchedLength ) -{ - kdDebug() << "slotHighlight Index:" << matchingIndex << " Length:" << matchedLength - << " Substr:" << str.mid(matchingIndex, matchedLength) - << endl; - // Emulate the user saying yes - // animateClick triggers a timer, hence the enterloop/exitloop - // Calling slotReplace directly would lead to infinite loop anyway (Match never returned, - // so slotReplaceNext never returns) - if ( m_replace->options() & KReplaceDialog::PromptOnReplace ) { - m_replace->replaceNextDialog( false )->actionButton( (KDialogBase::ButtonCode)m_button )->animateClick(); - m_needEventLoop = true; - } -} - - -void KReplaceTest::slotReplace(const TQString &text, int replacementIndex, int replacedLength, int matchedLength) -{ - kdDebug() << "slotReplace index=" << replacementIndex << " replacedLength=" << replacedLength << " matchedLength=" << matchedLength << " text=" << text.left( 50 ) << endl; - *m_currentPos = text; // KReplace hacked the replacement into 'text' in already. -} - -void KReplaceTest::slotReplaceNext() -{ - //kdDebug() << k_funcinfo << endl; - KFind::Result res = KFind::NoMatch; - while ( res == KFind::NoMatch && m_currentPos != m_text.end() ) { - if ( m_replace->needData() ) - m_replace->setData( *m_currentPos ); - - // Let KReplace inspect the text fragment, and display a dialog if a match is found - res = m_replace->replace(); - - if ( res == KFind::NoMatch ) { - if ( m_replace->options() & KFindDialog::FindBackwards ) - m_currentPos--; - else - m_currentPos++; - } - } - -#if 0 // commented out so that this test doesn't require interaction - if ( res == KFind::NoMatch ) // i.e. at end - if ( m_replace->shouldRestart() ) { - if ( m_replace->options() & KFindDialog::FindBackwards ) - m_currentPos = m_text.fromLast(); - else - m_currentPos = m_text.begin(); - slotReplaceNext(); - } -#endif - if ( res == KFind::NoMatch && m_needEventLoop ) - tqApp->eventLoop()->exitLoop(); -} - -void KReplaceTest::print() -{ - TQStringList::Iterator it = m_text.begin(); - for ( ; it != m_text.end() ; ++it ) - kdDebug() << *it << endl; -} - -/* button is the button that we emulate pressing, when options includes PromptOnReplace. - Valid possibilities are User1 (replace all) and User3 (replace) */ -static void testReplaceSimple( int options, int button = 0 ) -{ - kdDebug() << "testReplaceSimple: " << options << endl; - KReplaceTest test( TQString( "hellohello" ), button ); - test.replace( "hello", "HELLO", options ); - TQStringList textLines = test.textLines(); - assert( textLines.count() == 1 ); - if ( textLines[ 0 ] != "HELLOHELLO" ) { - kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of 'HELLOHELLO'" << endl; - exit(1); - } -} - -// Replacing "a" with "". -// input="aaaaaa", expected output="" -static void testReplaceBlank( int options, int button = 0 ) -{ - kdDebug() << "testReplaceBlank: " << options << endl; - KReplaceTest test( TQString( "aaaaaa" ), button ); - test.replace( "a", "", options ); - TQStringList textLines = test.textLines(); - assert( textLines.count() == 1 ); - if ( !textLines[ 0 ].isEmpty() ) { - kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of ''" << endl; - exit(1); - } -} - -// Replacing "" with "foo" -// input="bbbb", expected output="foobfoobfoobfoobfoo" -static void testReplaceBlankSearch( int options, int button = 0 ) -{ - kdDebug() << "testReplaceBlankSearch: " << options << endl; - KReplaceTest test( TQString( "bbbb" ), button ); - test.replace( "", "foo", options ); - TQStringList textLines = test.textLines(); - assert( textLines.count() == 1 ); - if ( textLines[ 0 ] != "foobfoobfoobfoobfoo" ) { - kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of 'foobfoobfoobfoobfoo'" << endl; - exit(1); - } -} - -static void testReplaceLonger( int options, int button = 0 ) -{ - kdDebug() << "testReplaceLonger: " << options << endl; - // Standard test of a replacement string longer than the matched string - KReplaceTest test( TQString( "aaaa" ), button ); - test.replace( "a", "bb", options ); - TQStringList textLines = test.textLines(); - assert( textLines.count() == 1 ); - if ( textLines[ 0 ] != "bbbbbbbb" ) { - kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of 'bbbbbbbb'" << endl; - exit(1); - } -} - -static void testReplaceLongerInclude( int options, int button = 0 ) -{ - kdDebug() << "testReplaceLongerInclude: " << options << endl; - // Similar test, where the replacement string includes the search string - KReplaceTest test( TQString( "a foo b" ), button ); - test.replace( "foo", "foobar", options ); - TQStringList textLines = test.textLines(); - assert( textLines.count() == 1 ); - if ( textLines[ 0 ] != "a foobar b" ) { - kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of 'a foobar b'" << endl; - exit(1); - } -} - -static void testReplaceLongerInclude2( int options, int button = 0 ) -{ - kdDebug() << "testReplaceLongerInclude2: " << options << endl; - // Similar test, but with more chances of matches inside the replacement string - KReplaceTest test( TQString( "aaaa" ), button ); - test.replace( "a", "aa", options ); - TQStringList textLines = test.textLines(); - assert( textLines.count() == 1 ); - if ( textLines[ 0 ] != "aaaaaaaa" ) { - kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of 'aaaaaaaa'" << endl; - exit(1); - } -} - -// Test for the \0 backref -static void testReplaceBackRef( int options, int button = 0 ) -{ - kdDebug() << "testReplaceBackRef: " << options << endl; - KReplaceTest test( TQString( "abc def" ), button ); - test.replace( "abc", "(\\0)", options ); - TQStringList textLines = test.textLines(); - assert( textLines.count() == 1 ); - TQString expected = options & KReplaceDialog::BackReference ? "(abc) def" : "(\\0) def"; - if ( textLines[ 0 ] != expected ) { - kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of '"<< expected << "'" << endl; - exit(1); - } -} - -static void testReplacementHistory( const TQStringList& findHistory, const TQStringList& replaceHistory ) -{ - KReplaceDialog dlg( 0, 0, 0, findHistory, replaceHistory ); - dlg.show(); - kdDebug() << "testReplacementHistory:" << dlg.replacementHistory() << endl; - assert( dlg.replacementHistory() == replaceHistory ); -} - -static void testReplacementHistory() -{ - TQStringList findHistory; - TQStringList replaceHistory; - findHistory << "foo" << "bar"; - replaceHistory << "FOO" << "BAR"; - testReplacementHistory( findHistory, replaceHistory ); - - findHistory.clear(); - replaceHistory.clear(); - findHistory << "foo" << "bar"; - replaceHistory << TQString::null << "baz"; // #130831 - testReplacementHistory( findHistory, replaceHistory ); -} - -int main( int argc, char **argv ) -{ - TDECmdLineArgs::init(argc, argv, "kreplacetest", 0, 0); - TDEApplication app; - - testReplacementHistory(); // #130831 - - testReplaceBlank( 0 ); - testReplaceBlank( KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceBlank( KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - testReplaceBlank( KReplaceDialog::FindBackwards, 0 ); - testReplaceBlank( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceBlank( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - - testReplaceBlankSearch( 0 ); - testReplaceBlankSearch( KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceBlankSearch( KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - testReplaceBlankSearch( KReplaceDialog::FindBackwards, 0 ); - testReplaceBlankSearch( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceBlankSearch( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - - testReplaceSimple( 0 ); - testReplaceSimple( KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceSimple( KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - testReplaceSimple( KReplaceDialog::FindBackwards, 0 ); - testReplaceSimple( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceSimple( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - - testReplaceLonger( 0 ); - testReplaceLonger( KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceLonger( KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - testReplaceLonger( KReplaceDialog::FindBackwards, 0 ); - testReplaceLonger( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceLonger( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - - testReplaceLongerInclude( 0 ); - testReplaceLongerInclude( KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceLongerInclude( KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - testReplaceLongerInclude( KReplaceDialog::FindBackwards, 0 ); - testReplaceLongerInclude( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceLongerInclude( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - - testReplaceLongerInclude2( 0 ); - testReplaceLongerInclude2( KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceLongerInclude2( KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - testReplaceLongerInclude2( KReplaceDialog::FindBackwards, 0 ); - testReplaceLongerInclude2( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceLongerInclude2( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - - testReplaceBackRef( 0 ); - testReplaceBackRef( KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceBackRef( KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - testReplaceBackRef( KReplaceDialog::FindBackwards, 0 ); - testReplaceBackRef( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceBackRef( KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - testReplaceBackRef( KReplaceDialog::BackReference | KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceBackRef( KReplaceDialog::BackReference | KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - testReplaceBackRef( KReplaceDialog::BackReference | KReplaceDialog::FindBackwards, 0 ); - testReplaceBackRef( KReplaceDialog::BackReference | KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace - testReplaceBackRef( KReplaceDialog::BackReference | KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all - - TQString text = "This file is part of the KDE project.\n" - "This library is free software; you can redistribute it and/or\n" - "modify it under the terms of the GNU Library General Public\n" - "License version 2, as published by the Free Software Foundation.\n" - "\n" - " This library is distributed in the hope that it will be useful,\n" - " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" - " Library General Public License for more details.\n" - "\n" - " You should have received a copy of the GNU Library General Public License\n" - " along with this library; see the file COPYING.LIB. If not, write to\n" - " the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,\n" - " Boston, MA 02110-1301, USA.\n" - "More tests:\n" - "ThisThis This, This. This\n" - "aGNU\n" - "free"; - KReplaceTest test( TQStringList::split( '\n', text, true ), 0 ); - - test.replace( "GNU", "KDE", 0 ); - test.replace( "free", "*free*", 0 ); - test.replace( "This", "THIS*", KFindDialog::FindBackwards ); - - test.print(); - //return app.exec(); - return 0; -} -#include "kreplacetest.moc" diff --git a/kutils/tests/kreplacetest.h b/kutils/tests/kreplacetest.h deleted file mode 100644 index b8fb8120b..000000000 --- a/kutils/tests/kreplacetest.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (C) 2002, David Faure <david@mandrakesoft.com> - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2, as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KREPLACETEST_H -#define KREPLACETEST_H - -#include <tqobject.h> -#include <tqstringlist.h> - -class KReplace; - -class KReplaceTest : public TQObject -{ - Q_OBJECT -public: - KReplaceTest( const TQStringList& text, int button ) - : TQObject( 0L ), m_text( text ), m_replace( 0 ), m_button( button ) {} - - void replace( const TQString &pattern, const TQString &replacement, long options ); - void print(); - const TQStringList& textLines() const { return m_text; } - -public slots: - void slotHighlight( const TQString &, int, int ); - void slotReplaceNext(); - void slotReplace(const TQString &text, int replacementIndex, int replacedLength, int matchedLength); - -private: - TQStringList::Iterator m_currentPos; - TQStringList m_text; - KReplace* m_replace; - bool m_needEventLoop; - int m_button; -}; - -#endif |