TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KDE2PORTING.html 37KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 2//EN//2.0">
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Guide to Porting Applications to KDE 2.0</TITLE>
  5. </HEAD>
  6. <BODY>
  7. <H2>Porting Applications to KDE 2.0</H2>
  8. <H3>Last Modified on November 28, 2000</H3>
  9. This document contains the changes you have to apply to programs written for
  10. KDE1.1 when you want to port them to KDE2.0.<P>
  11. As a start you should have a look at doc/porting.doc in the Qt package,
  12. or <a href="http://doc.trolltech.com/porting.html">this page online</a>.<P>
  13. <H3><A NAME="TOC">Table of Contents</A></H3>
  14. <UL>
  15. <LI><A HREF="#gettingstarted">Getting Started</A></LI>
  16. <LI><A HREF="#general">Global changes</A></LI>
  17. <LI><A HREF="#autotqmoc">autotqmoc/am_edit, Makefile.am tags</A></LI>
  18. <LI><A HREF="#KApplication">KApplication</A></LI>
  19. <LI><A HREF="#KCmdLineArgs">KCmdLineArgs</A></LI>
  20. <LI><A HREF="#KLocale">KLocale</A></LI>
  21. <LI><A HREF="#KGlobal">KGlobal: access to KDE global objects.</A></LI>
  22. <LI><A HREF="#KIconLoader">KIconLoader</A></LI>
  23. <LI><A HREF="#KTMainWindow">KTMainWindow</A></LI>
  24. <LI><A HREF="#KHelpMenu">KHelpMenu</A></LI>
  25. <LI><A HREF="#KToolBar">KToolBar</A></LI>
  26. <LI><A HREF="#launching">Starting other programs</A></LI>
  27. <LI><A HREF="#khtmlw">khtmlw</A></LI>
  28. <LI><A HREF="#KIntegerLine">KIntegerLine, KIntLineEdit</A></LI>
  29. <LI><A HREF="#KDNDIcon">KDNDIcon, KDNDDropZone, KDNDWidget, kdecore/drag.h</A></LI>
  30. <LI><A HREF="#KConfigBase">KConfigBase, KConfig, KSimpleConfig</A></LI>
  31. <LI><A HREF="#libkfm">libkfm</A></LI>
  32. <LI><A HREF="#KDialog">KDialog</A></LI>
  33. <LI><A HREF="#kcharsets">kcharsets</A></LI>
  34. <LI><A HREF="#KWizard">KWizard, KNoteBook</A></LI>
  35. <LI><A HREF="#KSpinBox">KSpinBox, KNumericSpinBox</A></LI>
  36. <LI><A HREF="#KClipboard">KClipboard</A></LI>
  37. <LI><A HREF="#KPanner">KPanner, KNewPanner</A></LI>
  38. <LI><A HREF="#KTreeList">KTreeList, KTreeListItem</A></LI>
  39. <LI><A HREF="#KMsgBox">KMsgBox</A></LI>
  40. <LI><A HREF="#KCombo">KCombo</A></LI>
  41. <LI><A HREF="#KQuickHelp">KQuickHelp</A></LI>
  42. <LI><A HREF="#KPixmapgradientFill">KPixmap::gradientFill</A></LI>
  43. <LI><A HREF="#KTabListBox">KTabListBox</A></LI>
  44. <LI><A HREF="#KToolBarButton">KToolBarButton &amp; KRadioGroup</A></LI>
  45. <LI><A HREF="#KAccel">KAccel</A></LI>
  46. <LI><A HREF="#kstring">kstring.h / KString</A></LI>
  47. <LI><A HREF="#ktopwidget">ktopwidget.h / KTopWidget</A></LI>
  48. <LI><A HREF="#kbutton">kbutton.h / KButton</A></LI>
  49. <LI><A HREF="#kbuttonbox">kbuttonbox.h / KButtonBox</A></LI>
  50. <LI><A HREF="#kcolorgroup">kcolorgroup.h / KColorGroup</A></LI>
  51. <LI><A HREF="#kled">kled.h, kledlamp.h / KLed, KLedLamp</A></LI>
  52. <LI><A HREF="#KDockWidget">KDockWidget</A></LI>
  53. <LI><A HREF="#KPixmap">KPixmap, KPixmapEffect</A></LI>
  54. <LI><A HREF="#KControlCenter">KDE Control Center</A></LI>
  55. <LI><A HREF="#KWMModuleApplication">KWMModuleApplication libkdeui/kwmmapp.h</A></LI>
  56. <LI><A HREF="#KDebug">KDebug</A></LI>
  57. <LI><A HREF="#KFileDialog">KFileDialog - General Stuff</A></LI>
  58. <LI><A HREF="#KFileDialogPreview">KFileDialog - Preview Mode</A></LI>
  59. <LI><A HREF="#ImageEffects">Image Effects</A></LI>
  60. <LI><A HREF="#KAudio">KAudio (kaudio.h)</A></LI>
  61. <LI><A HREF="#KImageIO">KImageIO (kimgio.h)</A></LI>
  62. </UL>
  63. <H3><A NAME="gettingstarted">Getting started</A></H3>
  64. The first step to get your KDE application to compile under KDE 2.0,
  65. is to detect KDE 2.0 and Qt 2.x at configure time. The easiest way to
  66. get a working autoconf/automake framework, is to either use
  67. <a href="http://www.kdevelop.org">KDevelop</a> or
  68. <a href="http://home.earthlink.net/~granroth/kapptemplate/index.html">kapptemplate</a>
  69. (available in CVS under the module "kdesdk"), to generate a new
  70. application template. Replace the generated source files by yours
  71. and adapt Makefile.am accordingly.
  72. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  73. <H3><A NAME="general">Global changes</A></H3>
  74. We did our best to clean up the header files of kdelibs, so they do
  75. not include unnecessary bloat for your application. As a consequence, you
  76. may notice that some header files are missing from your source files as
  77. they have been included before by kapp.h for example. There is a script
  78. in kdesdk/scripts called "fixheaders" that takes care of most of these
  79. cases. Just call "make -k 2&gt;&amp;1 | perl .../fixheaders" and it will try
  80. to look after the error messages and add includes as it recognize the
  81. errors.<P>
  82. Also, if your code does not compile and complains about missing member
  83. functions, you should check for methods that started with get...().
  84. These methods have been renamed to xy*() for consistency.<P>
  85. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  86. <H3><A NAME="autotqmoc">autotqmoc/am_edit, Makefile.am tags</A></H3>
  87. On the subject of the compilation framework, autotqmoc has been removed from
  88. the admin directory. It has been replaced by am_edit which provides a lot of
  89. additional features.<P>
  90. METASOURCES=AUTO still does the job of generating the appropriate tqmoc files,
  91. but in addition, you should use KDE_ICON for the icons representing the application
  92. (and naming those icons conforming to lo16-app-&lt;appname&gt;.png), and install
  93. the application-specific icons under $(kde_datadir)/&lt;appname&gt;/pics.
  94. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  95. <H3><A NAME="KApplication">KApplication</A></H3>
  96. doesn't hold any longer a KLocale instance. With this getLocale()
  97. and isLocaleInstantiated are now replaced by KGlobal::locale()<P>
  98. it also doesn't hold a KiconLoader instance. As this also getIconLoader()
  99. has been removed. Replace kapp-&gt;getIconLoader()-&gt;loadIcon() with
  100. BarIcon() or use KGlobal::iconLoader() instead of getIconLoader()<P>
  101. kde_*dir() have been removed as they require a unique top level directory
  102. for all applications (KDEDIR). This concept doesn't exist in KDE 2.0
  103. any more, it has been replaced with "multiple levels of directories",
  104. set in KDEDIRS, so that it's possible to have global settings and
  105. group settings, applied before user settings.<P>
  106. Replace code that uses kde_*dir() + filename with calls to
  107. locate(filetype, filename) where filetype is what * used to be
  108. in kde_*dir(). locate is defined as function in kstddirs.h to call
  109. KGlobal::dirs()-&gt;findResource.<P>
  110. Use locateLocal to get the path of a writable file. For instance,
  111. KApplication::localconfigdir()+filename is now locateLocal( "config", filename ),
  112. but for most cases, simply using KGlobal::config() is enough, if you're happy
  113. with saving the application's configuration into appnamerc, or
  114. KSimpleConfig cfg("anothercfgfile") to create a config file with another name.<P>
  115. generalFont() and fixedFont() are deprecated and will be removed soon.
  116. Please use KGlobalSettings::generalFont() and KGlobalSettings::fixedFont() instead.<P>
  117. appName() is deprecated. Please use TQApplication::name() or instanceName
  118. instead.<P>
  119. The methods tempSaveName() and checkRecoverFile() return QString
  120. now. The returned values must _not_ be free()d.<P>
  121. helpMenu() has been moved to KMainWindow. aboutKDE(), aboutApp() and
  122. appHelpActivated() have all been removed See section for KMainWindow
  123. for more info.<P>
  124. The KApplication constructor has changed. Command line arguments and
  125. program name should no longer be passed to KApplication but to
  126. KCmdLineArgs. KCmdLineArgs performs command line parsing and a command
  127. line help. See below for more info.<P>
  128. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  129. <H3><A NAME="KCmdLineArgs">KCmdLineArgs</A></H3>
  130. KCmdLineArgs is a new class that handles command line parsing and
  131. command line help. It is now required that your application
  132. specifies at least:<P>
  133. <UL>
  134. <LI>Its name.
  135. <LI>A short description what it does. (e.g. 1 line)
  136. <LI>A version.
  137. <LI>All command line options that it supports.
  138. </UL>
  139. KCmdLineArgs itself will add the command line options supported by Qt
  140. and KApplication.<P>
  141. You can also use the KAboutData class to specify name, description and
  142. version.<P>
  143. In return for this information you can query KCmdLineArgs whether an
  144. certain option was specified on the command line and your application
  145. now automatically supports --help and --version. It aborts with a
  146. useful error message when the command line contains a syntax error.
  147. See kdelibs/kdecore/kcmdlineargs.h for more info.<P>
  148. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  149. <H3><A NAME="KLocale">KLocale</A></H3>
  150. i18n is no longer a macro<P>
  151. KApplication::getApplication()-&gt;getLocale()-&gt;translate<P>
  152. but a function on its own. klocale is obsolete and replace every call
  153. to klocale-&gt;translate with i18n.<P>
  154. The return value of i18n is also no longer a const char*,
  155. but a tqunicode TQString.<P>
  156. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  157. <H3><A NAME="KGlobal">KGlobal: access to KDE global objects.</A></H3>
  158. KGlobal allows centralized access to KDE global objects without including
  159. extraneous headers. object creation is deferred if possible.<P>
  160. All methods are static and headers for returned types are not included. You
  161. must have created a KApplication object before the methods can be used.<P>
  162. <TABLE BORDER="0">
  163. <TR>
  164. <TD COLSPAN="2">
  165. <PRE>
  166. #include &lt;kglobal.h&gt;
  167. #include &lt;kconfig.h&gt; // Needed to use KConfig
  168. #include &lt;klocale.h&gt; // Needed to use KLocale
  169. #include &lt;kiconloader.h&gt; // Needed to use KIconLoader
  170. </PRE>
  171. </TD>
  172. </TR>
  173. <TR>
  174. <TD>
  175. <PRE>
  176. ...
  177. KConfig *appcfg = KGlobal::config();
  178. TQString mystr = i18n( "This is a string" );
  179. KIconLoader *loader = KGlobal::iconLoader();
  180. </PRE>
  181. </TD>
  182. </TR>
  183. </TABLE>
  184. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  185. <H3><A NAME="KIconLoader">KIconLoader</A></H3>
  186. KIconLoader in 1.1 used to mix icons for applications and for toolbars.
  187. This has changed, so you may notice that your application doesn't find
  188. the right icons. loadIcon (used by BarIcon) returns only toolbar icons.<P>
  189. If you need icons for applications, use loadApplicationIcon.<P>
  190. loadMiniIcon and loadApplicationMiniIcon have been removed, instead
  191. loadApplicationIcon now takes a "size" argument where you can specify the
  192. size of the icon (small, medium, large).<P>
  193. The other big change you may notice, is that ICON and Icon have been
  194. removed as they caused big confusion for not loading application icons
  195. (see above). For this we added BarIcon which does the same as ICON before.
  196. The third change in this row is that loadIcon doesn't need the extension
  197. anymore, but looks for standard extensions (png, xpm) itself. If you hard-
  198. coded .xpm, loadIcon will issue a warning at runtime, but will still work
  199. in stripping off the .xpm part<P>
  200. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  201. <H3><A NAME="KTMainWindow">KTMainWindow</A></H3>
  202. KTMainWindow has been replaced with KMainWindow.<p>
  203. The KMainWindow constructor needs a parent widget as first argument.
  204. You can use 0 for this.<p>
  205. setView() has been replaced with setCentralWidget().<p>
  206. view() has been replaced with centralWidget().<p>
  207. addToolBar() has been removed, it is not needed any more.<p>
  208. setMenu(...) has been removed, it is not needed any more.<p>
  209. setStatusBar(...) has been removed, it is not needed any more.<p>
  210. updateRects() has been removed, it is not needed any more.<p>
  211. enableStatusBar(...) has been removed, use statusBar()-&gt;show() and/or
  212. statusBar()-&gt;hide() instead.<p>
  213. enableToolBar(...) has been removed, use toolBar()-&gt;show() and/or
  214. toolBar()-&gt;hide() instead. <p>
  215. view_* public variables do no longer exist. There is really no reason
  216. for an app to use this information. If you do need it anyway, use
  217. mainViewGeometry() instead.<P>
  218. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  219. <H3><A NAME="KHelpMenu">KHelpMenu</A></H3>
  220. helpMenu() has been moved to KMainWindow from KApplication (kapp).<P>
  221. Both the "About KDE" and the "About &lt;Application&gt;" dialog boxes
  222. are now modeless. "About KDE" is a completely new widget.<P>
  223. If you used in the toplevel window (that is derived from KMainWindow)
  224. "kapp-&gt;helpMenu( bool, TQString )" to get the help menu
  225. you must now change this to "helpMenu( TQString )". The TQString defaults
  226. to TQString::null so it is sufficient to write helpMenu().<P>
  227. The old aboutKDE(), aboutApp() and appHelpActivated() of KApplication
  228. have all been removed. If you need direct access to these or need
  229. access to a help menu in a class that is not derived from
  230. KMainWindow then allocate an instance of the new class KHelpMenu.
  231. See KDE 2.0 API reference or khelpmenu.h (kdeui) for additional info.<P>
  232. Espen Sand &lt;<A HREF="mailto:espen@kde.org">espen@kde.org</A>&gt;<P>
  233. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  234. <H3><A NAME="KToolBar">KToolBar</A></H3>
  235. enable(...) is depreciated, use show()/hide() instead.<p>
  236. enableFloating(...) has been removed, use enableMoving() instead.<p>
  237. setMaxHeight() is depreciated, use setMaximumHeight() instead.<p>
  238. maxHeight() is depreciated, use maximumHeight() instead.<p>
  239. setMaxWidth() is depreciated, use setMaximumWidth() instead.<p>
  240. maxWidth() is depreciated, use maximumWidth() instead.<p>
  241. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  242. <H3><A NAME="launching">Starting other programs</A></H3>
  243. In KDE 2.0 there are several ways to start other programs from within
  244. your application. Here is a short summary of your options with reasons why
  245. you should or should not use them.
  246. <H4>1. fork + exec</H4>
  247. <P>
  248. You never want to use this unless you have a very good reason why it is
  249. impossible to use KProcess.
  250. </P>
  251. <H4>2. KProcess</H4>
  252. <P>
  253. You want to use this if you need to start a new process which needs to be a
  254. child of your process, e.g. because you want to catch stdout/stderr or need
  255. to send it data via stdin. You should never use this to start other KDE
  256. applications unless your application is called kgdb :-) If you need to
  257. send/receive text like data to/from the process, you are probably better
  258. off with KProcIO
  259. </P>
  260. <H4>3. KProcIO</H4>
  261. <P>
  262. Like KProcess. Unlike KProcess, this class actually makes it easy to
  263. send data to and receive data from the process.
  264. </P>
  265. <H4>4. startServiceByDesktopPath</H4>
  266. <P>
  267. Preferred way to launch desktop (KDE/Gnome/X) applications or KDE services.
  268. The application/service must have a .desktop file. It will make use of
  269. KDEinit for increased startup performance and lower memory usage. These
  270. benefits only apply to applications available as KDEinit loadable module (KLM)
  271. </P>
  272. <H4>5. KRun</H4>
  273. <P>
  274. Generic way to open documents/applications/shell commands. Uses
  275. startServiceBy.... where applicable. Offers the additional
  276. benefit of startup-notification.<BR>
  277. KRun can start any application, from the binary or the desktop file,
  278. it will determine the mimetype of a file before running the
  279. preferred handler for it, and it can also start shell commands.
  280. This makes KRun the recommended way to run another program in KDE 2.
  281. </P>
  282. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  283. <H3><A NAME="khtmlw">khtmlw</A></H3>
  284. khtmlw has been replaced with khtml.<BR>
  285. <UL>
  286. <LI>KHTMLView has vanished. Just use KHTMLWidget, which does scrollbar
  287. managing for free.
  288. <LI>A lot of the API has changed. If you just want to open a file/URL,
  289. you just need to do:<P>
  290. <PRE>
  291. KHTMLWidget *w = new KHTMLWidget();
  292. w-&gt;openURL(myURL);
  293. </PRE>
  294. <LI>khtml uses QString's instead of char *'s now. This means, that most
  295. of the api has changed. In all functions:<P>
  296. <PRE>
  297. const char * -&gt; QString
  298. TQStrList -&gt; QStringList
  299. </PRE>
  300. The only exception for the moment is KHTMLWidget::write(), which does
  301. also exist in a const char * version.<P>
  302. <LI>you won't need the getKHTMLWiget function anymore. Just replace
  303. getKHTMLWidget-&gt;xxx() with xxx()<P>
  304. <LI>xxx(TQString) -&gt; xxx(const TQString &amp;)<P>
  305. <LI>consistent naming. All getXyz() functions are renamed to xyz()<P>
  306. <LI>replaced/changed functions:<P>
  307. <TABLE BORDER="1">
  308. <TR>
  309. <TD>KHTMLWidget::setDefaultFontBase()</TD>
  310. <TD>-&gt; setFontSizes()</TD>
  311. </TR>
  312. <TR>
  313. <TD>x/yOffset()</TD>
  314. <TD>-&gt; contentsX/Y()</TD>
  315. </TR>
  316. <TR>
  317. <TD>getSelectedText(TQString &amp;)</TD>
  318. <TD>-&gt; TQString selectedText()</TD>
  319. </TR>
  320. <TR>
  321. <TD COLSPAN="2" ROWSPAN="0">findTextEnd() has vanished. just remove the call from your code</TD>
  322. </TR>
  323. <TR>
  324. <TD>gotoXY(x, y)</TD>
  325. <TD>-&gt; setContentsPos(x, y)</TD>
  326. </TR>
  327. <TR>
  328. <TD>docWidth()</TD>
  329. <TD>-&gt; contentsWidth()</TD>
  330. </TR>
  331. <TR>
  332. <TD>docHeight()</TD>
  333. <TD>-&gt; contentsHeight()</TD>
  334. </TR>
  335. </TABLE><P>
  336. <LI>Don't forget to change the link-flags! (-lkhtml -lkjava instead of -lkhtmlw)
  337. </UL>
  338. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  339. <H3><A NAME="KIntegerLine">KIntegerLine, KIntLineEdit</A></H3>
  340. KIntegerLine and KIntLineEdit have been replaced by KIntNumInput.
  341. The new header file is called knuminput.h.<P>
  342. The new KIntNumInput can have an optional slider attached, ensures
  343. that the entered value is in a given range (use MAX_INT or similar
  344. if you don't care about the range) and can maintain a descriptive
  345. label and also a unit for the edited value.<P>
  346. The API is almost the same and it simplifies existing code a bit,
  347. so give it a try. If you need more functionality, please contact
  348. me, Dirk A. Mueller &lt;<A HREF="mailto:mueller@kde.org">mueller@kde.org</A>&gt;.<P>
  349. The additional class KDoubleNumInput gives you the same look &amp; feel,
  350. but allows you to edit floating point numbers.<P>
  351. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  352. <H3><A NAME="KDNDIcon">KDNDIcon, KDNDDropZone, KDNDWidget, kdecore/drag.h</A></H3>
  353. KDE Drag and Drop is Dead. Long live Qt Xdnd.<P>
  354. Xdnd is better anyway, because it has been adopted by all the other
  355. major GUI toolkits still under active development (this precludes
  356. Motif, but maybe we can convince the lesstif guys!). Some changes
  357. are necessary to convert your old KDND-based stuff to Qt DND.<P>
  358. <UL>
  359. <LI>Remove drag.h from all of your sources / header files.<P>
  360. <LI>Remove KDNDDropZone object creations. Instead of creating an
  361. object of this type and then connecting it to some arbitrary slot
  362. to handle drops, call "setAcceptDrops(true)" in your widget
  363. constructor and then override the protected methods dragEnterEvent,
  364. dragMoveEvent, dragLeaveEvent, and dropEvent.<P>
  365. <LI>You should be aware that to handle drops, you will either have to
  366. inherit a widget and then override the methods mentioned above,
  367. or install an event handler for the widget in that widget's parent,
  368. and then handle TQEvent::DragMove or TQEvent::Drop inside there (if
  369. you want to avoid inheritance).<P>
  370. <LI>You can emulate the old DndURL drop-type behavior with the Qt
  371. Drag Object type QUriList.<P>
  372. <LI>You can start a drag from inside your widget's mouseMoveEvent
  373. method if you wish.<P>
  374. <LI>Qt includes a Drag and Drop tutorial. We suggest you read that
  375. now if you are confused.<P>
  376. <LI>TQMultiLineEdit has already a DnD interface that accepts text/*
  377. If you want to add support for other mimetypes, you need to
  378. re-implement all DnD-methods (also dragMoveEvent()) and pass
  379. QTextDrag's to the parent methods.<P>
  380. <LI>TQTextDrag also accepts text/uri-list, which means that you
  381. always need to check for TQUriDrag first if you want to get
  382. both working.<P>
  383. <LI>The mimetype for Uri's is now text/uri-list. If you've used
  384. the proprietary Qt 1.x url/url, you need to adjust that.
  385. </UL>
  386. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  387. <H3><A NAME="KConfigBase">KConfigBase, KConfig, KSimpleConfig</A></H3>
  388. These classes have been largely re-implemented. The external API
  389. remains mostly the same, with the single notable change that
  390. the groupIterator and entryIterator methods have been removed and
  391. instead replaced by groupList (which returns a TQStringList of groups)
  392. and entryMap(const TQString &amp;group) (which returns a TQMap of entries
  393. in the specified group). This is due to internal changes in KConfig
  394. which would make providing iterators possibly rather difficult.<P>
  395. Much more extensive documentation on the KConfig and friends API can
  396. be found in the kdoc generated documentation from the header files,
  397. and in kdecore/KCONFIG_DESIGN.<P>
  398. To use the new iterator, you will probably want to do something like
  399. this:<P>
  400. <PRE>
  401. TQMap&lt;TQString, TQString&gt; tmpMap = config-&lt;entryMap(myGroup);
  402. TQMap&lt;TQString, TQString&gt;::Iterator aIt(tmpMap.begin());
  403. for (; aIt != tmpMap.end(); ++aIt) {
  404. // body here. Access iterator key as aIt.key(),
  405. // data as *aIt.
  406. }
  407. </PRE>
  408. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  409. <H3><A NAME="libkfm">libkfm has disappeared</A></H3>
  410. Lots of other functionalities have been taken out of kfm, some being
  411. now in libkio, some in libkonq.<P>
  412. <STRONG> Replacement table :</STRONG><P>
  413. <TABLE BORDER="1">
  414. <TR><TD>KFM::download </TD><TD>-&gt; KIO::NetAccess::download (kdelibs/kio/netaccess.h)</TD></TR>
  415. <TR><TD>KFM::removeTempFile </TD><TD>-&gt; KIO::NetAccess::removeTempFile</TD></TR>
  416. <TR><TD COLSPAN="2" ROWSPAN="0">refreshDesktop, sortDesktop, selectRootIcons : removed; kdesktop handles it</TD></TR>
  417. <TR><TD>KFM::configure </TD><TD>-&gt; see konqueror DCOP interface</TD></TR>
  418. <TR><TD>KFM::openURL </TD><TD>-&gt; "(void) new KRun (url)" (kdelibs/kio/krun.h)</TD></TR>
  419. <TR><TD>KFM::refreshDirectory </TD><TD>-&gt; not needed anymore since konqy/kdesktop use KDirWatch</TD></TR>
  420. <TR><TD>KFM::openProperties </TD><TD>-&gt; "(void) new KPropertiesDialog (url)" (kdelibs/kfile/kpropsdlg.h)</TD></TR>
  421. <TR><TD>KFM::exec </TD><TD>-&gt; "(void) new KRun (url)" (kdelibs/kio/krun.h)</TD></TR>
  422. <TR><TD>KFM::copy, KFM::move </TD><TD>-&gt; KIO::Job (async, see kio/job.h)<BR>
  423. or KIO::NetAccess (sync, see kio/netaccess.h)</TD></TR>
  424. <TR><TD>DlgLocation </TD><TD>-&gt; Use KLineEditDlg (kdeui/klineeditdlg.h) instead</TD></TR>
  425. </TABLE>
  426. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  427. <H3><A NAME="KDialog">KDialog</A></H3>
  428. KDialog is no longer defined in kwizard.h. Include kdialog.h instead.<P>
  429. Note that the best way to write new dialogs is to use KDialogBase (see kdialogbase.h)<P>
  430. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  431. <H3><A NAME="kcharsets">kcharsets</A></H3>
  432. The kcharsets class has been completely rewritten, and most of it has
  433. vanished, since support for it moved to Qt.<P>
  434. Most applications will only need to replace kapp-&gt;getKCharsets() with
  435. KGlobal::charsets().<P>
  436. For conversion of various input formats to QStrings, please have a
  437. look at TQTextCodec and classes derived from it.<P>
  438. Character entities are now converted from and to QChars. The name has
  439. changed from convertTag to fromEntity and toEntity.<P>
  440. To get a font, which can display a certain charset (if such a font
  441. exists), you can use the KCharsets::setQFont methods. Input is a font and
  442. a charset. Kcharsets tries to find an output font, which matches the
  443. input font most closely, but can display the given charset.<P>
  444. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  445. <H3><A NAME="KWizard">KWizard, KNoteBook</A></H3>
  446. KWizard is based on TQWizard now. The API has changed. Consult Qt's
  447. documentation and kdelibs/kdetest/kwizardtest.cpp for an example use.<P>
  448. KNoteBook (deeply entwined with the former KWizard) has been removed until
  449. someone is willing to port it to work with the new wizard. If you want to
  450. use it you'll find the necessary files in kdegraphics/kiconedit.<P>
  451. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  452. <H3><A NAME="KSpinBox">KSpinBox, KNumericSpinBox</A></H3>
  453. These classes have been replaced by TQSpinBox. API is almost the same
  454. HINTS:<P>
  455. <UL>
  456. <LI>valueincreased()/valuedecreased -&gt; valueChanged()
  457. <LI>getValue() -&gt; value()
  458. </UL>
  459. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  460. <H3><A NAME="KClipboard">KClipboard</A></H3>
  461. KClipboard has been removed. In case you've been using KClipboard,
  462. QClipboard is the way to go now, as it has all the functionality the K
  463. version had, and more.<P>
  464. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  465. <H3><A NAME="KPanner">KPanner, KNewPanner</A></H3>
  466. KPanner and KNewPanner have been removed. TQSplitter does everything
  467. KPanner did and more. The api is similar, but not compatible.
  468. Basically to set it up so that you have a vertical splitter between a
  469. listbox, a listview and multi line editor, you would do something like
  470. this:<P>
  471. <TABLE><TR><TD>
  472. TQSplitter *split = new TQSplitter( parent );<BR>
  473. TQListBox *lb = new TQListBox( split );<BR>
  474. KListView *lv = new KListView( split );<BR>
  475. TQMultiLineEdit *ed = new TQMultiLineEdit( split );
  476. </TD></TR></TABLE>
  477. As you can see you are not limited to two children. Additionally, you
  478. do not have to call activate when you are done, and opaque resizing is
  479. possible if you call setOpaqueResize(true).<P>
  480. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  481. <H3><A NAME="KTreeList">KTreeList, KTreeListItem</A></H3>
  482. Use KListView, TQListViewItem instead. API is almost the same, you only
  483. need to add a Column (KListView::addColum) before KListView is useable.<P>
  484. KListView has no addChild(), insertItem() and removeItem() calls. Inserting
  485. a root item is done by constructing a TQListViewItem with the KListView
  486. passed as the parent widget. adding a child item is done by constructing
  487. a TQListViewItem with the parent item as parameter. removeItem() should
  488. be replaced by delete &lt;pointer to item&gt;.<P>
  489. The root items are not shown in a tree fashion by default. to get this,
  490. use KListView::setDecorativeRoot(true).<P>
  491. Expanding and collapsing can by done by using TQListViewItem::setOpen(bool).<P>
  492. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  493. <H3><A NAME="KMsgBox">KMsgBox</A></H3>
  494. KMsgBox has been superseded by TQMessageBox. Which has been superseded
  495. by KMessageBox.<P>
  496. <UL>
  497. <LI>KMsgBox had return codes starting with 1 for the first button, 2 for
  498. the second, and so on. KMessageBox defines an enum which you should
  499. use instead.
  500. <LI>Please note that you shouldn't add the name of your application
  501. to the caption argument. It is already added automatically.
  502. </UL>
  503. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  504. <H3><A NAME="KCombo">KCombo</A></H3>
  505. KCombo has been removed. Use KComboBox instead, it is completely
  506. compatible with the old KCombo API. The method that you may have problems
  507. with is the old KCombo::setText. This has been renamed to
  508. KComboBox::setEditText.<P>
  509. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  510. <H3><A NAME="KQuickHelp">KQuickHelp</A></H3>
  511. KQuickHelp, the "super-tooltip" widget, has been replaced by TQWhatsThis.
  512. It provides a compatible API and almost the same look and feel, in addition
  513. to some new functionality.<P>
  514. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  515. <H3><A NAME="KPixmapgradientFill">KPixmap::gradientFill</A></H3>
  516. Instead of old KPixmap::gradientFill, use:<P>
  517. KPixmapEffect::gradient(KPixmap&amp;, TQColor, TQColor, enum KPixmapEffect::GradientType, int)<P>
  518. Hence:<P>
  519. pix.gradientFill(ca, cb, direction, ncols)<P>
  520. becomes, for direction == true :<P>
  521. KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::VerticalGradient, ncols)<P>
  522. There are now:<P>
  523. <TABLE><TR><TD align=top>
  524. KPixmapEffect::<BR></TD>
  525. <TD> [Vertical,<BR>
  526. Horizontal,<BR>
  527. Diagonal,<BR>
  528. CrossDiagonal,<BR>
  529. Rectangle,<BR>
  530. Pyramid,<BR>
  531. PipeCross,<BR>
  532. Elliptic]</TD></TR></TABLE>
  533. Gradients. See kdelibs/kdetest/kgradienttest &amp; kunbalancedgradienttest for
  534. information on how they actually look.<P>
  535. Look further in this document for other info about pixmap effect code
  536. reorganization (essentially, all effects are now in libkdeui.so: gradient(),
  537. unbalancedGradient(), hash(), desaturate(), pattern(), fade(), blend() etc.<P>
  538. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  539. <H3><A NAME="KTabListBox">KTabListBox</A></H3>
  540. This widget has been replaced by the almighty KListView. Everything said
  541. about KTreeList could be repeated here. The good thing is, that you now
  542. can combine TreeView's and normal Tablists without problems.<P>
  543. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  544. <H3><A NAME="KToolBarButton">KToolBarButton &amp; KRadioGroup</A></H3>
  545. If you need to do anything with KToolBarButton you now need to include
  546. &lt;ktoolbarbutton.h&gt; KRadioGroup has been renamed to KToolBarRadioGroup and
  547. requires you to include &lt;ktoolbarradiogroup.h&gt;<P>
  548. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  549. <H3><A NAME="KAccel">KAccel</A></H3>
  550. The functions keyToString() and stringToKey() which were previously
  551. declared globally in kaccel.h are now static methods in KAccel.<P>
  552. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  553. <H3><A NAME="kstring">kstring.h / KString</A></H3>
  554. The KString class is obsolete and is not defined in
  555. kstring.h anymore. The header file only existed for compatibility reasons.
  556. The file has been removed completely, use TQString instead. (<A HREF="mailto:mirko@kde.org">mirko@kde.org</A>)<P>
  557. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  558. <H3><A NAME="ktopwidget">ktopwidget.h / KTopWidget</A></H3>
  559. KMainWindow replaces this class completely. ktopwidget.h does not
  560. exist in KDE 2. (<A HREF="mailto:mirko@kde.org">mirko@kde.org</A>)<P>
  561. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  562. <H3><A NAME="kbutton">kbutton.h / KButton</A></H3>
  563. Since Qt 2.0, the class TQToolButton provides the functionality of
  564. buttons that raise when the mouse is moved over them, so there is no
  565. reason to have a class providing the same feature in KDE libs. All
  566. occurrences of KButton in the KDE CVS have been replaced by QToolButtons,
  567. but for applications not in the CVS it has to be done by the respective
  568. developer. (<A HREF="mailto:mirko@kde.org">mirko@kde.org</A>)<P>
  569. <H3><A NAME="kbuttonbox">kbuttonbox.h / KButtonBox</A></H3>
  570. KButtonBox::Orientation has been removed in favor of Qt::Orientation.
  571. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  572. <H3><A NAME="kcolorgroup">kcolorgroup.h / KColorGroup</A></H3>
  573. KColorGroup was not used in sources in the KDE CVS, and its
  574. functionality is provided by Qt. It has been removed. (<A HREF="mailto:mirko@kde.org">mirko@kde.org</A>)<P>
  575. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  576. <H3><A NAME="kled">kled.h, kledlamp.h / KLed, KLedLamp</A></H3>
  577. There where two different classes for showing an LED lamp. Both are
  578. merged to the KLed class, but THE USER INTERFACE IS DIFFERENT, as both
  579. where more or less broken.<P>
  580. Please adjust your code accordingly.<P>
  581. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  582. <H3><A NAME="KDockWidget">KDockWidget</A></H3>
  583. KDockWidget inherits form KMainWindow instead of KTMainWindow now.
  584. See <A HREF="KTMainWindow">KTMainWindow</A> for more details.
  585. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  586. <H3><A NAME="KPixmap">KPixmap, KPixmapEffect</A></H3>
  587. KPixmap::gradientFill, KPixmap::patternFill, KPixmap::tile and
  588. KPixmap::mapFill have been moved to KPixmapEffect, which is now part
  589. of libkdeui.<P>
  590. KPixmap::tile() has been renamed to KPixmapEffects::createTile().<P>
  591. Dirk A. Mueller &lt;<A HREF="mailto:mueller@kde.org">mueller@kde.org</A>&gt;<P>
  592. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  593. <H3><A NAME="KControlCenter">KDE Control Center</A></H3>
  594. The format for modules for the KDE Control Center has changed quite
  595. a bit. If you want to port your module to the new schema, please
  596. consult<P>
  597. kdebase/kcontrol/README<P>
  598. which explains what needs to be done.<P>
  599. Matthias Hoelzer-Kluepfel &lt;<A HREF="mailto:hoelzer@kde.org">hoelzer@kde.org</A>&gt;<P>
  600. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  601. <H3><A NAME="KWMModuleApplication">KWMModuleApplication libkdeui/kwmmapp.h</A></H3>
  602. The KWMModuleApplication has been removed. Instead, use the class
  603. KWinModule in libkdecore. The API is a bit cleaner but very similar,
  604. so you will feel comfortable immediately. One of the advantages of
  605. KWinModule is that it doesn't require a special KApplication
  606. subclass. This lead to many problems and misunderstandings in the
  607. past. KWinModule is now just an object that emits fancy signals (and
  608. provides some useful lists, like the list of all managed windows).
  609. (<A HREF="mailto:ettrich@kde.org">ettrich@kde.org</A>)<P>
  610. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  611. <H3><A NAME="KDebug">kDebug</A></H3>
  612. Use kdDebug, kdWarning, kdError, kdFatal to log debug output, warnings and
  613. errors in a very flexible way. kdebug has been improved, and the API simplified.
  614. kdesdk/scripts/kDebug2kdDebug.sh provides a script for automating the conversion.
  615. Note that enabling/disabling debug output can now be done with kdebugdialog,
  616. which can be found in kdebase. The hidden dialog on C+S+F12 no longer exists.
  617. <P>
  618. Also, note that qDebug and fprintf aren't disabled by -DNDEBUG, whereas kdDebug is.
  619. One more reason to use kdDebug !
  620. (<A HREF="mailto:faure@kde.org">faure@kde.org</A>)<P>
  621. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  622. <H3><A NAME="KFileDialog">KFileDialog - General Stuff</A></H3>
  623. The new (rewritten) KFileDialog (KFD) is a lot more like the new QFileDialog
  624. but still looks quite different. Normally you may want to use the static
  625. methods provided for convenience (getOpenFileName and getSaveFileName).
  626. If you need special features you can configure the dialog extensively. Just
  627. create an object and use the different methods. <P>
  628. Werner Trobin &lt;<A HREF="mailto:wtrobin@carinthia.com">wtrobin@carinthia.com</A>&gt;<P>
  629. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  630. <H3><A NAME="KFileDialogPreview">KFileDialog - Preview Mode</A></H3>
  631. There is also a new preview mode which is quite different to the one we had in
  632. the KDE 1.x KFD. There are no preview modules you have to register but there
  633. is a single method you can use to set a preview widget. This widget has to
  634. inherit TQWidget and you have to implement a slot (showPreview(const KURL &amp;))
  635. in this class. This slot is called each time the selected file/dir changes.
  636. In this slot you have to react appropriate (i.e. show the preview :). The
  637. easiest way this can be done is to derive your class from TQWidgetStack and
  638. add a Object (derived from TQWidget) for each file type. In the showPreview
  639. method you just raise the matching widget. If you can't find an appropriate
  640. widget just hide() the widget stack.<P>
  641. If you need some "inspiration" on how that could be done, please have a look
  642. at koffice/lib/kofficecore/koFilterManager.cc (PreviewStack).<P>
  643. Werner Trobin &lt;<A HREF="mailto:wtrobin@carinthia.com">wtrobin@carinthia.com</A>&gt;<P>
  644. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  645. <H3><A NAME="ImageEffects">Image effects</A></H3>
  646. The kFSDither class is now gone. Its functionality was moved to
  647. KImageEffect::dither(). Whereas before, you would done:<P>
  648. <TABLE>
  649. <TR>
  650. <TD>
  651. <PRE>
  652. kFSDither dither(palette, ncols);
  653. image = dither.dither(image);
  654. </PRE>
  655. </TD>
  656. </TR>
  657. </TABLE>
  658. <P>
  659. Now do:<BR>
  660. <TABLE>
  661. <TR>
  662. <TD>
  663. <PRE>
  664. KImageEffect::dither(image, palette, ncols);
  665. </PRE>
  666. </TD>
  667. </TR>
  668. </TABLE>
  669. <P>
  670. Kurt Granroth &lt;<A HREF="mailto:granroth@kde.org">granroth@kde.org</A>&gt;
  671. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  672. <H3><A NAME="KAudio">KAudio (kaudio.h)</A></H3>
  673. The KAudio class no longer exists. Here are your options for porting.
  674. <p>
  675. <ul>
  676. <li>notifications like "you have got new mail"
  677. <p>
  678. The way to go for this one is to use the KNotify API, which will allow
  679. users to reconfigure how your application should sound. On the other hand,
  680. they will also be able to disable specific sounds, rather let the events
  681. log to a file, and so on. You can provide an rc file with the default
  682. configuration. (Include "knotifyclient.h" and use the KNotifyClient class).
  683. <p>
  684. <li>very simple cases
  685. <p>
  686. On the other hand, if you just want a really small solution, there is the
  687. KAudioPlayer class (declared kaudioplayer.h), which has a static member
  688. function for playing, like
  689. <p>
  690. <pre>
  691. KAudioPlayer::play("/var/samples/foo.wav");
  692. </pre>
  693. <p>
  694. <li>multimedia apps
  695. <p>
  696. If you are writing "real multimedia apps", you may also have a look at the
  697. even more advanced sound/multimedia support, that using the aRts/MCOP
  698. libraries directly can offer you.
  699. </ul>
  700. Stefan Westerfeld <A HREF="mailto:stefan@space.twc.de">stefan@space.twc.de</A>
  701. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  702. <H3><A NAME="KImageIO">KImageIO (kimgio.h)</A></H3>
  703. <p>
  704. KImageIO has moved from 'kimgio.h' to 'kimageio.h'. LIB_KIMGIO does no longer
  705. exists, you need to link against LIB_KSYCOCA instead.
  706. </p>
  707. <p>
  708. kimgioRegister() has been replaced by KImageIO::registerFormats().
  709. </p>
  710. <p>
  711. Waldo Bastian <A HREF="mailto:bastian@kde.org">bastian@kde.org</A>
  712. <H4><P ALIGN="RIGHT"><A HREF="#TOC">Return to the Table of Contents</A></P></H4>
  713. </BODY>
  714. </HTML>