forked from KDE/kdelibs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KDE4PORTING.html
3084 lines (2672 loc) · 133 KB
/
KDE4PORTING.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Guide to Porting Applications to KDE 4.x</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body {
font-size: 0.8em;
font-family: "Bitstream Vera Sans", "Lucida Grande", "Trebuchet MS", sans-serif;
color: #535353;
background-color: #ffffff;
}
h1, h2, h3, h4, h5 {
font-weight: bold;
color: #f7800a;
}
a:link {
padding-bottom: 0;
text-decoration: none;
color: #0057ae;
}
a:visited {
padding-bottom: 0;
text-decoration: none;
color: #644A9B;
}
a[href]:hover {
text-decoration: underline;
}
pre {
display: block;
margin: 0.3em;
padding: 0.3em;
font-size: 1em;
font-family: Courier, 'Courier New', 'Andale Mono', Monaco, monospace;
color: #000000;
background: #f9f9f9;
border: #2f6fab dashed;
border-width: 1px;
overflow: auto;
line-height: 1.1em;
}
-->
</style>
</head>
<body>
<h1>Porting Applications to KDE 4</h1>
<h2>Note</h2>
<p>All modules should build from /trunk/KDE/kdelibs; there is no snapshot branch any longer. Major changes happen on Mondays (in any timezone) so expect rapid changes during that time. Things should be generally stable otherwise, but this <b>is</b> the development area, so there are no guarantees.</p>
<p>Deprecated classed that have been renamed to e.g. K3Foo are in kde3support.</p>
<p>This document contains the changes you have to apply to programs written for
KDE 3.x when you want to port them to KDE 4.x.<br>
<h3><a name="TOC">Table of Contents</a></h3>
<UL>
<li><a href="#gettingstarted">Getting Started</a></li>
<li><a href="#globalchanges">Global Changes</a></li>
<li><a href="#kab">Changes in kab</a></li>
<li><a href="#kdefx">kdefx porting (kdefx has been removed)</a></li>
<li><a href="#kdecore">Changes in kdecore</a></li>
<li><a href="#kdeui">Changes in kdeui</a></li>
<li><a href="#kio">Changes in kio</a></li>
<li><a href="#kparts">Changes in kparts</a></li>
<li><a href="#kded">Changes in kded</a></li>
<li><a href="#kspell">Changes in kspell</a></li>
<li><a href="#kdnssd">Changes in kdnssd</a></li>
<li><a href="#khtmlpart">API-cleanup in KHTML</a></li>
<li><a href="#kfile">Changes in kfile</a></li>
<li><a href="#kdesu">Changes in kdesu</a></li>
<li><a href="#kcontrol">KDE Control Center</a></li>
<li><a href="#kicker">Panel Applets and Extensions</a></li>
<li><a href="#kscreensaver">KScreensaver</a></li>
<li><a href="#i18n">I18N</a></li>
<li><a href="#kssl">KSSL</a></li>
<li><a href="#mimetypes">Mime types names</a></li>
<li><a href="#knewstuff">KNewStuff</a></li>
<li><a href="#dcop">DCOP</a></li>
<li><a href="#printing">Printing</a></li>
</UL>
<h3><a name="gettingstarted">Getting started</a></h3>
<p>As a start you should have a look at doc/html/porting4.html in the Qt package,
or <a href="http://doc.trolltech.com/4.3/porting4.html">this page online</a>.</p>
<p>To start with the porting, you can run "qt3to4 -strict list_of_files"
followed by kdesdk/scripts/qt4/adapt-to-qt4-api.pl and kdesdk/scripts/qt4/adapt-to-kde4-api.pl</p>
<h4 align="right"><a href="#TOC">Return to the Table of Contents</a></h4>
<h3><a name="globalchanges">Global Changes</a></h3>
<ul>
<li>
The "const char *name" arguments in the constructors of QObject derived classes
have been removed. Use setObjectName() instead if the object name is really necessary.
</li>
<li>The define KDE_DEPRECATED must be used now at the start of the declaration
(but still after an eventual "static", "inline" or "virtual" keyword).
KDE_DEPRECATED does not work with constructors, use KDE_CONSTRUCTOR_DEPRECATED
instead.</li>
</ul>
<h4 align="right"><a href="#TOC">Return to the Table of Contents</a></h4>
<h3><a name="kab">Changes in kab</a></h3>
<h4 align="right"><a href="#TOC">Return to the Table of Contents</a></h4>
<h3><a name="kdefx">Changes in kdefx</a></h3>
<p>kdefx has been removed.</p>
<ul>
<li>KStyle moved to kdeui</li>
<li>Use Solid::Processor instead of KCPUInfo.</li>
<li>Most of KImageEffect is now available in blitz; the bits that aren't can be done with QPainter.
<ul>
<li>Qt has gradients now, please use them if you can. Otherwise blitz has gradients ala KImageEffect.</li>
</ul>
</li>
<li>KPixmapEffect was little more than a wrapper around pixmap->image->KImageEffect->image->pixmap. Use the replacements for KImageEffect.</li>
<li>kdrawutils.h is gone.
<ul>
<li>If you already ported your code to KDE4, your code now has a copy of whatever kdrawutil code you were using.</li>
<li>If you haven't ported your code yet, you get to find a copy of what you need in svn's revision history (or in branches/3.5).</li>
</ul>
</li>
<li>The functionality of KPixmapSplitter cen be emulated with this code, courtesy of Matt Newell:
<pre>
QRect getFlowedRect(int index, const QSize &itemSize,
int layoutWidth, int h_spacing, int v_spacing)
{
// NOTE: if using h_spacing, depending on your use you might want to replace
// layoutWidth with (layoutWidth + h_spacing)
int itemsPerRow = layoutWidth / (itemSize.width() + h_spacing);
return QRect( QPoint( (index % itemsPerRow) * (itemSize.width() + h_spacing),
(index / itemsPerRow) * (itemSize.height() + v_spacing) ),
itemSize );
}
</pre>
</li>
<li>Use QPixmap instead of KPixmap.</li>
</ul>
<h4 align="right"><a href="#TOC">Return to the Table of Contents</a></h4>
<h3><a name="kdecore">Changes in kdecore</a></h3>
<ul>
<li>kuniqueapp.h => kuniqueapplication.h</li>
<li>klargefile.h => kde_file.h</li>
<li>kcatalogue.h => kcatalog.h</li>
<li>kaccelmanager.h => kacceleratormanager.h</li>
<li>kprocctrl.h => k3protocolcontroller.h</li>
<li>KInstance was renamed to KComponentData</li>
<li>KGlobalAccel moved to kdeui</li>
<li>KGlobalSettings moved to kdeui</li>
<li>KIconLoaded moved to kdeui</li>
<li>KSessionManaged renamed to KSessionManager and moved to kdeui</li>
<li>KShortcut moved to kdeui</li>
</ul>
<h4>KAboutData</h4>
<ul>
<li>KAboutData::setTranslator needs different parameters now.
(Please see the corresponding Doxygen comment for the current state.)</li>
<li>new catalogName parameter to constructor can be null or empty, then appName is used as catalog name</li>
<li>all setter methods return object reference, so they can be chained to avoid repeating object name (eg. for addAuthor(), addCredits(), etc.)</li>
</ul>
<p>I18N_NOOPs in general replaced with KLocalizedString, produced by ki18n()/ki18nc() calls,
or just KLocalizedString() if wanted empty.
See also <a href="#i18n">the I18N section below</a>.</p>
<h4>KAccel</h4>
<p>Removed. Replaced by the new KAction/QAction framework.
See KActionCollection::associateWidget() if you need the old KAccel widget-binding behavior.</p>
<h4>KAccelAction</h4>
<ul>
<li>Removed. Replaced by the new KAction/QAction framework.</li>
<li>[Old note] KDE3 supported 3 modifier key shortcuts and 4 modifier key (3+META) shortcuts, because earlier versions of Qt3 didn't
support a META modifier/WIN key. This is changed, so now all shortcuts can be 4 modifier key. All instances of
shortcut3 and shortcut4 have been reduced just to "shortcut".</li>
<li>[Old note] The constructor, init(), and insert() functions now only take only KShortcut "default" argument instead of two</li>
<li>[Old note] Removed shortcutDefault3() and shortcutDefault4(). Use shortcutDefault() instead</li>
</ul>
<h4>KAccelBase</h4>
<p>Removed. Replaced by the new KAction/QAction framework.</p>
<h4>KApplication</h4>
<ul>
<li>Moved to kdeui. This means no change for GUI applications.
For text-based applications, you should consider switching to QCoreApplication + KComponentData.
There are two cases:
<ul>
<li>Command-line argument parsing needed: use KCmdLineArgs as usual and then
<pre>QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );</pre></li>
<li>No command-line argument parsing needed: simply create a KComponentData (with &aboutData or just a name),
and then use <pre>QCoreApplication app( argc, argv );</pre>
</li>
</ul>
<li>Of course if you don't create a KApplication, then you should turn any "kapp->" into "qApp->" in the
rest of the code.</li>
<li>KApplication does not inherit KInstance/KComponentData anymore. The KComponentData object is
available through KGlobal::mainComponent() (if KApplication is the first object to create a
KComponentData object, but everything else probably is a bug).</li>
<li>caption() was moved to KGlobal; you can now use it if you don't have a KApplication object</li>
<li>makeStdCaption() was moved to KDialog::makeStandardCaption()</li>
</ul>
<ul>
<li>isRestored() should now use qApp->isSessionRestored(). </li>
<li>keyboardMouseState() has been removed, its functionality is now provided by QApplication::keyboardModifiers() and QApplication::mouseButtons() </li>
<li>random() has been moved to the KRandom class </li>
<li>For using the kiosk restriction/authorization system you have to use the functions provided in KAuthorized. </li>
<li>invoke* functions have been moved to ktoolinvocation. there are static methods invoke*, if you want to use slots as before connect to the invoke* slots of KToolInvocation::self() </li>
<li>startService*, kdeinitExec* have been moved to KToolInvocation </li>
<li>static void addCmdLineOptions(); has moved to KCmdLineArgs::addStdCmdLineOptions </li>
<li>getDisplay() has been removed, its functionality is now provided by QX11Info::display() </li>
<li>cut(), copy(), paste(), clear() and selectAll() were moved to KStandardAction. Rather than creating a copy action and connecting it to kapp just use the KStandardAction::copy </li>
<li>guiEnabled() was removed, use QApplication::type() instead. </li>
<li>ref()/deref() was moved to KGlobal (as static methods) </li>
<li>geometryArgument was removed, please use:
<pre>
QString geometry;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde");
if (args && args->isSet("geometry"))
geometry = args->getOption("geometry");
</pre>
</li>
<li>installSigpipeHandler() was removed. </li>
<li>propagateSessionManager(), requestShutDown() methods and associated ShutdownConfirm, ShutdownType and ShutdownMode enums have been moved into the kworkspace library (which is found in kdebase/workspace/lib); the methods are static functions in KWorkspace namespace. </li>
<li>The shutDown() signal has been removed, use QApplication's signal aboutToQuit() </li>
<li>enableStyles(), disableStyles(), and the constructor argument has been removed. </li>
<li>installKDEPropertyMap has been moved into k3sqlpropertymap.h and renamed to kInstallKDEPropertyMap. It can be used to keep old c
ode that uses the Q3Data* classes working.For new code, use User in the meta object to determine which Q_PROPERTY to use for any widget.
<pre>
const QMetaObject *metaObject = widget->metaObject();
for (int i = 0; i < metaObject->propertyCount(); ++i) {
const QMetaProperty metaProperty = metaObject->property(i);
if (metaProperty.isUser()) {
QString propertyToUse = metaProperty.name();
break;
}
}
</pre>
</li>
<li>caption() has moved to KComponentData </li>
<li>makeStdCaption(const QString&, bool, bool) has moved to KDialog and changed signature to makeStdCaption(const QString&, CaptionFlags) </li>
<li>addKipcEventMask() is unneeded now, and the signals like settingsChanged(), fontChanged() etc. with enums SettingsCategory have moved to KGlobalSettings::self() which is now a QObject</li>
<li>updateRemoteUserTimestamp() now takes DBUS service id instead of dbus name (i.e. something like org.kde. needs to be prepended)</li>
</ul>
<h4>KAudioPlayer</h4>
<p>Removed, use now Phonon::AudioPlayer</p>
<h4>KCatalogue</h4>
<p>Renamed to KCatalog. Method name parts with "catalogue" have been renamed to use "catalog" instead.</p>
<h4>KCharsets</h4>
<ul>
<li>KCharsets::codecForName cannot use glibc's i18n data anymore.
(Note: this feature was new in KDE 3.5 but never publicly announced.)</li>
<li>The user-visible encoding names are now mostly upper-case
(instead of being always lower-case).</li>
<li>KCharsets::languageForEncoding should be replaced
by KCharsets::descriptionForEncoding. The function KCharsets::languageForEncoding is planned to be removed before the release of KDE4.</li>
<li>The status of the encoding UTF-7 is not guaranteed to be kept, as Qt
does not support this encoding.</li>
<li><b>TODO</b>: see which member functions can be removed. The functions handling entites are planned to be moved out of the class KCharsets.</li>
</ul>
<h4>KCodecs</h4>
<ul>
<li>All methods using a QCString removed. The methods use QByteArray now. </li>
<li>Header renamed to kcodecs.h</li>
</ul>
<h4>KConfigBackend</h4>
<ul>
<li>Removed filename(), use fileName()</li>
</ul>
<h4>KSimpleConfig</h4>
<p>This class was removed. It was a very thin wrapper around KConfig and should
be replaced.</p>
<ul>
<li>If you use an absolute path, just change KSimpleConfig with KConfig - there was
no difference between uses of them for KDE3 either.</li>
<li>If you want just the local file to open replace KSimpleConfig("file") with
KConfig("file", KConfig::SimpleConfig);</li>
</ul>
<h4>KConfig</h4>
<ul>
<li>setGroup is deprecated as it creates state. Use group(QString) to receive
a KConfigGroup object or create a KConfigGroup object yourself:
<pre>
KConfig *config = KGlobal::config();
config->setGroup("Group");
config->writeEntry("Key", 0);
</pre>
should be rewritten as
<pre>
KConfigGroup config = KGlobal::config()->group("Group");
config.writeEntry("Key", 0);
</pre>
</li>
<li>setDesktopGroup is gone. Use KDesktopFile (and its desktopGroup() method) if
you want to read .desktop files - or use group("Desktop Entry") instead</li>
<li>It's no longer necessary to specify a KConfig object is read-only - they are always
unless you use change it</li>
<li>The KConfig constructors were changed to receive flags instead of boolean values, i.e.
<ul>
<li><tt>KConfig("file", false /* read-write */, false /* no globals */);</tt> becomes
<tt>KConfig("file", KConfig::NoGlobals);</tt> (note the read-write flag is gone)</li>
<li><tt>KConfig("file", true);</tt>becomes <tt>KConfig("file");</tt></li>
</ul>
</li>
</ul>
<h4>KConfigBase</h4>
<ul>
<li>all read*Entry methods deprecated, use <b>template <typename T> readEntry(key, const T&)</b> in KConfigGroup instead.
This uses QVariant in the background so only types that QVariant can convert to QString work. The use of QVariant allows some ambiguous conversions, so it might be necessary to use <em>explicit</em> construction to disambiguate the type wanted, i.e.
<ul>
<li>bool var = readEntry(key, <b>false</b>);</li>
<li>int var = readEntry(key, <b>int(SomeEnumValue)</b>);</li>
<li>QColor var = readEntry(key, QColor(<b>Qt::black</b>)); // no conversion from Qt::GlobalColor to QVariant
<li>long var = readEntry(key, <b>0</b>); // conversion from long to QVariant is ambiguous, so can't use <b>long(0)</b>.</li>
</ul>
If you need to access top-level config entries (those without any group), use KConfigGroup with the group name <i><default></i>.
</li>
<li>readEntry(const QString&, const QString&) no longer has a default argument, add QString() as
second argument.
</li>
<li>all writeEntry* methods removed, mostly not noticeable, but some types don't automatically convert
to QVariant. You need to cast to a type that is directly convertible to QVariant. i.e.
<pre>
time_t timeVal;
group.writeEntry("someKey", timeVal); // ambiguous conversion
group.writeEntry("someKey", int(timeVal)); // ok
</pre>
</li>
<li>all read*ListEntry methods deprecated, renamed to KConfigGroup::readEntry. Most types use the template version.<br/>
<b>template <typename T> readEntry(key, const QList<T>&)</b><br/>If you just write group.readEntry(key, list) it should work for any type that QVariant can convert to QString.
</li>
<li>writeEntry, deleteGroup, and deleteEntry do not take several boolean options (persistent,global,localized) anymore, but instead one QFlags</li>
</ul>
<h4>KConfigGroupSaver</h4>
<p>
The class KConfigGroupSaver has been removed, instead use KConfigGroup. The
difference is a KConfigGroupSaver object directly affects the config object it
is acting on, while a KConfigGroup object only ensures the entries read or
written through it are in the correct group.</p>
Instead of:
<pre>
KConfig *config = KGlobal::config();
KConfigGroupSaver saver(config, "group name");
...
config->readXXX("entry name");
</pre>
should be rewritten as:
<pre>
KConfigGroup cg = KGlobal::config()->group("group name");
...
cg.readXXX("entry name");
</pre>
<h4>KCmdLineArgs</h4>
<ul>
<li> static void init(int _argc, char **_argv, const char *_appname, const char *_description, const char *_version, bool noKApp = false) KDE_DEPRECATED; -> static void init(int _argc, char **_argv, const QByteArray &appname, const QByteArray &catalog, const KLocalizedString &programName, const QByteArray &version, const KLocalizedString &description = KLocalizedString(), StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE)));
<li> noKApp parameter is gone, instead: Q_FLAGS(StdCmdLineArgs)</li>
<li> new catalog parameter can be null or empty, then appname is used as catalog name</li>
<li> KLocalizedString objects produced by ki18n()/ki18nc() calls (instead of previous I18N_NOOPs), or just KLocalizedString() if needed empty</li>
<li> static void usage(const QString &error) -> static void usageError(const QString &error)</li>
</ul>
<h4>KCmdLineOptions</h4>
Now a proper class, instead of statically initialized struct. Use add() method for adding options (option syntax same as before); add() returns object reference, so calls can be chained to avoid repeating variable name all the way.
<h4><a name="KComponentData">KComponentData</a> (was KInstance)</h4>
<ul>
<li>value based class using shared data: In KDE4 don't work with pointers to KComponentData anymore.
Internally it is reference counted and the data deleted when the last reference goes out of scope.</li>
<li>config() returns a KSharedConfigPtr</li>
<li>sharedConfig() was removed in favour of config()</li>
<li>iconLoader() was moved to KApplication</li>
<li>newIconLoader() was moved to KApplication</li>
</ul>
<h4>kdDebug/kdWarning/kdFatal</h4>
<p>These functions have been renamed to <code>kDebug</code>,
<code>kWarning</code>, <code>kFatal</code>, resp. They now print the
function info, so printing the function name by hand, or using
<code>k_funcinfo</code> is now deprecated. An <code>endl</code> is
performed implicitly. The type of stream used is now
<code>QDebug</code>.</p>
<p>Instead of repeating the debug area all over the place, define
<code>KDE_DEFAULT_DEBUG_AREA</code> instead:</p>
<pre>
- kdDebug( 1234 ) << k_funcinfo << "entered" << endl;
+ kDebug() << "entered";
</pre>
<p>And, in your <code>CMakeLists.txt</code>:</p>
<pre>
+ add_definitions( -DKDE_DEFAULT_DEBUG_AREA=1234 )
</pre>
<h4>KDesktopFile</h4>
<ul>
<li>QString filename() const -> QString fileName() const</li>
<li>more standards compliant. See
<a href="http://www.freedesktop.org/Standards/desktop-entry-spec/latest">
Desktop Entry Spec</a>
<ul>
<li>.kdelnk files are no longer supported, rename to .desktop.</li>
<li>deprecated header [KDE Desktop Entry], change to [Desktop Entry], using desktopGroup()</li>
<li>type FSDev is no longer supported, change to FSDevice</li>
</ul>
</li>
<li>Same as in KConfig: the use of readEntry() or writeEntry() on a KDesktopFile should
be replaced by readEntry/writeEntry on a KConfigGroup. By default the desktopGroup() of
the KDesktopFile was used, otherwise use group("another_group").</li>
</ul>
<h4>KExtendedSocket</h4>
<p>This class has been removed. See below on KNetwork::K*Socket.</p>
<h4>KFilterDev</h4>
<ul>
<li>device() -> createDevice() to indicate that you must delete the device afterwards.</li>
</ul>
<h4>KGlobal</h4>
<ul>
<li>"int kasciistricmp( const char *str1, const char *str2 )" has been moved into kascii.h</li>
<li>"KIconLoader* iconLoader()" has been moved to KIconLoader::global()</li>
<li>instance() renamed to mainComponent()</li>
<li>activeInstance() renamed to activeComponent()</li>
<li>setActiveInstance() renamed to setActiveComponent()</li>
<li>static members _locale, _instance and so on are private now, if you want to get or set the
KLocale use locale()/setLocale()/hasLocale() and if you want to know whether a mainComponent is set use
hasMainComponent()</li>
<li>config() returns a KSharedConfig::Ptr now instead of KConfig*</li>
<li>sharedConfig() has been removed in favour of config()</li>
</ul>
<h4>KIcon</h4>
<p>Deprecated and renamed to K3Icon; replacement is KIcon in kdeui.</p>
<p><b>Note:</b> at the moment you have to keep using K3Icon as a namespace for states, groups, and contexts though.</p>
<h4>KInstance</h4>
<p>Renamed to <a href="#kcomponentdata">KComponentData</a></p>
<h4>KIPC</h4>
<p>Removed. Use KGlobalSettings::self()->emitChange() instead of KIPC::sendMessageAll().</p>
<h4>KKey</h4>
<p>Removed. Use plain ints as the Qt key code instead.</p>
<ul>
<li>When replacing KKey(QKeyEvent*), you need to OR the event->key() and event->modifiers() to get the replacement.</li>
<li>The QtWIN enum has been removed. Use Qt::META or Qt::MetaModifier instead.</li>
<li>modFlagLabel() was removed, use either KKeyServer::modToStringUser(), or QKeySequence(Qt::yourmodifier).toString()</li>
</ul>
<h4>KKeyNative</h4>
<p>Removed. Use plain ints as the Qt key code instead.</p>
<h4>KKeySequence</h4>
<p>Removed. Use QKeySequence instead.
Note that QKeySequence expects multiple shortcuts to be separated by ", " (i.e. a comma then a space) in converting from text.</p>
<h4>KLibLoader</h4>
<ul>
<li>use KPluginLoader or KService::createInstance instead whenever possible</li>
<li>The resolve(const char* name) and symbol(const char* name) methods were merged and renamed to resolveSymbol</li>
<li>bool hasSymbol was removed, use resolveFunction instead</li>
<li>resolveFunction( const char* name ) was added which returns not a void* but a KLibrary::void_function_ptr which can be used as a void* would in boolean tests and for making subsequent function calls.</li>
</ul>
<h4>KLibFactory</h4>
<ul>
<li>renamed to KPluginFactory</li>
<li>create methods take a QVariantList instead of QStringList</li>
</ul>
<h4>KGenericFactory</h4>
<ul>
<li>use K_PLUGIN_FACTORY macro instead: this will require to change your plugin constructor from QStringList to QVariantList</li>
<li>instead of K_EXPORT_COMPONENT_FACTORY use K_EXPORT_PLUGIN (defined with KPluginLoader) which adds Qt and kdelibs version information that KPluginLoader uses to check the validity of the plugin.</li>
</ul>
<h4>KLocale</h4>
<ul>
<li> QString formatNumber(const QString &numStr) const -> QString formatNumber(const QString &numStr, bool round=true, int precision=2) const;</li>
<li> bool weekStartsMonday() const -> int weekStartDay() const</li>
<li> QString monthName(int i, bool shortName = false) const -> QString KCalendarSystem::monthName (int month, int year, bool shortName = false) const = 0; or QString KCalendarSystem::monthName (const QDate & date, bool shortName = false ) const = 0;</li>
<li> QString weekDayName(int i, bool shortName = false) const -> calendar()->weekDayName</li>
<li> QString monthNamePossessive(int i, bool shortName = false) const -> calendar()->monthNamePossessive()</li>
<li> void setWeekStartsMonday(bool start) -> setWeekStartDay</li>
<li> QString formatDate(const QDate&, bool shortFormat = false) const -> QString formatDate(const QDate&, DateFormat = LongDate) const</li>
<li> QString formatDateTime(const QDateTime&, bool shortFormat = true, bool includeSecs = false) const -> QString formatDateTime(const QDateTime&, DateFormat = ShortDate, bool includeSecs = false) const</li>
<li> languages() -> languageList()</li>
<li> formatMoney(const QString &numStr) -> QString formatMoney(double num, const QString & currency = QString::null, int digits = -1) const;</li>
<li> charset() -> gone</li>
<li> setCharset() -> gone</li>
<li>removeCatalogue was renamed to removeCatalog</li>
<li>QStringList languagesTwoAlpha() -> QStringList languageList()</li>
<li>QStringList allLanguagesTwoAlpha() -> QStringList allLanguagesList()</li>
<li>QStringList allCountriesTwoAlpha() -> QStringList allCountriesList()</li>
<li>QString twoAlphaToLanguageName(const QString &language) -> QString languageCodeToName(const QString &language)</li>
<li>QString twoAlphaToCountryName(const QString &country) -> QString countryCodeToName(const QString &country)</li>
</ul>
<p>See also <a href="#i18n">the I18N section below</a>.</p>
<h4>KMacroExpander</h4>
<ul>
<li>KMacroExpander now takes a QHash and not a QMap</li>
</ul>
<h4>KMimeSourceFactory</h4>
<p>KMimeSourceFactory was automatically instanciated by KApplication which allowed the use of "icon:name" in Qt richtext.
Q3MimeSourceFactory being in Qt3Support, and this feature being very rarely used, K3MimeSourceFactory isn't instanciated
automatically anymore, you need to call K3MimeSourceFactory::install() in your main if you still depend on this feature.</p>
<h4>KMultipleDrag</h4>
<p>KMultipleDrag is obsolete, use QMimeData directly to provide contents in different mime formats.</p>
<p>To make porting more incremental, K3MultipleDrag is provided for code that needs to work with
Q3DragObject until being fully ported.</p>
<h4>KNetwork::KIpAddress</h4>
<p>Removed. Use QHostAddress instead.</p>
<h4>KNetwork::KResolver</h4>
<p>Removed. If you need to resolve a hostname, use QHostInfo from QtNetwork.</p>
<h4>KNetwork::KSocketAddress and KNetwork::KInetSocketAddress</h4>
<p>Removed. Use QHostAddress and an integer (a quint16_t) to store the port number.</p>
<h4>KNetwork::KUnixSocketAddress</h4>
<p>Removed. Simply use a QString to represent the path or identifier. See the documentation on KLocalSocket.</p>
<h4>KNetwork::K*Socket</h4>
<ul>
<li>All of these classes are deprecated. Use the QTcpSocket,
QUdpSocket and QTcpServer equivalents from QtNetwork.</li>
<li>When porting, use KSocketFactory when creating any sockets that
are used to communicate with remote hosts (that is, anything that is
not "localhost"). Examples follow:<br>
<b>Connecting to a remote host:</b>
<p><em>Old code:</em></p>
<pre>
QString host;
int port;
KBufferedSocket *socket = new KBufferedSocket(parent);
if (!socket->connect(host, QString::number(port))) {
// error happened
// deal with it
}
connect(socket, SIGNAL(connected(KResolverEntry)), SLOT(socketConnected()));
connect(socket, SIGNAL(gotError(int)), SLOT(socketError(int)));
</pre>
<p>New code:</p>
<pre>
QString protocol;
QString host;
int port;
QUrl url(QString("%1://%2:%3").arg(prototocol, host).arg(port));
QTcpSocket *socket = KSocketFactory::connectToHost(protocol, host, port, parent);
// alternatively:
// QTcpSocket *socket = KSocketFactory::connectToHost(url, parent);
connect(socket, SIGNAL(connected()), SLOT(socketConnected()));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError), SLOT(QAbstractSocket::SocketError)));
</pre>
<b>Opening a socket for receiving remote connections:</b>
<p><em>Old code:</em></p>
<pre>
int port;
KServerSocket *ss = new KServerSocket(QString::number(port), parent);
connect(ss, SIGNAL(readyAccept()), this, SLOT(slotReadyAccept()));
connect(ss, SIGNAL(gotError(int)), this, SLOT(slotSocketError(int)));
ss->listen();
</pre>
<p>New code:</p>
<pre>
QString protocol;
int port;
QTcpServer *ts = KSocketFactory::listen(protocol, QHostAddress::Any, port, parent);
connect(ts, SIGNAL(newConnection()), this, SLOT(slotReadyAccept()));
</pre>
</li>
<li><b>Caveat:</b> all member functions in QTcpSocket
are <em>asynchronous</em> and buffered. There's no equivalent
"blocking" mode for QTcpSocket. If you need an action to complete,
you have to use <tt>waitForReadyRead</tt> and <tt>flush</tt>
(or <tt>waitForBytesWritten</tt>) in the socket object. If you need
to wait for a connection to be established,
use <tt>KSocketFactory::synchronousConnectToHost</tt>.</li>
</ul>
<h4>KNotifyClient</h4>
<p>Replaced by KNotification. The API is quite similar, but the config file need to be updated. See KNotification documentation, and the file kdelibs/knotify/PORTING.html</p>
<h4>KProcess</h4>
<p>The kde3 version was deprecated and renamed to K3Process, header is k3process.h.
Its usage is discouraged as it will create problems when being used together with
the new KProcess or QProcess in the same application, this is more of a problem in
applications that use KParts or plugins and can't control what those plugins do.</p>
<ul>
<li>start() lost all arguments, the setup of communication and program/arguments
has to be done before starting the process</li>
<li>suspend() and resume() where removed for now</li>
<li>quoting support moved to KShell namespace</li>
<li>getPid() was renamed to just pid()</li>
<li>clearArguments() was renamed to clearProgram()</li>
</ul>
<h4>KProcCtrl</h4>
<p>Deprecated and renamed to K3ProcessController, header is k3processcontroller.h.</p>
<h4>KProcIO</h4>
<p>Deprecated and renamed to K3ProcIO, header is k3procio.h.</p>
<h4>KRegExp</h4>
<p>Removed. Use QRegExp instead.</p>
<h4>KRFCDate</h4>
This class has been deprecated by KDateTime. It has been renamed K3RFCDate and moved to the libkde3support. The following method changes make porting easy:
<ul>
<li>KRFCDate::parseDate( string ) becomes KDateTime::fromString( string, KDateTime::RFCDate).toTime_t();</li>
<li>KRFCDate::parseDateISO8601( string ) becomes KDateTime::fromString( string ).toTime_t();</li>
<li>KRFCDate::localUTCOffset() becomes KDateTime::Spec::LocalZone().utcOffset / 60. Note that the KRFCDate version returned minutes while KDateTime returns seconds.</li>
</ul>
<h4>KSaveFile</h4>
<ul>
<li>KSaveFile has been modified from its KDE 3.x behavior to allow for new backup methods:
<ul>
<li>KSaveFile::backupFile() will use the backup behavior specified in KConfig.</li>
<li>KSaveFile::simpleBackupFile() will emulate the KDE 3.x behavior</li>
<li>KSaveFile::numberedBackupFile() will create a numbered set of backup files (default: 10)</li>
<li>KSaveFile::rcsBackupFile() will use rcs to maintain the backup file</li>
</ul></li>
<li>KSaveFile now derives from QFile so you can use it just like you would use a normal QFile. The close() function has been renamed to finalize(). Use the error() and errorString() functions to check for errors instead of status().</li>
<li>KSaveFile::close() is now KSaveFile::finalize()</li>
<li>You must call KSaveFile::open() to create the file.</li>
</ul>
<h4>KShortcutDialog</h4>
<p>Removed, see KKeySequenceWidget/KShortcutWidget.</p>
<h4>KShortcutList and derivatives</h4>
<p>Removed - no longer needed. Saving and loading of shortcuts is now performed in KActionCollection, KGlobalAccel, and KStandardShortcut.</p>
<h4>KSortableValueList</h4>
<ul>
<li>Has been ported to QList, renamed to KSortableList and the header is ksortablelist.h</li>
</ul>
<h4>KStandardDirs</h4>
<ul>
<li>boolean values as parameters for recursive, unique and checking for executability in the following methods were changed to instead take SearchOptions flags for improved code readability:
<ul>
<li>calcResourceHash</li>
<li>findAllResources</li>
<li>findResource</li>
<li>findExe</li>
<li>findAllExe</li>
</ul>
</li>
</ul>
<h4><a name="KStandardShortcut">KStandardShortcut</a> (was KStdAccel)</h4>
<ul>
<li>Removed deprecated methods</li>
<li>Removed WhatThis, use WhatsThis</li>
<li>shortcutDefault3() and shortcutDefault4() have been removed, use shortcutDefault() instead</li>
</ul>
<h4>KStaticDeleter</h4>
<p>Either use K3StaticDeleter or port to the <a href="http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/group__KDEMacros.html#ga75ca0c60b03dc5e4f9427263bf4043c7">K_GLOBAL_STATIC</a> macro.
<h4>KStdAccel</h4>
<p>Renamed to <a href="#KStandardShortcut">KStandardShortcut</a></p>
<h4>KStringHandler</h4>
<ul>
<li>static QString ljust( const QString &text , int width ) -> QString::leftJustified</li>
<li>static QString rjust( const QString &text , int width ) -> QString::rightJustified</li>
<li>matchFilename -> matchFileName</li>
<li>static QString word( const QString &text , int pos ) -> QString::section </li>
<li>::randomString() has been moved to KRandom::randomString()</li>
<li>::lPixelSqueeze( text, fm, width ) -> fm.elidedText( text, Qt::ElideLeft, width )</li>
<li>::cPixelSqueeze( text, fm, width ) -> fm.elidedText( text, Qt::ElideMiddle, width )</li>
<li>::rPixelSqueeze( text, fm, width ) -> fm.elidedText( text, Qt::ElideRight, width )</li>
</ul>
<h4>KTempDir</h4>
<ul>
<li>existing() was removed, use exists() instead</li>
<li>setAutoDelete() renamed to setAutoRemove()</li>
<li>The default for setAutoRemove() is now true instead of false</li>
<li>qDir() was removed as it was unused</li>
</ul>
<h4>KTempFile</h4>
<p>Deprecated and renamed to K3TempFile. Use KTemporaryFile instead.</p>
<p>When porting old KTempFile calls to KTemporaryFile, you need to remember that KTempFile by default will not automatically remove the fileonce the object is destroyed, but KTemporaryFile will! You also need to call open() in order to actually create the file.</p>
<h4>KURL</h4>
<ul>
<li>Renamed to KUrl, but a typedef is available for source compatibility</li>
<li>KUrl inherits QUrl now, but the API offered by KUrl is mostly unchanged</li>
<li>filename() has been removed, use fileName() instead</li>
<li>isMalformed -> !isValid()</li>
<li>prettyURL(0,KUrl::StripFileProtocol) -> pathOrURL()</li>
<li>fromPathOrURL() is deprecated, use the KUrl(str) constructor which now accepts both paths and urls</li>
<li>htmlURL() had to be removed, please use Qt::escape(url.prettyUrl()) now, with #include <QTextDocument>.
This requires libQtGui, which is why it can't be in KUrl anymore.</li>
<li>url(0,106) or any other use of the 'mib enum' for encoding has been removed. QUrl is UTF8 based, and the world is becoming more and more utf8 based as well, the old encoding hacks inside urls should disappear.</li>
<li>Runtime behavior change: port() used to return 0 if no port was specified. It now returns -1 in that case, or you can use port(defaultPort) to set what it should return if no port was specified.</li>
<li>adjustPath(), path(), encodedPathAndQuery() , url() , prettyUrl() was taking a int argument for handling trailing slash that has been replaced by an enum AdjustPathOption (0 => KUrl::LeaveTrailingSlash, 1 => KUrl::AddTrailingSlash, -1 => KUrl::RemoveTrailingSlash).
<li>cleanPath(), queryItems(), fileName(), directory(), equals() now take a QFlags argument instead of boolean</li>
<li>*URL* renamed to *Url*:
<ul>
<li>hasSubURL() -> hasSubUrl()</li>
<li>prettyURL() -> prettyUrl()</li>
<li>pathOrURL() -> pathOrUrl()</li>
<li>upURL() -> upUrl()</li>
<li>isRelativeURL() -> isRelativeUrl()</li>
<li>relativeURL() -> relativeUrl()</li>
</ul>
</li>
</ul>
<h4>KURLDrag</h4>
<p>This class has been moved to kde3support. Use KUrl::populateMimeData() and
KUrl::List::populateMimeData() in the drag/copy side,
and the static methods KUrl::List::canDecode() and KUrl::List::fromMimeData()
in the drop/paste side.</p>
<ul>
<li>Example: Replace <pre> KURL::List uriList;
if ( KURLDrag::canDecode(e) && KURLDrag::decode( e, uriList ) ) {</pre>
by <pre> KUrl::List uriList = KUrl::List::fromMimeData( e->mimeData() );
if ( !uriList.isEmpty() ) {</pre></li>
</ul>
<h4>KVMAllocator</h4>
<p>Removed, as it was unused.</p>
<h4>KWin</h4>
This class has been merged with KWinModule into class KWindowSystem (in kdeui).
<ul>
<li>appStarted() removed, use KStartupInfo::appStarted() instead</li>
<li>info(WId win) removed, use windowInfo() instead</li>
<li>struct Info was removed, use WindowInfo instead</li>
</ul>
<h4>KWinModule</h4>
This class has been merged with KWinModule into class KWindowSystem (in kdeui).
Don't create instances, use static functions and KWindowSystem::self() for connecting to signals.
<ul>
<li>Functions related to systemtray have been removed. They worked only with the obsolete
KDE systray mechanism.</li>
<li>stackingOrder() no longer returns a reference to a list. Make a copy of the value first if using iterators.</li>
</ul>
<h4>KWin::WindowInfo</h4>
This class has been renamed KWindowInfo and moved to its own header: KWindowInfo or kwindowinfo.h. This class is not to be confused with KWindowInfo in KDE3 which was a small utility class to display message in the window icon and title. KWindowInfo represents the windowing system information for a give window, such as its geometry, desktop positioning, type, name, etc.
<h4>locate</h4>
<ul>
<li>locate() and locateLocal() moved into the namespace KStandardDirs</li>
</ul>
<h4>NETRootInfo</h4>
<ul>
<li>NETRootInfo(Display *display, Window supportWindow, const char *wmName,unsigned long properties, int screen = -1, bool doActivate = true) ->
NETRootInfo(Display *display, Window supportWindow, const char *wmName,
const unsigned long properties[], int properties_size,
int screen = -1, bool doActivate = true); old properties is the first element of the new array
</li>
<li>unsigned long supported() -> const unsigned long* supportedProperties() const;</li>
<li> unsigned long properties() const -> gone</li>
<li> WindowType windowType() -> WindowType windowType( unsigned long supported_types ) const;</li>
</ul>
<h4 align="right"><a href="#TOC">Return to the Table of Contents</a></h4>
<h3><a name="kdeui">Changes in kdeui</a></h3>
<ul>
<li>kactionclasses.h went away, use the several kxxxaction.h instead</li>
<li>kanimwidget.h was renamed to kanimatedbutton.h to reflect the class name</li>
<li>kcolordlg.h went away, use kcolordialog.h</li>
<li>kcolorbtn.h went away, use kcolorbutton.h</li>
<li>kdatapik.h went away, use kdatepicker.h</li>
<li>kdualcolorbtn.h went away, use kdualcolorbutton.h</li>
<li>KLanguageButton (and therefore klanguagebutton.h) was removed due to licensing issues (GPLv2, which is not allowed in kdelibs)</li>
<li>klistbox.h was renamed to klistwidget.h to reflect the class name</li>
<li>kpassdlg.h went away, use kpassworddialog.h</li>
<li>kxmlgui.h went away, use kxmlguifactory.h</li>
<li>kfontcombo.h went away, use QFontComboBox</li>
<li>libkwalletclient (which used to provide the KWallet class) has been merged with kdeui</li>
<li>system color scheme accessors in kglobalsettings.h are deprecated, use kcolorscheme.h</li>
<li>KPalette was renamed to KColorCollection</li>
<li>KPaletteTable was renamed to KColorTable and moved to private API</li>
</ul>
<h4>KAboutContainer</h4>
<p>Deprecated and renamed to K3AboutContainer. Use KAboutApplicationDialog or KAboutKdeDialog directly.</p>
<ul>
<li>KAboutContainer constructor int args have been replaced by Qt::Alignment</li>
<li>addTitle int args replaced by Qt::Alignment</li>
<li>addImage int args replaced by Qt::Alignment</li>
</ul>
<h4>KAboutContributor</h4>
<p>Deprecated and renamed to K3AboutContributor. Use KAboutApplicationDialog or KAboutKdeDialog directly.</p>
<ul>
<li>void setURL( const QString& ) -> void setUrl( const QString& )</li>
<li>QString getName( void ) const -> QString name() const</li>
<li>QString getEmail( void ) const -> QString email() const</li>
<li>QString getURL( void ) const -> QString url() const</li>
<li>QString getWork( void ) const -> QString work() const</li>
<li>signal void openURL() -> void openUrl()</li>
</ul>
<h4>KAboutDialog</h4>
<p>Deprecated and renamed to K3AboutDialog. Use KAboutApplicationDialog or KAboutKdeDialog directly.</p>
<ul>
<li>changed enum names<br>
<pre>
AbtPlain -> Plain
AbtTabbed -> Tabbed
AbtTitle -> Title
AbtImageLeft -> ImageLeft
AbtImageRight -> ImageRight
AbtImageOnly -> ImageOnly
AbtProduct -> Product
AbtKDEStandard -> KDEStandard
AbtAppStandard -> AppStandard
AbtImageAndTitle -> ImageAndTitle
</pre>
</li>
<li>Constructor: K3AboutDialog( QWidget *parent = 0, bool modal = true ) -> KAboutDialog( QWidget *parent = 0 )</li>
<li>Constructor: K3AboutDialog( int dialogLayout, const QString &caption, ButtonCodes buttonMask,
ButtonCode defaultButton, QWidget *parent=0, bool modal=false, bool separator = false,
const QString &user1 = QString(),
const QString &user2 = QString(),
const QString &user3 = QString() ) ->
K3AboutDialog( int dialogLayout, const QString &caption, QWidget *parent = 0 ) (see KDialog how to port)</li>
<li>void setIcon( const QString &fileName ) which was deprecated has been removed</li>
<li>addContainerPage int args are now Qt::Alignment args</li>
<li>addScrolledContainerPage int args are now Qt::Alignment args</li>
<li>addContainer int args are now Qt::Alignment args</li>
<li>signal void openURL() -> void openUrl()</li>
<li>void imageURL() -> void imageUrl()</li>
<li>void openURLSlot() -> void openUrlSlot()</li>
</ul>
<h4>KAboutWidget</h4>
<p>Deprecated and renamed to K3AboutWidget. Use KAboutApplicationDialog or KAboutKdeDialog directly.</p>
<ul>
<li>signal void openURL() -> void openUrl()</li>
<li>void openURLSlot() -> void openUrlSlot()</li>
</ul>
<h4><a name="KAction">KAction</a></h4>
<p>Making KAction a subclass of QAction (actually QWidgetAction) brings KDE more into line with the Qt way of creating user interfaces, improves accessibility, and removes code duplication.</p>
<p>QAction in Qt4 is a true first-class citizen - all QWidgets now have a list of associated actions, and QToolBar, QMenu etc. all use this list directly to show the graphical items (widgets, entries in the menu, etc). This has replaced all usage of integers as "id"s. There is also a new QEvent (QActionEvent), and the corresponding virtual protected function in QWidget, actionEvent().</p>
<ul>
<li>KAction is now a subclass of QWidgetAction.</li>
<li>For actions that are mostly in menus, you should port setToolTip to setStatusTip. The goal in kde3 was mostly to see the help text in the status bar, while in Qt4 setToolTip has no effect on menu items.<li>
<li>Don't use setIconSet() anymore, use setIcon(KIcon(iconName)) instead</li>
<li>activated(), activated(int) signals deprecated - use triggered() signal instead</li>
<li>activate() is now trigger(), as in QAction</li>
<li>there is a replacement for activation providing keyboard + mouse states, see triggered(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) [currently buggy]</li>
<li>plugAccel(), unplugAccel(), kaccelCount() removed - they have no use now (accelerator management is inside Qt)</li>
<li>itemId(), getToolButtonID() removed - actions no longer have ids, basically the QAction* is its replacement</li>
<li>setGroup() / group() removed - use QActionGroup instead (setActionGroup() / actionGroup())</li>
<li>ActivationReason has been removed (not supported by Qt). For a surrogate, you can connect to QMenu::triggered(QAction*), QToolBar::actionTriggered(QAction*), etc.</li>
<li>setters are no longer slots; where they were used as such, an intermediary will be required</li>
<li>New feature from Qt: statusTip() / setStatusTip(). Usually this will be the same as the tooltip. It appears in the status bar whenever the action is hovered in a QMenu. A porting convenience is being investigated for automatic toolTip() -> statusTip(), but the best solution is to set both.</li>
<li>New feature: globalShortcut() and globalShortcutAllowed(). Automatically communicates with KGlobalAccel to register a global shortcut (i.e. one that does not need the application to have focus to be activated).</li>
<li>setShortcut() now defaults to setting the default shortcut as well (as it was by far the most common use case). To just set the custom shortcut, use setShortcut(myShortcut, KAction::CustomShortcut)</li>
<li>Renamed "Custom" shortcuts to "Active" shortcuts.</li>
<li>Added setShortcut(QKeySequence &) to explicitly override QAction::setShortcut.</li>
<li>Functions in KActionCollection or KXMLGUIFactory for example don't take or return KAction pointers
anymore but instead operate on QAction pointers. If you get compilation errors with code like the
following then just replace KAction with QAction:
<pre>
QAction *a = actionCollection()->action("foo");
...
</pre>
Also if you get errors about KAction being an unknown type it is often enough to forward declare
KAction in your header file.
<li>plug() -> QWidget::addAction()
<li>unplug() -> QWidget::removeAction()
<li>isPlugged() -> !action->associatedWidgets().isEmpty()
<li>containerCount() -> action->associatedWidgets().count()
<li>container(int i) -> action->associatedWidgets().value(i)
<li>hasIcon() -> !action->icon().isNull()
<li>setIconName(string) -> setIcon(KIcon(string))
<li>unplugAll() -> Rarely needed, but if you are sure that you need it replace it with the following
code:
<pre>
foreach (QWidget *w, action->associatedWidgets())
w->removeAction(action);
</pre>
<li>The KAction constructors changed completely. The constructors taking various action properties,
a pointer to an acion collection and the name of the action have been removed. The new pattern is to
create the actions like regular QObjects with a parent (owner). Then you set various properties using
setText, setIcon, etc. . As a last step the action can be added to the action collection with a name.
<pre>
KAction *a = new KAction(this);
a->setText(i18n("I am ported"));
a->setIcon(KIcon("shiny"));
a->setShortcut(Qt::ControlModifier + Qt::Key_A);
actionCollection - > addAction("name_of_the_action", a);
</pre>
KActionCollection additional provides convenience overloads for creating named KAction objects or
standard actions (KStandardAction). For example:
<pre>
QAction *a = actionCollection -> addAction("action_name");
a->setText(i18n("I have been ported, too"));
connect(a, SIGNAL(triggered()), this, SLOT(portedToKde4()));
actionCollection -> addAction(KStandardAction::Copy, this, SLOT(copy()))
</pre>
</ul>
<h4>KActionCollection</h4>
<ul>
<li>constructor (QWidget* watch, ..) and setWidget() replaced by associateWidget() - allows actions to respond to matching key presses on a widget level (basically a convenience method to have all actions in the collection added to the associated widget(s) and their shortcut scopes set to Qt::WidgetShortcut). (note: associateWidget() replaces {set|add|remove}AssociatedWidget() from kde4 beta)</li>
<li>*AutoConnectShortcuts removed - irrelevant</li>
<li>*accel() removed - irrelevant (KAccel no longer handles key presses)</li>
<li>New functions setConfigGroup(), setConfigGlobal(), configGroup(), configIsGlobal() - the action collection now stores the group whether the config is global. referenced in readSettings() / writeSettings()</li>
<li>readShortcutSettings() and writeShortcutSettings() renamed without the "Shortcut". Set the configGroup() with setConfigGroup() either prior to each call, or (preferably) at the creation time of the action collection.</li>
<li>{set}HighlightingEnabled(), {connect|disconnect}Highlight() removed - highlighting is always enabled now</li>
<li>actionHighlighted(), actionStatusText(), clearStatusText() removed - use QAction::setStatusTip() as a replacement. QStatusBars belonging to QMainWindow automatically get the statusTip() applied to them when they are moused over in a QMenu, via a QStatusTipEvent.</li>
<li>groups() removed (now using QActionGroups) - see actionGroups() (and actionsWithoutGroup()) for replacement</li>
<li>actions( const QString& group ) removed - use actionGroups() instead, and then QActionGroup::actions()</li>
<li>action(const char* name, const char* className) removed: action(const QString& name), actions(const QString& name), actionOfType<Class>(const QString& name), actionsOfType<Class>(const QString& name) are the replacements</li>
<li>insert(KAction *) -> addAction(const QString &name, QAction *action)
<li>remove(KAction *) -> removeAction(QAction *action)
<li>take(KAction *) -> takeAction(QAction *action)
</ul>
<h4>KActionSelector</h4>
<ul>
<li>Q3ListBox -> QListWidget</li>
<li>selectedListBox -> selectedListWidget</li>
<li>availableListBox -> availableListWidget</li>
</ul>
<h4>KActionSeparator</h4>
<p>Used to be renamed to KSeparatorAction. KSeparatorAction/KActionSeparator is dead now. Just create a QAction object and call setSeparator(true); on it.</p>
<p><b>Note:</b> you need to create multiple separator actions if you want to insert multiple separators into a widget, unlike with KDE3.</p>
<h4>KActiveLabel</h4>
<p>Deprecated and renamed to K3ActiveLabel. Use QLabel instead.</p>
<ul>
<li>Use QLabel::setOpenExternalLinks(true) for labels with hyperlinks.</li>
<li>Use QLabel::setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard) for labels whose text should be selectable by user.</li>
<li>Inherits from KTextBrowser instead of Q3TextBrowser</li>
<li>You don't need anymore to disconnect the linkClicked signal to handle manually link, use KTextBrowser::setNotifyClick(true)</li>
<li>linkClicked -> KTextBrowser::urlClick</li>
</ul>
<h4><a name="KAnimatedButton">KAnimatedButton</a> (was KAnimWidget)</h4>
<ul>
<li>Now a subclass of QToolButton, acts in a much more standard fashion</li>
<li>size(), setSize() replaced by iconSize(), setIconSize()</li>
<li>Call updateIcons() whenever you change the iconSize() (the setter is non-virtual :( )</li>
</ul>
<h4>KAnimWidget</h4>