Porting Applications to KDE 3.0

This document contains the changes you have to apply to programs written for KDE 2.x when you want to port them to KDE 3.0.

As a start you should have a look at doc/porting.doc in the Qt package, or this page online.

Table of Contents

Getting started

The first step to get your KDE application to compile under KDE 3.0, is to detect KDE 3.0 and Qt 3.x at configure time. The easiest way to get a working autoconf/automake framework, is to either use KDevelop or kapptemplate (available in CVS under the module "tdesdk"), to generate a new application template. Replace the generated source files by yours and adapt Makefile.am accordingly.

Please note that we tried to be mostly source-compatible where it was possible. To accomplish that, we added commonly used but still deprecated / removed API parts in a #ifndef KDE_NO_COMPAT-block. That means you can "test" and adjust your application by #defining KDE_NO_COMPAT for compiling and see where it breaks. This is recommended, as those backward compatibility "hacks" are not kept for long.

WARNING:In some cases the names or signatures of signals or slots have changed. Check your source carefully for this since these changes will not be discovered by your compiler but will result in incorrect runtime behavior if left uncorrected in your application.

Return to the Table of Contents

Changes in kab

AddressBook

The getStandardFilename() method has been renamed to getStandardFileName(). The old name will still work unless KDE_NO_COMPAT is defined.

Return to the Table of Contents

Changes in tdecore

KDesktopWidget

KDesktopWidget is obsolete. Include <tqdesktopwidget.h> and use QDesktopWidget instead, everything else is source compatible.

Header file names

This is to help finding out header files from class names and the other way round. Compatibility headers have been created. You can use them as long as you don't compile with KDE_NO_COMPAT.

DCOP

The file with the DCOP connection information has been renamed. The new name is $HOME/.DCOPserver__. The screen part has been stripped from and the ':' character that separates host and display-number has been replaced with a '_'. If you access DCOP via DCOPClient you do not need to change anything.

It is no longer possible to make calls to an application registered as "-" with "" only. The full name can be obtained by using either TDEApplication::startServiceBy...() or DCOPClient::findObject() or their command line equivalents "dcopstart" and "dcopfind".

KLibFactory

KLibFactory's create method is no more virtual and the createObject method is now pure virtual. The former was marked as deprecated since KDE 2.0. All it takes in your component is to rename your existing create implementation to createObject and remove the 'emit objectCreated( yourObject );' line.

KDesktopFile

The filename() method has been renamed to fileName(). The old name will still work unless KDE_NO_COMPAT is defined.

KPixmapSplitter

KPixmapSplitter has now been moved to the new tdefx library.

KStringHandler

The matchFilename( const TQString& filename, const TQString& pattern ) method has been renamed to
matchFileName( const TQString& filename, const TQString& pattern ). The old name will still work unless KDE_NO_COMPAT is defined.

KStyle

Due to the major changes in the TQStyle API in Qt3, KStyle has been completely re-written. KStyle is now a thin wrapper around TQCommonStyle with a few extra primitive elements and a simple popupMenu transparency engine. All KStyles can now style Qt apps like designer and assistant automatically. KStyle is no longer present in tdecore. It is now in a new library called tdefx to allow Qt apps to use KDE's styles without having the styles linked to tdecore/tdeui.

KURL

The filename( bool _ignore_trailing_slash_in_path = true ) method has been renamed to
fileName( bool _ignore_trailing_slash_in_path = true ). The old name will still work unless KDE_NO_COMPAT is defined.

KMD5

HASHHEX and HASH has been removed to make this class namespace clean. They have been replaced by TQCString and KMD5::Digest.
The API has been cleaned up, it is no longer necessary to call finalize(). Simply remove any calls to it.

KLocale

  • charset() has been removed. You might want to use encoding() instead.
  • setCharset(const TQString &) has been removed. You might want to use setEncoding(int) instead.
  • formatMoney(const TQString &) has been removed.
  • formatNumber(const TQString &) has been removed.
  • languages() has been removed. Use languageList() instead.
  • All references to monthName(), monthNamePossessive(), and weekDayName() should be replaced with methods from KLocale::calendar().
  • Hard coded date handling or date handling with TQDate should in most cases be replaced by methods in KLocale::calendar().

    Accelerators Keys

    KAccel
    The following methods of been deprecated, and if KDE_NO_COMPAT is defined they will not be available.
    • KAccel::insertItem() and KAccel::connectItem().
      	- kaccel->insertItem( i18n("Scroll Up"), "Scroll Up", "Up" );
      	- kaccel->connectItem( "Scroll Up", this, TQT_SLOT(scrollUp()) );
      	+ kaccel->insert( "Scroll Up", i18n("Scroll Up"), TQString::null,
      		Key_Up, this, TQT_SLOT(scrollUp()) );
      
      Note that a What's This parameter is now a part of the insert function. You might replace the TQString::null parameter with
       i18n("Scroll the current document's contents up by one line.") 
      for example.
    • KAccel::changeMenuAccel() has been deprecated because it was never used in cvs. If you've used it in your application, the following can replace it. Note, however, that this would be handled automatically by using KAction instead.
      	- kaccel->changeMenuAccel( menu, id, "file_open" );
      	+ menu->setAccel( kaccel->shortcut( "file_open" ).keyCodeQt(), id );
      
    The preferred means of defining a shortcut, however, is to use KAction.
    	new KAction( i18n("Scroll Up"), Key_Up,
    		this, TQT_SLOT(scrollUp()), actionCollection(), "Scroll Up" );
    
    TDEGlobalAccel
    • Call updateConnections() after all insert() or insertItem() (deprecated) calls have been made. This function then performs the actually key grabbing. In order to improve program startup speed, grabbing is no longer done automatically: usually readSettings() is called after the actions have been defined, and this may cause shortcut reassignments, which in turn used to make an expensive ungrab of the old key and second grab of the new key necessary.
    KStdAccel
    • StdAccel::WhatThis has been renamed to StdAccel::WhatsThis.
    • StdAccel::Insert and the corresponding insert() have been removed. (Nobody on the list knew what its function was supposed to be.) Calls to insert() and the equivalent key(KStdAccel::Insert) can be replaced with the former default of Qt::CTRL+Qt::Key_Insert.
    • The following functions have been deprecated and will need to be changed if KDE_NO_COMPAT is defined:
      OldNew
      TQString action(StdAccel id)TQString name(StdAccel id)
      int defaultKey(StdAccel accel)KShortcut shortcutDefault(StdAccel id)
      TQString description(StdAccel id)TQString label(StdAccel id)
      bool isEqual(const TQKeyEvent* pEvent, int keyQt) The best method for replacing this varies. One possibility is to use KKey(const TQKeyEvent*) == KKey(int). Another is to use KShortcut::contains( const KKey&/KKeySequence& ).
      int key(StdAccel)const KShortcut& shortcut(StdAccel)

    KIconLoader, KIconTheme

    Methods now use KIcon::Group and KIcon::Context instead of int as types for group and context arguments. The change should affect only code using hardcoded numeric values instead of using the proper enum constants. This applies to classes KIconLoader, KIconTheme and (in kio and kfile) KMimeType, KService, KIconDialog, KIconButton, KURLBar and KURLBarItem.

    Return to the Table of Contents

    Changes in tdeui

    KAccelMenu

    This class has been removed, Qt offers the same functionality. Use QPopupMenu/KPopupMenu or the XML-UI method for building menus.

    KAction

    • The following methods have been deprecated and will need to be replaced if KDE_NO_COMPAT is defined.
      OldNew
      int accel()const KShortcut& shortcut()
      int menuId()int itemId()
      void setAccel(int)void setShortcut(const KShortcut&)

    KActionCollection

    • When constructing a KActionCollection object, a pointer to the focus widget should be passed.
    • The insert(), remove(), and take() methods have been deprecated. If you wish to keep a list of actions, use the KActionPtrList container instead. If you want to configure the shortcuts from multiple actions collections, pass each collection to KKeyChooser or KKeyDialog via their insert() methods.

    KAlphaPainter

    KAlphaPainter has been dropped, since Qt 3 has native support for hardware accelerated alpha blending.

    KAnimWidget

    This class no longer supports reading a list of images, instead it uses a single image-file that has been prepared with the kimage_concat tool. See tdelibs/pics/hicolor/kde for an example of its use.

    KContainerLayout

    This class has been removed, use Qt layouts instead.

    KCommand

    This class has been made lighter: the name isn't stored into the command anymore, but must be provided by the inherited class, as the result of the virtual name() function. This saves storing a TQString into each command in memory. The former behavior is available in the class KNamedCommand, so for a quick port simply replace KCommand with KNamedCommand.

    KDialogBase

    The deprecated getMainWidget() method has been removed. Use mainWidget() instead.

    KDirectionButton

    ...is gone. Use KArrowButton instead, it offers about the same functionality.

    KDockWidget

    The WidgetList parameter has been renamed to TQWidgetList. Behaviour is identical.

    KEdit

    KEdit is now deprecated. You should use use KTextEditor::Editor or KTextEdit instead.

    KImageEffect

    KImageEffect has now been moved to the new tdefx library.

    KMessageBox

    KMessageBox now does automatic line-breaking. When using plain-text, you should remove any mid-sentence linebreaks. Only use line-breaks to indicate the end of a paragraph.

    KPanelApplet

    A new protected member method 'void reportBug()' was added. It gets called by Kicker if the 'Report Bug' entry in the context menu gets selected and should be overridden by applets which support the KPanelApplet::ReportBug action. This means that you don't have to extend KPanelApplet's generic action dispatcher void KPanelApplet::action() anymore.

    KPanelMenu

    The old KPanelMenu class has been renamed to KPanelAppMenu. The KPanelMenu class now corresponds to a new Kicker menu extension that is handled by the panel in a way similar to other applets (shared library loaded at run-time). See KDE 3.0 documentation for more informations on this new extension.

    KPixmapEffect

    PixmapEffect has now been moved to the new tdefx library.

    KProgress

    KProgress is now based on TQProgressBar. This has led to a few API changes. In particular the constructors have been simplified, you simply need to pass the total number of steps instead of min / max / initialvalue / orientation. See documentation of both KProgress and TQProgressBar.

    KRootPixmap

    The KRootPixmap class has been extended to make it more flexible, and the checkAvailable(bool ignored) method has been renamed to isAvailable(). The old name will still work unless KDE_NO_COMPAT is defined.

    KThemeBase, KThemeStyle

    KThemeBase and KThemeStyle have been ported over to the new QStyle/KStyle API present in Qt3/KDE3. KThemeBase is no longer in tdeui, but in kstyles/kthemestyle as its use is basically limited to KThemeStyle.

    KAction, KToolBar, KToolBarButton and icons

    The preferred way for specifying icons is passing the icon names (and the icons will be loaded by KIconLoader), instead of using TQIconSet or TQPixmap. This results in always using the correct icon size and allows delayed on-demand icon loading.

    Method KAction::hasIconSet() has been renamed to KAction::hasIcon(), the old name will still work unless KDE_NO_COMPAT is defined. KAction::iconSet() now has an argument specifying icon group, the old KAction::iconSet() is still available unless KDE_NO_COMPAT is defined and returns KIcon::Small iconset, just like in KDE2.

    KToolBarButton methods setPixmap(), setDefaultPixmap(), setDisabledPixmap(), setDefaultIcon() and setDisabledIcon() are deprecated. Use KToolBarButton::setIcon() (preferred) or KToolBarButton::setIconSet() instead.

    KAction and derived classes

    The protected set* methods have been renamed to update* and they now take only one argument (i.e. setText(int, const TQString&) is now updateText(int) ). Because the former second argument was always the value of the a corresponding data member, you can simply call the accessor method (i.e. in updateText() call text() to get the text).

    KToggleAction

    exclusiveGroup() is no more virtual. setExclusiveGroup(const TQString&) is not a slot anymore.

    Return to the Table of Contents

    Changes in kio

    KPropertiesDialog

    • The header file has been renamed from kpropsdlg.h to kpropertiesdialog.h.
    • KPropertiesDialog::KPropertiesDialog(const KURL&, mode_t, TQWidget*, const char*, bool, bool ) has been removed since mode_t was no longer used. Simply omit the mode_t parameter.

    KTarGz/KTarBase/KTarData

    • The KTarBase and KTarData classes have been removed.
    • KTarGz is now KTar (#define for source compatibility)
    • A base class KArchive has been written, to support other archive formats in the future
    • KTarEntry is now KArchiveEntry, KTarDirectory is now KArchiveDirectory, and KTarFile is now KArchiveFile.
    • The classes ProgressBase, StatusbarProgress and DefaultProgress have been moved to the KIO namespace.
    • The signal KDirLister::started(const TQString &url) has changed to KDirLister::started(const KURL &url).
    • KServiceTypeProfile::preferredService( const TQString & serviceType, bool needApp ) has been removed, use KServiceTypeProfile::preferredService( ..., "Application") if needApp was true, or KServiceTypeProfile::preferredService( ..., TQString::null) if needApp was false.
    • The following functions in KProtocolManager have been replaced:
      • ftpProxy(), use proxyFor("ftp") instead.
      • httpProxy(), use proxyFor("http") instead.
      • slaveProtocol(const TQString&), use slaveProtocol(const KURL &url, TQString &proxy) instead.
      • defaultReadTimeout(), use DEFAULT_READ_TIMEOUT instead. (See ioslave_defaults.h)
      • defaultProxyConnectTimeout(), use DEFAULT_PROXY_CONNECT_TIMEOUT instead. (See ioslave_defaults.h)
      • defaultResponseTimeout(), use DEFAULT_RESPONSE_TIMEOUT instead. (See ioslave_defaults.h)
      • minimumTimeoutThreshold(), use MIN_TIMEOUT_VALUE instead. (See ioslave_defaults.h)
    • The following functions in KProtocolManager have been removed:
      • setUserAgentList( const TQStringList& )
      • userAgentList();
      • setReadTimeout()
      • setConnectTimeout( int )
      • setProxyConnectTimeout( int )
      • setResponseTimeout( int )
      • setMarkPartial( bool )
      • setMinimumKeepSize( int )
      • setAutoResume( bool )
      • setPersistentConnections( bool )
      • setMaxCacheAge( int )
      • setUseCache( bool )
      • setMaxCacheSize( int )
      • setCacheControl( KIO::CacheControl )
      • setUseProxy( bool )
      • setUseReverseProxy( bool )
      • setProxyType( ProxyType )
      • setProxyAuthMode( ProxyAuthMode )
      • setFtpProxy( const TQString& )
      • setHttpProxy( const TQString& )
      • setProxyFor( const TQString&, const TQString& )
      • setNoProxyFor( const TQString& )
      • setProxyConfigScript( const TQString& )
    • In order to support files > 4Gb, the file size / file-offset argument in the signals totalSize, processedSize and canResume, which are used by the io-slaves and passed along to jobs, has been changed from unsigned long to KIO::filesize_t. Make sure to check if you use these signals since your compiler will typically not generate a compile-time error for these changes, instead you might get a run-time error when you try to connect to one of these signals using the old signature.

    KOpenWithHandler / KFileOpenWithHandler

    Those two classes are deprecated, no need to create a KFileOpenWithHandler anymore. The merging of libkio, libksycoca, libkfile and libkssl into a single libkio has allowed to fix this dependency problem: KRun can now use the OpenWith dialog directly.

    KMimeType, KService

    Methods now use KIcon::Group and KIcon::Context instead of int as types for group and context arguments. The change should affect only code using hardcoded numeric values instead of using the proper enum constants.

    KFilterDev

    The createFilterDevice method is deprecated. Use deviceForFile instead.

    KDirWatch

    • The signal fileDirty( const TQString& ) has been removed
    • The signal created( const TQString& ) has been added
    • The signal deleted( const TQString& ) has been added
    • The signal dirty( const TQString& ) may be emitted with a file name, not only a directory name. This depends on which backend is used but will probably always be the case in KDE 3.1. You should prepare to receive dirty( dirname ) or dirty( filename ) when a file has changed.

    Return to the Table of Contents

    Changes in kparts

    KParts::Factory

    The createPart method is no more virtual and the createPartObject method is now pure virtual. The former was marked as deprecated since KDE 2.0. All it takes in your component is to rename your existing createPart implementation to createPartObject and remove the 'emit objectCreated( yourObject );' line.

    KParts::Part

    The bool isSelectable() const is no more virtual. So when you want to change the behavior of the selectable property you don't need to re-implement both virtual functions, setSelectable and isSelectable, but instead just re-implementing setSelectable does the job. The very same applies for the KURL url() const and ReadWritePart's bool isReadWrite const and bool isModified() const methods.

    The void showProgressInfo(bool) method has been renamed to bool setProgressInfoEnabled(bool). The old name will still work unless KDE_NO_COMPAT is defined.

    KParts::BrowserExtension

    The URLArgs urlArgs() method is no more virtual. So when you want to change the behavior of the urlArgs property you don't need to re-implement both virtual functions, setURLArgs and urlArgs, but instead just re-implementing setURLArgs does the job.

    Return to the Table of Contents

    Changes in kspell

    KSpell

    The API has been cleaned up to be in line with the rest of tdelibs, in particular:
    • suggestions() now returns a TQStringList instead of a pointer to a QStringList
    • intermediateBuffer() now returns a TQString instead of a pointer to a QString
    • The signal misspelling(TQString, TQStringList *, unsigned) has changed to misspelling(const TQString &, const TQStringList &, unsigned int)
    • The signal corrected(TQString, TQString, unsigned) has changed to corrected(const TQString &, const TQString &, unsigned int)
    • The signal ignoreall(TQString) has changed to ignoreall(const TQString &)
    • The signal ignoreword(TQString) has changed to ignoreword(const TQString &)
    • The signal addword(TQString) has changed to addword(const TQString &)
    Make sure to check if you use the above signals since your compiler will typically not generate a compile-time error for these changes, instead you might get a run-time error when you try to connect to one of these signals using the old signature.

    Return to the Table of Contents

    API-cleanups in KHTML

    There were a few relatively minor API-adjustements in KHTMLPart. In particular:
    • enableJScript(bool) has been replaced by setJScriptEnabled(bool)
    • enableJava(bool) has been replaced by setJavaEnabled(bool)
    • enablePlugins(bool) has been replaced by setPluginsEnabled(bool)
    • autoloadImages(bool) has been replaced by setAutoloadImages(bool)
    • enableMetaRefresh(bool) has been replaced by setMetaRefreshEnabled(bool)
    • setBaseURL and setBaseTarget have been removed. baseURL(), baseTarget() and completeURL() are remained for compatibility reasons, but they're deprecated now. use the variants in DOM::HTMLDocument() instead.
    • the second parameter of KHTMLPart::completeURL is removed. it didn't have any effect before either.
    Besides that, all methods previously marked as deprecated or were internal but accidentally part of the public API are now private or removed. As they were marked as becoming private already you should not experience any problems. Backward compatibility exists for the common methods, to disable this use a #define KDE_NO_COMPAT.

    In KHTMLView, the following changes were done:

    • gotoNextLink has been replaced by gotoLink(true);
    • gotoPrevLink has been replaced by gotoLink(false);

    Return to the Table of Contents

    Changes in kfile

    The kfile-library, as used by the KFileDialog provides classes for directory browsing widgets. Those classes gained some new features, some parts were merged with other existing classes and in some cases the API was cleaned up/fixed. The library is now built as part of libkio library (there's no need to modify Makefiles which use $LIB_KFILE instead of hardcoding -lkfile).

    Even if the list of changes is long, the affected code base should be relatively small, as most parts are rarely used outside of kfile.

    The changes are:

    KFileItem

    The KFileViewItem class is completely replaced with KFileItem from kio. All its functionality has been merged with its former base class KFileItem. Additionally, some of its methods have been modified:
    Old:New:
    access()permissionsString()
    date()timeString()
    setViewItem( const KFileView *view, const void *item )setExtraData( const void *key, void *value )
    pixmap()The parameterless method has been removed, use pixmap( int size, int state = 0 ) instead.

    KFileReader

    This class has been merged with KDirLister from kio.

    KDirOperator

    Old:New:
    saveConfig()writeConfig()
    setFileReader()setDirLister()
    fileReader()dirLister()
    activatedMenu( const KFileViewItem * )activatedMenu( const KFileItem *, const TQPoint& pos )

    KFileDetailView

    The protected method setSortIndicator() has been removed, it's not needed anymore.

    KFileView

    This is the baseclass for all the views. It changed in many respects to allow for greater flexibility and efficiency.

    Sorting has changed radically. Previously, KFileView had protected methods QuickSort, compareItems() and mergeLists() to sort directory entries for displaying in the views. Now, KFileView does not do any sorting anymore. Instead, the view's (i.e. KIconView, KListView) sorting is utilized by letting its view-items provide a TQString key() method. Therefore, KFileView offers the two methods
    • TQString sortingKey( const TQString& value, bool isDir, int sortSpec )
    • TQString sortingKey( KIO::filesize_t value, bool isDir, int sortSpec )
    which the view-classes can use to generate the string for the key() method. The KFile::SortMode enum has been removed, as TQDir::SortSpec is used entirely.

    Further changes:
    Old:New:
    not existantvirtual void readConfig( KConfig *, const TQString& group = TQString::null )
    not existantvoid writeConfig( KConfig *, const TQString& group = TQString::null)
    virtual void setCurrentItem( const TQString& filename, KFileViewItem * )Replaced with the two methods below.
     void setCurrentItem( const TQString& filename );
     virtual void setCurrentItem( const KFileViewItem * ) = 0;
    setOperator( TQObject * )setParentView( KFileView * )
    virtual void insertSorted( KFileViewItem *, uint count )virtual void insertItem( KFileItem * )
    virtual void addItemList( const KFileViewItemList &list )not virtual anymore. Sufficient to reimplement insertItem()


    Three more pure virtual methods have been added:
    • virtual KFileItem * firstFileItem() const = 0
    • virtual KFileItem * nextItem( const KFileItem * ) const = 0
    • virtual KFileItem * prevItem( const KFileItem * ) const = 0

    State-changes are now signaled solely via the KFileViewSignaler object, that every KFileView has a protected member of ("sig"). The methods activateMenu(), highlight() and select() have been removed. If you implemented a KFileView, change your code in the following way:
    Old:New:
    activateMenu( item )sig->activateMenu( item, pos )
    highlight( item )sig->highlightFile( item )
    select( item )sig->select( item )

    KFileViewSignaler

    The methods activateDir( const KFileViewItem * ) and activateFile( const KFileViewItem * ) have been merged into the new method activate( const KFileItem * ).

    Carsten Pfeiffer pfeiffer@kde.org

    KIconDialog, KIconButton, KURLBar, KURLBarItem

    Methods now use KIcon::Group and KIcon::Context instead of int as types for group and context arguments. The change should affect only code using hardcoded numeric values instead of using the proper enum constants.

    Return to the Table of Contents

    Changes in KControl

    Modules that require root permission

    The meaning of the X-TDE-RootOnly flag in the .desktop files has changed. In KControl 2.0 a message was shown if the user did not press the "modify" button. With the additional flag X-TDE-HasReadOnlyMode it was possible to show a disabled version of the module instead of the message. The behavior was inconsistent and has been changed:
    • X-TDE-HasReadOnlyMode is not used anymore and is ignored by KControl > 2.0.
    • X-TDE-RootOnly does now show a disabled preview of the widget and a notification box.
    • If you want the old behavior back set X-TDE-IsHiddenByDefault along with X-TDE-RootOnly. Please note that this behavior is deprecated the sake of usability.
    For more details please consult the HOWTO file in the kcontrol directory.

    Return to the Table of Contents

    Panel Applets and Extensions

    The API for Kicker panel applets and extensions has changed. Panels can now be left/top, center, or right/bottom aligned, and applets and extensions may receive notification about a change in alignment.

    KPanelApplet

    The virtual methods orientationChange() and popupDirectionChange() are deprecated. Instead you should reimplement positionChange() and alignmentChange() to be notified of changes in the position and alignment of the panel on which your applet resides. In addition, the popupDirection() method and the Direction enum are deprecated. Instead you should use the position() method and Position enum. Applets that use the deprecated methods will still work with KDE 3, but may not compile or work with a future version.

    KPanelExtension

    There is a new method alignmentChange() that your extension should reimplement if it needs to know about changes in alignment.

    Return to the Table of Contents

    Dirk Mueller mueller@kde.org