summaryrefslogtreecommitdiffstats
path: root/kommander/editor
diff options
context:
space:
mode:
Diffstat (limited to 'kommander/editor')
-rw-r--r--kommander/editor/Makefile.am53
-rw-r--r--kommander/editor/actiondnd.cpp1244
-rw-r--r--kommander/editor/actiondnd.h304
-rw-r--r--kommander/editor/actioneditor.ui201
-rw-r--r--kommander/editor/actioneditorimpl.cpp261
-rw-r--r--kommander/editor/actioneditorimpl.h64
-rw-r--r--kommander/editor/actionlistview.cpp111
-rw-r--r--kommander/editor/actionlistview.h75
-rw-r--r--kommander/editor/asciivalidator.cpp77
-rw-r--r--kommander/editor/asciivalidator.h46
-rw-r--r--kommander/editor/assistproc.cpp74
-rw-r--r--kommander/editor/assistproc.h47
-rw-r--r--kommander/editor/assoctexteditor.ui222
-rw-r--r--kommander/editor/assoctexteditorimpl.cpp506
-rw-r--r--kommander/editor/assoctexteditorimpl.h133
-rw-r--r--kommander/editor/choosewidget.ui150
-rw-r--r--kommander/editor/choosewidgetimpl.cpp128
-rw-r--r--kommander/editor/choosewidgetimpl.h45
-rw-r--r--kommander/editor/command.cpp1838
-rw-r--r--kommander/editor/command.h931
-rw-r--r--kommander/editor/connectioneditor.ui418
-rw-r--r--kommander/editor/connectioneditorimpl.cpp373
-rw-r--r--kommander/editor/connectioneditorimpl.h76
-rw-r--r--kommander/editor/createtemplate.ui222
-rw-r--r--kommander/editor/defs.cpp78
-rw-r--r--kommander/editor/defs.h35
-rw-r--r--kommander/editor/filechooser.cpp63
-rw-r--r--kommander/editor/filechooser.h42
-rw-r--r--kommander/editor/formfile.cpp302
-rw-r--r--kommander/editor/formfile.h74
-rw-r--r--kommander/editor/formsettings.ui338
-rw-r--r--kommander/editor/formsettingsimpl.cpp58
-rw-r--r--kommander/editor/formsettingsimpl.h43
-rw-r--r--kommander/editor/formwindow.cpp2609
-rw-r--r--kommander/editor/formwindow.h292
-rw-r--r--kommander/editor/functions.ui722
-rw-r--r--kommander/editor/functionsimpl.cpp392
-rw-r--r--kommander/editor/functionsimpl.h61
-rw-r--r--kommander/editor/globaldefs.h45
-rw-r--r--kommander/editor/hierarchyview.cpp724
-rw-r--r--kommander/editor/hierarchyview.h161
-rw-r--r--kommander/editor/iconvieweditor.ui450
-rw-r--r--kommander/editor/iconvieweditorimpl.cpp158
-rw-r--r--kommander/editor/iconvieweditorimpl.h52
-rw-r--r--kommander/editor/kmdr-editor.desktop129
-rw-r--r--kommander/editor/kommander-new.xml587
-rw-r--r--kommander/editor/kommander.xml998
-rw-r--r--kommander/editor/kommanderui.rc5
-rw-r--r--kommander/editor/layout.cpp956
-rw-r--r--kommander/editor/layout.h180
-rw-r--r--kommander/editor/listboxeditor.ui455
-rw-r--r--kommander/editor/listboxeditorimpl.cpp216
-rw-r--r--kommander/editor/listboxeditorimpl.h55
-rw-r--r--kommander/editor/listeditor.ui147
-rw-r--r--kommander/editor/listvieweditor.ui936
-rw-r--r--kommander/editor/listvieweditorimpl.cpp585
-rw-r--r--kommander/editor/listvieweditorimpl.h94
-rw-r--r--kommander/editor/main.cpp81
-rw-r--r--kommander/editor/mainwindow.cpp1903
-rw-r--r--kommander/editor/mainwindow.h317
-rw-r--r--kommander/editor/mainwindowactions.cpp1201
-rw-r--r--kommander/editor/messagelog.cpp149
-rw-r--r--kommander/editor/messagelog.h55
-rw-r--r--kommander/editor/metadatabase.cpp1219
-rw-r--r--kommander/editor/metadatabase.h222
-rw-r--r--kommander/editor/multilineeditor.ui225
-rw-r--r--kommander/editor/multilineeditorimpl.cpp98
-rw-r--r--kommander/editor/multilineeditorimpl.h61
-rw-r--r--kommander/editor/newform.ui210
-rw-r--r--kommander/editor/newformimpl.cpp202
-rw-r--r--kommander/editor/newformimpl.h73
-rw-r--r--kommander/editor/orderindicator.cpp107
-rw-r--r--kommander/editor/orderindicator.h52
-rw-r--r--kommander/editor/paletteeditor.ui518
-rw-r--r--kommander/editor/paletteeditoradvanced.ui766
-rw-r--r--kommander/editor/paletteeditoradvancedimpl.cpp638
-rw-r--r--kommander/editor/paletteeditoradvancedimpl.h90
-rw-r--r--kommander/editor/paletteeditorimpl.cpp299
-rw-r--r--kommander/editor/paletteeditorimpl.h70
-rw-r--r--kommander/editor/parser.cpp66
-rw-r--r--kommander/editor/parser.h33
-rw-r--r--kommander/editor/pics/Makefile.am5
-rw-r--r--kommander/editor/pics/arrow.xbm10
-rw-r--r--kommander/editor/pics/background.pngbin0 -> 15068 bytes
-rw-r--r--kommander/editor/pics/cross.xbm10
-rw-r--r--kommander/editor/pics/hand.xbm10
-rw-r--r--kommander/editor/pics/hsplit.xbm10
-rw-r--r--kommander/editor/pics/ibeam.xbm10
-rw-r--r--kommander/editor/pics/images.h10979
-rw-r--r--kommander/editor/pics/kfontcombo.pngbin0 -> 1194 bytes
-rw-r--r--kommander/editor/pics/kommandersplash.pngbin0 -> 242008 bytes
-rw-r--r--kommander/editor/pics/large/adjustsize.xpm187
-rw-r--r--kommander/editor/pics/large/buttongroup.xpm79
-rw-r--r--kommander/editor/pics/large/checkbox.xpm67
-rw-r--r--kommander/editor/pics/large/combobox.xpm192
-rw-r--r--kommander/editor/pics/large/connecttool.xpm187
-rw-r--r--kommander/editor/pics/large/customwidget.xpm41
-rw-r--r--kommander/editor/pics/large/datepicker.xpm121
-rw-r--r--kommander/editor/pics/large/dial.xpm51
-rw-r--r--kommander/editor/pics/large/disabled/adjustsize.xpm51
-rw-r--r--kommander/editor/pics/large/disabled/connecttool.xpm57
-rw-r--r--kommander/editor/pics/large/disabled/editbreaklayout.xpm54
-rw-r--r--kommander/editor/pics/large/disabled/editcopy.xpm69
-rw-r--r--kommander/editor/pics/large/disabled/editgrid.xpm49
-rw-r--r--kommander/editor/pics/large/disabled/editpaste.xpm69
-rw-r--r--kommander/editor/pics/large/disabled/editslots.xpm65
-rw-r--r--kommander/editor/pics/large/disabled/editvlayout.xpm55
-rw-r--r--kommander/editor/pics/large/disabled/layout.xpm52
-rw-r--r--kommander/editor/pics/large/disabled/left.xpm59
-rw-r--r--kommander/editor/pics/large/disabled/redo.xpm52
-rw-r--r--kommander/editor/pics/large/disabled/right.xpm57
-rw-r--r--kommander/editor/pics/large/disabled/undo.xpm52
-rw-r--r--kommander/editor/pics/large/editbreaklayout.xpm250
-rw-r--r--kommander/editor/pics/large/editcopy.xpm43
-rw-r--r--kommander/editor/pics/large/editcut.xpm42
-rw-r--r--kommander/editor/pics/large/editdelete.xpm226
-rw-r--r--kommander/editor/pics/large/editgrid.xpm206
-rw-r--r--kommander/editor/pics/large/edithlayout.xpm103
-rw-r--r--kommander/editor/pics/large/editlower.xpm144
-rw-r--r--kommander/editor/pics/large/editpaste.xpm46
-rw-r--r--kommander/editor/pics/large/editraise.xpm149
-rw-r--r--kommander/editor/pics/large/editslots.xpm264
-rw-r--r--kommander/editor/pics/large/editvlayout.xpm89
-rw-r--r--kommander/editor/pics/large/filenew.xpm42
-rw-r--r--kommander/editor/pics/large/fileopen.xpm44
-rw-r--r--kommander/editor/pics/large/filesave.xpm42
-rw-r--r--kommander/editor/pics/large/form.xpm91
-rw-r--r--kommander/editor/pics/large/frame.xpm58
-rw-r--r--kommander/editor/pics/large/groupbox.xpm60
-rw-r--r--kommander/editor/pics/large/help.xpm182
-rw-r--r--kommander/editor/pics/large/home.xpm250
-rw-r--r--kommander/editor/pics/large/iconview.xpm142
-rw-r--r--kommander/editor/pics/large/image.xpm267
-rw-r--r--kommander/editor/pics/large/label.xpm105
-rw-r--r--kommander/editor/pics/large/layout.xpm167
-rw-r--r--kommander/editor/pics/large/lcdnumber.xpm154
-rw-r--r--kommander/editor/pics/large/left.xpm181
-rw-r--r--kommander/editor/pics/large/line.xpm45
-rw-r--r--kommander/editor/pics/large/lineedit.xpm135
-rw-r--r--kommander/editor/pics/large/listbox.xpm121
-rw-r--r--kommander/editor/pics/large/listview.xpm148
-rw-r--r--kommander/editor/pics/large/multilineedit.xpm108
-rw-r--r--kommander/editor/pics/large/newform.xpm35
-rw-r--r--kommander/editor/pics/large/ordertool.xpm157
-rw-r--r--kommander/editor/pics/large/pixlabel.xpm204
-rw-r--r--kommander/editor/pics/large/pointer.xpm27
-rw-r--r--kommander/editor/pics/large/print.xpm155
-rw-r--r--kommander/editor/pics/large/progress.xpm145
-rw-r--r--kommander/editor/pics/large/project.xpm50
-rw-r--r--kommander/editor/pics/large/pushbutton.xpm72
-rw-r--r--kommander/editor/pics/large/radiobutton.xpm67
-rw-r--r--kommander/editor/pics/large/redo.xpm42
-rw-r--r--kommander/editor/pics/large/right.xpm181
-rw-r--r--kommander/editor/pics/large/slider.xpm133
-rw-r--r--kommander/editor/pics/large/spacer.xpm248
-rw-r--r--kommander/editor/pics/large/spinbox.xpm102
-rw-r--r--kommander/editor/pics/large/table.xpm69
-rw-r--r--kommander/editor/pics/large/tabwidget.xpm94
-rw-r--r--kommander/editor/pics/large/textbrowser.xpm196
-rw-r--r--kommander/editor/pics/large/textview.xpm103
-rw-r--r--kommander/editor/pics/large/toolbutton.xpm123
-rw-r--r--kommander/editor/pics/large/undo.xpm42
-rw-r--r--kommander/editor/pics/mini/down.xpm71
-rw-r--r--kommander/editor/pics/mini/form.xpm27
-rw-r--r--kommander/editor/pics/mini/image.xpm28
-rw-r--r--kommander/editor/pics/mini/left.xpm69
-rw-r--r--kommander/editor/pics/mini/resetproperty.xpm13
-rw-r--r--kommander/editor/pics/mini/right.xpm77
-rw-r--r--kommander/editor/pics/mini/up.xpm68
-rw-r--r--kommander/editor/pics/mkimages3
-rw-r--r--kommander/editor/pics/mkpics2
-rw-r--r--kommander/editor/pics/no.xbm10
-rw-r--r--kommander/editor/pics/qtlogo.pngbin0 -> 12615 bytes
-rw-r--r--kommander/editor/pics/sizeall.xbm10
-rw-r--r--kommander/editor/pics/sizeb.xbm10
-rw-r--r--kommander/editor/pics/sizef.xbm10
-rw-r--r--kommander/editor/pics/sizeh.xbm10
-rw-r--r--kommander/editor/pics/sizev.xbm10
-rw-r--r--kommander/editor/pics/small/adjustsize.pngbin0 -> 495 bytes
-rw-r--r--kommander/editor/pics/small/book.xpm32
-rw-r--r--kommander/editor/pics/small/buttongroup.pngbin0 -> 648 bytes
-rw-r--r--kommander/editor/pics/small/checkbox.pngbin0 -> 817 bytes
-rw-r--r--kommander/editor/pics/small/closebutton.pngbin0 -> 585 bytes
-rw-r--r--kommander/editor/pics/small/combobox.pngbin0 -> 549 bytes
-rw-r--r--kommander/editor/pics/small/connecttool.pngbin0 -> 553 bytes
-rw-r--r--kommander/editor/pics/small/customwidget.pngbin0 -> 1133 bytes
-rw-r--r--kommander/editor/pics/small/databrowser.xpm156
-rw-r--r--kommander/editor/pics/small/datatable.xpm156
-rw-r--r--kommander/editor/pics/small/dataview.xpm156
-rw-r--r--kommander/editor/pics/small/dateedit.pngbin0 -> 505 bytes
-rw-r--r--kommander/editor/pics/small/datepicker.pngbin0 -> 965 bytes
-rw-r--r--kommander/editor/pics/small/datetimeedit.pngbin0 -> 1074 bytes
-rw-r--r--kommander/editor/pics/small/dial.pngbin0 -> 1024 bytes
-rw-r--r--kommander/editor/pics/small/disabled/adjustsize.pngbin0 -> 659 bytes
-rw-r--r--kommander/editor/pics/small/disabled/connecttool.pngbin0 -> 836 bytes
-rw-r--r--kommander/editor/pics/small/disabled/editbreaklayout.pngbin0 -> 1126 bytes
-rw-r--r--kommander/editor/pics/small/disabled/editcopy.pngbin0 -> 931 bytes
-rw-r--r--kommander/editor/pics/small/disabled/editcut.xpm32
-rw-r--r--kommander/editor/pics/small/disabled/editgrid.pngbin0 -> 735 bytes
-rw-r--r--kommander/editor/pics/small/disabled/edithlayout.pngbin0 -> 601 bytes
-rw-r--r--kommander/editor/pics/small/disabled/edithlayoutsplit.pngbin0 -> 754 bytes
-rw-r--r--kommander/editor/pics/small/disabled/editpaste.pngbin0 -> 901 bytes
-rw-r--r--kommander/editor/pics/small/disabled/editslots.xpm44
-rw-r--r--kommander/editor/pics/small/disabled/editvlayout.pngbin0 -> 617 bytes
-rw-r--r--kommander/editor/pics/small/disabled/editvlayoutsplit.pngbin0 -> 752 bytes
-rw-r--r--kommander/editor/pics/small/disabled/filesave.pngbin0 -> 587 bytes
-rw-r--r--kommander/editor/pics/small/disabled/layout.xpm42
-rw-r--r--kommander/editor/pics/small/disabled/left.xpm32
-rw-r--r--kommander/editor/pics/small/disabled/redo.pngbin0 -> 531 bytes
-rw-r--r--kommander/editor/pics/small/disabled/right.xpm32
-rw-r--r--kommander/editor/pics/small/disabled/searchfind.pngbin0 -> 1013 bytes
-rw-r--r--kommander/editor/pics/small/disabled/undo.pngbin0 -> 541 bytes
-rw-r--r--kommander/editor/pics/small/editbreaklayout.pngbin0 -> 744 bytes
-rw-r--r--kommander/editor/pics/small/editcopy.pngbin0 -> 485 bytes
-rw-r--r--kommander/editor/pics/small/editcut.pngbin0 -> 649 bytes
-rw-r--r--kommander/editor/pics/small/editdelete.xpm226
-rw-r--r--kommander/editor/pics/small/editgrid.pngbin0 -> 520 bytes
-rw-r--r--kommander/editor/pics/small/edithlayout.pngbin0 -> 706 bytes
-rw-r--r--kommander/editor/pics/small/edithlayoutsplit.pngbin0 -> 809 bytes
-rw-r--r--kommander/editor/pics/small/editlower.xpm113
-rw-r--r--kommander/editor/pics/small/editpaste.pngbin0 -> 902 bytes
-rw-r--r--kommander/editor/pics/small/editraise.xpm110
-rw-r--r--kommander/editor/pics/small/editslots.pngbin0 -> 690 bytes
-rw-r--r--kommander/editor/pics/small/editvlayout.pngbin0 -> 289 bytes
-rw-r--r--kommander/editor/pics/small/editvlayoutsplit.pngbin0 -> 355 bytes
-rw-r--r--kommander/editor/pics/small/exec.pngbin0 -> 1408 bytes
-rw-r--r--kommander/editor/pics/small/filenew.pngbin0 -> 313 bytes
-rw-r--r--kommander/editor/pics/small/fileopen.pngbin0 -> 681 bytes
-rw-r--r--kommander/editor/pics/small/filesave.pngbin0 -> 328 bytes
-rw-r--r--kommander/editor/pics/small/form.xpm67
-rw-r--r--kommander/editor/pics/small/frame.pngbin0 -> 400 bytes
-rw-r--r--kommander/editor/pics/small/groupbox.pngbin0 -> 439 bytes
-rw-r--r--kommander/editor/pics/small/help.pngbin0 -> 837 bytes
-rw-r--r--kommander/editor/pics/small/home.xpm160
-rw-r--r--kommander/editor/pics/small/iconview.pngbin0 -> 613 bytes
-rw-r--r--kommander/editor/pics/small/image.xpm226
-rw-r--r--kommander/editor/pics/small/konsole.pngbin0 -> 1155 bytes
-rw-r--r--kommander/editor/pics/small/label.pngbin0 -> 953 bytes
-rw-r--r--kommander/editor/pics/small/layout.xpm121
-rw-r--r--kommander/editor/pics/small/lcdnumber.pngbin0 -> 558 bytes
-rw-r--r--kommander/editor/pics/small/left.xpm141
-rw-r--r--kommander/editor/pics/small/line.pngbin0 -> 287 bytes
-rw-r--r--kommander/editor/pics/small/lineedit.pngbin0 -> 461 bytes
-rw-r--r--kommander/editor/pics/small/listbox.pngbin0 -> 386 bytes
-rw-r--r--kommander/editor/pics/small/listview.pngbin0 -> 759 bytes
-rw-r--r--kommander/editor/pics/small/multilineedit.pngbin0 -> 454 bytes
-rw-r--r--kommander/editor/pics/small/newform.xpm35
-rw-r--r--kommander/editor/pics/small/ordertool.pngbin0 -> 587 bytes
-rw-r--r--kommander/editor/pics/small/pixlabel.pngbin0 -> 1229 bytes
-rw-r--r--kommander/editor/pics/small/pointer.pngbin0 -> 586 bytes
-rw-r--r--kommander/editor/pics/small/print.xpm117
-rw-r--r--kommander/editor/pics/small/progress.pngbin0 -> 609 bytes
-rw-r--r--kommander/editor/pics/small/pushbutton.pngbin0 -> 408 bytes
-rw-r--r--kommander/editor/pics/small/radiobutton.pngbin0 -> 586 bytes
-rw-r--r--kommander/editor/pics/small/redo.pngbin0 -> 592 bytes
-rw-r--r--kommander/editor/pics/small/richtextedit.pngbin0 -> 834 bytes
-rw-r--r--kommander/editor/pics/small/right.xpm141
-rw-r--r--kommander/editor/pics/small/scrollbar.pngbin0 -> 408 bytes
-rw-r--r--kommander/editor/pics/small/searchfind.pngbin0 -> 843 bytes
-rw-r--r--kommander/editor/pics/small/shellscript.pngbin0 -> 1053 bytes
-rw-r--r--kommander/editor/pics/small/slider.pngbin0 -> 729 bytes
-rw-r--r--kommander/editor/pics/small/spacer.pngbin0 -> 715 bytes
-rw-r--r--kommander/editor/pics/small/spinbox.pngbin0 -> 455 bytes
-rw-r--r--kommander/editor/pics/small/statusbar.pngbin0 -> 294 bytes
-rw-r--r--kommander/editor/pics/small/table.pngbin0 -> 483 bytes
-rw-r--r--kommander/editor/pics/small/tabwidget.pngbin0 -> 572 bytes
-rw-r--r--kommander/editor/pics/small/textbrowser.pngbin0 -> 514 bytes
-rw-r--r--kommander/editor/pics/small/textedit.pngbin0 -> 497 bytes
-rw-r--r--kommander/editor/pics/small/textview.pngbin0 -> 498 bytes
-rw-r--r--kommander/editor/pics/small/timeedit.pngbin0 -> 1520 bytes
-rw-r--r--kommander/editor/pics/small/timer.pngbin0 -> 1462 bytes
-rw-r--r--kommander/editor/pics/small/toolbutton.pngbin0 -> 1262 bytes
-rw-r--r--kommander/editor/pics/small/undo.pngbin0 -> 572 bytes
-rw-r--r--kommander/editor/pics/temp.tmp0
-rw-r--r--kommander/editor/pics/toolbox.pngbin0 -> 783 bytes
-rw-r--r--kommander/editor/pics/uparrow.xbm10
-rw-r--r--kommander/editor/pics/vsplit.xbm10
-rw-r--r--kommander/editor/pics/wait.xbm10
-rw-r--r--kommander/editor/pixmapchooser.cpp1105
-rw-r--r--kommander/editor/pixmapchooser.h86
-rw-r--r--kommander/editor/pixmapfunction.ui923
-rw-r--r--kommander/editor/preferences.ui669
-rw-r--r--kommander/editor/previewframe.cpp52
-rw-r--r--kommander/editor/previewframe.h53
-rw-r--r--kommander/editor/previewwidget.ui279
-rw-r--r--kommander/editor/previewwidgetimpl.cpp60
-rw-r--r--kommander/editor/previewwidgetimpl.h37
-rw-r--r--kommander/editor/propertyeditor.cpp3706
-rw-r--r--kommander/editor/propertyeditor.h670
-rw-r--r--kommander/editor/qcompletionedit.cpp185
-rw-r--r--kommander/editor/qcompletionedit.h53
-rw-r--r--kommander/editor/resource.cpp2858
-rw-r--r--kommander/editor/resource.h159
-rw-r--r--kommander/editor/sizehandle.cpp384
-rw-r--r--kommander/editor/sizehandle.h91
-rw-r--r--kommander/editor/styledbutton.cpp290
-rw-r--r--kommander/editor/styledbutton.h97
-rw-r--r--kommander/editor/tableeditor.ui813
-rw-r--r--kommander/editor/tableeditorimpl.cpp464
-rw-r--r--kommander/editor/tableeditorimpl.h56
-rw-r--r--kommander/editor/templates/Configuration_Dialog.ui156
-rw-r--r--kommander/editor/templates/Dialog_with_Buttons_(Bottom).ui114
-rw-r--r--kommander/editor/templates/Dialog_with_Buttons_(Right).ui114
-rw-r--r--kommander/editor/templates/Makefile.am0
-rw-r--r--kommander/editor/templates/Tab_Dialog.ui138
-rw-r--r--kommander/editor/templates/cpp_template16
-rw-r--r--kommander/editor/templates/header_template16
-rw-r--r--kommander/editor/timestamp.cpp81
-rw-r--r--kommander/editor/timestamp.h57
-rw-r--r--kommander/editor/widgetdatabase.cpp1029
-rw-r--r--kommander/editor/widgetdatabase.h87
-rw-r--r--kommander/editor/widgetfactory.cpp1928
-rw-r--r--kommander/editor/widgetfactory.h473
-rw-r--r--kommander/editor/widgetinterface.h29
-rw-r--r--kommander/editor/wizardeditor.ui320
-rw-r--r--kommander/editor/wizardeditorimpl.cpp220
-rw-r--r--kommander/editor/wizardeditorimpl.h64
-rw-r--r--kommander/editor/workspace.cpp787
-rw-r--r--kommander/editor/workspace.h170
319 files changed, 68621 insertions, 0 deletions
diff --git a/kommander/editor/Makefile.am b/kommander/editor/Makefile.am
new file mode 100644
index 00000000..aad9e81d
--- /dev/null
+++ b/kommander/editor/Makefile.am
@@ -0,0 +1,53 @@
+SUBDIRS = pics
+# this is the program that gets installed. it's name is used for all
+# of the other Makefile.am variables
+bin_PROGRAMS = kmdr-editor
+
+# set the include path for X, qt and KDE
+AM_CPPFLAGS = -I$(top_srcdir)/kommander/widget -I$(top_srcdir)/kommander/widgets -I$(top_srcdir)/kommander/plugin -I$(top_srcdir)/kommander/factory -Ishared -Iinterfaces -Ipics $(all_includes)
+
+# the library search path.
+kmdr_editor_LDFLAGS = $(KDE_RPATH) $(all_libraries)
+
+# the libraries to link against.
+kmdr_editor_LDADD = $(top_builddir)/kommander/factory/libkommanderfactory.la \
+ $(top_builddir)/kommander/widget/libkommanderwidget.la \
+ $(top_builddir)/kommander/widgets/libkommanderwidgets.la \
+ $(top_builddir)/kommander/plugin/libkommanderplugin.la -lktexteditor
+
+# which sources should be compiled for kmdr_editor
+kmdr_editor_SOURCES = actiondnd.cpp actioneditorimpl.cpp \
+ assoctexteditorimpl.cpp actionlistview.cpp asciivalidator.cpp assistproc.cpp command.cpp \
+ connectioneditorimpl.cpp defs.cpp filechooser.cpp formfile.cpp formsettingsimpl.cpp \
+ formwindow.cpp hierarchyview.cpp iconvieweditorimpl.cpp layout.cpp \
+ listboxeditorimpl.cpp listvieweditorimpl.cpp main.cpp mainwindow.cpp mainwindowactions.cpp \
+ metadatabase.cpp multilineeditorimpl.cpp newformimpl.cpp orderindicator.cpp \
+ paletteeditoradvancedimpl.cpp paletteeditorimpl.cpp parser.cpp pixmapchooser.cpp previewframe.cpp \
+ previewwidgetimpl.cpp propertyeditor.cpp qcompletionedit.cpp resource.cpp sizehandle.cpp \
+ styledbutton.cpp tableeditorimpl.cpp widgetdatabase.cpp widgetfactory.cpp \
+ wizardeditorimpl.cpp workspace.cpp actioneditor.ui assoctexteditor.ui connectioneditor.ui \
+ createtemplate.ui formsettings.ui iconvieweditor.ui listboxeditor.ui listeditor.ui \
+ listvieweditor.ui multilineeditor.ui newform.ui paletteeditor.ui paletteeditoradvanced.ui \
+ pixmapfunction.ui preferences.ui previewwidget.ui tableeditor.ui wizardeditor.ui \
+ choosewidget.ui choosewidgetimpl.cpp functions.ui functionsimpl.cpp messagelog.cpp
+
+# these are the headers for your project that won't be installed
+noinst_HEADERS = actiondnd.h actioneditorimpl.h actionlistview.h \
+ asciivalidator.h assistproc.h assoctexteditorimpl.h command.h connectioneditorimpl.h \
+ defs.h filechooser.h formfile.h formsettingsimpl.h formwindow.h globaldefs.h \
+ hierarchyview.h iconvieweditorimpl.h layout.h listboxeditorimpl.h listvieweditorimpl.h \
+ mainwindow.h metadatabase.h multilineeditorimpl.h newformimpl.h orderindicator.h \
+ paletteeditoradvancedimpl.h paletteeditorimpl.h parser.h pixmapchooser.h previewframe.h \
+ previewwidgetimpl.h propertyeditor.h qcompletionedit.h resource.h sizehandle.h \
+ styledbutton.h tableeditorimpl.h widgetdatabase.h widgetfactory.h widgetinterface.h \
+ wizardeditorimpl.h workspace.h choosewidgetimpl.h messagelog.h
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+xdg_apps_DATA = kmdr-editor.desktop
+
+syntaxkatedir = $(kde_datadir)/katepart/syntax
+syntaxkate_DATA = kommander.xml kommander-new.xml
+
+
diff --git a/kommander/editor/actiondnd.cpp b/kommander/editor/actiondnd.cpp
new file mode 100644
index 00000000..0da7c650
--- /dev/null
+++ b/kommander/editor/actiondnd.cpp
@@ -0,0 +1,1244 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include <qaction.h>
+#include <qapplication.h>
+#include <qbitmap.h>
+#include <qdragobject.h>
+#include <kinputdialog.h>
+#include <qlayout.h>
+#include <qmainwindow.h>
+#include <qmenudata.h>
+#include <qmessagebox.h>
+#include <qobjectlist.h>
+#include <qpainter.h>
+#include <qstyle.h>
+#include <qtimer.h>
+
+#include "actiondnd.h"
+#include "command.h"
+#include "defs.h"
+#include "formwindow.h"
+#include "mainwindow.h"
+#include "metadatabase.h"
+#include "widgetfactory.h"
+
+#include <klocale.h>
+
+bool QDesignerAction::addTo( QWidget *w )
+{
+ if ( !widgetToInsert )
+ return QAction::addTo( w );
+
+ if ( w->inherits( "QPopupMenu" ) )
+ return false;
+
+ widgetToInsert->reparent( w, QPoint( 0, 0 ), false );
+ addedTo( widgetToInsert, w );
+ return true;
+}
+
+bool QDesignerAction::removeFrom( QWidget *w )
+{
+ if ( !widgetToInsert )
+ return QAction::removeFrom( w );
+
+ remove();
+ return true;
+}
+
+void QDesignerAction::remove()
+{
+ if ( !widgetToInsert )
+ return;
+ MainWindow::self->formWindow()->selectWidget( widgetToInsert, false );
+ widgetToInsert->reparent( 0, QPoint( 0, 0 ), false );
+}
+
+QDesignerToolBarSeparator::QDesignerToolBarSeparator(Orientation o , QToolBar *parent,
+ const char* name )
+ : QWidget( parent, name )
+{
+ connect( parent, SIGNAL(orientationChanged(Orientation)),
+ this, SLOT(setOrientation(Orientation)) );
+ setOrientation( o );
+ setBackgroundMode( parent->backgroundMode() );
+ setBackgroundOrigin( ParentOrigin );
+ setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
+}
+
+void QDesignerToolBarSeparator::setOrientation( Orientation o )
+{
+ orient = o;
+}
+
+void QDesignerToolBarSeparator::styleChange( QStyle& )
+{
+ setOrientation( orient );
+}
+
+QSize QDesignerToolBarSeparator::sizeHint() const
+{
+ int extent = style().pixelMetric( QStyle::PM_DockWindowSeparatorExtent,
+ this );
+ if ( orient == Horizontal )
+ return QSize( extent, 0 );
+ else
+ return QSize( 0, extent );
+}
+
+void QDesignerToolBarSeparator::paintEvent( QPaintEvent * )
+{
+ QPainter p( this );
+ QStyle::SFlags flags = QStyle::Style_Default;
+
+ if ( orientation() == Horizontal )
+ flags |= QStyle::Style_Horizontal;
+
+ style().drawPrimitive( QStyle::PE_DockWindowSeparator, &p, rect(),
+ colorGroup(), flags );
+}
+
+
+
+QSeparatorAction::QSeparatorAction( QObject *parent )
+ : QAction( parent, "qt_designer_separator" ), wid( 0 )
+{
+}
+
+bool QSeparatorAction::addTo( QWidget *w )
+{
+ if ( w->inherits( "QToolBar" ) ) {
+ QToolBar *tb = (QToolBar*)w;
+ wid = new QDesignerToolBarSeparator( tb->orientation(), tb );
+ return true;
+ } else if ( w->inherits( "QPopupMenu" ) ) {
+ idx = ( (QPopupMenu*)w )->count();
+ ( (QPopupMenu*)w )->insertSeparator( idx );
+ return true;
+ }
+ return false;
+}
+
+bool QSeparatorAction::removeFrom( QWidget *w )
+{
+ if ( w->inherits( "QToolBar" ) ) {
+ delete wid;
+ return true;
+ } else if ( w->inherits( "QPopupMenu" ) ) {
+ ( (QPopupMenu*)w )->removeItemAt( idx );
+ return true;
+ }
+ return false;
+}
+
+QWidget *QSeparatorAction::widget() const
+{
+ return wid;
+}
+
+
+
+
+QDesignerToolBar::QDesignerToolBar( QMainWindow *mw )
+ : QToolBar( mw ), lastIndicatorPos( -1, -1 )
+{
+ insertAnchor = 0;
+ afterAnchor = true;
+ setAcceptDrops( true );
+ MetaDataBase::addEntry( this );
+ lastIndicatorPos = QPoint( -1, -1 );
+ indicator = new QDesignerIndicatorWidget( this );
+ indicator->hide();
+ installEventFilter( this );
+ widgetInserting = false;
+ findFormWindow();
+ mw->setDockEnabled( DockTornOff, false );
+}
+
+QDesignerToolBar::QDesignerToolBar( QMainWindow *mw, Dock dock )
+ : QToolBar( QString::null, mw, dock), lastIndicatorPos( -1, -1 )
+{
+ insertAnchor = 0;
+ afterAnchor = true;
+ setAcceptDrops( true );
+ indicator = new QDesignerIndicatorWidget( this );
+ indicator->hide();
+ MetaDataBase::addEntry( this );
+ installEventFilter( this );
+ widgetInserting = false;
+ findFormWindow();
+ mw->setDockEnabled( DockTornOff, false );
+}
+
+void QDesignerToolBar::findFormWindow()
+{
+ QWidget *w = this;
+ while ( w ) {
+ if ( w->inherits( "FormWindow" ) )
+ formWindow = (FormWindow*)w;
+ w = w->parentWidget();
+ }
+}
+
+void QDesignerToolBar::addAction( QAction *a )
+{
+ actionList.append( a );
+ connect( a, SIGNAL( destroyed() ), this, SLOT( actionRemoved() ) );
+ if ( a->inherits( "QActionGroup" ) ) {
+ ( (QDesignerActionGroup*)a )->widget()->installEventFilter( this );
+ actionMap.insert( ( (QDesignerActionGroup*)a )->widget(), a );
+ } else if ( a->inherits( "QSeparatorAction" ) ) {
+ ( (QSeparatorAction*)a )->widget()->installEventFilter( this );
+ actionMap.insert( ( (QSeparatorAction*)a )->widget(), a );
+ } else {
+ ( (QDesignerAction*)a )->widget()->installEventFilter( this );
+ actionMap.insert( ( (QDesignerAction*)a )->widget(), a );
+ }
+}
+
+static void fixObject( QObject *&o )
+{
+ while ( o && o->parent() && !o->parent()->inherits( "QDesignerToolBar" ) )
+ o = o->parent();
+}
+
+bool QDesignerToolBar::eventFilter( QObject *o, QEvent *e )
+{
+ if ( !o || !e || o->inherits( "QDockWindowHandle" ) || o->inherits( "QDockWindowTitleBar" ) )
+ return QToolBar::eventFilter( o, e );
+
+ if ( o == this && e->type() == QEvent::MouseButtonPress &&
+ ( ( QMouseEvent*)e )->button() == LeftButton ) {
+ mousePressEvent( (QMouseEvent*)e );
+ return true;
+ }
+
+ if ( o == this )
+ return QToolBar::eventFilter( o, e );
+
+ if ( e->type() == QEvent::MouseButtonPress ) {
+ QMouseEvent *ke = (QMouseEvent*)e;
+ fixObject( o );
+ if ( !o )
+ return false;
+ buttonMousePressEvent( ke, o );
+ return true;
+ } else if(e->type() == QEvent::ContextMenu ) {
+ QContextMenuEvent *ce = (QContextMenuEvent*)e;
+ fixObject( o );
+ if( !o )
+ return false;
+ buttonContextMenuEvent( ce, o );
+ return true;
+ } else if ( e->type() == QEvent::MouseMove ) {
+ QMouseEvent *ke = (QMouseEvent*)e;
+ fixObject( o );
+ if ( !o )
+ return false;
+ buttonMouseMoveEvent( ke, o );
+ return true;
+ } else if ( e->type() == QEvent::MouseButtonRelease ) {
+ QMouseEvent *ke = (QMouseEvent*)e;
+ fixObject( o );
+ if ( !o )
+ return false;
+ buttonMouseReleaseEvent( ke, o );
+ return true;
+ } else if ( e->type() == QEvent::DragEnter ) {
+ QDragEnterEvent *de = (QDragEnterEvent*)e;
+ if ( de->provides( "application/x-designer-actions" ) ||
+ de->provides( "application/x-designer-actiongroup" ) ||
+ de->provides( "application/x-designer-separator" ) )
+ de->accept();
+ } else if ( e->type() == QEvent::DragMove ) {
+ QDragMoveEvent *de = (QDragMoveEvent*)e;
+ if ( de->provides( "application/x-designer-actions" ) ||
+ de->provides( "application/x-designer-actiongroup" ) ||
+ de->provides( "application/x-designer-separator" ) )
+ de->accept();
+ }
+
+ return QToolBar::eventFilter( o, e );
+}
+
+void QDesignerToolBar::paintEvent( QPaintEvent *e )
+{
+ QToolBar::paintEvent( e );
+ if ( e->rect() != rect() )
+ return;
+ lastIndicatorPos = QPoint( -1, -1 );
+}
+
+void QDesignerToolBar::contextMenuEvent( QContextMenuEvent *e )
+{
+ e->accept();
+ QPopupMenu menu( 0 );
+ menu.insertItem( i18n("Delete Toolbar" ), 1 );
+ int res = menu.exec( e->globalPos() );
+ if ( res != -1 ) {
+ RemoveToolBarCommand *cmd = new RemoveToolBarCommand( i18n("Delete Toolbar '%1'" ).arg( name() ),
+ formWindow, 0, this );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ }
+}
+
+void QDesignerToolBar::mousePressEvent( QMouseEvent *e )
+{
+ widgetInserting = false;
+ if ( e->button() == LeftButton &&
+ MainWindow::self->currentTool() != POINTER_TOOL &&
+ MainWindow::self->currentTool() != ORDER_TOOL ) {
+
+ if ( MainWindow::self->currentTool() == CONNECT_TOOL ) {
+
+ } else {
+ widgetInserting = true;
+ }
+
+ return;
+ }
+}
+
+void QDesignerToolBar::mouseReleaseEvent( QMouseEvent *e )
+{
+ if ( widgetInserting )
+ doInsertWidget( mapFromGlobal( e->globalPos() ) );
+ widgetInserting = false;
+}
+
+void QDesignerToolBar::buttonMouseReleaseEvent( QMouseEvent *e, QObject *w )
+{
+ if ( widgetInserting )
+ doInsertWidget( mapFromGlobal( e->globalPos() ) );
+ else if ( w->isWidgetType() && formWindow->widgets()->find( w ) ) {
+ formWindow->clearSelection( false );
+ formWindow->selectWidget( w );
+ }
+ widgetInserting = false;
+}
+
+void QDesignerToolBar::buttonContextMenuEvent( QContextMenuEvent *e, QObject *o )
+{
+ e->accept();
+ QPopupMenu menu( 0 );
+ const int ID_DELETE = 1;
+ const int ID_SEP = 2;
+ const int ID_DELTOOLBAR = 3;
+ QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o );
+ if ( it != actionMap.end() && (*it)->inherits( "QSeparatorAction" ) )
+ menu.insertItem( i18n("Delete Separator" ), ID_DELETE );
+ else
+ menu.insertItem( i18n("Delete Item" ), ID_DELETE );
+ menu.insertItem( i18n("Insert Separator" ), ID_SEP );
+ menu.insertSeparator();
+ menu.insertItem( i18n("Delete Toolbar" ), ID_DELTOOLBAR );
+ int res = menu.exec( e->globalPos() );
+ if ( res == ID_DELETE ) {
+ QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o );
+ if ( it == actionMap.end() )
+ return;
+ QAction *a = *it;
+ int index = actionList.find( a );
+ RemoveActionFromToolBarCommand *cmd = new RemoveActionFromToolBarCommand(
+ i18n("Delete Action '%1' From Toolbar '%2'" ).
+ arg( a->name() ).arg( caption() ),
+ formWindow, a, this, index );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ } else if ( res == ID_SEP ) {
+ calcIndicatorPos( mapFromGlobal( e->globalPos() ) );
+ QAction *a = new QSeparatorAction( 0 );
+ int index = actionList.findRef( *actionMap.find( insertAnchor ) );
+ if ( index != -1 && afterAnchor )
+ ++index;
+ if ( !insertAnchor )
+ index = 0;
+
+ AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand(
+ i18n("Add Separator to Toolbar '%1'" ).
+ arg( a->name() ),
+ formWindow, a, this, index );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ } else if ( res == ID_DELTOOLBAR ) {
+ RemoveToolBarCommand *cmd = new RemoveToolBarCommand( i18n("Delete Toolbar '%1'" ).arg( name() ),
+ formWindow, 0, this );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ }
+}
+
+void QDesignerToolBar::buttonMousePressEvent( QMouseEvent *e, QObject * )
+{
+ widgetInserting = false;
+
+ if ( e->button() == MidButton )
+ return;
+
+ if ( e->button() == LeftButton &&
+ MainWindow::self->currentTool() != POINTER_TOOL &&
+ MainWindow::self->currentTool() != ORDER_TOOL ) {
+
+ if ( MainWindow::self->currentTool() == CONNECT_TOOL ) {
+
+ } else {
+ widgetInserting = true;
+ }
+
+ return;
+ }
+
+
+ dragStartPos = e->pos();
+}
+
+void QDesignerToolBar::removeWidget( QWidget *w )
+{
+ QMap<QWidget*, QAction*>::Iterator it = actionMap.find( w );
+ if ( it == actionMap.end() )
+ return;
+ QAction *a = *it;
+ int index = actionList.find( a );
+ RemoveActionFromToolBarCommand *cmd =
+ new RemoveActionFromToolBarCommand( i18n("Delete Action '%1' From Toolbar '%2'" ).
+ arg( a->name() ).arg( caption() ),
+ formWindow, a, this, index );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ QApplication::sendPostedEvents();
+ adjustSize();
+}
+
+void QDesignerToolBar::buttonMouseMoveEvent( QMouseEvent *e, QObject *o )
+{
+ if ( widgetInserting || ( e->state() & LeftButton ) == 0 )
+ return;
+ if ( QABS( QPoint( dragStartPos - e->pos() ).manhattanLength() ) < QApplication::startDragDistance() )
+ return;
+ QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o );
+ if ( it == actionMap.end() )
+ return;
+ QAction *a = *it;
+ if ( !a )
+ return;
+ int index = actionList.find( a );
+ RemoveActionFromToolBarCommand *cmd =
+ new RemoveActionFromToolBarCommand( i18n("Delete Action '%1' From Toolbar '%2'" ).
+ arg( a->name() ).arg( caption() ),
+ formWindow, a, this, index );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ QApplication::sendPostedEvents();
+ adjustSize();
+
+ QString type = a->inherits( "QActionGroup" ) ? QString( "application/x-designer-actiongroup" ) :
+ a->inherits( "QSeparatorAction" ) ? QString( "application/x-designer-separator" ) : QString( "application/x-designer-actions" );
+ QStoredDrag *drag = new QStoredDrag( type, this );
+ QString s = QString::number( (long)a ); // #### huha, that is evil
+ drag->setEncodedData( QCString( s.latin1() ) );
+ drag->setPixmap( a->iconSet().pixmap() );
+ if ( a->inherits( "QDesignerAction" ) ) {
+ if ( formWindow->widgets()->find( ( (QDesignerAction*)a )->widget() ) )
+ formWindow->selectWidget( ( (QDesignerAction*)a )->widget(), false );
+ }
+ if ( !drag->drag() ) {
+ AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( i18n("Add Action '%1' to Toolbar '%2'" ).
+ arg( a->name() ).arg( caption() ),
+ formWindow, a, this, index );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ }
+ lastIndicatorPos = QPoint( -1, -1 );
+ indicator->hide();
+}
+
+#ifndef QT_NO_DRAGANDDROP
+
+void QDesignerToolBar::dragEnterEvent( QDragEnterEvent *e )
+{
+ widgetInserting = false;
+ lastIndicatorPos = QPoint( -1, -1 );
+ if ( e->provides( "application/x-designer-actions" ) ||
+ e->provides( "application/x-designer-actiongroup" ) ||
+ e->provides( "application/x-designer-separator" ) )
+ e->accept();
+}
+
+void QDesignerToolBar::dragMoveEvent( QDragMoveEvent *e )
+{
+ if ( e->provides( "application/x-designer-actions" ) ||
+ e->provides( "application/x-designer-actiongroup" ) ||
+ e->provides( "application/x-designer-separator" ) )
+ e->accept();
+ else
+ return;
+ drawIndicator( calcIndicatorPos( e->pos() ) );
+}
+
+void QDesignerToolBar::dragLeaveEvent( QDragLeaveEvent * )
+{
+ indicator->hide();
+ insertAnchor = 0;
+ afterAnchor = true;
+}
+
+void QDesignerToolBar::dropEvent( QDropEvent *e )
+{
+ if ( e->provides( "application/x-designer-actions" ) ||
+ e->provides( "application/x-designer-actiongroup" ) ||
+ e->provides( "application/x-designer-separator" ) )
+ e->accept();
+ else
+ return;
+ QString s;
+ if ( e->provides( "application/x-designer-actiongroup" ) )
+ s = QString( e->encodedData( "application/x-designer-actiongroup" ) );
+ else if ( e->provides( "application/x-designer-separator" ) )
+ s = QString( e->encodedData( "application/x-designer-separator" ) );
+ else
+ s = QString( e->encodedData( "application/x-designer-actions" ) );
+
+ indicator->hide();
+ QAction *a = 0;
+ int index = actionList.findRef( *actionMap.find( insertAnchor ) );
+ if ( index != -1 && afterAnchor )
+ ++index;
+ if ( !insertAnchor )
+ index = 0;
+ if ( e->provides( "application/x-designer-actions" ) ||
+ e->provides( "application/x-designer-separator" ) ) {
+ if ( e->provides( "application/x-designer-actions" ) )
+ a = (QDesignerAction*)s.toLong();
+ else
+ a = (QSeparatorAction*)s.toLong();
+ } else {
+ a = (QDesignerActionGroup*)s.toLong();
+ }
+
+ if ( actionList.findRef( a ) != -1 ) {
+ QMessageBox::warning( MainWindow::self, i18n("Insert/Move Action" ),
+ i18n("Action '%1' has already been added to this toolbar.\n"
+ "An Action may only occur once in a given toolbar." ).
+ arg( a->name() ) );
+ return;
+ }
+
+ AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( i18n("Add Action '%1' to Toolbar '%2'" ).
+ arg( a->name() ).arg( caption() ),
+ formWindow, a, this, index );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+
+ lastIndicatorPos = QPoint( -1, -1 );
+}
+
+#endif
+
+void QDesignerToolBar::reInsert()
+{
+ QAction *a = 0;
+ actionMap.clear();
+ clear();
+ for ( a = actionList.first(); a; a = actionList.next() ) {
+ a->addTo( this );
+ if ( a->inherits( "QActionGroup" ) ) {
+ actionMap.insert( ( (QDesignerActionGroup*)a )->widget(), a );
+ if ( ( (QDesignerActionGroup*)a )->widget() )
+ ( (QDesignerActionGroup*)a )->widget()->installEventFilter( this );
+ } else if ( a->inherits( "QDesignerAction" ) ) {
+ actionMap.insert( ( (QDesignerAction*)a )->widget(), a );
+ ( (QDesignerAction*)a )->widget()->installEventFilter( this );
+ } else if ( a->inherits( "QSeparatorAction" ) ) {
+ actionMap.insert( ( (QSeparatorAction*)a )->widget(), a );
+ ( (QSeparatorAction*)a )->widget()->installEventFilter( this );
+ }
+ }
+ QApplication::sendPostedEvents();
+ adjustSize();
+}
+
+void QDesignerToolBar::actionRemoved()
+{
+ actionList.removeRef( (QAction*)sender() );
+}
+
+QPoint QDesignerToolBar::calcIndicatorPos( const QPoint &pos )
+{
+ if ( orientation() == Horizontal ) {
+ QPoint pnt( width() - 2, 0 );
+ insertAnchor = 0;
+ afterAnchor = true;
+ if ( !children() )
+ return pnt;
+ pnt = QPoint( 13, 0 );
+ QObjectListIt it( *children() );
+ QObject * obj;
+ while( (obj=it.current()) != 0 ) {
+ ++it;
+ if ( obj->isWidgetType() &&
+ qstrcmp( "qt_dockwidget_internal", obj->name() ) != 0 ) {
+ QWidget *w = (QWidget*)obj;
+ if ( w->x() < pos.x() ) {
+ pnt.setX( w->x() + w->width() + 1 );
+ insertAnchor = w;
+ afterAnchor = true;
+ }
+ }
+ }
+ return pnt;
+ } else {
+ QPoint pnt( 0, height() - 2 );
+ insertAnchor = 0;
+ afterAnchor = true;
+ if ( !children() )
+ return pnt;
+ pnt = QPoint( 0, 13 );
+ QObjectListIt it( *children() );
+ QObject * obj;
+ while( (obj=it.current()) != 0 ) {
+ ++it;
+ if ( obj->isWidgetType() &&
+ qstrcmp( "qt_dockwidget_internal", obj->name() ) != 0 ) {
+ QWidget *w = (QWidget*)obj;
+ if ( w->y() < pos.y() ) {
+ pnt.setY( w->y() + w->height() + 1 );
+ insertAnchor = w;
+ afterAnchor = true;
+ }
+ }
+ }
+ return pnt;
+ }
+}
+
+void QDesignerToolBar::drawIndicator( const QPoint &pos )
+{
+ if ( lastIndicatorPos == pos )
+ return;
+ bool wasVsisible = indicator->isVisible();
+ if ( orientation() == Horizontal ) {
+ indicator->resize( 3, height() );
+ if ( pos != QPoint( -1, -1 ) )
+ indicator->move( pos.x() - 1, 0 );
+ indicator->show();
+ indicator->raise();
+ lastIndicatorPos = pos;
+ } else {
+ indicator->resize( width(), 3 );
+ if ( pos != QPoint( -1, -1 ) )
+ indicator->move( 0, pos.y() - 1 );
+ indicator->show();
+ indicator->raise();
+ lastIndicatorPos = pos;
+ }
+ if ( !wasVsisible )
+ QApplication::sendPostedEvents();
+}
+
+void QDesignerToolBar::doInsertWidget( const QPoint &p )
+{
+ if ( formWindow != MainWindow::self->formWindow() )
+ return;
+ calcIndicatorPos( p );
+ QWidget *w = WidgetFactory::create( MainWindow::self->currentTool(), this, 0, true );
+ installEventFilters( w );
+ MainWindow::self->formWindow()->insertWidget( w, true );
+ QDesignerAction *a = new QDesignerAction( w, parent() );
+ int index = actionList.findRef( *actionMap.find( insertAnchor ) );
+ if ( index != -1 && afterAnchor )
+ ++index;
+ if ( !insertAnchor )
+ index = 0;
+ AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( i18n("Add Widget '%1' to Toolbar '%2'" ).
+ arg( w->name() ).arg( caption() ),
+ formWindow, a, this, index );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ MainWindow::self->resetTool();
+}
+
+void QDesignerToolBar::clear()
+{
+ for ( QAction *a = actionList.first(); a; a = actionList.next() ) {
+ if ( a->inherits( "QDesignerAction" ) )
+ ( (QDesignerAction*)a )->remove();
+ }
+ QToolBar::clear();
+}
+
+void QDesignerToolBar::installEventFilters( QWidget *w )
+{
+ if ( !w )
+ return;
+ QObjectList *l = w->queryList( "QWidget" );
+ for ( QObject *o = l->first(); o; o = l->next() )
+ o->installEventFilter( this );
+ delete l;
+}
+
+
+
+QDesignerMenuBar::QDesignerMenuBar( QWidget *mw )
+ : QMenuBar( mw, 0 )
+{
+ show();
+ setAcceptDrops( true );
+ MetaDataBase::addEntry( this );
+ itemNum = 0;
+ mousePressed = false;
+ lastIndicatorPos = QPoint( -1, -1 );
+ insertAt = -1;
+ indicator = new QDesignerIndicatorWidget( this );
+ indicator->hide();
+ findFormWindow();
+}
+
+void QDesignerMenuBar::findFormWindow()
+{
+ QWidget *w = this;
+ while ( w ) {
+ if ( w->inherits( "FormWindow" ) )
+ formWindow = (FormWindow*)w;
+ w = w->parentWidget();
+ }
+}
+
+void QDesignerMenuBar::contextMenuEvent( QContextMenuEvent *e )
+{
+ e->accept();
+ int itm = itemAtPos( e->pos() );
+ if ( itm == -1 ) {
+ if ( formWindow )
+ formWindow->mainWindow()->popupFormWindowMenu( e->globalPos(), formWindow );
+ return;
+ }
+ QPopupMenu menu( this );
+ menu.insertItem( i18n("Delete Item" ), 1 );
+ menu.insertItem( i18n("Rename Item..." ), 2 );
+ int res = menu.exec( e->globalPos() );
+ if ( res == 1 ) {
+ QMenuItem *item = findItem( idAt( itm ) );
+ RemoveMenuCommand *cmd = new RemoveMenuCommand( i18n("Delete Menu '%1'" ).arg( item->text() ),
+ formWindow,
+ (QMainWindow*)parentWidget(), this,
+ (QDesignerPopupMenu*)item->popup(),
+ idAt( itm ), itm, item->text() );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ // #### need to do a proper invalidate and re-layout
+ parentWidget()->layout()->invalidate();
+ parentWidget()->layout()->activate();
+ } else if ( res == 2 ) {
+ bool ok;
+ QString old = text( idAt( itm ) );
+ QString txt = KInputDialog::getText( i18n("Rename Menu Item" ), i18n("Menu text:" ),
+ text( idAt( itm ) ), &ok, 0 );
+ if ( ok ) {
+ RenameMenuCommand *cmd = new RenameMenuCommand(
+ i18n("Rename Menu '%1' to '%2'" ).arg( old ).arg( txt ),
+ formWindow, this, idAt( itm ), old, txt );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ }
+ }
+}
+
+void QDesignerMenuBar::mousePressEvent( QMouseEvent *e )
+{
+ lastIndicatorPos = QPoint( -1, -1 );
+ insertAt = -1;
+ mousePressed = true;
+ if ( e->button() == MidButton || e->button() == RightButton )
+ return;
+
+ dragStartPos = e->pos();
+ QMenuBar::mousePressEvent( e );
+}
+
+void QDesignerMenuBar::mouseMoveEvent( QMouseEvent *e )
+{
+ if ( !mousePressed || e->state() == NoButton ) {
+ QMenuBar::mouseMoveEvent( e );
+ return;
+ }
+ if ( QABS( QPoint( dragStartPos - e->pos() ).manhattanLength() ) < QApplication::startDragDistance() )
+ return;
+ hidePopups();
+ activateItemAt( -1 );
+ int itm = itemAtPos( dragStartPos );
+ if ( itm == -1 )
+ return;
+ QPopupMenu *popup = findItem( idAt( itm ) )->popup();
+ QString txt = findItem( idAt( itm ) )->text();
+ removeItemAt( itm );
+
+ QStoredDrag *drag = new QStoredDrag( "application/x-designer-menuitem", this );
+ QString s = QString::number( (long)popup );
+ s += "/" + txt;
+ drag->setEncodedData( QCString( s.latin1() ) );
+ QSize sz( fontMetrics().boundingRect( txt ).size() );
+ QPixmap pix( sz.width() + 20, sz.height() * 2 );
+ pix.fill( white );
+ QPainter p( &pix, this );
+ p.drawText( 2, 0, pix.width(), pix.height(), 0, txt );
+ p.end();
+ pix.setMask( pix.createHeuristicMask() );
+ drag->setPixmap( pix );
+ oldPos = itm;
+ if ( !drag->drag() ) {
+ insertItem( txt, popup, -1, itm );
+ }
+ lastIndicatorPos = QPoint( -1, -1 );
+ indicator->hide();
+ mousePressed = false;
+}
+
+void QDesignerMenuBar::mouseReleaseEvent( QMouseEvent *e )
+{
+ QMenuBar::mouseReleaseEvent( e );
+ mousePressed = false;
+}
+
+#ifndef QT_NO_DRAGANDDROP
+
+void QDesignerMenuBar::dragEnterEvent( QDragEnterEvent *e )
+{
+ if ( e->provides( "application/x-designer-actions" ) ||
+ e->provides( "application/x-designer-actiongroup" ) ||
+ e->provides( "application/x-designer-separator" ) )
+ e->accept();
+ if ( e->provides( "application/x-designer-menuitem" ) )
+ e->accept();
+ lastIndicatorPos = QPoint( -1, -1 );
+ insertAt = -1;
+}
+
+void QDesignerMenuBar::dragMoveEvent( QDragMoveEvent *e )
+{
+ if ( e->provides( "application/x-designer-actions" ) ||
+ e->provides( "application/x-designer-menuitem" ) ||
+ e->provides( "application/x-designer-actiongroup" ) ||
+ e->provides( "application/x-designer-separator" ) )
+ e->accept();
+ else
+ return;
+ if ( e->provides( "application/x-designer-actions" ) ||
+ e->provides( "application/x-designer-actiongroup" ) ||
+ e->provides( "application/x-designer-separator" ) ) {
+ int item = itemAtPos( e->pos() );
+ bool uieffect = QApplication::isEffectEnabled( UI_AnimateMenu );
+ QApplication::setEffectEnabled( UI_AnimateMenu, false );
+ if ( !qApp->activePopupWidget() )
+ actItem = -1;
+ activateItemAt( item );
+ QApplication::setEffectEnabled( UI_AnimateMenu, uieffect );
+ if ( item == -1 )
+ hidePopups();
+ } else {
+ drawIndicator( calcIndicatorPos( e->pos() ) );
+ }
+}
+
+void QDesignerMenuBar::dragLeaveEvent( QDragLeaveEvent * )
+{
+ mousePressed = false;
+ lastIndicatorPos = QPoint( -1, -1 );
+ insertAt = -1;
+}
+
+void QDesignerMenuBar::dropEvent( QDropEvent *e )
+{
+ mousePressed = false;
+ if ( !e->provides( "application/x-designer-menuitem" ) )
+ return;
+ e->accept();
+ QString s( e->encodedData( "application/x-designer-menuitem" ) );
+ QString s1 = s.left( s.find( "/" ) );
+ QString s2 = s.mid( s.find( "/" ) + 1 );
+ QPopupMenu *popup = (QPopupMenu*)s1.toLong(); // #### huha, that is evil
+ QString txt = s2;
+ insertItem( txt, popup, -1, insertAt );
+
+ MoveMenuCommand *cmd = new MoveMenuCommand( i18n("Move Menu '%1'" ).arg( txt ), formWindow,
+ this, (QDesignerPopupMenu*)popup, oldPos, insertAt, txt );
+ // do not execute, we did the work already
+ formWindow->commandHistory()->addCommand( cmd );
+
+ indicator->hide();
+}
+
+#endif
+
+QPoint QDesignerMenuBar::calcIndicatorPos( const QPoint &pos )
+{
+ int w = frameWidth();
+ insertAt = count();
+ for ( int i = 0; i < (int)count(); ++i ) {
+ QRect r = itemRect( i );
+ if ( pos.x() < w + r.width() / 2 ) {
+ insertAt = i;
+ break;
+ }
+ w += r.width();
+ }
+
+ return QPoint( w, 0 );
+}
+
+void QDesignerMenuBar::drawIndicator( const QPoint &pos )
+{
+ if ( lastIndicatorPos == pos )
+ return;
+ bool wasVsisible = indicator->isVisible();
+ indicator->resize( 3, height() );
+ indicator->move( pos.x() - 1, 0 );
+ indicator->show();
+ indicator->raise();
+ lastIndicatorPos = pos;
+ if ( !wasVsisible )
+ QApplication::sendPostedEvents();
+}
+
+void QDesignerMenuBar::setItemNumber( int num )
+{
+ itemNum = num;
+}
+
+int QDesignerMenuBar::itemNumber() const
+{
+ return itemNum;
+}
+
+void QDesignerMenuBar::setItemText( const QString &s )
+{
+ if ( itemNum < 0 || itemNum >= (int)count() )
+ return;
+ changeItem( idAt( itemNum ), s );
+}
+
+QString QDesignerMenuBar::itemText() const
+{
+ if ( itemNum < 0 || (int)itemNum >= (int)count() )
+ return QString::null;
+ return text( idAt( itemNum ) );
+}
+
+void QDesignerMenuBar::setItemName( const QCString &s )
+{
+ if ( itemNum < 0 || itemNum >= (int)count() )
+ return;
+ findItem( idAt( itemNum ) )->popup()->setName( s );
+}
+
+QCString QDesignerMenuBar::itemName() const
+{
+ if ( itemNum < 0 || itemNum >= (int)count() )
+ return "";
+ return findItem( idAt( itemNum ) )->popup()->name();
+}
+
+
+
+QDesignerPopupMenu::QDesignerPopupMenu( QWidget *w )
+ : QPopupMenu( w, 0 ),
+ popupMenu( 0 )
+{
+ findFormWindow();
+ setAcceptDrops( true );
+ insertAt = -1;
+ mousePressed = false;
+ lastIndicatorPos = QPoint( -1, -1 );
+ indicator = new QDesignerIndicatorWidget( this );
+ indicator->hide();
+}
+
+void QDesignerPopupMenu::contextMenuEvent( QContextMenuEvent *e )
+{
+#if defined( Q_WS_MAC ) //the mac needs us to use context menu rather than right click
+ e->accept();
+ QMouseEvent me( QEvent::MouseButtonPress, e->pos(), e->globalPos(), RightButton, RightButton );
+ mousePressEvent(&me);
+#else
+ Q_UNUSED( e );
+#endif
+}
+
+void QDesignerPopupMenu::mousePressEvent( QMouseEvent *e )
+{
+ if ( e->button() == MidButton )
+ return;
+
+ if ( e->button() == RightButton ) {
+ // A popup for a popup, we only need one, so make sure that
+ // we don't create multiple. The timer keeps the event loop sane.
+ popupPos = e->globalPos();
+ popupLocalPos = e->pos();
+ if ( popupMenu ) {
+ popupMenu->close();
+ }
+ e->accept();
+ QTimer::singleShot( 0, this, SLOT(createPopupMenu()) );
+ return;
+ }
+ mousePressed = true;
+ dragStartPos = e->pos();
+ QPopupMenu::mousePressEvent( e );
+}
+
+void QDesignerPopupMenu::createPopupMenu()
+{
+ // actually creates our popup for the popupmenu.
+ QPopupMenu menu( 0 );
+ popupMenu = &menu;
+ int itm;
+ const int ID_DELETE = 1;
+ const int ID_SEP = 2;
+ itm = itemAtPos( popupLocalPos, false );
+ if ( itm == -1 )
+ return;
+ QAction *a = actionList.at( itm );
+ if ( a && a->inherits( "QSeparatorAction" ) )
+ menu.insertItem( i18n("Delete Separator" ), ID_DELETE );
+ else
+ menu.insertItem( i18n("Delete Item" ), ID_DELETE );
+ menu.insertItem( i18n("Insert Separator" ), ID_SEP );
+ int res = menu.exec( popupPos );
+ if ( res == ID_DELETE ) {
+ QAction *a = actionList.at( itm );
+ if ( !a )
+ return;
+ RemoveActionFromPopupCommand *cmd = new RemoveActionFromPopupCommand(
+ i18n("Delete Action '%1' From Popup Menu '%2'" ).
+ arg( a->name() ).arg( caption() ),
+ formWindow, a, this, itm );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ } else if ( res == ID_SEP ) {
+ QPoint p( pos() );
+ calcIndicatorPos( mapFromGlobal( popupPos ) );
+ QAction *a = new QSeparatorAction( 0 );
+ AddActionToPopupCommand *cmd = new AddActionToPopupCommand(
+ i18n("Add Separator to Popup Menu '%1'" ).
+ arg( name() ),
+ formWindow, a, this, insertAt );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ ( (QDesignerMenuBar*)( (QMainWindow*)parentWidget() )->menuBar() )->hidePopups();
+ ( (QDesignerMenuBar*)( (QMainWindow*)parentWidget() )->menuBar() )->activateItemAt( -1 );
+ popup( p );
+ }
+ // set this back to zero so we know a popup (will soon) not exist.
+ popupMenu = 0;
+}
+
+void QDesignerPopupMenu::mouseMoveEvent( QMouseEvent *e )
+{
+ if ( !mousePressed || e->state() == NoButton ) {
+ QPopupMenu::mouseMoveEvent( e );
+ return;
+ }
+ if ( QABS( QPoint( dragStartPos - e->pos() ).manhattanLength() ) < QApplication::startDragDistance() ) {
+ QPopupMenu::mouseMoveEvent( e );
+ return;
+ }
+ int itm = itemAtPos( dragStartPos, false );
+ if ( itm == -1 )
+ return;
+ QAction *a = actionList.at( itm );
+ if ( !a )
+ return;
+ RemoveActionFromPopupCommand *cmd = new RemoveActionFromPopupCommand( i18n("Delete Action '%1' From Popup Menu '%2'" ).
+ arg( a->name() ).arg( caption() ),
+ formWindow, a, this, itm );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+
+ QString type = a->inherits( "QActionGroup" ) ? QString( "application/x-designer-actiongroup" ) :
+ a->inherits( "QSeparatorAction" ) ? QString( "application/x-designer-separator" ) : QString( "application/x-designer-actions" );
+ QStoredDrag *drag = new QStoredDrag( type, this );
+ QString s = QString::number( (long)a ); // #### huha, that is evil
+ drag->setEncodedData( QCString( s.latin1() ) );
+ drag->setPixmap( a->iconSet().pixmap() );
+ if ( !drag->drag() ) {
+ AddActionToPopupCommand *cmd = new AddActionToPopupCommand( i18n("Add Action '%1' to Popup Menu '%2'" ).
+ arg( a->name() ).arg( name() ),
+ formWindow, a, this, itm );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ }
+ indicator->hide();
+ lastIndicatorPos = QPoint( -1, -1 );
+ mousePressed = false;
+}
+
+void QDesignerPopupMenu::mouseReleaseEvent( QMouseEvent *e )
+{
+ mousePressed = false;
+ QPopupMenu::mouseReleaseEvent( e );
+}
+
+#ifndef QT_NO_DRAGANDDROP
+
+void QDesignerPopupMenu::dragEnterEvent( QDragEnterEvent *e )
+{
+ mousePressed = false;
+ lastIndicatorPos = QPoint( -1, -1 );
+ if ( e->provides( "application/x-designer-actions" ) ||
+ e->provides( "application/x-designer-actiongroup" ) ||
+ e->provides( "application/x-designer-separator" ) )
+ e->accept();
+}
+
+void QDesignerPopupMenu::dragMoveEvent( QDragMoveEvent *e )
+{
+ mousePressed = false;
+ if ( e->provides( "application/x-designer-actions" ) ||
+ e->provides( "application/x-designer-actiongroup" ) ||
+ e->provides( "application/x-designer-separator" ) )
+ e->accept();
+ else
+ return;
+ drawIndicator( calcIndicatorPos( e->pos() ) );
+}
+
+void QDesignerPopupMenu::dragLeaveEvent( QDragLeaveEvent * )
+{
+ mousePressed = false;
+ indicator->hide();
+ insertAt = -1;
+}
+
+void QDesignerPopupMenu::dropEvent( QDropEvent *e )
+{
+ mousePressed = false;
+ if ( e->provides( "application/x-designer-actions" ) ||
+ e->provides( "application/x-designer-actiongroup" ) ||
+ e->provides( "application/x-designer-separator" ) )
+ e->accept();
+ else
+ return;
+
+ QPoint p = pos();
+ QAction *a = 0;
+ if ( e->provides( "application/x-designer-actiongroup" ) ) {
+ QString s( e->encodedData( "application/x-designer-actiongroup" ) );
+ a = (QDesignerActionGroup*)s.toLong();
+ } else {
+ QString s;
+ if ( e->provides( "application/x-designer-separator" ) ) {
+ s = QString( e->encodedData( "application/x-designer-separator" ) );
+ a = (QSeparatorAction*)s.toLong();
+ } else {
+ s = QString( e->encodedData( "application/x-designer-actions" ) );
+ a = (QDesignerAction*)s.toLong();
+ }
+ }
+
+ if ( actionList.findRef( a ) != -1 ) {
+ QMessageBox::warning( MainWindow::self, i18n("Insert/Move Action" ),
+ i18n("Action '%1' has already been added to this menu.\n"
+ "An Action may only occur once in a given menu." ).
+ arg( a->name() ) );
+ return;
+ }
+
+ AddActionToPopupCommand *cmd = new AddActionToPopupCommand( i18n("Add Action '%1' to Popup Menu '%2'" ).
+ arg( a->name() ).arg( name() ),
+ formWindow, a, this, insertAt );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+
+ ( (QDesignerMenuBar*)( (QMainWindow*)parentWidget() )->menuBar() )->hidePopups();
+ ( (QDesignerMenuBar*)( (QMainWindow*)parentWidget() )->menuBar() )->activateItemAt( -1 );
+ indicator->hide();
+ popup( p );
+}
+
+#endif
+
+void QDesignerPopupMenu::reInsert()
+{
+ clear();
+ for ( QAction *a = actionList.first(); a; a = actionList.next() )
+ a->addTo( this );
+}
+
+void QDesignerPopupMenu::drawIndicator( const QPoint &pos )
+{
+ if ( lastIndicatorPos == pos )
+ return;
+ bool wasVsisible = indicator->isVisible();
+ indicator->resize( width(), 3 );
+ indicator->move( 0, pos.y() - 1 );
+ indicator->show();
+ indicator->raise();
+ lastIndicatorPos = pos;
+ if ( !wasVsisible )
+ QApplication::sendPostedEvents();
+}
+
+QPoint QDesignerPopupMenu::calcIndicatorPos( const QPoint &pos )
+{
+ int h = frameWidth();
+ insertAt = count();
+ for ( int i = 0; i < (int)count(); ++i ) {
+ QRect r = itemGeometry( i );
+ if ( pos.y() < h + r.height() / 2 ) {
+ insertAt = i;
+ break;
+ }
+ h += r.height();
+ }
+
+ return QPoint( 0, h );
+}
+
+void QDesignerPopupMenu::addAction( QAction *a )
+{
+ actionList.append( a );
+ connect( a, SIGNAL( destroyed() ), this, SLOT( actionRemoved() ) );
+}
+
+void QDesignerPopupMenu::actionRemoved()
+{
+ actionList.removeRef( (QAction*)sender() );
+}
+
+void QDesignerPopupMenu::paintEvent( QPaintEvent *e )
+{
+ QPopupMenu::paintEvent( e );
+ if ( e->rect() != rect() )
+ return;
+ lastIndicatorPos = QPoint( -1, -1 );
+}
+
+void QDesignerPopupMenu::findFormWindow()
+{
+ QWidget *w = this;
+ while ( w ) {
+ if ( w->inherits( "FormWindow" ) )
+ formWindow = (FormWindow*)w;
+ w = w->parentWidget();
+ }
+}
+
+#include "actiondnd.moc"
diff --git a/kommander/editor/actiondnd.h b/kommander/editor/actiondnd.h
new file mode 100644
index 00000000..d99cc54c
--- /dev/null
+++ b/kommander/editor/actiondnd.h
@@ -0,0 +1,304 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef ACTIONDND_H
+#define ACTIONDND_H
+
+#include <qaction.h>
+#include <qmap.h>
+#include <qmenubar.h>
+#include <qpixmap.h>
+#include <qpopupmenu.h>
+#include <qptrlist.h>
+#include <qtoolbar.h>
+#include <qguardedptr.h>
+
+class QDesignerPopupMenu;
+class QDesignerIndicatorWidget;
+class FormWindow;
+
+class QDesignerActionGroup : public QActionGroup
+{
+ Q_OBJECT
+
+public:
+ QDesignerActionGroup( QObject *parent )
+ : QActionGroup( !parent || parent->inherits( "QActionGroup" ) ? parent : 0 ), wid( 0 ), idx( -1 ) {}
+
+ QWidget *widget() const { return wid; }
+ QWidget *widget( QAction *a ) const { return *widgets.find( a ); }
+ int index() const { return idx; }
+
+protected:
+ void addedTo( QWidget *w, QWidget * ) {
+ wid = w;
+ }
+ void addedTo( QWidget *w, QWidget *, QAction *a ) {
+ widgets.insert( a, w );
+ }
+ void addedTo( int index, QPopupMenu * ) {
+ idx = index;
+ }
+
+private:
+ QWidget *wid;
+ QMap<QAction *, QWidget *> widgets;
+ int idx;
+
+};
+
+class QDesignerAction : public QAction
+{
+ Q_OBJECT
+
+public:
+ QDesignerAction( QObject *parent )
+ : QAction( !parent || parent->inherits( "QActionGroup" ) ? parent : 0 ), wid( 0 ), idx( -1 ), widgetToInsert( 0 ) {}
+ QDesignerAction( QWidget *w, QObject *parent )
+ : QAction( !parent || parent->inherits( "QActionGroup" ) ? parent : 0 ), wid( 0 ), idx( -1 ), widgetToInsert( w ) {}
+
+ QWidget *widget() const { return wid; }
+ int index() const { return idx; }
+
+ bool addTo( QWidget *w );
+ bool removeFrom( QWidget *w );
+
+ void remove();
+ bool supportsMenu() const { return !widgetToInsert; }
+
+protected:
+ void addedTo( QWidget *w, QWidget * ) {
+ wid = w;
+ }
+ void addedTo( int index, QPopupMenu * ) {
+ idx = index;
+ }
+
+private:
+ QWidget *wid;
+ int idx;
+ QWidget *widgetToInsert;
+
+};
+
+class QDesignerToolBarSeparator : public QWidget
+{
+ Q_OBJECT
+
+public:
+ QDesignerToolBarSeparator( Orientation, QToolBar *parent, const char* name=0 );
+
+ QSize sizeHint() const;
+ Orientation orientation() const { return orient; }
+public slots:
+ void setOrientation( Orientation );
+protected:
+ void styleChange( QStyle& );
+ void paintEvent( QPaintEvent * );
+private:
+ Orientation orient;
+};
+
+
+class QSeparatorAction : public QAction
+{
+ Q_OBJECT
+
+public:
+ QSeparatorAction( QObject *parent );
+
+ bool addTo( QWidget *w );
+ bool removeFrom( QWidget *w );
+ QWidget *widget() const;
+ int index() const;
+
+private:
+ QWidget *wid;
+ int idx;
+
+};
+
+class QDesignerToolBar : public QToolBar
+{
+ Q_OBJECT
+
+public:
+ QDesignerToolBar( QMainWindow *mw );
+ QDesignerToolBar( QMainWindow *mw, Dock dock );
+ QPtrList<QAction> insertedActions() const { return actionList; }
+ void addAction( QAction *a );
+
+ void clear();
+ void installEventFilters( QWidget *w );
+ void insertAction( QWidget *w, QAction *a ) { actionMap.insert( w, a ); }
+ void insertAction( int index, QAction *a ) { actionList.insert( index, a ); }
+ void appendAction( QAction *a ) { actionList.append( a ); }
+ void removeAction( QAction *a ) { actionList.remove( a ); }
+ void reInsert();
+ void removeWidget( QWidget *w );
+
+protected:
+ bool eventFilter( QObject *, QEvent * );
+ void paintEvent( QPaintEvent * );
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent( QDragEnterEvent * );
+ void dragMoveEvent( QDragMoveEvent * );
+ void dragLeaveEvent( QDragLeaveEvent * );
+ void dropEvent( QDropEvent * );
+#endif
+ void contextMenuEvent( QContextMenuEvent *e );
+ void mousePressEvent( QMouseEvent *e );
+ void mouseReleaseEvent( QMouseEvent *e );
+
+private slots:
+ void actionRemoved();
+
+private:
+ void drawIndicator( const QPoint &pos );
+ QPoint calcIndicatorPos( const QPoint &pos );
+ void buttonContextMenuEvent( QContextMenuEvent *e, QObject *o );
+ void buttonMousePressEvent( QMouseEvent *e, QObject *o );
+ void buttonMouseMoveEvent( QMouseEvent *e, QObject *o );
+ void buttonMouseReleaseEvent( QMouseEvent *e, QObject *o );
+ void doInsertWidget( const QPoint &p );
+ void findFormWindow();
+
+private:
+ QPoint lastIndicatorPos;
+ QWidget *insertAnchor;
+ bool afterAnchor;
+ QPtrList<QAction> actionList;
+ QMap<QWidget*, QAction*> actionMap;
+ QPoint dragStartPos;
+ QDesignerIndicatorWidget *indicator;
+ bool widgetInserting;
+ FormWindow *formWindow;
+
+};
+
+class QDesignerMenuBar : public QMenuBar
+{
+ Q_OBJECT
+ friend class QDesignerPopupMenu;
+
+ Q_PROPERTY( int itemNumber WRITE setItemNumber READ itemNumber )
+ Q_PROPERTY( QString itemText WRITE setItemText READ itemText )
+ Q_PROPERTY( QCString itemName WRITE setItemName READ itemName )
+
+public:
+ QDesignerMenuBar( QWidget *mw );
+
+ void setItemNumber( int num );
+ int itemNumber() const;
+ void setItemText( const QString &s );
+ QString itemText() const;
+ void setItemName( const QCString &s );
+ QCString itemName() const;
+
+protected:
+ void mousePressEvent( QMouseEvent *e );
+ void mouseMoveEvent( QMouseEvent *e );
+ void mouseReleaseEvent( QMouseEvent *e );
+ void contextMenuEvent( QContextMenuEvent *e );
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent( QDragEnterEvent * );
+ void dragMoveEvent( QDragMoveEvent * );
+ void dragLeaveEvent( QDragLeaveEvent * );
+ void dropEvent( QDropEvent * );
+#endif
+
+private:
+ void drawIndicator( const QPoint &pos );
+ QPoint calcIndicatorPos( const QPoint &pos );
+ void findFormWindow();
+
+private:
+ int itemNum;
+ QPoint dragStartPos;
+ bool mousePressed;
+ QPoint lastIndicatorPos;
+ int insertAt;
+ QDesignerIndicatorWidget *indicator;
+ FormWindow *formWindow;
+ int oldPos;
+
+};
+
+class QDesignerPopupMenu : public QPopupMenu
+{
+ Q_OBJECT
+
+public:
+ QDesignerPopupMenu( QWidget *w );
+ QPtrList<QAction> insertedActions() const { return actionList; }
+ void addAction( QAction *a );
+ void reInsert();
+ void insertAction( int index, QAction *a ) { actionList.insert( index, a ); }
+ void removeAction( QAction *a ) { actionList.remove( a ); }
+
+protected:
+ void mousePressEvent( QMouseEvent *e );
+ void mouseMoveEvent( QMouseEvent *e );
+ void mouseReleaseEvent( QMouseEvent *e );
+ void contextMenuEvent( QContextMenuEvent *e );
+ void paintEvent( QPaintEvent * );
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent( QDragEnterEvent * );
+ void dragMoveEvent( QDragMoveEvent * );
+ void dragLeaveEvent( QDragLeaveEvent * );
+ void dropEvent( QDropEvent * );
+#endif
+
+private slots:
+ void actionRemoved();
+ void createPopupMenu();
+
+private:
+ void drawIndicator( const QPoint &pos );
+ QPoint calcIndicatorPos( const QPoint &pos );
+ void findFormWindow();
+
+private:
+ QPoint lastIndicatorPos;
+ int insertAt;
+ QPtrList<QAction> actionList;
+ QPoint dragStartPos;
+ bool mousePressed;
+ QDesignerIndicatorWidget *indicator;
+ FormWindow *formWindow;
+ QGuardedPtr<QPopupMenu> popupMenu;
+ QPoint popupPos;
+ QPoint popupLocalPos;
+
+};
+
+class QDesignerIndicatorWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ QDesignerIndicatorWidget( QWidget *p )
+ : QWidget( p, "qt_dockwidget_internal" ) {
+ setBackgroundColor( red );
+ }
+
+};
+
+#endif
diff --git a/kommander/editor/actioneditor.ui b/kommander/editor/actioneditor.ui
new file mode 100644
index 00000000..733e5b29
--- /dev/null
+++ b/kommander/editor/actioneditor.ui
@@ -0,0 +1,201 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>ActionEditorBase</class>
+<include location="local" implDecl="in declaration">actioneditor.ui.h</include>
+<forward>class QListViewItem;</forward>
+<layoutdefaults spacing="6" margin="11"/>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ActionEditorBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>206</width>
+ <height>227</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Edit Actions</string>
+ </property>
+ <property name="layoutMargin" stdset="0">
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QToolButton">
+ <property name="name">
+ <cstring>buttonNewAction</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image0</pixmap>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Create new Action</string>
+ </property>
+ </widget>
+ <widget class="QToolButton">
+ <property name="name">
+ <cstring>buttonDeleteAction</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image1</pixmap>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Delete current Action</string>
+ </property>
+ </widget>
+ <widget class="QToolButton">
+ <property name="name">
+ <cstring>buttonConnect</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image2</pixmap>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Connect current Action</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="ActionListView">
+ <property name="name">
+ <cstring>listActions</cstring>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>ActionListView</class>
+ <header location="local">actionlistview.h</header>
+ <sizehint>
+ <width>200</width>
+ <height>200</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>7</hordata>
+ <verdata>7</verdata>
+ </sizepolicy>
+ <pixmap>image3</pixmap>
+ <signal>selectionChanged( QListViewItem * )</signal>
+ <signal>currentChanged( QListViewItem * )</signal>
+ <signal>clicked( QListViewItem * )</signal>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="XPM.GZ" length="721">789cedd2310ac23014c6f13da778245b11ab29c114f1088aa3200eaf2f151daaa07510f1eef64553ac696fe04787fcf90dc9d03481cd7a09492aae35d647023ae0051277abaafb76b77808a93534df0ca67224e4180856e753c967d59cd5c48fb3e0d4b9269d7312a741e30c723a4e9b596333ce92930c69329cc8b9f7f3b7f42e886a1709bea70a3524142812172892325024182892f681bff2f1bf74a5bb2f19fe0f7ae439172f13a0a94f</data>
+ </image>
+ <image name="image1">
+ <data format="XPM.GZ" length="661">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523232520022630543251d2e253d856405bffcbc54105b19c856360003103711c6b53006abc40a90649491482ac92863955146d6822ca387474619c9301419a03842825819245bd064129513b1cb242602512216994430d44bc4904984c8c1a5e032897a3019a8144c26518f800c92715864d0ec81ab4dc4701b924fb0850e8a4cad351700fe117ccc</data>
+ </image>
+ <image name="image2">
+ <data format="XPM.GZ" length="1142">789cbdd1cb6e82401480e1bd4f4174671a1c70504cd3055e60d5a6cb264d17330378451450b44ddfbd73ce19489abae8caa30bbefccc108641df7a7b7db6fa834e59896aad2cb51285d58f4f59767dff78faea745dd7d2ffa16739dd874ed7b694f592ef13b85ee8eb1e630e971c786898605d1baad803ee5a622d1a2623e0b125d619d165b4f6d212ebd990d3dab225d60ae93bbe2f8121d061ae923170451cf2340506868a18217d7d33be9104baba2a5cbb6d483767c0e1849b07a5c491437509f4c478423c0105673ef3815343c5187083544dfd34343501aad8610eb206c69ec3897364d25018ea03005e81c9a8a9b9a1a97b64a21f848c8169ca19c76fdd238e27637c4145149ec0c3b16fce5d4b4fd0d8b21d2aa2a770e2c496e91267b5a62228c46263cb2d955d4665af07b6cb753a1c8b6359ee2a2a34b9fe9d6c599cf5ac7f15985a2728977f96ab0e9fb62ccb1bbbc18a2028ffee564f9b709e5199d7347a850cce380b3a1d136a389d308cc2288aeefc7d6e97efc7ce0ff25f14ae</data>
+ </image>
+ <image name="image3">
+ <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
+ </image>
+</images>
+<connections>
+ <connection language="C++">
+ <sender>listActions</sender>
+ <signal>currentChanged( QListViewItem * )</signal>
+ <receiver>ActionEditorBase</receiver>
+ <slot>currentActionChanged(QListViewItem*)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>listActions</sender>
+ <signal>clicked( QListViewItem * )</signal>
+ <receiver>ActionEditorBase</receiver>
+ <slot>currentActionChanged(QListViewItem*)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>listActions</sender>
+ <signal>selectionChanged( QListViewItem * )</signal>
+ <receiver>ActionEditorBase</receiver>
+ <slot>currentActionChanged(QListViewItem*)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>buttonNewAction</sender>
+ <signal>clicked()</signal>
+ <receiver>ActionEditorBase</receiver>
+ <slot>newAction()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>buttonConnect</sender>
+ <signal>clicked()</signal>
+ <receiver>ActionEditorBase</receiver>
+ <slot>connectionsClicked()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>buttonDeleteAction</sender>
+ <signal>clicked()</signal>
+ <receiver>ActionEditorBase</receiver>
+ <slot>deleteAction()</slot>
+ </connection>
+ <slot access="protected" language="C++" returnType="void">init()</slot>
+ <slot access="protected" language="C++" returnType="void">destroy()</slot>
+ <slot access="protected" language="C++" returnType="void">connectionsClicked()</slot>
+ <slot access="protected" language="C++" returnType="void">currentActionChanged( QListViewItem * )</slot>
+ <slot access="protected" language="C++" returnType="void">deleteAction()</slot>
+ <slot access="protected" language="C++" returnType="void">newAction()</slot>
+</connections>
+</UI>
diff --git a/kommander/editor/actioneditorimpl.cpp b/kommander/editor/actioneditorimpl.cpp
new file mode 100644
index 00000000..0d694250
--- /dev/null
+++ b/kommander/editor/actioneditorimpl.cpp
@@ -0,0 +1,261 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "actioneditorimpl.h"
+#include "formwindow.h"
+#include "metadatabase.h"
+#include "actionlistview.h"
+#include "connectioneditorimpl.h"
+#include "mainwindow.h"
+
+#include <qaction.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qtoolbutton.h>
+#include <qlistview.h>
+#include <qcheckbox.h>
+#include <qpushbutton.h>
+#include <qpopupmenu.h>
+#include <qobjectlist.h>
+
+#include <klocale.h>
+
+ActionEditor::ActionEditor( QWidget* parent, const char* name, WFlags fl )
+ : ActionEditorBase( parent, name, fl ), currentAction( 0 ), formWindow( 0 )
+{
+ listActions->addColumn( i18n("Actions" ) );
+ setEnabled( false );
+ buttonConnect->setEnabled( false );
+
+ QPopupMenu *popup = new QPopupMenu( this );
+ popup->insertItem( i18n("New &Action" ), this, SLOT( newAction() ) );
+ popup->insertItem( i18n("New Action &Group" ), this, SLOT( newActionGroup() ) );
+ popup->insertItem( i18n("New &Dropdown Action Group" ), this, SLOT( newDropDownActionGroup() ) );
+ buttonNewAction->setPopup( popup );
+ buttonNewAction->setPopupDelay( 0 );
+
+ connect( listActions, SIGNAL( insertAction() ), this, SLOT( newAction() ) );
+ connect( listActions, SIGNAL( insertActionGroup() ), this, SLOT( newActionGroup() ) );
+ connect( listActions, SIGNAL( insertDropDownActionGroup() ), this, SLOT( newDropDownActionGroup() ) );
+ connect( listActions, SIGNAL( deleteAction() ), this, SLOT( deleteAction() ) );
+ connect( listActions, SIGNAL( connectAction() ), this, SLOT( connectionsClicked() ) );
+}
+
+void ActionEditor::closeEvent( QCloseEvent *e )
+{
+ emit hidden();
+ e->accept();
+}
+
+void ActionEditor::currentActionChanged( QListViewItem *i )
+{
+ buttonConnect->setEnabled( i != 0 );
+ if ( !i )
+ return;
+ currentAction = ( (ActionItem*)i )->action();
+ if ( !currentAction )
+ currentAction = ( (ActionItem*)i )->actionGroup();
+ if ( formWindow && currentAction )
+ formWindow->setActiveObject( currentAction );
+}
+
+void ActionEditor::deleteAction()
+{
+ if ( !currentAction )
+ return;
+
+ QListViewItemIterator it( listActions );
+ while ( it.current() ) {
+ if ( ( (ActionItem*)it.current() )->action() == currentAction ) {
+ formWindow->actionList().removeRef( currentAction );
+ delete currentAction;
+ QValueList<MetaDataBase::Connection> conns =
+ MetaDataBase::connections( formWindow, currentAction );
+ for ( QValueList<MetaDataBase::Connection>::Iterator it2 = conns.begin();
+ it2 != conns.end(); ++it2 )
+ MetaDataBase::removeConnection( formWindow, (*it2).sender, (*it2).signal,
+ (*it2).receiver, (*it2).slot );
+ delete it.current();
+ break;
+ } else if ( ( (ActionItem*)it.current() )->actionGroup() == currentAction ) {
+ formWindow->actionList().removeRef( currentAction );
+ delete currentAction;
+ QValueList<MetaDataBase::Connection> conns =
+ MetaDataBase::connections( formWindow, currentAction );
+ for ( QValueList<MetaDataBase::Connection>::Iterator it2 = conns.begin();
+ it2 != conns.end(); ++it2 )
+ MetaDataBase::removeConnection( formWindow, (*it2).sender, (*it2).signal,
+ (*it2).receiver, (*it2).slot );
+ delete it.current();
+ break;
+ }
+ ++it;
+ }
+
+ if ( formWindow )
+ formWindow->setActiveObject( formWindow->mainContainer() );
+}
+
+void ActionEditor::newAction()
+{
+ ActionItem *actionParent = (ActionItem*)listActions->selectedItem();
+ if ( actionParent ) {
+ if ( !actionParent->actionGroup() ||
+ !actionParent->actionGroup()->inherits( "QActionGroup" ) )
+ actionParent = (ActionItem*)actionParent->parent();
+ }
+
+ ActionItem *i = 0;
+ if ( actionParent )
+ i = new ActionItem( actionParent );
+ else
+ i = new ActionItem( listActions, (bool)false );
+ MetaDataBase::addEntry( i->action() );
+ QString n = "Action";
+ formWindow->unify( i->action(), n, true );
+ i->setText( 0, n );
+ i->action()->setName( n );
+ i->action()->setText( i->action()->name() );
+ if ( actionParent && actionParent->actionGroup() &&
+ actionParent->actionGroup()->usesDropDown() ) {
+ i->action()->setToggleAction( true );
+ MetaDataBase::setPropertyChanged( i->action(), "toggleAction", true );
+ }
+ MetaDataBase::setPropertyChanged( i->action(), "text", true );
+ MetaDataBase::setPropertyChanged( i->action(), "name", true );
+ listActions->setCurrentItem( i );
+ if ( !actionParent )
+ formWindow->actionList().append( i->action() );
+}
+
+void ActionEditor::newActionGroup()
+{
+ ActionItem *actionParent = (ActionItem*)listActions->selectedItem();
+ if ( actionParent ) {
+ if ( !actionParent->actionGroup() ||
+ !actionParent->actionGroup()->inherits( "QActionGroup" ) )
+ actionParent = (ActionItem*)actionParent->parent();
+ }
+
+ ActionItem *i = 0;
+ if ( actionParent )
+ i = new ActionItem( actionParent, true );
+ else
+ i = new ActionItem( listActions, true );
+
+ MetaDataBase::addEntry( i->actionGroup() );
+ MetaDataBase::setPropertyChanged( i->actionGroup(), "usesDropDown", true );
+ QString n = "ActionGroup";
+ formWindow->unify( i->action(), n, true );
+ i->setText( 0, n );
+ i->actionGroup()->setName( n );
+ i->actionGroup()->setText( i->actionGroup()->name() );
+ MetaDataBase::setPropertyChanged( i->actionGroup(), "text", true );
+ MetaDataBase::setPropertyChanged( i->actionGroup(), "name", true );
+ listActions->setCurrentItem( i );
+ i->setOpen( true );
+ if ( !actionParent )
+ formWindow->actionList().append( i->actionGroup() );
+}
+
+void ActionEditor::newDropDownActionGroup()
+{
+ newActionGroup();
+ ( (ActionItem*)listActions->currentItem() )->actionGroup()->setUsesDropDown( true );
+}
+
+void ActionEditor::setFormWindow( FormWindow *fw )
+{
+ listActions->clear();
+ formWindow = fw;
+ if ( !formWindow ||
+ !formWindow->mainContainer() ||
+ !formWindow->mainContainer()->inherits( "QMainWindow" ) ) {
+ setEnabled( false );
+ } else {
+ setEnabled( true );
+ for ( QAction *a = formWindow->actionList().first(); a; a = formWindow->actionList().next() ) {
+ ActionItem *i = 0;
+ if ( a->parent() && a->parent()->inherits( "QAction" ) )
+ continue;
+ i = new ActionItem( listActions, a );
+ i->setText( 0, a->name() );
+ i->setPixmap( 0, a->iconSet().pixmap() );
+ if ( a->inherits( "QActionGroup" ) ) {
+ insertChildActions( i );
+ }
+ }
+ if ( listActions->firstChild() ) {
+ listActions->setCurrentItem( listActions->firstChild() );
+ listActions->setSelected( listActions->firstChild(), true );
+ }
+ }
+}
+
+void ActionEditor::insertChildActions( ActionItem *i )
+{
+ if ( !i->actionGroup() || !i->actionGroup()->children() )
+ return;
+ QObjectListIt it( *i->actionGroup()->children() );
+ while ( it.current() ) {
+ QObject *o = it.current();
+ ++it;
+ if ( !o->inherits( "QAction" ) )
+ continue;
+ QAction *a = (QAction*)o;
+ ActionItem *i2 = new ActionItem( (QListViewItem*)i, a );
+ i->setOpen( true );
+ i2->setText( 0, a->name() );
+ i2->setPixmap( 0, a->iconSet().pixmap() );
+ if ( a->inherits( "QActionGroup" ) )
+ insertChildActions( i2 );
+ }
+}
+
+void ActionEditor::updateActionName( QAction *a )
+{
+ QListViewItemIterator it( listActions );
+ while ( it.current() ) {
+ if ( ( (ActionItem*)it.current() )->action() == a )
+ ( (ActionItem*)it.current() )->setText( 0, a->name() );
+ else if ( ( (ActionItem*)it.current() )->actionGroup() == a )
+ ( (ActionItem*)it.current() )->setText( 0, a->name() );
+ ++it;
+ }
+}
+
+void ActionEditor::updateActionIcon( QAction *a )
+{
+ QListViewItemIterator it( listActions );
+ while ( it.current() ) {
+ if ( ( (ActionItem*)it.current() )->action() == a )
+ ( (ActionItem*)it.current() )->setPixmap( 0, a->iconSet().pixmap() );
+ else if ( ( (ActionItem*)it.current() )->actionGroup() == a )
+ ( (ActionItem*)it.current() )->setPixmap( 0, a->iconSet().pixmap() );
+ ++it;
+ }
+}
+
+void ActionEditor::connectionsClicked()
+{
+ ConnectionEditor editor( formWindow->mainWindow(), currentAction, formWindow, formWindow );
+ editor.exec();
+}
+#include "actioneditorimpl.moc"
diff --git a/kommander/editor/actioneditorimpl.h b/kommander/editor/actioneditorimpl.h
new file mode 100644
index 00000000..9ecfaaa5
--- /dev/null
+++ b/kommander/editor/actioneditorimpl.h
@@ -0,0 +1,64 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef ACTIONEDITOR_H
+#define ACTIONEDITOR_H
+
+#include "actioneditor.h"
+
+class QAction;
+class FormWindow;
+class ActionItem;
+
+class ActionEditor : public ActionEditorBase
+{
+ Q_OBJECT
+
+public:
+ ActionEditor( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ void setFormWindow( FormWindow *fw );
+ void updateActionName( QAction *a );
+ void updateActionIcon( QAction *a );
+ FormWindow *form() const { return formWindow; }
+
+protected:
+ void closeEvent( QCloseEvent *e );
+
+protected slots:
+ void currentActionChanged( QListViewItem * );
+ void deleteAction();
+ void newAction();
+ void newActionGroup();
+ void newDropDownActionGroup();
+ void connectionsClicked();
+
+signals:
+ void hidden();
+
+private:
+ void insertChildActions( ActionItem *i );
+
+private:
+ QAction *currentAction;
+ FormWindow *formWindow;
+
+};
+
+#endif // ACTIONEDITOR_H
diff --git a/kommander/editor/actionlistview.cpp b/kommander/editor/actionlistview.cpp
new file mode 100644
index 00000000..0db57f76
--- /dev/null
+++ b/kommander/editor/actionlistview.cpp
@@ -0,0 +1,111 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "actionlistview.h"
+#include <qdragobject.h>
+#include <qheader.h>
+
+#include <klocale.h>
+
+ActionListView::ActionListView( QWidget *parent, const char *name )
+ : QListView( parent, name )
+{
+ header()->setStretchEnabled( true );
+ setRootIsDecorated( true );
+ setSorting( -1 );
+ connect( this, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint &, int ) ),
+ this, SLOT( rmbMenu( QListViewItem *, const QPoint & ) ) );
+}
+
+ActionItem::ActionItem( QListView *lv, QAction *ac )
+ : QListViewItem( lv ), a( 0 ), g( 0 )
+{
+ if ( ac->inherits( "QActionGroup" ) )
+ g = (QDesignerActionGroup*)ac;
+ else
+ a = (QDesignerAction*)ac;
+ setDragEnabled( true );
+}
+
+ActionItem::ActionItem( QListViewItem *i, QAction *ac )
+ : QListViewItem( i ), a( 0 ), g( 0 )
+{
+ if ( ac->inherits( "QActionGroup" ) )
+ g = (QDesignerActionGroup*)ac;
+ else
+ a = (QDesignerAction*)ac;
+ setDragEnabled( true );
+ moveToEnd();
+}
+
+void ActionItem::moveToEnd()
+{
+ QListViewItem *i = this;
+ while ( i->nextSibling() )
+ i = i->nextSibling();
+ if ( i != this )
+ moveItem( i );
+}
+
+QDragObject *ActionListView::dragObject()
+{
+ ActionItem *i = (ActionItem*)currentItem();
+ if ( !i )
+ return 0;
+ QStoredDrag *drag = 0;
+ if ( i->action() ) {
+ drag = new QStoredDrag( "application/x-designer-actions", viewport() );
+ QString s = QString::number( (long)i->action() ); // #### huha, that is evil
+ drag->setEncodedData( QCString( s.latin1() ) );
+ drag->setPixmap( i->action()->iconSet().pixmap() );
+ } else {
+ drag = new QStoredDrag( "application/x-designer-actiongroup", viewport() );
+ QString s = QString::number( (long)i->actionGroup() ); // #### huha, that is evil
+ drag->setEncodedData( QCString( s.latin1() ) );
+ drag->setPixmap( i->actionGroup()->iconSet().pixmap() );
+ }
+ return drag;
+}
+
+void ActionListView::rmbMenu( QListViewItem *i, const QPoint &p )
+{
+ QPopupMenu *popup = new QPopupMenu( this );
+ popup->insertItem( i18n("New &Action" ), 0 );
+ popup->insertItem( i18n("New Action &Group" ), 1 );
+ popup->insertItem( i18n("New &Dropdown Action Group" ), 2 );
+ if ( i ) {
+ popup->insertSeparator();
+ popup->insertItem( i18n("&Connect Action..." ), 3 );
+ popup->insertSeparator();
+ popup->insertItem( i18n("Delete Action" ), 4 );
+ }
+ int res = popup->exec( p );
+ if ( res == 0 )
+ emit insertAction();
+ else if ( res == 1 )
+ emit insertActionGroup();
+ else if ( res == 2 )
+ emit insertDropDownActionGroup();
+ else if ( res == 3 )
+ emit connectAction();
+ else if ( res == 4 )
+ emit deleteAction();
+}
+#include "actionlistview.moc"
diff --git a/kommander/editor/actionlistview.h b/kommander/editor/actionlistview.h
new file mode 100644
index 00000000..33709068
--- /dev/null
+++ b/kommander/editor/actionlistview.h
@@ -0,0 +1,75 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef ACTIONLISTVIEW_H
+#define ACTIONLISTVIEW_H
+
+#include <qlistview.h>
+#include "actiondnd.h"
+
+class ActionItem : public QListViewItem
+{
+public:
+ ActionItem( QListView *lv, bool group )
+ : QListViewItem( lv ),
+ a( group ? 0 : new QDesignerAction( 0 ) ),
+ g( group ? new QDesignerActionGroup( 0 ) : 0 ) { setDragEnabled( TRUE ); }
+ ActionItem( QListView *lv, QAction *ac );
+ ActionItem( QListViewItem *i, QAction *ac );
+ ActionItem( ActionItem *parent, bool group = FALSE )
+ : QListViewItem( parent ),
+ a( group ? 0 : new QDesignerAction( parent->actionGroup() ) ),
+ g( group ? new QDesignerActionGroup( parent->actionGroup() ) : 0 ) { setDragEnabled( TRUE ); moveToEnd(); }
+
+ QDesignerAction *action() const { return a; }
+ QDesignerActionGroup *actionGroup() const { return g; }
+
+private:
+ void moveToEnd();
+
+private:
+ QDesignerAction *a;
+ QDesignerActionGroup *g;
+
+};
+
+class ActionListView : public QListView
+{
+ Q_OBJECT
+
+public:
+ ActionListView( QWidget *parent = 0, const char *name = 0 );
+
+protected:
+ QDragObject *dragObject();
+
+private slots:
+ void rmbMenu( QListViewItem *i, const QPoint &p );
+
+signals:
+ void insertAction();
+ void insertActionGroup();
+ void insertDropDownActionGroup();
+ void deleteAction();
+ void connectAction();
+
+};
+
+#endif
diff --git a/kommander/editor/asciivalidator.cpp b/kommander/editor/asciivalidator.cpp
new file mode 100644
index 00000000..776e6e9f
--- /dev/null
+++ b/kommander/editor/asciivalidator.cpp
@@ -0,0 +1,77 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "asciivalidator.h"
+
+#include <qstring.h>
+
+AsciiValidator::AsciiValidator( QObject * parent, const char *name )
+ : QValidator( parent, name ), functionName( false )
+{
+}
+
+AsciiValidator::AsciiValidator( bool funcName, QObject * parent, const char *name )
+ : QValidator( parent, name ), functionName( funcName )
+{
+}
+
+AsciiValidator::AsciiValidator( const QString &allow, QObject * parent, const char *name )
+ : QValidator( parent, name ), functionName( false ), allowedChars( allow )
+{
+}
+
+AsciiValidator::~AsciiValidator()
+{
+}
+
+QValidator::State AsciiValidator::validate( QString &s, int & ) const
+{
+ bool inParen = false;
+ if ( !s.isEmpty() && s[0].row() == 0 && s[0].cell() >= '0' && s[0].cell() <= '9' ) {
+ s[0] = '_';
+ }
+ for ( int i = 0; i < (int) s.length(); i++ ) {
+ uchar r = s[i].row();
+ uchar c = s[i].cell();
+ if ( functionName && inParen ) {
+ if ( c != ')' )
+ continue;
+ s.truncate( i + 1 );
+ return QValidator::Acceptable;
+ }
+ if ( r == 0 && ( ( c >= '0' && c <= '9' ) ||
+ ( c >= 'a' && c <= 'z' ) ||
+ ( c >= 'A' && c <= 'Z' ) ) )
+ continue;
+ if ( functionName ) {
+ if ( c == '(' ) {
+ inParen = true;
+ continue;
+ }
+ }
+
+ if ( allowedChars.find( s[ i ] ) != -1 )
+ continue;
+
+ s[i] = '_';
+ }
+ return QValidator::Acceptable;
+}
+#include "asciivalidator.moc"
diff --git a/kommander/editor/asciivalidator.h b/kommander/editor/asciivalidator.h
new file mode 100644
index 00000000..50d273c2
--- /dev/null
+++ b/kommander/editor/asciivalidator.h
@@ -0,0 +1,46 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef ASCIIVALIDATOR_H
+#define ASCIIVALIDATOR_H
+
+
+#include <qvalidator.h>
+
+
+class AsciiValidator: public QValidator
+{
+ Q_OBJECT
+public:
+ AsciiValidator( QObject * parent, const char *name = 0 );
+ AsciiValidator( bool funcName, QObject * parent, const char *name = 0 );
+ AsciiValidator( const QString &allow, QObject * parent, const char *name = 0 );
+ ~AsciiValidator();
+
+ QValidator::State validate( QString &, int & ) const;
+
+private:
+ bool functionName;
+ QString allowedChars;
+
+};
+
+
+#endif
diff --git a/kommander/editor/assistproc.cpp b/kommander/editor/assistproc.cpp
new file mode 100644
index 00000000..58ac4f78
--- /dev/null
+++ b/kommander/editor/assistproc.cpp
@@ -0,0 +1,74 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#include "assistproc.h"
+
+AssistProc::AssistProc( QObject *parent, const char *name, const QString &path )
+ : QProcess( parent, name )
+{
+ assistantPath = path;
+ connect( this, SIGNAL(readyReadStdout()), this, SLOT(processOutput()) );
+ connect( this, SIGNAL(readyReadStderr()), this, SLOT(processErrOutput()) );
+}
+
+AssistProc::~AssistProc()
+{
+ tryTerminate();
+ QTimer::singleShot( 5000, this, SLOT(kill())); // If busy, kill in 5 sec...
+}
+
+bool AssistProc::run( const QString &path )
+{
+ if ( !path.isEmpty() )
+ assistantPath = path;
+
+ clearArguments();
+ addArgument( assistantPath );
+ addArgument( "-stdin" );
+
+ if ( !start() ) {
+ qWarning( "Assistant [exe]: Couldn't start \'%s\', please check path.", assistantPath.latin1() );
+ return false;
+ }
+ return true;
+}
+
+bool AssistProc::sendRequest( const QString &data )
+{
+ if ( isRunning() ) {
+ writeToStdin( data );
+ } else {
+ if ( run() ) // If not running, try to start
+ writeToStdin( data ); // and display requested page.
+ else
+ return false;
+ }
+ return true;
+}
+
+void AssistProc::processOutput()
+{
+ qWarning( "Assistant [out]: %s", readStdout().data() );
+}
+
+void AssistProc::processErrOutput()
+{
+ qWarning( "Assistant [err]: %s", readStderr().data() );
+}
+#include "assistproc.moc"
diff --git a/kommander/editor/assistproc.h b/kommander/editor/assistproc.h
new file mode 100644
index 00000000..1f584daf
--- /dev/null
+++ b/kommander/editor/assistproc.h
@@ -0,0 +1,47 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#ifndef ASSISTPROC_H
+#define ASSISTPROC_H
+
+#include <qprocess.h>
+#include <qtimer.h>
+#include <qsocket.h>
+#include <qstring.h>
+
+class AssistProc : public QProcess
+{
+ Q_OBJECT
+public:
+ AssistProc( QObject *parent=0, const char * name = 0, const QString &path = QString::null );
+ ~AssistProc();
+ bool run( const QString &path = QString::null );
+
+public slots:
+ bool sendRequest( const QString &data );
+
+private slots:
+ void processOutput();
+ void processErrOutput();
+
+private:
+ QString assistantPath;
+};
+
+#endif // ASSISTPROC_H
diff --git a/kommander/editor/assoctexteditor.ui b/kommander/editor/assoctexteditor.ui
new file mode 100644
index 00000000..e3258b73
--- /dev/null
+++ b/kommander/editor/assoctexteditor.ui
@@ -0,0 +1,222 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>AssocTextEditorBase</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>AssocTextEditorBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>627</width>
+ <height>457</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Edit Text</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Widget:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>widgetsComboBox</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>widgetsComboBox</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>3</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>treeWidgetButton</cstring>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Text for:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>stateComboBox</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>stateComboBox</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>2</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox" row="2" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Insert</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>functionButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Function...</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Wi&amp;dget:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>widgetComboBox</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>widgetComboBox</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>3</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>150</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>filePushButton</cstring>
+ </property>
+ <property name="text">
+ <string>Fi&amp;le...</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QFrame" row="1" column="0">
+ <property name="name">
+ <cstring>editorFrame</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>AssocTextEditorBase</sender>
+ <signal>destroyed(QObject*)</signal>
+ <receiver>AssocTextEditorBase</receiver>
+ <slot>AssocTextEditorBase_destroyed(QObject*)</slot>
+ </connection>
+</connections>
+<slots>
+ <slot>AssocTextEditorBase_destroyed(QObject*)</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kommander/editor/assoctexteditorimpl.cpp b/kommander/editor/assoctexteditorimpl.cpp
new file mode 100644
index 00000000..25ac7f30
--- /dev/null
+++ b/kommander/editor/assoctexteditorimpl.cpp
@@ -0,0 +1,506 @@
+/***************************************************************************
+ assoctexteditorimpl.cpp - Associated text editor implementation
+ -------------------
+ copyright : (C) 2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+ (C) 2006 Andras Mantia <amantia@kde.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+#include <klocale.h>
+#include <kfiledialog.h>
+#include <kmessagebox.h>
+#include <kglobal.h>
+#include <kglobalsettings.h>
+#include <kiconloader.h>
+#include <kpushbutton.h>
+#include <ktextedit.h>
+#include <kdebug.h>
+#include <kpopupmenu.h>
+#include <kactioncollection.h>
+#include <kdebug.h>
+
+#include <ktexteditor/view.h>
+#include <ktexteditor/editorchooser.h>
+#include <ktexteditor/editinterface.h>
+#include <ktexteditor/viewcursorinterface.h>
+#include <ktexteditor/highlightinginterface.h>
+#include <ktexteditor/popupmenuinterface.h>
+#include <ktexteditor/undointerface.h>
+
+#include <kparts/partmanager.h>
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qmetaobject.h>
+#include <qcombobox.h>
+#include <qstring.h>
+#include <qfile.h>
+#include <qobject.h>
+#include <qobjectlist.h>
+#include <qtimer.h>
+#include <qevent.h>
+#include <qvaluelist.h>
+
+/* OTHER INCLUDES */
+#include <cstdio>
+#include "assoctexteditorimpl.h"
+#include "kommanderwidget.h"
+#include "formwindow.h"
+#include "propertyeditor.h"
+#include "command.h"
+#include "metadatabase.h"
+#include "choosewidgetimpl.h"
+#include "functionsimpl.h"
+
+QValueList<QWidget *> openedWidgets;
+
+AssocTextEditor::AssocTextEditor(QWidget *a_widget, FormWindow* a_form,
+ PropertyEditor* a_property, KParts::PartManager *partManager, QWidget *a_parent, const char *a_name, bool a_modal)
+ : AssocTextEditorBase(a_parent, a_name, a_modal)
+{
+ // text editor
+/* associatedTextEdit->setFont(KGlobalSettings::fixedFont());
+ associatedTextEdit->setTabStopWidth(associatedTextEdit->fontMetrics().maxWidth() * 3);
+ associatedTextEdit->setTextFormat(Qt::PlainText);*/
+
+ // icon for non-empty scripts
+ scriptPixmap = KGlobal::iconLoader()->loadIcon("source", KIcon::Small);
+
+ // signals and slots connections
+ m_formWindow = a_form;
+ m_propertyEditor = a_property;
+ m_widget = a_widget;
+
+ // list of widgets that can be edited
+ buildWidgetList();
+ for (int i=0; i<widgetsComboBox->count(); i++)
+ if (widgetFromString(widgetsComboBox->text(i)) == m_widget)
+ {
+ widgetsComboBox->setCurrentItem(i);
+ break;
+ }
+
+ doc = KTextEditor::createDocument ("libkatepart", a_parent, "KTextEditor::Document");
+ QGridLayout *layout = new QGridLayout(editorFrame, 1, 1);
+ view = doc->createView(editorFrame);
+ layout->addWidget(view, 1,1);
+ partManager->addPart(doc, true);
+
+ //trick to import all the KatePart actions into the dialog
+ KPopupMenu *invisiblePopup = new KPopupMenu(this);
+ KActionCollection *ac = view->actionCollection();
+ uint count = ac->count();
+ for (uint i = 0; i < count; i++)
+ {
+ ac->action(i)->plug(invisiblePopup);
+ }
+
+ //add those KatePart actions to a popup menu that are important
+ KPopupMenu *popup = new KPopupMenu(this);
+ KAction *a = view->actionCollection()->action("edit_undo");
+ if (a)
+ a->plug(popup);
+ a = view->actionCollection()->action("edit_redo");
+ if (a)
+ a->plug(popup);
+ popup->insertSeparator();
+ a = view->actionCollection()->action("edit_find");
+ if (a)
+ a->plug(popup);
+ a = view->actionCollection()->action("edit_find_next");
+ if (a)
+ a->plug(popup);
+ a = view->actionCollection()->action("edit_find_prev");
+ if (a)
+ a->plug(popup);
+ a = view->actionCollection()->action("edit_replace");
+ if (a)
+ a->plug(popup);
+ popup->insertSeparator();
+ a = view->actionCollection()->action("edit_cut");
+ if (a)
+ a->plug(popup);
+ a = view->actionCollection()->action("edit_copy");
+ if (a)
+ a->plug(popup);
+ a = view->actionCollection()->action("edit_paste");
+ if (a)
+ a->plug(popup);
+ readOnlyAction = view->actionCollection()->action("tools_toggle_write_lock");
+ popup->insertSeparator();
+ highlightPopup = new KPopupMenu(popup);
+ connect(highlightPopup, SIGNAL(activated(int)), SLOT(slotHighlightingChanged(int)));
+
+ popup->insertItem(i18n("&Highlighting"), highlightPopup);
+
+ KTextEditor::PopupMenuInterface *popupIf = dynamic_cast<KTextEditor::PopupMenuInterface *>(view);
+ popupIf->installPopup(popup);
+
+ associatedTextEdit = dynamic_cast<KTextEditor::EditInterface*>(doc);
+ readOnly = true;
+ if (readOnlyAction)
+ readOnlyAction->activate();
+ setWidget(a_widget);
+
+ connect(doc, SIGNAL(textChanged()), SLOT(textEditChanged()));
+ connect(widgetsComboBox, SIGNAL(activated(int)), SLOT(widgetChanged(int)));
+ connect(stateComboBox, SIGNAL(activated(int)), SLOT(stateChanged(int)));
+ connect(filePushButton, SIGNAL(clicked()), SLOT(insertFile()));
+ connect(functionButton, SIGNAL(clicked()), SLOT(insertFunction()));
+ connect(widgetComboBox, SIGNAL(activated(int)), SLOT(insertWidgetName(int)));
+ connect(treeWidgetButton, SIGNAL(clicked()), SLOT(selectWidget()));
+
+ view->setFocus();
+}
+
+AssocTextEditor::~AssocTextEditor()
+{
+ save();
+ delete doc;
+ if (!readOnly)
+ openedWidgets.remove(m_widget);
+}
+
+void AssocTextEditor::setWidget(QWidget *a_widget)
+{
+ KommanderWidget *a_atw = dynamic_cast<KommanderWidget *>(a_widget);
+ if (!a_widget || !a_atw)
+ return;
+
+
+ if (!readOnly)
+ openedWidgets.remove(m_widget);
+ if (readOnly)
+ {
+ if (readOnlyAction)
+ readOnlyAction->activate();
+ readOnly = false;
+ setCaption(i18n("Edit text"));
+ }
+
+ m_widget = a_widget;
+ m_states = a_atw->states();
+ m_populationText = a_atw->populationText();
+
+ // list of states of current widget (plus population text)
+ stateComboBox->clear();
+ stateComboBox->insertStringList(a_atw->displayStates());
+ stateComboBox->insertItem("population");
+
+ // set states and population scripts
+ QStringList at = a_atw->associatedText();
+ m_atdict.clear();
+ QStringList::iterator at_it = at.begin();
+ for(QStringList::ConstIterator s_it = m_states.begin(); s_it != m_states.end(); ++s_it)
+ {
+ if(at_it != at.end())
+ {
+ m_atdict[(*s_it)] = (*at_it);
+ ++at_it;
+ }
+ else
+ m_atdict[(*s_it)] = QString::null;
+ }
+ m_populationText = a_atw->populationText();
+
+ // show pixmaps for nonempty scripts
+ int m_initialization = -1;
+ int p_population = stateComboBox->count()-1;
+ int active = -1;
+ for (int i = 0; i < p_population; i++)
+ {
+ if (!m_atdict[stateComboBox->text(i)].isEmpty())
+ {
+ stateComboBox->changeItem(scriptPixmap, stateComboBox->text(i), i);
+ if (active == -1) active = i;
+ }
+ if (stateComboBox->text(i) == "initialization")
+ m_initialization = i;
+ }
+ if (!m_populationText.isEmpty())
+ {
+ stateComboBox->changeItem(scriptPixmap, stateComboBox->text(p_population), p_population);
+ if (active == -1) active = p_population;
+ }
+ if (active == -1 && m_initialization != -1)
+ {
+ active = m_initialization;
+ }
+ if (active == -1) active = 0;
+
+ // initial text for initial state
+ stateComboBox->setCurrentItem(active);
+ m_currentState = stateComboBox->currentText();
+ stateChanged(active);
+
+ KTextEditor::UndoInterface *undoIf = dynamic_cast<KTextEditor::UndoInterface*>(doc);
+ undoIf->clearUndo();
+
+
+ if (openedWidgets.contains(m_widget))
+ {
+ if (readOnlyAction && !readOnly)
+ readOnlyAction->activate();
+ setCaption(i18n("Edit text - read only mode"));
+ readOnly = true;
+ }
+ else
+ {
+ openedWidgets.append(m_widget);
+ }
+
+}
+
+void AssocTextEditor::save() const
+{
+ KommanderWidget *atw = dynamic_cast<KommanderWidget *>(m_widget);
+ if (!atw)
+ return;
+
+ if (atw->associatedText() != associatedText())
+ {
+ QString text = i18n("Set the \'text association\' of \'%1\'").arg(m_widget->name());
+ SetPropertyCommand *cmd = new SetPropertyCommand(text, m_formWindow,
+ m_widget, m_propertyEditor, "associations", atw->associatedText(),
+ associatedText(), QString::null, QString::null, false);
+ cmd->execute();
+ m_formWindow->commandHistory()->addCommand(cmd);
+ MetaDataBase::setPropertyChanged(m_widget, "associations", true);
+ }
+ if (atw->populationText() != populationText())
+ {
+ QString text = i18n("Set the \'population text\' of \'%1\'").arg(m_widget->name());
+ SetPropertyCommand *cmd = new SetPropertyCommand(text, m_formWindow, m_widget,
+ m_propertyEditor, "populationText", atw->populationText(),
+ populationText(), QString::null, QString::null, false);
+ cmd->execute();
+ m_formWindow->commandHistory()->addCommand(cmd);
+ MetaDataBase::setPropertyChanged(m_widget, "populationText", true);
+ }
+}
+
+
+QStringList AssocTextEditor::associatedText() const
+{
+ QStringList at;
+ for(QStringList::ConstIterator it = m_states.begin(); it != m_states.end(); ++it)
+ at.append(m_atdict[(*it)]);
+ return at;
+}
+
+QString AssocTextEditor::populationText() const
+{
+ return m_populationText;
+}
+
+QStringList AssocTextEditor::buildWidgetList()
+{
+ QStringList widgetList;
+ QObject* thisObject = m_formWindow->mainContainer();
+ QObjectList *objectList = thisObject->queryList();
+ objectList->prepend(thisObject);
+
+ for (QObjectListIt it(*objectList); it.current(); ++it)
+ {
+ // There is a warning message with the property() function if it does not exist.
+ // Verify the property exists with the meta information first */
+ bool pExists = false;
+ QMetaObject *metaObj = it.current()->metaObject();
+ if(metaObj)
+ {
+ int id = metaObj->findProperty("KommanderWidget", true);
+ const QMetaProperty *metaProp = metaObj->property(id, true);
+ if(metaProp && metaProp->isValid())
+ pExists = true;
+ }
+ if(pExists)
+ {
+ QVariant flag = (it.current())->property("KommanderWidget");
+ if(flag.isValid() && !(QString(it.current()->name()).startsWith("qt_")))
+ {
+ widgetList.append( widgetToString( (QWidget*)it.current()) );
+ m_widgetList.insert(it.current()->name(), (QWidget*)it.current());
+ }
+ }
+ }
+ delete objectList;
+
+ widgetList.sort();
+ widgetComboBox->clear();
+ widgetComboBox->insertStringList(widgetList);
+ widgetsComboBox->clear();
+ widgetsComboBox->insertStringList(widgetList);
+ return widgetList;
+}
+
+void AssocTextEditor::stateChanged(int a_index)
+{
+ m_currentState = stateComboBox->text(a_index);
+ if (a_index == stateComboBox->count() - 1)
+ associatedTextEdit->setText(m_populationText);
+ else
+ associatedTextEdit->setText(m_atdict[m_currentState]);
+ KTextEditor::ViewCursorInterface *viewCursorIf = dynamic_cast<KTextEditor::ViewCursorInterface*>(view);
+ viewCursorIf->setCursorPositionReal(0, 0);
+ highlightPopup->clear();
+ QString hlType = "Kommander (old parser)";
+ if (useInternalParser())
+ hlType = "Kommander (new parser)";
+ KTextEditor::HighlightingInterface *hlIf = dynamic_cast<KTextEditor::HighlightingInterface*>(doc);
+ if (hlIf)
+ {
+ uint hlCount = hlIf->hlModeCount();
+ for (uint i = 0; i < hlCount; i++)
+ {
+ if (hlIf->hlModeSectionName(i) == "Scripts")
+ highlightPopup->insertItem(hlIf->hlModeName(i), i);
+ if (hlIf->hlModeName(i).contains(hlType, false) > 0)
+ {
+ hlIf->setHlMode(i);
+ highlightPopup->setItemChecked(i, true);
+ oldHlMode = i;
+ }
+ }
+ }
+
+}
+
+void AssocTextEditor::textEditChanged()
+{
+ if (m_currentState == "population")
+ m_populationText = associatedTextEdit->text();
+ m_atdict[m_currentState] = associatedTextEdit->text();
+ int index = stateComboBox->currentItem();
+ if (associatedTextEdit->text().isEmpty())
+ stateComboBox->changeItem(QPixmap(), stateComboBox->currentText(), index);
+ else if (!stateComboBox->pixmap(index) || stateComboBox->pixmap(index)->isNull())
+ stateComboBox->changeItem(scriptPixmap, stateComboBox->currentText(), index);
+}
+
+void AssocTextEditor::widgetChanged(int index)
+{
+ save();
+ setWidget( widgetFromString( widgetsComboBox->text(index)) ) ;
+}
+
+void AssocTextEditor::selectWidget()
+{
+ ChooseWidget cDialog(this);
+ cDialog.setWidget(m_formWindow->mainContainer());
+ if (cDialog.exec()) {
+ QString newWidget = cDialog.selection();
+ for (int i = 0; i<widgetsComboBox->count(); i++)
+ if (widgetsComboBox->text(i) == newWidget) {
+ widgetsComboBox->setCurrentItem(i);
+ widgetChanged(i);
+ break;
+ }
+ }
+}
+
+
+
+void AssocTextEditor::insertAssociatedText(const QString& a_text)
+{
+ uint line, col;
+ KTextEditor::ViewCursorInterface *viewCursorIf = dynamic_cast<KTextEditor::ViewCursorInterface*>(view);
+ viewCursorIf->cursorPositionReal(&line, &col);
+ associatedTextEdit->insertText(line, col, a_text);
+}
+
+void AssocTextEditor::insertFile()
+{
+ QString fileName = KFileDialog::getOpenFileName();
+
+ if(fileName.isEmpty())
+ return;
+
+ QFile insertFile(fileName);
+ if(!insertFile.open(IO_ReadOnly))
+ {
+ KMessageBox::error( this, i18n("<qt>Cannot open file<br><b>%1</b></qt").arg( fileName ) );
+ return;
+ }
+ QTextStream insertStream(&insertFile);
+ QString insertText = insertStream.read();
+ insertAssociatedText(insertText);
+ insertFile.close();
+}
+
+void AssocTextEditor::insertWidgetName(int index)
+{
+ QString prefix;
+ if (!useInternalParser())
+ prefix = QString(QChar(ESCCHAR));
+ insertAssociatedText(prefix + widgetToString(widgetFromString(widgetComboBox->text(index)), false));
+}
+
+void AssocTextEditor::insertFunction()
+{
+ FunctionsDialog pDialog(this, m_widgetList, useInternalParser(), 0);
+ if (pDialog.exec())
+ insertAssociatedText(pDialog.functionText());
+}
+
+QString AssocTextEditor::widgetToString(QWidget* widget, bool formatted)
+{
+ if (!widget)
+ return QString::null;
+ else if (formatted)
+ return QString("%1 (%2)").arg(widget->name()).arg(widget->className());
+ else
+ return widget->name();
+}
+
+QWidget* AssocTextEditor::widgetFromString(const QString& name)
+{
+ QString realname = name;
+ int i = realname.find(' ');
+ if (i != -1)
+ realname.truncate(i);
+ return m_widgetList[realname];
+}
+
+void AssocTextEditor::slotHighlightingChanged(int mode)
+{
+ highlightPopup->setItemChecked(oldHlMode, false);
+ KTextEditor::HighlightingInterface *hlIf = dynamic_cast<KTextEditor::HighlightingInterface*>(doc);
+ if (hlIf)
+ hlIf->setHlMode(mode);
+ highlightPopup->setItemChecked(mode, true);
+ oldHlMode = mode;
+}
+
+bool AssocTextEditor::useInternalParser()
+{
+ QString s = "";
+ int line = -1;
+ while (s.isEmpty() && line < (int)associatedTextEdit->numLines())
+ {
+ line++;
+ s = associatedTextEdit->textLine(line);
+ }
+ s = s.stripWhiteSpace();
+ if (s.startsWith("#!") && s != "#!kommander")
+ return false; //code is written in external script, old parser is used
+ if (KommanderWidget::useInternalParser || s == "#!kommander")
+ return true;
+ return false;
+}
+
+void AssocTextEditor::closeEvent ( QCloseEvent * e )
+{
+ deleteLater();
+ e->accept();
+}
+
+#include "assoctexteditorimpl.moc"
diff --git a/kommander/editor/assoctexteditorimpl.h b/kommander/editor/assoctexteditorimpl.h
new file mode 100644
index 00000000..65879cef
--- /dev/null
+++ b/kommander/editor/assoctexteditorimpl.h
@@ -0,0 +1,133 @@
+/***************************************************************************
+ assoctexteditorimpl.h - Associated text editor implementation
+ -------------------
+ copyright : (C) 2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+ (C) 2006 Andras Mantia <amantia@kde.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_ASSOCTEXTEDITORIMPL_H_
+#define _HAVE_ASSOCTEXTEDITORIMPL_H_
+
+#include <qdict.h>
+#include <qstringlist.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qobject.h>
+#include <qmap.h>
+#include <qptrvector.h>
+#include <qpixmap.h>
+
+
+#include "assoctexteditor.h"
+#include <kommanderwidget.h>
+
+class FormWindow;
+class PropertyEditor;
+
+namespace KTextEditor {
+ class EditInterface;
+ class Document;
+ class View;
+}
+
+namespace KParts{
+ class PartManager;
+}
+
+class KAction;
+class KPopupMenu;
+
+class AssocTextEditor : public AssocTextEditorBase
+{
+ Q_OBJECT
+public:
+ AssocTextEditor(QWidget*, FormWindow*, PropertyEditor*, KParts::PartManager *partManager, QWidget*, const char* = 0, bool = true);
+ ~AssocTextEditor();
+ // Set interface for given widget.
+ void setWidget(QWidget *);
+ // Save changes for current widget
+ void save() const;
+ // Return population text for current widget
+ QString populationText() const;
+ // Return associated text for current widget
+ QStringList associatedText() const;
+
+public slots:
+ // Current script text has changed - save it in m_atdict
+ void textEditChanged();
+ // Current widget has changed - store script and update interface
+ void widgetChanged(int);
+ // Current script has changed - store script and show new script
+ void stateChanged(int);
+ // Select widget via widget tree dialog
+ void selectWidget();
+
+ // Functions for script editing:
+
+ // Insert given text at cursor position for current widget and state
+ void insertAssociatedText(const QString&);
+ // Select file and insert its content at cursor position
+ void insertFile();
+ // Open function browser and insert chosen function at cursor position
+ void insertFunction();
+ // Insert selected function at cursor position
+ void insertWidgetName(int);
+
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+
+protected slots:
+
+ void slotHighlightingChanged(int mode);
+
+private:
+ bool useInternalParser();
+
+ // Current widget
+ QWidget *m_widget;
+ KommanderWidget* m_kommanderWidget;
+//FIXME: could it be done more cleanly?
+ // Current form and property editor
+ FormWindow* m_formWindow;
+ PropertyEditor* m_propertyEditor;
+ // Current state
+ QString m_currentState;
+ // List of states for current widget
+ QStringList m_states;
+ // Current widget list
+ QDict<QWidget> m_widgetList;
+ // Dictionary for current widget; contains pairs (state, script associated with current state)
+ QMap<QString, QString> m_atdict;
+ // Current population text
+ QString m_populationText;
+ // Non-enmpty script pixmap
+ QPixmap scriptPixmap;
+
+ // Create list of all widgets on the same dialog as current widget
+ // Set store to true, to update m_widgetList;
+ QStringList buildWidgetList();
+ // Convert widget to string displayed in combos
+ // If formatted, return formatted string, else just widget's name
+ QString widgetToString(QWidget* widget, bool formatted = true);
+ // Conver combo string to widget
+ QWidget* widgetFromString(const QString& name);
+
+ KTextEditor::EditInterface *associatedTextEdit;
+ KTextEditor::Document *doc;
+ KTextEditor::View *view;
+ KPopupMenu *highlightPopup;
+ int oldHlMode;
+ bool readOnly;
+ KAction *readOnlyAction;
+};
+
+#endif
diff --git a/kommander/editor/choosewidget.ui b/kommander/editor/choosewidget.ui
new file mode 100644
index 00000000..809f38ea
--- /dev/null
+++ b/kommander/editor/choosewidget.ui
@@ -0,0 +1,150 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>ChooseWidgetBase</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>ChooseWidgetBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>431</width>
+ <height>390</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Choose Widget</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Horizontal Spacing2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Horizontal Spacing2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="KListView" row="0" column="0">
+ <property name="name">
+ <cstring>widgetView</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Find:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>nameEdit</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>ChooseWidgetBase</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>ChooseWidgetBase</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klistview.h</includehint>
+</includehints>
+</UI>
diff --git a/kommander/editor/choosewidgetimpl.cpp b/kommander/editor/choosewidgetimpl.cpp
new file mode 100644
index 00000000..53580a6e
--- /dev/null
+++ b/kommander/editor/choosewidgetimpl.cpp
@@ -0,0 +1,128 @@
+ /***************************************************************************
+ choosewidgetimpl.cpp - dialog to choose widget
+ -------------------
+ begin : Thu 13 Apr 2004
+ copyright : (C) 2000 Michal Rudolf <mrudolf@kdewebdev.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+ /** KDE INCLUDES */
+#include <klistview.h>
+#include <klocale.h>
+
+/** QT INCLUDES */
+#include <qptrstack.h>
+#include <qobject.h>
+#include <qobjectlist.h>
+#include <qlineedit.h>
+#include "qmetaobject.h"
+
+/** OTHER INCLUDES */
+#include "choosewidgetimpl.h"
+#include "choosewidgetimpl.moc"
+
+ChooseWidget::ChooseWidget(QWidget* a_parent, const char* a_name, bool a_modal)
+ : ChooseWidgetBase(a_parent, a_name, a_modal)
+{
+ connect( nameEdit, SIGNAL(textChanged(const QString&)), SLOT(textChanged(const QString&)) );
+ connect( widgetView, SIGNAL(executed(QListViewItem*)), SLOT(selectedItem(QListViewItem*)));
+ widgetView->setFullWidth(true);
+ widgetView->addColumn(i18n("Widgets"));
+ widgetView->setRootIsDecorated(true);
+ nameEdit->setFocus();
+}
+
+ChooseWidget::~ChooseWidget()
+{
+
+}
+
+void ChooseWidget::setWidget(QWidget* w)
+{
+ widgetView->clear();
+ if (!w)
+ return;
+
+ QListViewItem* item;
+ QPtrStack<QWidget> p_widgets;
+ QPtrStack<QListViewItem> p_items;
+
+ item = new QListViewItem(widgetView, QString("%1 (%2)").arg(w->name()).arg(w->className()));
+ item->setOpen(true);
+
+ p_widgets.push(w);
+ p_items.push(item);
+
+ while (!p_widgets.isEmpty()) {
+ w = p_widgets.pop();
+ item = p_items.pop();
+ QObjectList *objectList = w->queryList(0, 0, true, false);
+ for (QObjectListIt it(*objectList); it.current(); ++it) {
+ QListViewItem* newItem = item;
+ if (isKommanderWidget(*it))
+ newItem = new QListViewItem(item, QString("%1 (%2)").arg((*it)->name()).arg((*it)->className()));
+ if ((*it)->children()) {
+ p_widgets.push((QWidget*)(*it));
+ p_items.push(newItem);
+ }
+ }
+ delete objectList;
+ }
+ if (widgetView->childCount()) {
+ widgetView->setCurrentItem(widgetView->firstChild());
+ widgetView->firstChild()->setSelected(true);
+ }
+}
+
+
+QString ChooseWidget::selection()
+{
+ if (widgetView->currentItem())
+ return widgetView->currentItem()->text(0);
+ else
+ return QString::null;
+}
+
+void ChooseWidget::textChanged(const QString& text)
+{
+ QListViewItem* item = widgetView->findItem(text, 0, Qt::BeginsWith);
+ if (item) {
+ widgetView->setCurrentItem(item);
+ widgetView->ensureItemVisible(item);
+ }
+}
+
+bool ChooseWidget::isKommanderWidget(QObject* w)
+{
+ bool pExists = false;
+ QMetaObject *metaObj = w->metaObject();
+ if (metaObj)
+ {
+ int id = metaObj->findProperty("KommanderWidget", true);
+ const QMetaProperty *metaProp = metaObj->property(id, true);
+ if (metaProp && metaProp->isValid())
+ pExists = true;
+ }
+ if (pExists)
+ {
+ QVariant flag = (w)->property("KommanderWidget");
+ if(flag.isValid() && !(QString(w->name()).startsWith("qt_")))
+ return true;
+ }
+ return false;
+}
+
+void ChooseWidget::selectedItem(QListViewItem* item)
+{
+ if (item)
+ accept();
+}
+
diff --git a/kommander/editor/choosewidgetimpl.h b/kommander/editor/choosewidgetimpl.h
new file mode 100644
index 00000000..877bcd07
--- /dev/null
+++ b/kommander/editor/choosewidgetimpl.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+ choosewidgetimpl.h - dialog to choose widget
+ -------------------
+ begin : Thu 13 Apr 2004
+ copyright : (C) 2000 Michal Rudolf <mrudolf@kdewebdev.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_CHOOSEWIDGETIMPL_H_
+#define _HAVE_CHOOSEWIDGETIMPL_H_
+
+#include "choosewidget.h"
+
+class ChooseWidget : public ChooseWidgetBase
+{
+ Q_OBJECT
+public:
+ ChooseWidget(QWidget*, const char* = 0, bool=true);
+ ~ChooseWidget();
+ // Put current widget and all of its children in a tree
+ void setWidget(QWidget *);
+ // Return current widget
+ QString selection();
+
+public slots:
+ // Filter text changed - find matching widget
+ void textChanged(const QString&);
+ // Double clicked on listviwew
+ void selectedItem(QListViewItem *);
+private:
+ // Check if given widget is a Kommander widget
+ bool isKommanderWidget(QObject* w);
+
+};
+
+#endif
+
diff --git a/kommander/editor/command.cpp b/kommander/editor/command.cpp
new file mode 100644
index 00000000..b6bbe82c
--- /dev/null
+++ b/kommander/editor/command.cpp
@@ -0,0 +1,1838 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#include <scriptobject.h>
+#include "command.h"
+#include "formwindow.h"
+#include "widgetfactory.h"
+#include "propertyeditor.h"
+#include "metadatabase.h"
+#include "widgetdatabase.h"
+#include "mainwindow.h"
+#include "hierarchyview.h"
+#include "workspace.h"
+#include "actioneditorimpl.h"
+#include "actiondnd.h"
+#include "formfile.h"
+
+#include <qmap.h>
+#include <qfeatures.h>
+#include <qwidget.h>
+#include <qmetaobject.h>
+#include <qapplication.h>
+#include <qlayout.h>
+#include <qmessagebox.h>
+#include <qlistbox.h>
+#include <qiconview.h>
+#include <qmultilineedit.h>
+#include <qptrstack.h>
+#include <qheader.h>
+#ifndef QT_NO_TABLE
+#include <qtable.h>
+#endif
+#include <qaction.h>
+
+#include <klocale.h>
+
+
+CommandHistory::CommandHistory( int s )
+ : current( -1 ), steps( s ), savedAt( -1 )
+{
+ history.setAutoDelete( true );
+ modified = false;
+ compressedCommand = 0;
+}
+
+void CommandHistory::addCommand( Command *cmd, bool tryCompress )
+{
+ if ( tryCompress ) {
+ if ( !compressedCommand ||
+ compressedCommand->type() != cmd->type() ||
+ !compressedCommand->canMerge( cmd ) ) {
+ checkCompressedCommand();
+ compressedCommand = 0;
+ }
+
+ if ( compressedCommand ) {
+ compressedCommand->merge( cmd );
+ modified = true;
+ modificationChanged( modified );
+ return;
+ }
+ compressedCommand = cmd;
+ } else {
+ checkCompressedCommand();
+ }
+
+ if ( current < (int)history.count() - 1 ) {
+ if ( current < savedAt )
+ savedAt = -2;
+
+ QPtrList<Command> commands;
+ commands.setAutoDelete( false );
+
+ for( int i = 0; i <= current; ++i ) {
+ commands.insert( i, history.at( 0 ) );
+ history.take( 0 );
+ }
+
+ commands.append( cmd );
+ history.clear();
+ history = commands;
+ history.setAutoDelete( true );
+ } else {
+ history.append( cmd );
+ }
+
+ if ( (int)history.count() > steps ) {
+ savedAt--;
+ history.removeFirst();
+ } else {
+ ++current;
+ }
+
+ emitUndoRedo();
+ modified = true;
+ modificationChanged( modified );
+}
+
+void CommandHistory::undo()
+{
+ checkCompressedCommand();
+ compressedCommand = 0;
+ if ( current > -1 ) {
+ history.at( current )->unexecute();
+ --current;
+ }
+ emitUndoRedo();
+ modified = savedAt != current;
+ modificationChanged( modified );
+}
+
+void CommandHistory::redo()
+{
+ checkCompressedCommand();
+ compressedCommand = 0;
+ if ( current > -1 ) {
+ if ( current < (int)history.count() - 1 ) {
+ ++current;
+ history.at( current )->execute();
+ }
+ } else {
+ if ( history.count() > 0 ) {
+ ++current;
+ history.at( current )->execute();
+ }
+ }
+ emitUndoRedo();
+ modified = savedAt != current;
+ modificationChanged( modified );
+}
+
+void CommandHistory::emitUndoRedo()
+{
+ Command *undoCmd = 0;
+ Command *redoCmd = 0;
+
+ if ( current >= 0 && current < (int)history.count() )
+ undoCmd = history.at( current );
+ if ( current + 1 >= 0 && current + 1 < (int)history.count() )
+ redoCmd = history.at( current + 1 );
+
+ bool ua = (undoCmd != 0);
+ QString uc;
+ if ( ua )
+ uc = undoCmd->name();
+ bool ra = (redoCmd != 0);
+ QString rc;
+ if ( ra )
+ rc = redoCmd->name();
+ emit undoRedoChanged( ua, ra, uc, rc );
+}
+
+void CommandHistory::setModified( bool m )
+{
+ modified = m;
+ if ( !modified )
+ savedAt = current;
+ modificationChanged( modified );
+}
+
+bool CommandHistory::isModified() const
+{
+ return modified;
+}
+
+void CommandHistory::checkCompressedCommand()
+{
+ if ( compressedCommand && compressedCommand->type() == Command::SetProperty ) {
+ Command *c = compressedCommand;
+ compressedCommand = 0;
+ if ( !( (SetPropertyCommand*)c )->checkProperty() ) {
+ history.remove( current );
+ --current;
+ emitUndoRedo();
+ }
+ }
+}
+
+// ------------------------------------------------------------
+
+Command::Command( const QString &n, FormWindow *fw )
+ : cmdName( n ), formWin( fw )
+{
+}
+
+Command::~Command()
+{
+}
+
+QString Command::name() const
+{
+ return cmdName;
+}
+
+FormWindow *Command::formWindow() const
+{
+ return formWin;
+}
+
+void Command::merge( Command * )
+{
+}
+
+bool Command::canMerge( Command * )
+{
+ return false;
+}
+
+
+// ------------------------------------------------------------
+
+ResizeCommand::ResizeCommand( const QString &n, FormWindow *fw,
+ QWidget *w, const QRect &oldr, const QRect &nr )
+ : Command( n, fw ), widget( w ), oldRect( oldr ), newRect( nr )
+{
+}
+
+void ResizeCommand::execute()
+{
+ widget->setGeometry( newRect );
+ formWindow()->updateSelection( widget );
+ formWindow()->emitUpdateProperties( widget );
+ if ( WidgetFactory::layoutType( widget ) != WidgetFactory::NoLayout )
+ formWindow()->updateChildSelections( widget );
+}
+
+void ResizeCommand::unexecute()
+{
+ widget->setGeometry( oldRect );
+ formWindow()->updateSelection( widget );
+ formWindow()->emitUpdateProperties( widget );
+ if ( WidgetFactory::layoutType( widget ) != WidgetFactory::NoLayout )
+ formWindow()->updateChildSelections( widget );
+}
+
+// ------------------------------------------------------------
+
+InsertCommand::InsertCommand( const QString &n, FormWindow *fw,
+ QWidget *w, const QRect &g )
+ : Command( n, fw ), widget( w ), geometry( g )
+{
+}
+
+void InsertCommand::execute()
+{
+ if ( geometry.size() == QSize( 0, 0 ) ) {
+ widget->move( geometry.topLeft() );
+ widget->adjustSize();
+ } else {
+ QSize s = geometry.size().expandedTo( widget->minimumSize() );
+ s = s.expandedTo( widget->minimumSizeHint() );
+ QRect r( geometry.topLeft(), s );
+ widget->setGeometry( r );
+ }
+ widget->show();
+ formWindow()->widgets()->insert( widget, widget );
+ formWindow()->clearSelection( false );
+ formWindow()->selectWidget( widget );
+ formWindow()->mainWindow()->objectHierarchy()->widgetInserted( widget );
+}
+
+void InsertCommand::unexecute()
+{
+ widget->hide();
+ formWindow()->selectWidget( widget, false );
+ formWindow()->widgets()->remove( widget );
+ formWindow()->mainWindow()->objectHierarchy()->widgetRemoved( widget );
+ }
+
+// ------------------------------------------------------------
+
+MoveCommand::MoveCommand( const QString &n, FormWindow *fw,
+ const QWidgetList &w,
+ const QValueList<QPoint> op,
+ const QValueList<QPoint> np,
+ QWidget *opr, QWidget *npr )
+ : Command( n, fw ), widgets( w ), oldPos( op ), newPos( np ),
+ oldParent( opr ), newParent( npr )
+{
+ widgets.setAutoDelete( false );
+}
+
+void MoveCommand::merge( Command *c )
+{
+ MoveCommand *cmd = (MoveCommand*)c;
+ newPos = cmd->newPos;
+}
+
+bool MoveCommand::canMerge( Command *c )
+{
+ MoveCommand *cmd = (MoveCommand*)c;
+ return widgets == cmd->widgets;
+}
+
+
+void MoveCommand::execute()
+{
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
+ if ( !w->parentWidget() || WidgetFactory::layoutType( w->parentWidget() ) == WidgetFactory::NoLayout ) {
+ if ( newParent && oldParent && newParent != oldParent ) {
+ QPoint pos = newParent->mapFromGlobal( w->mapToGlobal( QPoint( 0,0 ) ) );
+ w->reparent( newParent, pos, true );
+ formWindow()->raiseSelection( w );
+ formWindow()->raiseChildSelections( w );
+ formWindow()->widgetChanged( w );
+ formWindow()->mainWindow()->objectHierarchy()->widgetRemoved( w );
+ formWindow()->mainWindow()->objectHierarchy()->widgetInserted( w );
+ }
+ w->move( newPos[ widgets.at() ] );
+ }
+ formWindow()->updateSelection( w );
+ formWindow()->updateChildSelections( w );
+ formWindow()->emitUpdateProperties( w );
+ }
+}
+
+void MoveCommand::unexecute()
+{
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
+ if ( !w->parentWidget() || WidgetFactory::layoutType( w->parentWidget() ) == WidgetFactory::NoLayout ) {
+ if ( newParent && oldParent && newParent != oldParent ) {
+ QPoint pos = oldParent->mapFromGlobal( w->mapToGlobal( QPoint( 0,0 ) ) );
+ w->reparent( oldParent, pos, true );
+ formWindow()->raiseSelection( w );
+ formWindow()->raiseChildSelections( w );
+ formWindow()->widgetChanged( w );
+ formWindow()->mainWindow()->objectHierarchy()->widgetRemoved( w );
+ formWindow()->mainWindow()->objectHierarchy()->widgetInserted( w );
+ }
+ w->move( oldPos[ widgets.at() ] );
+ }
+ formWindow()->updateSelection( w );
+ formWindow()->updateChildSelections( w );
+ formWindow()->emitUpdateProperties( w );
+ }
+}
+
+// ------------------------------------------------------------
+
+DeleteCommand::DeleteCommand( const QString &n, FormWindow *fw,
+ const QWidgetList &w )
+ : Command( n, fw ), widgets( w )
+{
+ widgets.setAutoDelete( false );
+}
+
+void DeleteCommand::execute()
+{
+ formWindow()->setPropertyShowingBlocked( true );
+ connections.clear();
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
+ w->hide();
+ QString s = w->name();
+ s.prepend( "qt_dead_widget_" );
+ w->setName( s );
+ formWindow()->selectWidget( w, false );
+ formWindow()->widgets()->remove( w );
+ QValueList<MetaDataBase::Connection> conns = MetaDataBase::connections( formWindow(), w );
+ connections.insert( w, conns );
+ QValueList<MetaDataBase::Connection>::Iterator it = conns.begin();
+ for ( ; it != conns.end(); ++it ) {
+ MetaDataBase::removeConnection( formWindow(), (*it).sender,
+ (*it).signal, (*it).receiver, (*it).slot );
+ }
+ }
+ formWindow()->setPropertyShowingBlocked( false );
+ formWindow()->emitShowProperties();
+ formWindow()->mainWindow()->objectHierarchy()->widgetsRemoved( widgets );
+
+}
+
+void DeleteCommand::unexecute()
+{
+ formWindow()->setPropertyShowingBlocked( true );
+ formWindow()->clearSelection( false );
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
+ w->show();
+ QString s = w->name();
+ s.remove( 0, QString( "qt_dead_widget_" ).length() );
+ w->setName( s );
+ formWindow()->widgets()->insert( w, w );
+ formWindow()->selectWidget( w );
+ QValueList<MetaDataBase::Connection> conns = *connections.find( w );
+ QValueList<MetaDataBase::Connection>::Iterator it = conns.begin();
+ for ( ; it != conns.end(); ++it ) {
+ MetaDataBase::addConnection( formWindow(), (*it).sender,
+ (*it).signal, (*it).receiver, (*it).slot );
+ }
+ }
+ formWindow()->setPropertyShowingBlocked( false );
+ formWindow()->emitShowProperties();
+ formWindow()->mainWindow()->objectHierarchy()->widgetsInserted( widgets );
+}
+
+// ------------------------------------------------------------
+
+SetPropertyCommand::SetPropertyCommand( const QString &n, FormWindow *fw,
+ QObject *w, PropertyEditor *e,
+ const QString &pn, const QVariant &ov,
+ const QVariant &nv, const QString &ncut,
+ const QString &ocut, bool reset )
+ : Command( n, fw ), widget( w ), editor( e ), propName( pn ),
+ oldValue( ov ), newValue( nv ), oldCurrentItemText( ocut ), newCurrentItemText( ncut ),
+ wasChanged( true ), isResetCommand( reset )
+{
+ wasChanged = MetaDataBase::isPropertyChanged( w, propName );
+}
+
+
+void SetPropertyCommand::execute()
+{
+ if ( !wasChanged )
+ MetaDataBase::setPropertyChanged( widget, propName, true );
+ if ( isResetCommand ) {
+ MetaDataBase::setPropertyChanged( widget, propName, false );
+ if ( WidgetFactory::resetProperty( widget, propName ) ) {
+ if ( !formWindow()->isWidgetSelected( widget ) && widget != formWindow() )
+ formWindow()->selectWidget( widget );
+ if ( editor->widget() != widget )
+ editor->setWidget( widget, formWindow() );
+ editor->propertyList()->setCurrentProperty( propName );
+ PropertyItem *i = (PropertyItem*)editor->propertyList()->currentItem();
+ if ( !i )
+ return;
+ i->setValue( widget->property( propName ) );
+ i->setChanged( false );
+ editor->refetchData();
+ editor->emitWidgetChanged();
+ return;
+ }
+ }
+ setProperty( newValue, newCurrentItemText );
+}
+
+void SetPropertyCommand::unexecute()
+{
+ if ( !wasChanged )
+ MetaDataBase::setPropertyChanged( widget, propName, false );
+ if ( isResetCommand )
+ MetaDataBase::setPropertyChanged( widget, propName, true );
+ setProperty( oldValue, oldCurrentItemText );
+}
+
+bool SetPropertyCommand::canMerge( Command *c )
+{
+ SetPropertyCommand *cmd = (SetPropertyCommand*)c;
+ const QMetaProperty *p =
+ widget->metaObject()->property( widget->metaObject()->findProperty( propName, true ), true );
+ if ( !p ) {
+ if ( propName == "toolTip" || propName == "whatsThis" )
+ return true;
+ if ( widget->inherits( "CustomWidget" ) ) {
+ MetaDataBase::CustomWidget *cw = ( (CustomWidget*)widget )->customWidget();
+ if ( !cw )
+ return false;
+ for ( QValueList<MetaDataBase::Property>::Iterator it = cw->lstProperties.begin(); it != cw->lstProperties.end(); ++it ) {
+ if ( QString( (*it ).property ) == propName ) {
+ if ( (*it).type == "String" || (*it).type == "CString" || (*it).type == "Int" || (*it).type == "UInt" )
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ QVariant::Type t = QVariant::nameToType( p->type() );
+ return ( cmd->propName == propName &&
+ t == QVariant::String || t == QVariant::CString || t == QVariant::Int || t == QVariant::UInt );
+}
+
+void SetPropertyCommand::merge( Command *c )
+{
+ SetPropertyCommand *cmd = (SetPropertyCommand*)c;
+ newValue = cmd->newValue;
+ newCurrentItemText = cmd->newCurrentItemText;
+}
+
+bool SetPropertyCommand::checkProperty()
+{
+ if ( propName == "name" /*|| propName == "itemName"*/ ) { // ### fix that
+ QString s = newValue.toString();
+ if ( !formWindow()->unify( widget, s, false ) ) {
+ QMessageBox::information( formWindow()->mainWindow(),
+ i18n("Set 'name' Property" ),
+ i18n("The name of a widget must be unique.\n"
+ "'%1' is already used in form '%2',\n"
+ "so the name has been reverted to '%3'." ).
+ arg( newValue.toString() ).
+ arg( formWindow()->name() ).
+ arg( oldValue.toString() ));
+ setProperty( oldValue, oldCurrentItemText, false );
+ return false;
+ }
+ if ( s.isEmpty() ) {
+ QMessageBox::information( formWindow()->mainWindow(),
+ i18n("Set 'name' Property" ),
+ i18n("The name of a widget must not be null.\n"
+ "The name has been reverted to '%1'." ).
+ arg( oldValue.toString() ));
+ setProperty( oldValue, oldCurrentItemText, false );
+ return false;
+ }
+
+ if ( widget->parent() && widget->parent()->inherits( "FormWindow" ) )
+ formWindow()->mainWindow()->formNameChanged( (FormWindow*)( (QWidget*)widget )->parentWidget() );
+ }
+ return true;
+}
+
+void SetPropertyCommand::setProperty( const QVariant &v, const QString &currentItemText, bool select )
+{
+ if ( !formWindow()->isWidgetSelected( widget ) && !formWindow()->isMainContainer( widget ) && select )
+ formWindow()->selectWidget( widget );
+ if ( editor->widget() != widget && select )
+ editor->setWidget( widget, formWindow() );
+ if ( select )
+ editor->propertyList()->setCurrentProperty( propName );
+
+ const QMetaProperty *p =
+ widget->metaObject()->property( widget->metaObject()->findProperty( propName, true ), true );
+ if ( !p ) {
+ if ( propName == "hAlign" ) {
+ p = widget->metaObject()->property( widget->metaObject()->findProperty( "alignment", true ), true );
+ int align = widget->property( "alignment" ).toInt();
+ align &= ~( AlignHorizontal_Mask );
+ align |= p->keyToValue( currentItemText );
+ widget->setProperty( "alignment", QVariant( align ) );
+ } else if ( propName == "vAlign" ) {
+ p = widget->metaObject()->property( widget->metaObject()->findProperty( "alignment", true ), true );
+ int align = widget->property( "alignment" ).toInt();
+ align &= ~( AlignVertical_Mask );
+ align |= p->keyToValue( currentItemText );
+ widget->setProperty( "alignment", QVariant( align ) );
+ } else if ( propName == "wordwrap" ) {
+ int align = widget->property( "alignment" ).toInt();
+ align &= ~WordBreak;
+ if ( v.toBool() )
+ align |= WordBreak;
+ widget->setProperty( "alignment", QVariant( align ) );
+ } else if ( propName == "layoutSpacing" ) {
+ MetaDataBase::setSpacing( WidgetFactory::containerOfWidget( (QWidget*)editor->widget() ), v.toInt() );
+ } else if ( propName == "layoutMargin" ) {
+ MetaDataBase::setMargin( WidgetFactory::containerOfWidget( (QWidget*)editor->widget() ), v.toInt() );
+ } else if ( propName == "toolTip" || propName == "whatsThis" || propName == "database" || propName == "frameworkCode" ) {
+ MetaDataBase::setFakeProperty( editor->widget(), propName, v );
+ } else if ( editor->widget()->inherits( "CustomWidget" ) ) {
+ MetaDataBase::CustomWidget *cw = ( (CustomWidget*)widget )->customWidget();
+ if ( cw ) {
+ MetaDataBase::setFakeProperty( editor->widget(), propName, v );
+ }
+ }
+ editor->refetchData();
+ editor->emitWidgetChanged();
+ ( ( PropertyItem* )editor->propertyList()->currentItem() )->setChanged( MetaDataBase::isPropertyChanged( widget, propName ) );
+#ifndef QT_NO_SQL
+ if ( propName == "database" )
+ formWindow()->mainWindow()->objectHierarchy()->databasePropertyChanged( (QWidget*)widget, MetaDataBase::fakeProperty( widget, "database" ).toStringList() );
+#endif
+ return;
+ }
+
+ if ( p->isSetType() ) {
+ ;
+ } else if ( p->isEnumType() ) {
+ widget->setProperty( propName, p->keyToValue( currentItemText ) );
+ } else {
+ QVariant ov;
+ if ( propName == "name" || propName == "itemName" )
+ ov = widget->property( propName );
+ int oldSerNum = -1;
+ if ( v.type() == QVariant::Pixmap )
+ oldSerNum = v.toPixmap().serialNumber();
+ widget->setProperty( propName, v );
+ if ( oldSerNum != -1 && oldSerNum != widget->property( propName ).toPixmap().serialNumber() )
+ MetaDataBase::setPixmapKey( formWindow(),
+ widget->property( propName ).toPixmap().serialNumber(),
+ MetaDataBase::pixmapKey( formWindow(), oldSerNum ) );
+ if ( propName == "cursor" )
+ MetaDataBase::setCursor( (QWidget*)widget, v.toCursor() );
+ if ( propName == "name" && widget->isWidgetType() ) {
+ formWindow()->mainWindow()->objectHierarchy()->namePropertyChanged( (QWidget*)widget, ov );
+ if ( formWindow()->isMainContainer( widget ) )
+ formWindow()->setName( v.toCString() );
+ }
+ if ( propName == "name" && widget->inherits( "QAction" ) &&
+ formWindow()->mainContainer() &&
+ formWindow()->mainContainer()->inherits( "QMainWindow" ) ) {
+ formWindow()->mainWindow()->actioneditor()->updateActionName( (QAction*)widget );
+ }
+ if ( propName == "iconSet" && widget->inherits( "QAction" ) &&
+ formWindow()->mainContainer() &&
+ formWindow()->mainContainer()->inherits( "QMainWindow" ) ) {
+ formWindow()->mainWindow()->actioneditor()->updateActionIcon( (QAction*)widget );
+ }
+ if ( propName == "caption" ) {
+ if ( formWindow()->isMainContainer( widget ) )
+ formWindow()->setCaption( v.toString() );
+ }
+ if ( propName == "icon" ) {
+ if ( formWindow()->isMainContainer( widget ) )
+ formWindow()->setIcon( v.toPixmap() );
+ }
+ }
+ editor->refetchData();
+ if ( editor->propertyList()->currentItem() && select ) {
+ ( ( PropertyItem* )editor->propertyList()->currentItem() )->showEditor();
+ ( ( PropertyItem* )editor->propertyList()->currentItem() )->setChanged( MetaDataBase::isPropertyChanged( widget, propName ) );
+ }
+ editor->emitWidgetChanged();
+ formWindow()->killAccels( widget );
+}
+
+// ------------------------------------------------------------
+
+LayoutHorizontalCommand::LayoutHorizontalCommand( const QString &n, FormWindow *fw,
+ QWidget *parent, QWidget *layoutBase,
+ const QWidgetList &wl )
+ : Command( n, fw ), layout( wl, parent, fw, layoutBase )
+{
+}
+
+void LayoutHorizontalCommand::execute()
+{
+ formWindow()->clearSelection( false );
+ layout.doLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+}
+
+void LayoutHorizontalCommand::unexecute()
+{
+ formWindow()->clearSelection( false );
+ layout.undoLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+}
+
+// ------------------------------------------------------------
+
+LayoutHorizontalSplitCommand::LayoutHorizontalSplitCommand( const QString &n, FormWindow *fw,
+ QWidget *parent, QWidget *layoutBase,
+ const QWidgetList &wl )
+ : Command( n, fw ), layout( wl, parent, fw, layoutBase, true, true )
+{
+}
+
+void LayoutHorizontalSplitCommand::execute()
+{
+ formWindow()->clearSelection( false );
+ layout.doLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+}
+
+void LayoutHorizontalSplitCommand::unexecute()
+{
+ formWindow()->clearSelection( false );
+ layout.undoLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+}
+
+// ------------------------------------------------------------
+
+LayoutVerticalCommand::LayoutVerticalCommand( const QString &n, FormWindow *fw,
+ QWidget *parent, QWidget *layoutBase,
+ const QWidgetList &wl )
+ : Command( n, fw ), layout( wl, parent, fw, layoutBase )
+{
+}
+
+void LayoutVerticalCommand::execute()
+{
+ formWindow()->clearSelection( false );
+ layout.doLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+}
+
+void LayoutVerticalCommand::unexecute()
+{
+ formWindow()->clearSelection( false );
+ layout.undoLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+}
+
+// ------------------------------------------------------------
+
+LayoutVerticalSplitCommand::LayoutVerticalSplitCommand( const QString &n, FormWindow *fw,
+ QWidget *parent, QWidget *layoutBase,
+ const QWidgetList &wl )
+ : Command( n, fw ), layout( wl, parent, fw, layoutBase, true, true )
+{
+}
+
+void LayoutVerticalSplitCommand::execute()
+{
+ formWindow()->clearSelection( false );
+ layout.doLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+}
+
+void LayoutVerticalSplitCommand::unexecute()
+{
+ formWindow()->clearSelection( false );
+ layout.undoLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+}
+
+// ------------------------------------------------------------
+
+LayoutGridCommand::LayoutGridCommand( const QString &n, FormWindow *fw,
+ QWidget *parent, QWidget *layoutBase,
+ const QWidgetList &wl, int xres, int yres )
+ : Command( n, fw ), layout( wl, parent, fw, layoutBase, QSize( QMAX(5,xres), QMAX(5,yres) ) )
+{
+}
+
+void LayoutGridCommand::execute()
+{
+ formWindow()->clearSelection( false );
+ layout.doLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+}
+
+void LayoutGridCommand::unexecute()
+{
+ formWindow()->clearSelection( false );
+ layout.undoLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+}
+
+// ------------------------------------------------------------
+
+BreakLayoutCommand::BreakLayoutCommand( const QString &n, FormWindow *fw,
+ QWidget *layoutBase, const QWidgetList &wl )
+ : Command( n, fw ), lb( layoutBase ), widgets( wl )
+{
+ WidgetFactory::LayoutType lay = WidgetFactory::layoutType( layoutBase );
+ spacing = MetaDataBase::spacing( layoutBase );
+ margin = MetaDataBase::margin( layoutBase );
+ layout = 0;
+ if ( lay == WidgetFactory::HBox )
+ layout = new HorizontalLayout( wl, layoutBase, fw, layoutBase, false, layoutBase->inherits( "QSplitter" ) );
+ else if ( lay == WidgetFactory::VBox )
+ layout = new VerticalLayout( wl, layoutBase, fw, layoutBase, false, layoutBase->inherits( "QSplitter" ) );
+ else if ( lay == WidgetFactory::Grid )
+ layout = new GridLayout( wl, layoutBase, fw, layoutBase, QSize( QMAX( 5, fw->grid().x()), QMAX( 5, fw->grid().y()) ), false );
+}
+
+void BreakLayoutCommand::execute()
+{
+ if ( !layout )
+ return;
+ formWindow()->clearSelection( false );
+ layout->breakLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() )
+ w->resize( QMAX( 16, w->width() ), QMAX( 16, w->height() ) );
+}
+
+void BreakLayoutCommand::unexecute()
+{
+ if ( !layout )
+ return;
+ formWindow()->clearSelection( false );
+ layout->doLayout();
+ formWindow()->mainWindow()->objectHierarchy()->rebuild();
+ MetaDataBase::setSpacing( WidgetFactory::containerOfWidget( lb ), spacing );
+ MetaDataBase::setMargin( WidgetFactory::containerOfWidget( lb ), margin );
+}
+
+// ------------------------------------------------------------
+
+MacroCommand::MacroCommand( const QString &n, FormWindow *fw,
+ const QPtrList<Command> &cmds )
+ : Command( n, fw ), commands( cmds )
+{
+}
+
+void MacroCommand::execute()
+{
+ for ( Command *c = commands.first(); c; c = commands.next() )
+ c->execute();
+}
+
+void MacroCommand::unexecute()
+{
+ for ( Command *c = commands.last(); c; c = commands.prev() )
+ c->unexecute();
+}
+
+// ------------------------------------------------------------
+
+AddTabPageCommand::AddTabPageCommand( const QString &n, FormWindow *fw,
+ QTabWidget *tw, const QString &label )
+ : Command( n, fw ), tabWidget( tw ), tabLabel( label )
+{
+ tabPage = new QDesignerWidget( formWindow(), tabWidget, "tab" );
+ tabPage->hide();
+ index = -1;
+ MetaDataBase::addEntry( tabPage );
+}
+
+void AddTabPageCommand::execute()
+{
+ if ( index == -1 )
+ index = ( (QDesignerTabWidget*)tabWidget )->count();
+ tabWidget->insertTab( tabPage, tabLabel, index );
+ tabWidget->showPage( tabPage );
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );
+}
+
+void AddTabPageCommand::unexecute()
+{
+ tabWidget->removePage( tabPage );
+ tabPage->hide();
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );
+}
+
+// ------------------------------------------------------------
+// ------------------------------------------------------------
+
+AddToolBoxPageCommand::AddToolBoxPageCommand( const QString &n, FormWindow *fw,
+ QToolBox *tw, const QString &_label )
+ : Command( n, fw ), toolBox( tw ), label( _label )
+{
+ page = new QDesignerWidget( formWindow(), toolBox, "tab" );
+ page->hide();
+ index = -1;
+ MetaDataBase::addEntry( page );
+}
+
+void AddToolBoxPageCommand::execute()
+{
+ if ( index == -1 )
+ index = ( (EditorToolBox*)toolBox)->count();
+ toolBox->insertItem(index, page, label);
+ toolBox->setCurrentItem( page );
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->tabsChanged( toolBox );
+}
+
+void AddToolBoxPageCommand::unexecute()
+{
+ toolBox->removeItem( page );
+ page->hide();
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->tabsChanged( toolBox );
+}
+
+// ------------------------------------------------------------
+
+MoveTabPageCommand::MoveTabPageCommand( const QString &n, FormWindow *fw,
+ QTabWidget *tw, QWidget* page, const QString& label, int nIndex, int oIndex )
+ : Command( n, fw ), tabWidget( tw ), tabPage( page ), tabLabel( label )
+{
+ newIndex = nIndex;
+ oldIndex = oIndex;
+}
+
+void MoveTabPageCommand::execute()
+{
+ ((QDesignerTabWidget*)tabWidget )->removePage( tabPage );
+ ((QDesignerTabWidget*)tabWidget )->insertTab( tabPage, tabLabel, newIndex );
+ ((QDesignerTabWidget*)tabWidget )->showPage( tabPage );
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );
+}
+
+void MoveTabPageCommand::unexecute()
+{
+ ((QDesignerTabWidget*)tabWidget )->removePage( tabPage );
+ ((QDesignerTabWidget*)tabWidget )->insertTab( tabPage, tabLabel, oldIndex );
+ ((QDesignerTabWidget*)tabWidget )->showPage( tabPage );
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );
+}
+
+// ------------------------------------------------------------
+
+DeleteTabPageCommand::DeleteTabPageCommand( const QString &n, FormWindow *fw,
+ QTabWidget *tw, QWidget *page )
+ : Command( n, fw ), tabWidget( tw ), tabPage( page )
+{
+ tabLabel = ( (QDesignerTabWidget*)tabWidget )->pageTitle();
+ index = ( (QDesignerTabWidget*)tabWidget )->currentPage();
+}
+
+void DeleteTabPageCommand::execute()
+{
+ tabWidget->removePage( tabPage );
+ tabPage->hide();
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );
+}
+
+void DeleteTabPageCommand::unexecute()
+{
+ tabWidget->insertTab( tabPage, tabLabel, index );
+ tabWidget->showPage( tabPage );
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->tabsChanged( tabWidget );
+}
+
+// ------------------------------------------------------------
+
+DeleteToolBoxPageCommand::DeleteToolBoxPageCommand( const QString &n, FormWindow *fw,
+ QToolBox *tw, QWidget *_page )
+ : Command( n, fw ), toolBox( tw ), page( _page )
+{
+ label = ( (EditorToolBox*)toolBox )->pageTitle();
+ index = ( (EditorToolBox*)toolBox )->currentPage();
+}
+
+void DeleteToolBoxPageCommand::execute()
+{
+ toolBox->removeItem( page );
+ page->hide();
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->tabsChanged( toolBox );
+}
+
+void DeleteToolBoxPageCommand::unexecute()
+{
+ toolBox->insertItem(index, page, label);
+ toolBox->setCurrentItem( page );
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->tabsChanged( toolBox );
+}
+
+// ------------------------------------------------------------
+
+AddWizardPageCommand::AddWizardPageCommand( const QString &n, FormWindow *fw,
+ QWizard *w, const QString &label, int i, bool s )
+ : Command( n, fw ), wizard( w ), pageLabel( label )
+{
+ page = new QDesignerWidget( formWindow(), wizard, "page" );
+ page->hide();
+ index = i;
+ show = s;
+ MetaDataBase::addEntry( page );
+}
+
+void AddWizardPageCommand::execute()
+{
+ if ( index == -1 )
+ index = wizard->pageCount();
+ wizard->insertPage( page, pageLabel, index );
+ if ( show )
+ ( (QDesignerWizard*)wizard )->setCurrentPage( ( (QDesignerWizard*)wizard )->pageNum( page ) );
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );
+}
+
+void AddWizardPageCommand::unexecute()
+{
+ wizard->removePage( page );
+ page->hide();
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );
+}
+
+// ------------------------------------------------------------
+
+DeleteWizardPageCommand::DeleteWizardPageCommand( const QString &n, FormWindow *fw,
+ QWizard *w, int i, bool s )
+ : Command( n, fw ), wizard( w ), index( i )
+{
+ show = s;
+}
+
+void DeleteWizardPageCommand::execute()
+{
+ page = wizard->page( index );
+ pageLabel = wizard->title( page );
+ wizard->removePage( page );
+ page->hide();
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );
+}
+
+void DeleteWizardPageCommand::unexecute()
+{
+ wizard->insertPage( page, pageLabel, index );
+ if ( show )
+ ( (QDesignerWizard*)wizard )->setCurrentPage( ( (QDesignerWizard*)wizard )->pageNum( page ) );
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );
+}
+
+// ------------------------------------------------------------
+
+RenameWizardPageCommand::RenameWizardPageCommand( const QString &n, FormWindow *fw,
+ QWizard *w, int i, const QString& name )
+ : Command( n, fw ), wizard( w ), index( i ), label( name )
+{
+
+}
+
+void RenameWizardPageCommand::execute()
+{
+ page = wizard->page( index );
+ QString oldLabel = wizard->title( page );
+
+ wizard->setTitle( page, label );
+ label = oldLabel;
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+}
+
+void RenameWizardPageCommand::unexecute()
+{
+ execute();
+}
+
+// ------------------------------------------------------------
+
+SwapWizardPagesCommand::SwapWizardPagesCommand( const QString &n, FormWindow *fw, QWizard *w, int i1, int i2 )
+ : Command( n, fw ), wizard( w ), index1( i1 ), index2( i2 )
+{
+}
+
+void SwapWizardPagesCommand::execute()
+{
+ QWidget *page1 = wizard->page( index1 );
+ QWidget *page2 = wizard->page( index2 );
+ QString page1Label = wizard->title( page1 );
+ QString page2Label = wizard->title( page2 );
+ wizard->removePage( page1 );
+ wizard->removePage( page2 );
+ wizard->insertPage( page1, page1Label, index2 );
+ wizard->insertPage( page2, page2Label, index1 );
+ formWindow()->emitUpdateProperties( formWindow()->currentWidget() );
+ formWindow()->mainWindow()->objectHierarchy()->pagesChanged( wizard );
+}
+
+void SwapWizardPagesCommand::unexecute()
+{
+ execute();
+}
+
+// ------------------------------------------------------------
+
+AddConnectionCommand::AddConnectionCommand( const QString &name, FormWindow *fw,
+ MetaDataBase::Connection c )
+ : Command( name, fw ), connection( c )
+{
+}
+
+void AddConnectionCommand::execute()
+{
+ MetaDataBase::addConnection( formWindow(), connection.sender,
+ connection.signal, connection.receiver, connection.slot );
+#ifndef KOMMANDER
+ if ( connection.receiver == formWindow()->mainContainer() )
+ {
+ // qDebug("AddConnectionCommand::execute(): Would have called EventList::setup()");
+ formWindow()->mainWindow()->propertyeditor()->eventList()->setup();
+ }
+#endif
+}
+
+void AddConnectionCommand::unexecute()
+{
+ MetaDataBase::removeConnection( formWindow(), connection.sender,
+ connection.signal, connection.receiver, connection.slot );
+#ifndef KOMMANDER
+ if ( connection.receiver == formWindow()->mainContainer() )
+ {
+ // qDebug("AddConnectionCommand::unexecute(): Would have called EventList::setup()");
+ formWindow()->mainWindow()->propertyeditor()->eventList()->setup();
+ }
+#endif
+}
+
+// ------------------------------------------------------------
+
+RemoveConnectionCommand::RemoveConnectionCommand( const QString &name, FormWindow *fw,
+ MetaDataBase::Connection c )
+ : Command( name, fw ), connection( c )
+{
+}
+
+void RemoveConnectionCommand::execute()
+{
+ MetaDataBase::removeConnection( formWindow(), connection.sender,
+ connection.signal, connection.receiver, connection.slot );
+#ifndef KOMMANDER
+ if ( connection.receiver == formWindow()->mainContainer() )
+ {
+ // qDebug("RemoveConnectionCommand::execute(): Would have called EventList::setup()");
+ formWindow()->mainWindow()->propertyeditor()->eventList()->setup();
+ }
+#endif
+}
+
+void RemoveConnectionCommand::unexecute()
+{
+ MetaDataBase::addConnection( formWindow(), connection.sender,
+ connection.signal, connection.receiver, connection.slot );
+#ifndef KOMMANDER
+ if ( connection.receiver == formWindow()->mainContainer() )
+ {
+ // qDebug("RemoveConnectionCommand::unexecute(): Would have called EventList::setup()");
+ formWindow()->mainWindow()->propertyeditor()->eventList()->setup();
+ }
+#endif
+}
+
+// ------------------------------------------------------------
+
+/* TODO : We don't need these commands. */
+AddSlotCommand::AddSlotCommand( const QString &name, FormWindow *fw, const QCString &s,
+ const QString& spec, const QString &a, const QString &l, const QString &rt )
+ : Command( name, fw ), slot( s ), specifier( spec ), access( a ), language( l ), returnType( rt )
+{
+ // qDebug("AddSlotCommand::AddSlotCommand()");
+}
+
+void AddSlotCommand::execute()
+{
+ MetaDataBase::addSlot( formWindow(), slot, specifier, access, language, returnType );
+#ifndef KOMMANDER
+ formWindow()->mainWindow()->slotsChanged();
+#endif
+ if ( formWindow()->formFile() )
+ formWindow()->formFile()->setModified( true );
+}
+
+void AddSlotCommand::unexecute()
+{
+ MetaDataBase::removeSlot( formWindow(), slot, specifier, access, language, returnType );
+#ifndef KOMMANDER
+ formWindow()->mainWindow()->slotsChanged();
+#endif
+ if ( formWindow()->formFile() )
+ formWindow()->formFile()->setModified( true );
+}
+
+// ------------------------------------------------------------
+
+RemoveSlotCommand::RemoveSlotCommand( const QString &name, FormWindow *fw, const QCString &s,
+ const QString& spec, const QString &a, const QString &l, const QString &rt )
+ : Command( name, fw ), slot( s ), specifier( spec ), access( a ), language( l ), returnType( rt )
+{
+ // qDebug("RemoveSlotCommand::RemoveSlotCommand()");
+}
+
+void RemoveSlotCommand::execute()
+{
+ MetaDataBase::removeSlot( formWindow(), slot, specifier, access, language, returnType );
+#ifndef KOMMANDER
+ formWindow()->mainWindow()->slotsChanged();
+#endif
+ if ( formWindow()->formFile() )
+ formWindow()->formFile()->setModified( true );
+}
+
+void RemoveSlotCommand::unexecute()
+{
+ MetaDataBase::addSlot( formWindow(), slot, specifier, access, language, returnType );
+#ifndef KOMMANDER
+ formWindow()->mainWindow()->slotsChanged();
+#endif
+ if ( formWindow()->formFile() )
+ formWindow()->formFile()->setModified( true );
+}
+
+// ------------------------------------------------------------
+
+LowerCommand::LowerCommand( const QString &name, FormWindow *fw, const QWidgetList &w )
+ : Command( name, fw ), widgets( w )
+{
+}
+
+void LowerCommand::execute()
+{
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
+ w->lower();
+ formWindow()->raiseSelection( w );
+ }
+
+}
+
+void LowerCommand::unexecute()
+{
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
+ w->raise();
+ formWindow()->raiseSelection( w );
+ }
+}
+
+// ------------------------------------------------------------
+
+RaiseCommand::RaiseCommand( const QString &name, FormWindow *fw, const QWidgetList &w )
+ : Command( name, fw ), widgets( w )
+{
+}
+
+void RaiseCommand::execute()
+{
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
+ w->raise();
+ formWindow()->raiseSelection( w );
+ }
+
+}
+
+void RaiseCommand::unexecute()
+{
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
+ w->lower();
+ formWindow()->raiseSelection( w );
+ }
+}
+
+// ------------------------------------------------------------
+
+PasteCommand::PasteCommand( const QString &n, FormWindow *fw,
+ const QWidgetList &w )
+ : Command( n, fw ), widgets( w )
+{
+}
+
+void PasteCommand::execute()
+{
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
+ w->show();
+ formWindow()->selectWidget( w );
+ formWindow()->widgets()->insert( w, w );
+ formWindow()->mainWindow()->objectHierarchy()->widgetInserted( w );
+ }
+}
+
+void PasteCommand::unexecute()
+{
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
+ w->hide();
+ formWindow()->selectWidget( w, false );
+ formWindow()->widgets()->remove( w );
+ formWindow()->mainWindow()->objectHierarchy()->widgetRemoved( w );
+ }
+ }
+
+// ------------------------------------------------------------
+
+TabOrderCommand::TabOrderCommand( const QString &n, FormWindow *fw,
+ const QWidgetList &ol, const QWidgetList &nl )
+ : Command( n, fw ), oldOrder( ol ), newOrder( nl )
+{
+}
+
+void TabOrderCommand::merge( Command *c )
+{
+ TabOrderCommand *cmd = (TabOrderCommand*)c;
+ newOrder = cmd->newOrder;
+}
+
+bool TabOrderCommand::canMerge( Command * )
+{
+ return true;
+}
+
+void TabOrderCommand::execute()
+{
+ MetaDataBase::setTabOrder( formWindow(), newOrder );
+}
+
+void TabOrderCommand::unexecute()
+{
+ MetaDataBase::setTabOrder( formWindow(), oldOrder );
+}
+
+// ------------------------------------------------------------
+
+PopulateListBoxCommand::PopulateListBoxCommand( const QString &n, FormWindow *fw,
+ QListBox *lb, const QValueList<Item> &items )
+ : Command( n, fw ), newItems( items ), listbox( lb )
+{
+ QListBoxItem *i = 0;
+ for ( i = listbox->firstItem(); i; i = i->next() ) {
+ Item item;
+ if ( i->pixmap() )
+ item.pix = *i->pixmap();
+ item.text = i->text();
+ oldItems.append( item );
+ }
+}
+
+void PopulateListBoxCommand::execute()
+{
+ listbox->clear();
+ for ( QValueList<Item>::Iterator it = newItems.begin(); it != newItems.end(); ++it ) {
+ Item i = *it;
+ if ( !i.pix.isNull() )
+ (void)new QListBoxPixmap( listbox, i.pix, i.text );
+ else
+ (void)new QListBoxText( listbox, i.text );
+ }
+ formWindow()->mainWindow()->propertyeditor()->refetchData();
+}
+
+void PopulateListBoxCommand::unexecute()
+{
+ listbox->clear();
+ for ( QValueList<Item>::Iterator it = oldItems.begin(); it != oldItems.end(); ++it ) {
+ Item i = *it;
+ if ( !i.pix.isNull() )
+ (void)new QListBoxPixmap( listbox, i.pix, i.text );
+ else
+ (void)new QListBoxText( listbox, i.text );
+ }
+ formWindow()->mainWindow()->propertyeditor()->refetchData();
+}
+
+// ------------------------------------------------------------
+
+PopulateIconViewCommand::PopulateIconViewCommand( const QString &n, FormWindow *fw,
+ QIconView *iv, const QValueList<Item> &items )
+ : Command( n, fw ), newItems( items ), iconview( iv )
+{
+#ifndef QT_NO_ICONVIEW
+ QIconViewItem *i = 0;
+ for ( i = iconview->firstItem(); i; i = i->nextItem() ) {
+ Item item;
+ if ( i->pixmap() )
+ item.pix = *i->pixmap();
+ item.text = i->text();
+ oldItems.append( item );
+ }
+#endif
+}
+
+void PopulateIconViewCommand::execute()
+{
+#ifndef QT_NO_ICONVIEW
+ iconview->clear();
+ for ( QValueList<Item>::Iterator it = newItems.begin(); it != newItems.end(); ++it ) {
+ Item i = *it;
+ (void)new QIconViewItem( iconview, i.text, i.pix );
+ }
+#endif
+}
+
+void PopulateIconViewCommand::unexecute()
+{
+#ifndef QT_NO_ICONVIEW
+ iconview->clear();
+ for ( QValueList<Item>::Iterator it = oldItems.begin(); it != oldItems.end(); ++it ) {
+ Item i = *it;
+ (void)new QIconViewItem( iconview, i.text, i.pix );
+ }
+#endif
+}
+
+// ------------------------------------------------------------
+
+PopulateListViewCommand::PopulateListViewCommand( const QString &n, FormWindow *fw,
+ QListView *lv, QListView *from )
+ : Command( n, fw ), listview( lv )
+{
+ newItems = new QListView();
+ newItems->hide();
+ transferItems( from, newItems );
+ oldItems = new QListView();
+ oldItems->hide();
+ transferItems( listview, oldItems );
+}
+
+void PopulateListViewCommand::execute()
+{
+ listview->clear();
+ transferItems( newItems, listview );
+}
+
+void PopulateListViewCommand::unexecute()
+{
+ listview->clear();
+ transferItems( oldItems, listview );
+}
+
+void PopulateListViewCommand::transferItems( QListView *from, QListView *to )
+{
+ QHeader *header = to->header();
+ while ( header->count() )
+ to->removeColumn( 0 );
+ QHeader *h2 = from->header();
+ for ( int i = 0; i < h2->count(); ++i ) {
+ to->addColumn( h2->label( i ) );
+ if ( h2->iconSet( i ) && !h2->iconSet( i )->pixmap().isNull() )
+ header->setLabel( i, *h2->iconSet( i ), h2->label( i ) );
+ header->setResizeEnabled( h2->isResizeEnabled( i ), i );
+ header->setClickEnabled( h2->isClickEnabled( i ), i );
+ }
+
+ QListViewItemIterator it( from );
+ QPtrStack<QListViewItem> fromParents, toParents;
+ fromParents.push( 0 );
+ toParents.push( 0 );
+ QPtrStack<QListViewItem> toLasts;
+ QListViewItem *fromLast = 0;
+ toLasts.push( 0 );
+ int cols = from->columns();
+ to->setSorting( -1 );
+ from->setSorting( -1 );
+ for ( ; it.current(); ++it ) {
+ QListViewItem *i = it.current();
+ if ( i->parent() == fromParents.top() ) {
+ QListViewItem *pi = toParents.top();
+ QListViewItem *ni = 0;
+ if ( pi )
+ ni = new QListViewItem( pi, toLasts.top() );
+ else
+ ni = new QListViewItem( to, toLasts.top() );
+ for ( int c = 0; c < cols; ++c ) {
+ ni->setText( c, i->text( c ) );
+ if ( i->pixmap( c ) )
+ ni->setPixmap( c, *i->pixmap( c ) );
+ }
+ toLasts.pop();
+ toLasts.push( ni );
+ if ( pi )
+ pi->setOpen( true );
+ } else {
+ if ( i->parent() == fromLast ) {
+ fromParents.push( fromLast );
+ toParents.push( toLasts.top() );
+ toLasts.push( 0 );
+ QListViewItem *pi = toParents.top();
+ QListViewItem *ni = 0;
+ if ( pi )
+ ni = new QListViewItem( pi );
+ else
+ ni = new QListViewItem( to );
+ for ( int c = 0; c < cols; ++c ) {
+ ni->setText( c, i->text( c ) );
+ if ( i->pixmap( c ) )
+ ni->setPixmap( c, *i->pixmap( c ) );
+ }
+ toLasts.pop();
+ toLasts.push( ni );
+ if ( pi )
+ pi->setOpen( true );
+ } else {
+ while ( fromParents.top() != i->parent() ) {
+ fromParents.pop();
+ toParents.pop();
+ toLasts.pop();
+ }
+
+ QListViewItem *pi = toParents.top();
+ QListViewItem *ni = 0;
+ if ( pi )
+ ni = new QListViewItem( pi, toLasts.top() );
+ else
+ ni = new QListViewItem( to, toLasts.top() );
+ for ( int c = 0; c < cols; ++c ) {
+ ni->setText( c, i->text( c ) );
+ if ( i->pixmap( c ) )
+ ni->setPixmap( c, *i->pixmap( c ) );
+ }
+ if ( pi )
+ pi->setOpen( true );
+ toLasts.pop();
+ toLasts.push( ni );
+ }
+ }
+ fromLast = i;
+ }
+}
+
+
+
+// ------------------------------------------------------------
+
+PopulateMultiLineEditCommand::PopulateMultiLineEditCommand( const QString &n, FormWindow *fw,
+ QMultiLineEdit *mle, const QString &txt )
+ : Command( n, fw ), newText( txt ), mlined( mle )
+{
+ oldText = mlined->text();
+ wasChanged = MetaDataBase::isPropertyChanged( mlined, "text" );
+}
+
+void PopulateMultiLineEditCommand::execute()
+{
+ mlined->setText( newText );
+ MetaDataBase::setPropertyChanged( mlined, "text", true );
+ formWindow()->emitUpdateProperties( mlined );
+}
+
+void PopulateMultiLineEditCommand::unexecute()
+{
+ mlined->setText( oldText );
+ MetaDataBase::setPropertyChanged( mlined, "text", wasChanged );
+ formWindow()->emitUpdateProperties( mlined );
+}
+
+// ------------------------------------------------------------
+
+PopulateTableCommand::PopulateTableCommand( const QString &n, FormWindow *fw, QTable *t,
+ const QValueList<Row> &rows,
+ const QValueList<Column> &columns )
+ : Command( n, fw ), newRows( rows ), newColumns( columns ), table( t )
+{
+#ifndef QT_NO_TABLE
+ int i = 0;
+ QMap<QString, QString> columnFields = MetaDataBase::columnFields( table );
+ for ( i = 0; i < table->horizontalHeader()->count(); ++i ) {
+ PopulateTableCommand::Column col;
+ col.text = table->horizontalHeader()->label( i );
+ if ( table->horizontalHeader()->iconSet( i ) )
+ col.pix = table->horizontalHeader()->iconSet( i )->pixmap();
+ col.field = *columnFields.find( col.text );
+ oldColumns.append( col );
+ }
+ for ( i = 0; i < table->verticalHeader()->count(); ++i ) {
+ PopulateTableCommand::Row row;
+ row.text = table->verticalHeader()->label( i );
+ if ( table->verticalHeader()->iconSet( i ) )
+ row.pix = table->verticalHeader()->iconSet( i )->pixmap();
+ oldRows.append( row );
+ }
+#endif
+}
+
+void PopulateTableCommand::execute()
+{
+#ifndef QT_NO_TABLE
+ QMap<QString, QString> columnFields;
+ table->setNumCols( newColumns.count() );
+ int i = 0;
+ for ( QValueList<Column>::Iterator cit = newColumns.begin(); cit != newColumns.end(); ++cit, ++i ) {
+ table->horizontalHeader()->setLabel( i, (*cit).pix, (*cit).text );
+ if ( !(*cit).field.isEmpty() )
+ columnFields.insert( (*cit).text, (*cit).field );
+ }
+ MetaDataBase::setColumnFields( table, columnFields );
+ table->setNumRows( newRows.count() );
+ i = 0;
+ for ( QValueList<Row>::Iterator rit = newRows.begin(); rit != newRows.end(); ++rit, ++i )
+ table->verticalHeader()->setLabel( i, (*rit).pix, (*rit).text );
+#endif
+}
+
+void PopulateTableCommand::unexecute()
+{
+#ifndef QT_NO_TABLE
+ QMap<QString, QString> columnFields;
+ table->setNumCols( oldColumns.count() );
+ int i = 0;
+ for ( QValueList<Column>::Iterator cit = oldColumns.begin(); cit != oldColumns.end(); ++cit, ++i ) {
+ table->horizontalHeader()->setLabel( i, (*cit).pix, (*cit).text );
+ if ( !(*cit).field.isEmpty() )
+ columnFields.insert( (*cit).text, (*cit).field );
+ }
+ MetaDataBase::setColumnFields( table, columnFields );
+ table->setNumRows( oldRows.count() );
+ i = 0;
+ for ( QValueList<Row>::Iterator rit = oldRows.begin(); rit != oldRows.end(); ++rit, ++i )
+ table->verticalHeader()->setLabel( i, (*rit).pix, (*rit).text );
+#endif
+}
+
+// ------------------------------------------------------------
+
+AddActionToToolBarCommand::AddActionToToolBarCommand( const QString &n, FormWindow *fw,
+ QAction *a, QDesignerToolBar *tb, int idx )
+ : Command( n, fw ), action( a ), toolBar( tb ), index( idx )
+{
+}
+
+void AddActionToToolBarCommand::execute()
+{
+ action->addTo( toolBar );
+
+ if ( action->inherits( "QDesignerAction" ) ) {
+ QString s = ( (QDesignerAction*)action )->widget()->name();
+ if ( s.startsWith( "qt_dead_widget_" ) ) {
+ s.remove( 0, QString( "qt_dead_widget_" ).length() );
+ ( (QDesignerAction*)action )->widget()->setName( s );
+ }
+ }
+
+ if ( action->inherits( "QDesignerAction" ) ) {
+ toolBar->insertAction( ( (QDesignerAction*)action )->widget(), action );
+ ( (QDesignerAction*)action )->widget()->installEventFilter( toolBar );
+ } else if ( action->inherits( "QDesignerActionGroup" ) ) {
+ if ( ( (QDesignerActionGroup*)action )->usesDropDown() ) {
+ toolBar->insertAction( ( (QDesignerActionGroup*)action )->widget(), action );
+ ( (QDesignerActionGroup*)action )->widget()->installEventFilter( toolBar );
+ }
+ } else if ( action->inherits( "QSeparatorAction" ) ) {
+ toolBar->insertAction( ( (QSeparatorAction*)action )->widget(), action );
+ ( (QSeparatorAction*)action )->widget()->installEventFilter( toolBar );
+ }
+ if ( !action->inherits( "QActionGroup" ) || ( (QActionGroup*)action )->usesDropDown()) {
+ if ( index == -1 )
+ toolBar->appendAction( action );
+ else
+ toolBar->insertAction( index, action );
+ toolBar->reInsert();
+ QObject::connect( action, SIGNAL( destroyed() ), toolBar, SLOT( actionRemoved() ) );
+ } else {
+ QObjectListIt it( *action->children() );
+ if ( action->children() ) {
+ int i = 0;
+ while ( it.current() ) {
+ QObject *o = it.current();
+ ++it;
+ if ( !o->inherits( "QAction" ) )
+ continue;
+ // ### fix it for nested actiongroups
+ if ( o->inherits( "QDesignerAction" ) ) {
+ QDesignerAction *ac = (QDesignerAction*)o;
+ toolBar->insertAction( ac->widget(), ac );
+ ac->widget()->installEventFilter( toolBar );
+ if ( index == -1 )
+ toolBar->appendAction( ac );
+ else
+ toolBar->insertAction( index + (i++), ac );
+ }
+ }
+ }
+ toolBar->reInsert();
+ QObject::connect( action, SIGNAL( destroyed() ), toolBar, SLOT( actionRemoved() ) );
+ }
+}
+
+void AddActionToToolBarCommand::unexecute()
+{
+ if ( action->inherits( "QDesignerAction" ) ) {
+ QString s = ( (QDesignerAction*)action )->widget()->name();
+ s.prepend( "qt_dead_widget_" );
+ ( (QDesignerAction*)action )->widget()->setName( s );
+ }
+
+ toolBar->removeAction( action );
+ action->removeFrom( toolBar );
+ QObject::disconnect( action, SIGNAL( destroyed() ), toolBar, SLOT( actionRemoved() ) );
+ if ( !action->inherits( "QActionGroup" ) || ( (QActionGroup*)action )->usesDropDown()) {
+ action->removeEventFilter( toolBar );
+ } else {
+ if ( action->children() ) {
+ QObjectListIt it( *action->children() );
+ while ( it.current() ) {
+ QObject *o = it.current();
+ ++it;
+ if ( !o->inherits( "QAction" ) )
+ continue;
+ if ( o->inherits( "QDesignerAction" ) ) {
+ o->removeEventFilter( toolBar );
+ toolBar->removeAction( (QAction*)o );
+ }
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------
+
+AddActionToPopupCommand::AddActionToPopupCommand( const QString &n, FormWindow *fw,
+ QAction *a, QDesignerPopupMenu *p, int idx )
+ : Command( n, fw ), action( a ), popup( p ), index( idx )
+{
+}
+
+void AddActionToPopupCommand::execute()
+{
+ if ( action->inherits( "QActionGroup" ) ) {
+ if ( ( (QActionGroup*)action )->usesDropDown() ) {
+ action->addTo( popup );
+ popup->insertAction( index, action );
+ } else {
+ action->addTo( popup );
+ if ( action->children() ) {
+ QObjectListIt it( *action->children() );
+ int i = 0;
+ while ( it.current() ) {
+ QObject *o = it.current();
+ ++it;
+ if ( !o->inherits( "QAction" ) )
+ continue;
+ QDesignerAction *ac = (QDesignerAction*)o;
+ popup->insertAction( index + (i++), ac );
+ }
+ }
+ }
+ popup->reInsert();
+ QObject::connect( action, SIGNAL( destroyed() ), popup, SLOT( actionRemoved() ) );
+ } else {
+ if ( !action->inherits( "QDesignerAction" ) || ( (QDesignerAction*)action )->supportsMenu() ) {
+ action->addTo( popup );
+ popup->insertAction( index, action );
+ popup->reInsert();
+ QObject::connect( action, SIGNAL( destroyed() ), popup, SLOT( actionRemoved() ) );
+ }
+ }
+}
+
+void AddActionToPopupCommand::unexecute()
+{
+ action->removeFrom( popup );
+ popup->removeAction( action );
+ QObject::disconnect( action, SIGNAL( destroyed() ), popup, SLOT( actionRemoved() ) );
+ if ( !action->inherits( "QActionGroup" ) || ( (QActionGroup*)action )->usesDropDown()) {
+ action->removeEventFilter( popup );
+ } else {
+ if ( action->children() ) {
+ QObjectListIt it( *action->children() );
+ while ( it.current() ) {
+ QObject *o = it.current();
+ ++it;
+ if ( !o->inherits( "QAction" ) )
+ continue;
+ if ( o->inherits( "QDesignerAction" ) ) {
+ o->removeEventFilter( popup );
+ popup->removeAction( (QAction*)o );
+ }
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------
+
+AddMenuCommand::AddMenuCommand( const QString &n, FormWindow *fw, QMainWindow *mw )
+ : Command( n, fw ), menuBar( 0 ), popup( 0 ), mainWindow( mw ), id( -1 ), name( "Menu" )
+{
+}
+
+void AddMenuCommand::execute()
+{
+ if ( !popup ) {
+ QString n = "PopupMenu";
+ popup = new QDesignerPopupMenu( mainWindow );
+ formWindow()->unify( popup, n, true );
+ popup->setName( n );
+ }
+ if ( !mainWindow->child( 0, "QMenuBar" ) ) {
+ menuBar = new QDesignerMenuBar( (QWidget*)mainWindow );
+ menuBar->setName( "menubar" );
+ } else {
+ menuBar = (QDesignerMenuBar*)mainWindow->menuBar();
+ }
+ if ( id == -1 )
+ id = mainWindow->menuBar()->insertItem( name, popup );
+ else
+ id = mainWindow->menuBar()->insertItem( name, popup, id, index );
+ formWindow()->killAccels( formWindow() );
+}
+
+void AddMenuCommand::unexecute()
+{
+ if ( !popup || !menuBar )
+ return;
+ menuBar->removeItem( id );
+ formWindow()->killAccels( formWindow() );
+}
+
+// ------------------------------------------------------------
+
+RenameMenuCommand::RenameMenuCommand( const QString &n, FormWindow *fw, QDesignerMenuBar *mb,
+ int i, const QString &on, const QString &nn )
+ : Command( n, fw ), menuBar( mb ), id( i ), oldName( on ), newName( nn )
+{
+}
+
+void RenameMenuCommand::execute()
+{
+ menuBar->changeItem( id, newName );
+ formWindow()->killAccels( formWindow() );
+}
+
+void RenameMenuCommand::unexecute()
+{
+ menuBar->changeItem( id, oldName );
+ formWindow()->killAccels( formWindow() );
+}
+
+// ------------------------------------------------------------
+
+MoveMenuCommand::MoveMenuCommand( const QString &n, FormWindow *fw, QDesignerMenuBar *mb,
+ QDesignerPopupMenu *p, int fidx, int tidx, const QString &txt )
+ : Command( n, fw ), menuBar( mb ), popup( p ), fromIdx( fidx ), toIdx( tidx ), text( txt )
+{
+}
+
+void MoveMenuCommand::execute()
+{
+ menuBar->removeItem( menuBar->idAt( fromIdx ) );
+ menuBar->insertItem( text, popup, -1, toIdx );
+ formWindow()->killAccels( formWindow() );
+}
+
+void MoveMenuCommand::unexecute()
+{
+ menuBar->removeItem( menuBar->idAt( toIdx ) );
+ menuBar->insertItem( text, popup, -1, fromIdx );
+ formWindow()->killAccels( formWindow() );
+}
+
+// ------------------------------------------------------------
+
+AddToolBarCommand::AddToolBarCommand( const QString &n, FormWindow *fw, QMainWindow *mw )
+ : Command( n, fw ), toolBar( 0 ), mainWindow( mw )
+{
+}
+
+void AddToolBarCommand::execute()
+{
+ if ( !toolBar ) {
+ toolBar = new QDesignerToolBar( mainWindow );
+ QString n = "Toolbar";
+ formWindow()->unify( toolBar, n, true );
+ toolBar->setName( n );
+ mainWindow->addToolBar( toolBar, n );
+ } else {
+ toolBar->show();
+ }
+}
+
+void AddToolBarCommand::unexecute()
+{
+ toolBar->hide();
+}
+#include "command.moc"
diff --git a/kommander/editor/command.h b/kommander/editor/command.h
new file mode 100644
index 00000000..80a3e569
--- /dev/null
+++ b/kommander/editor/command.h
@@ -0,0 +1,931 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef COMMAND_H
+#define COMMAND_H
+
+#include "metadatabase.h"
+#include "layout.h"
+
+#include <qstring.h>
+#include <qrect.h>
+#include <qvaluelist.h>
+#include <qvariant.h>
+#include <qobject.h>
+#include <qlistview.h>
+#include <qptrlist.h>
+#include <qmap.h>
+
+class QWizard;
+class QTabWidget;
+class Command;
+class QWidget;
+class FormWindow;
+class PropertyEditor;
+class QListBox;
+class QIconView;
+class QMultiLineEdit;
+class QTable;
+class QAction;
+class QDesignerToolBar;
+class QMainWindow;
+class QDesignerPopupMenu;
+class QDesignerMenuBar;
+class QToolBox;
+
+class Command : public Qt
+{
+public:
+ Command( const QString &n, FormWindow *fw );
+ virtual ~Command();
+
+ enum Type {
+ Resize,
+ Insert,
+ Move,
+ Delete,
+ SetProperty,
+ LayoutHorizontal,
+ LayoutVertical,
+ LayoutHorizontalSplitter,
+ LayoutVerticalSplitter,
+ LayoutGrid,
+ BreakLayout,
+ Macro,
+ AddTabPage,
+ DeleteTabPage,
+ MoveTabPage,
+ AddWizardPage,
+ DeleteWizardPage,
+ SwapWizardPages,
+ RenameWizardPage,
+ AddConnection,
+ RemoveConnection,
+ AddSlot,
+ RemoveSlot,
+ Lower,
+ Raise,
+ Paste,
+ TabOrder,
+ PopulateListBox,
+ PopulateIconView,
+ PopulateListView,
+ PopulateMultiLineEdit,
+ PopulateTable,
+ AddActionToToolBar,
+ RemoveActionFromToolBar,
+ AddActionToPopup,
+ RemoveActionFromPopup,
+ AddMenu,
+ RemoveMenu,
+ RenameMenu,
+ MoveMenu,
+ AddToolBar,
+ RemoveToolBar,
+ AddToolBoxPage,
+ DeleteToolBoxPage
+ };
+
+ QString name() const;
+
+ virtual void execute() = 0;
+ virtual void unexecute() = 0;
+ virtual Type type() const = 0;
+ virtual void merge( Command *c );
+ virtual bool canMerge( Command *c );
+
+ FormWindow *formWindow() const;
+
+private:
+ QString cmdName;
+ FormWindow *formWin;
+
+};
+
+
+class CommandHistory : public QObject
+{
+ Q_OBJECT
+
+public:
+ CommandHistory( int s );
+
+ void addCommand( Command *cmd, bool tryCompress = FALSE );
+ void undo();
+ void redo();
+
+ void emitUndoRedo();
+
+ void setModified( bool m );
+ bool isModified() const;
+
+public slots:
+ void checkCompressedCommand();
+
+signals:
+ void undoRedoChanged( bool undoAvailable, bool redoAvailable,
+ const QString &undoCmd, const QString &redoCmd );
+ void modificationChanged( bool m );
+
+private:
+ QPtrList<Command> history;
+ int current, steps;
+ bool modified;
+ int savedAt;
+ Command *compressedCommand;
+
+};
+
+class ResizeCommand : public Command
+{
+public:
+ ResizeCommand( const QString &n, FormWindow *fw,
+ QWidget *w, const QRect &oldr, const QRect &nr );
+
+ void execute();
+ void unexecute();
+ Type type() const { return Resize; }
+
+private:
+ QWidget *widget;
+ QRect oldRect, newRect;
+
+};
+
+class InsertCommand : public Command
+{
+public:
+ InsertCommand( const QString &n, FormWindow *fw, QWidget *w, const QRect &g );
+
+ void execute();
+ void unexecute();
+ Type type() const { return Insert; }
+
+private:
+ QWidget *widget;
+ QRect geometry;
+
+};
+
+class MoveCommand : public Command
+{
+public:
+ MoveCommand( const QString &n, FormWindow *fw,
+ const QWidgetList &w,
+ const QValueList<QPoint> op,
+ const QValueList<QPoint> np,
+ QWidget *opr, QWidget *npr );
+ void execute();
+ void unexecute();
+ Type type() const { return Move; }
+ void merge( Command *c );
+ bool canMerge( Command *c );
+
+private:
+ QWidgetList widgets;
+ QValueList<QPoint> oldPos, newPos;
+ QWidget *oldParent, *newParent;
+
+};
+
+class DeleteCommand : public Command
+{
+public:
+ DeleteCommand( const QString &n, FormWindow *fw,
+ const QWidgetList &w );
+ void execute();
+ void unexecute();
+ Type type() const { return Delete; }
+
+private:
+ QWidgetList widgets;
+ QMap< QWidget*, QValueList<MetaDataBase::Connection> > connections;
+
+};
+
+class SetPropertyCommand : public Command
+{
+public:
+ SetPropertyCommand( const QString &n, FormWindow *fw,
+ QObject *w, PropertyEditor *e,
+ const QString &pn, const QVariant &ov,
+ const QVariant &nv, const QString &ncut,
+ const QString &ocut,
+ bool reset = FALSE );
+
+ void execute();
+ void unexecute();
+ Type type() const { return SetProperty; }
+ void merge( Command *c );
+ bool canMerge( Command *c );
+ bool checkProperty();
+
+private:
+ void setProperty( const QVariant &v, const QString &currentItemText, bool select = TRUE );
+
+ QObject *widget;
+ PropertyEditor *editor;
+ QString propName;
+ QVariant oldValue, newValue;
+ QString oldCurrentItemText, newCurrentItemText;
+ bool wasChanged;
+ bool isResetCommand;
+
+};
+
+class LayoutHorizontalCommand : public Command
+{
+public:
+ LayoutHorizontalCommand( const QString &n, FormWindow *fw,
+ QWidget *parent, QWidget *layoutBase,
+ const QWidgetList &wl );
+
+ void execute();
+ void unexecute();
+ Type type() const { return LayoutHorizontal; }
+
+private:
+ HorizontalLayout layout;
+
+};
+
+class LayoutHorizontalSplitCommand : public Command
+{
+public:
+ LayoutHorizontalSplitCommand( const QString &n, FormWindow *fw,
+ QWidget *parent, QWidget *layoutBase,
+ const QWidgetList &wl );
+
+ void execute();
+ void unexecute();
+ Type type() const { return LayoutHorizontalSplitter; }
+
+private:
+ HorizontalLayout layout;
+
+};
+
+class LayoutVerticalCommand : public Command
+{
+public:
+ LayoutVerticalCommand( const QString &n, FormWindow *fw,
+ QWidget *parent, QWidget *layoutBase,
+ const QWidgetList &wl );
+
+ void execute();
+ void unexecute();
+ Type type() const { return LayoutVertical; }
+
+private:
+ VerticalLayout layout;
+
+};
+
+class LayoutVerticalSplitCommand : public Command
+{
+public:
+ LayoutVerticalSplitCommand( const QString &n, FormWindow *fw,
+ QWidget *parent, QWidget *layoutBase,
+ const QWidgetList &wl );
+
+ void execute();
+ void unexecute();
+ Type type() const { return LayoutVerticalSplitter; }
+
+private:
+ VerticalLayout layout;
+
+};
+
+class LayoutGridCommand : public Command
+{
+public:
+ LayoutGridCommand( const QString &n, FormWindow *fw,
+ QWidget *parent, QWidget *layoutBase,
+ const QWidgetList &wl, int xres, int yres );
+
+ void execute();
+ void unexecute();
+ Type type() const { return LayoutGrid; }
+
+private:
+ GridLayout layout;
+
+};
+
+class BreakLayoutCommand : public Command
+{
+public:
+ BreakLayoutCommand( const QString &n, FormWindow *fw,
+ QWidget *layoutBase, const QWidgetList &wl );
+
+ void execute();
+ void unexecute();
+ Type type() const { return BreakLayout; }
+
+private:
+ Layout *layout;
+ int spacing;
+ int margin;
+ QWidget *lb;
+ QWidgetList widgets;
+
+};
+
+class MacroCommand : public Command
+{
+public:
+ MacroCommand( const QString &n, FormWindow *fw,
+ const QPtrList<Command> &cmds );
+
+ void execute();
+ void unexecute();
+ Type type() const { return Macro; }
+
+private:
+ QPtrList<Command> commands;
+
+};
+
+class AddTabPageCommand : public Command
+{
+public:
+ AddTabPageCommand( const QString &n, FormWindow *fw,
+ QTabWidget *tw, const QString &label );
+
+ void execute();
+ void unexecute();
+ Type type() const { return AddTabPage; }
+
+private:
+ QTabWidget *tabWidget;
+ int index;
+ QWidget *tabPage;
+ QString tabLabel;
+
+};
+
+class DeleteTabPageCommand : public Command
+{
+public:
+ DeleteTabPageCommand( const QString &n, FormWindow *fw,
+ QTabWidget *tw, QWidget *page );
+
+ void execute();
+ void unexecute();
+ Type type() const { return DeleteTabPage; }
+
+private:
+ QTabWidget *tabWidget;
+ int index;
+ QWidget *tabPage;
+ QString tabLabel;
+
+};
+
+class AddToolBoxPageCommand : public Command
+{
+public:
+ AddToolBoxPageCommand( const QString &n, FormWindow *fw,
+ QToolBox *tw, const QString &label );
+
+ void execute();
+ void unexecute();
+ Type type() const { return AddToolBoxPage; }
+
+private:
+ QToolBox *toolBox;
+ int index;
+ QWidget *page;
+ QString label;
+
+};
+
+class DeleteToolBoxPageCommand : public Command
+{
+public:
+ DeleteToolBoxPageCommand( const QString &n, FormWindow *fw,
+ QToolBox *tw, QWidget *page );
+
+ void execute();
+ void unexecute();
+ Type type() const { return DeleteToolBoxPage; }
+
+private:
+ QToolBox *toolBox;
+ int index;
+ QWidget *page;
+ QString label;
+
+};
+class MoveTabPageCommand : public Command
+{
+public:
+ MoveTabPageCommand(const QString &n, FormWindow *fw,
+ QTabWidget *tw, QWidget *page, const QString& label, int nIndex, int oIndex );
+
+ void execute();
+ void unexecute();
+ Type type() const { return MoveTabPage; }
+
+private:
+ QTabWidget *tabWidget;
+ int newIndex, oldIndex;
+ QWidget *tabPage;
+ QString tabLabel;
+
+};
+
+class AddWizardPageCommand : public Command
+{
+public:
+ AddWizardPageCommand( const QString &n, FormWindow *fw,
+ QWizard *w, const QString &label, int index = -1, bool show = TRUE );
+
+ void execute();
+ void unexecute();
+ Type type() const { return AddWizardPage; }
+
+private:
+ QWizard *wizard;
+ int index;
+ bool show;
+ QWidget *page;
+ QString pageLabel;
+
+};
+
+class DeleteWizardPageCommand : public Command
+{
+public:
+ DeleteWizardPageCommand( const QString &n, FormWindow *fw,
+ QWizard *w, int index, bool show = TRUE );
+
+ void execute();
+ void unexecute();
+ Type type() const { return DeleteWizardPage; }
+
+private:
+ QWizard *wizard;
+ int index;
+ bool show;
+ QWidget *page;
+ QString pageLabel;
+
+};
+
+class RenameWizardPageCommand : public Command
+{
+public:
+ RenameWizardPageCommand( const QString &n, FormWindow *fw,
+ QWizard *w, int index, const QString& name );
+
+ void execute();
+ void unexecute();
+ Type type() const { return RenameWizardPage; }
+
+private:
+ QWizard *wizard;
+ int index;
+ QWidget *page;
+ QString label;
+
+};
+
+class SwapWizardPagesCommand : public Command
+{
+public:
+ SwapWizardPagesCommand( const QString &n, FormWindow *fw,
+ QWizard *w, int index1, int index2 );
+
+ void execute();
+ void unexecute();
+ Type type() const { return SwapWizardPages; }
+
+private:
+ QWizard *wizard;
+ int index1, index2;
+
+};
+
+class AddConnectionCommand : public Command
+{
+public:
+ AddConnectionCommand( const QString &name, FormWindow *fw,
+ MetaDataBase::Connection c );
+
+ void execute();
+ void unexecute();
+ Type type() const { return AddConnection; }
+
+private:
+ MetaDataBase::Connection connection;
+
+};
+
+class RemoveConnectionCommand : public Command
+{
+public:
+ RemoveConnectionCommand( const QString &name, FormWindow *fw,
+ MetaDataBase::Connection c );
+
+ void execute();
+ void unexecute();
+ Type type() const { return RemoveConnection; }
+
+private:
+ MetaDataBase::Connection connection;
+
+};
+
+class AddSlotCommand : public Command
+{
+public:
+ AddSlotCommand( const QString &name, FormWindow *fw, const QCString &s, const QString& spec,
+ const QString &a, const QString &l, const QString &rt );
+
+ void execute();
+ void unexecute();
+ Type type() const { return AddSlot; }
+
+private:
+ QCString slot;
+ QString specifier;
+ QString access;
+ QString language;
+ QString returnType;
+
+};
+
+class RemoveSlotCommand : public Command
+{
+public:
+ RemoveSlotCommand( const QString &name, FormWindow *fw, const QCString &s, const QString& spec,
+ const QString &a, const QString &l, const QString &rt );
+
+ void execute();
+ void unexecute();
+ Type type() const { return RemoveSlot; }
+
+private:
+ QCString slot;
+ QString specifier;
+ QString access;
+ QString language;
+ QString returnType;
+
+};
+
+class LowerCommand : public Command
+{
+public:
+ LowerCommand( const QString &name, FormWindow *fw, const QWidgetList &w );
+
+ void execute();
+ void unexecute();
+ Type type() const { return Lower; }
+
+private:
+ QWidgetList widgets;
+
+};
+
+class RaiseCommand : public Command
+{
+public:
+ RaiseCommand( const QString &name, FormWindow *fw, const QWidgetList &w );
+
+ void execute();
+ void unexecute();
+ Type type() const { return Raise; }
+
+private:
+ QWidgetList widgets;
+
+};
+
+class PasteCommand : public Command
+{
+public:
+ PasteCommand( const QString &n, FormWindow *fw, const QWidgetList &w );
+
+ void execute();
+ void unexecute();
+ Type type() const { return Paste; }
+
+private:
+ QWidgetList widgets;
+
+};
+
+class TabOrderCommand : public Command
+{
+public:
+ TabOrderCommand( const QString &n, FormWindow *fw, const QWidgetList &ol, const QWidgetList &nl );
+
+ void execute();
+ void unexecute();
+ Type type() const { return TabOrder; }
+ void merge( Command *c );
+ bool canMerge( Command *c );
+
+private:
+ QWidgetList oldOrder, newOrder;
+
+};
+
+class PopulateListBoxCommand : public Command
+{
+public:
+ struct Item
+ {
+ QString text;
+ QPixmap pix;
+#if defined(Q_FULL_TEMPLATE_INSTANTIATION)
+ bool operator==( const Item & ) const { return FALSE; }
+#endif
+ };
+
+ PopulateListBoxCommand( const QString &n, FormWindow *fw,
+ QListBox *lb, const QValueList<Item> &items );
+ void execute();
+ void unexecute();
+ Type type() const { return PopulateListBox; }
+
+ bool operator==( const PopulateListBoxCommand & ) const;
+
+private:
+ QValueList<Item> oldItems, newItems;
+ QListBox *listbox;
+
+};
+
+class PopulateIconViewCommand : public Command
+{
+public:
+ struct Item
+ {
+ QString text;
+ QPixmap pix;
+#if defined(Q_FULL_TEMPLATE_INSTANTIATION)
+ bool operator==( const Item & ) const { return FALSE; }
+#endif
+ };
+
+ PopulateIconViewCommand( const QString &n, FormWindow *fw,
+ QIconView *iv, const QValueList<Item> &items );
+ void execute();
+ void unexecute();
+ Type type() const { return PopulateIconView; }
+
+ bool operator==( const PopulateIconViewCommand & ) const;
+
+private:
+ QValueList<Item> oldItems, newItems;
+ QIconView *iconview;
+
+};
+
+class PopulateListViewCommand : public Command
+{
+public:
+ PopulateListViewCommand( const QString &n, FormWindow *fw,
+ QListView *lv, QListView *from );
+ void execute();
+ void unexecute();
+ Type type() const { return PopulateListView; }
+ static void transferItems( QListView *from, QListView *to );
+
+ bool operator==( const PopulateListViewCommand & ) const;
+
+private:
+ QListView *oldItems, *newItems;
+ QListView *listview;
+
+};
+
+class PopulateMultiLineEditCommand : public Command
+{
+public:
+ PopulateMultiLineEditCommand( const QString &n, FormWindow *fw,
+ QMultiLineEdit *mle, const QString &txt );
+ void execute();
+ void unexecute();
+ Type type() const { return PopulateMultiLineEdit; }
+
+private:
+ QString newText, oldText;
+ QMultiLineEdit *mlined;
+ bool wasChanged;
+
+};
+
+class PopulateTableCommand : public Command
+{
+public:
+ struct Row
+ {
+ QString text;
+ QPixmap pix;
+#if defined(Q_FULL_TEMPLATE_INSTANTIATION)
+ bool operator==( const Row& ) const { return FALSE; }
+#endif
+ };
+
+ struct Column
+ {
+ QString text;
+ QPixmap pix;
+ QString field;
+#if defined(Q_FULL_TEMPLATE_INSTANTIATION)
+ bool operator==( const Column& ) const { return FALSE; }
+#endif
+ };
+
+ PopulateTableCommand( const QString &n, FormWindow *fw, QTable *t,
+ const QValueList<Row> &rows,
+ const QValueList<Column> &columns );
+
+ void execute();
+ void unexecute();
+ Type type() const { return PopulateTable; }
+
+private:
+ QValueList<Row> oldRows, newRows;
+ QValueList<Column> oldColumns, newColumns;
+ QTable *table;
+
+};
+
+class AddActionToToolBarCommand : public Command
+{
+public:
+ AddActionToToolBarCommand( const QString &n, FormWindow *fw,
+ QAction *a, QDesignerToolBar *tb, int idx );
+
+ void execute();
+ void unexecute();
+ Type type() const { return AddActionToToolBar; }
+
+private:
+ QAction *action;
+ QDesignerToolBar *toolBar;
+ int index;
+
+};
+
+class RemoveActionFromToolBarCommand : public AddActionToToolBarCommand
+{
+public:
+ RemoveActionFromToolBarCommand( const QString &n, FormWindow *fw,
+ QAction *a, QDesignerToolBar *tb, int idx )
+ : AddActionToToolBarCommand( n, fw, a, tb, idx ) {}
+
+ void execute() { AddActionToToolBarCommand::unexecute(); }
+ void unexecute() { AddActionToToolBarCommand::execute(); }
+ Type type() const { return RemoveActionFromToolBar; }
+
+};
+
+class AddActionToPopupCommand : public Command
+{
+public:
+ AddActionToPopupCommand( const QString &n, FormWindow *fw,
+ QAction *a, QDesignerPopupMenu *p, int idx );
+
+ void execute();
+ void unexecute();
+ Type type() const { return AddActionToPopup; }
+
+private:
+ QAction *action;
+ QDesignerPopupMenu *popup;
+ int index;
+
+};
+
+class RemoveActionFromPopupCommand : public AddActionToPopupCommand
+{
+public:
+ RemoveActionFromPopupCommand( const QString &n, FormWindow *fw,
+ QAction *a, QDesignerPopupMenu *p, int idx )
+ : AddActionToPopupCommand( n, fw, a, p, idx ) {}
+
+ void execute() { AddActionToPopupCommand::unexecute(); }
+ void unexecute() { AddActionToPopupCommand::execute(); }
+ Type type() const { return RemoveActionFromPopup; }
+
+};
+
+class AddMenuCommand : public Command
+{
+public:
+ AddMenuCommand( const QString &n, FormWindow *fw, QMainWindow *mw );
+
+ void execute();
+ void unexecute();
+ Type type() const { return AddMenu; }
+
+protected:
+ QDesignerMenuBar *menuBar;
+ QDesignerPopupMenu *popup;
+ QMainWindow *mainWindow;
+ int id;
+ int index;
+ QString name;
+
+};
+
+class RemoveMenuCommand : public AddMenuCommand
+{
+public:
+ RemoveMenuCommand( const QString &n, FormWindow *fw, QMainWindow *mw,
+ QDesignerMenuBar *mb, QDesignerPopupMenu *p, int i, int idx, const QString &mn )
+ : AddMenuCommand( n, fw, mw ) { menuBar = mb; popup = p; id = i; index = idx, name = mn; }
+
+ void execute() { AddMenuCommand::unexecute(); }
+ void unexecute() { AddMenuCommand::execute(); }
+ Type type() const { return RemoveMenu; }
+
+};
+
+class RenameMenuCommand : public Command
+{
+public:
+ RenameMenuCommand( const QString &n, FormWindow *fw, QDesignerMenuBar *mb,
+ int i, const QString &on, const QString &nn );
+
+ void execute();
+ void unexecute();
+ Type type() const { return RenameMenu; }
+
+private:
+ QDesignerMenuBar *menuBar;
+ int id;
+ QString oldName, newName;
+
+};
+
+class MoveMenuCommand : public Command
+{
+public:
+ MoveMenuCommand( const QString &n, FormWindow *fw, QDesignerMenuBar *mb,
+ QDesignerPopupMenu *p, int fidx, int tidx, const QString &txt );
+
+ void execute();
+ void unexecute();
+ Type type() const { return MoveMenu; }
+
+private:
+ QDesignerMenuBar *menuBar;
+ QDesignerPopupMenu *popup;
+ int fromIdx, toIdx;
+ QString text;
+
+};
+
+class AddToolBarCommand : public Command
+{
+public:
+ AddToolBarCommand( const QString &n, FormWindow *fw, QMainWindow *mw );
+
+ void execute();
+ void unexecute();
+ Type type() const { return AddToolBar; }
+
+protected:
+ QDesignerToolBar *toolBar;
+ QMainWindow *mainWindow;
+
+};
+
+class RemoveToolBarCommand : public AddToolBarCommand
+{
+public:
+ RemoveToolBarCommand( const QString &n, FormWindow *fw, QMainWindow *mw, QDesignerToolBar *tb )
+ : AddToolBarCommand( n, fw, mw ) { toolBar = tb; }
+
+ void execute() { AddToolBarCommand::unexecute(); }
+ void unexecute() { AddToolBarCommand::execute(); }
+ Type type() const { return RemoveToolBar; }
+
+};
+
+#endif
diff --git a/kommander/editor/connectioneditor.ui b/kommander/editor/connectioneditor.ui
new file mode 100644
index 00000000..d9e5a161
--- /dev/null
+++ b/kommander/editor/connectioneditor.ui
@@ -0,0 +1,418 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>ConnectionEditorBase</class>
+<comment>*********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+*********************************************************************</comment>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>ConnectionEditorBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>780</width>
+ <height>538</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Edit Connections</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;b&gt;Edit Connections&lt;/b&gt;&lt;p&gt;Add and remove connections in the current form .&lt;/p&gt;&lt;p&gt;Select a signal and a corresponding slot then press the &lt;b&gt;Connect&lt;/b&gt;-button to create a connection.&lt;/p&gt;&lt;p&gt;Select a connection from the list then press the &lt;b&gt;Disconnect&lt;/b&gt;-button to delete the connection.&lt;/p&gt;</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="KListView" row="3" column="0" rowspan="1" colspan="2">
+ <column>
+ <property name="text">
+ <string>Sender</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Signal</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Receiver</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Slot</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>connectionView</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="fullWidth">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Displays the connections between the sender and the receiver.</string>
+ </property>
+ </widget>
+ <widget class="KListBox" row="1" column="1">
+ <property name="name">
+ <cstring>slotBox</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;b&gt;A list of slots for the receiver.&lt;/b&gt;&lt;p&gt;The slots that are displayed are only those which have arguments that correspond with the arguments of the signal that is currently selected in the Signal-list.&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <widget class="KListBox" row="1" column="0">
+ <property name="name">
+ <cstring>signalBox</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Displays the list of signals that the widget emits.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>labelSignal</cstring>
+ </property>
+ <property name="text">
+ <string>Si&amp;gnals:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>signalBox</cstring>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>comboSender</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="1">
+ <property name="name">
+ <cstring>Layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>labelSlot</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Slots:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>slotBox</cstring>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>comboReceiver</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="4" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>disconnectButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Disconnect</string>
+ </property>
+ <property name="accel">
+ <string>Alt+D</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Remove the selected connection</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Remove the selected connection.</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>71</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>okButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="accel">
+ <string>Alt+O</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Close the dialog and apply all the changes.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>cancelButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="accel">
+ <string>Alt+C</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Close the dialog and discard any changes.</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>230</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Connec&amp;tions:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>connectionView</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>231</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>connectButton</cstring>
+ </property>
+ <property name="text">
+ <string>Co&amp;nnect</string>
+ </property>
+ <property name="accel">
+ <string>Alt+N</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Create connection</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Create a connection between a signal and a slot.</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>211</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<tabstops>
+ <tabstop>comboSender</tabstop>
+ <tabstop>signalBox</tabstop>
+ <tabstop>comboReceiver</tabstop>
+ <tabstop>slotBox</tabstop>
+ <tabstop>connectButton</tabstop>
+ <tabstop>connectionView</tabstop>
+ <tabstop>disconnectButton</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+</tabstops>
+<slots>
+ <slot access="protected">init()</slot>
+ <slot access="protected">destroy()</slot>
+ <slot>addSlotClicked()</slot>
+ <slot access="protected">connectClicked()</slot>
+ <slot access="protected">connectionsChanged()</slot>
+ <slot access="protected">disconnectClicked()</slot>
+ <slot access="protected">receiverChanged( const QString &amp; )</slot>
+ <slot access="protected">okClicked()</slot>
+ <slot access="protected">signalChanged()</slot>
+ <slot access="protected">slotsChanged()</slot>
+ <slot access="protected">cancelClicked()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klistview.h</includehint>
+ <includehint>klistbox.h</includehint>
+ <includehint>klistbox.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kommander/editor/connectioneditorimpl.cpp b/kommander/editor/connectioneditorimpl.cpp
new file mode 100644
index 00000000..dafae5a7
--- /dev/null
+++ b/kommander/editor/connectioneditorimpl.cpp
@@ -0,0 +1,373 @@
+/**********************************************************************
+ This file is based on Qt Designer, Copyright (C) 2000 Trolltech AS. All rights reserved.
+
+ This file may be distributed and/or modified under the terms of the
+ GNU General Public License version 2 as published by the Free Software
+ Foundation and appearing in the file LICENSE.GPL included in the
+ packaging of this file.
+
+ This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+ See http://www.trolltech.com/gpl/ for GPL licensing information.
+
+ Modified for Kommander:
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+
+**********************************************************************/
+
+#include "connectioneditorimpl.h"
+#include "metadatabase.h"
+#include "formwindow.h"
+#include "mainwindow.h"
+#include "command.h"
+#include "widgetfactory.h"
+#include "pixmapchooser.h"
+#include <qmetaobject.h>
+#include <qlabel.h>
+#include <qregexp.h>
+
+#include <klistbox.h>
+#include <klistview.h>
+#include <kpushbutton.h>
+#include <kcombobox.h>
+#include <klocale.h>
+
+static const char *const ignore_slots[] = {
+ "destroyed()",
+ //"setCaption(const QString&)",
+ "setIcon(const QPixmap&)",
+ //"setIconText(const QString&)",
+ "setMouseTracking(bool)",
+ "clearFocus()",
+ "setUpdatesEnabled(bool)",
+ "update()",
+ "update(int,int,int,int)",
+ "update(const QRect&)",
+ "repaint()",
+ "repaint(bool)",
+ "repaint(int,int,int,int,bool)",
+ "repaint(const QRect&,bool)",
+ "repaint(const QRegion&,bool)",
+ "repaint(int,int,int,int)",
+ "repaint(const QRect&)",
+ "repaint(const QRegion&)",
+ //"show()",
+ //"hide()",
+ "iconify()",
+ "showMinimized()",
+ "showMaximized()",
+ "showFullScreen()",
+ "showNormal()",
+ "polish()",
+ "constPolish()",
+ //"raise()",
+ //"lower()",
+ "stackUnder(QWidget*)",
+ //"move(int,int)",
+ "move(const QPoint&)",
+ //"resize(int,int)",
+ "resize(const QSize&)",
+ //"setGeometry(int,int,int,int)",
+ "setGeometry(const QRect&)",
+ "focusProxyDestroyed()",
+ "showExtension(bool)",
+ "setUpLayout()",
+ //"showDockMenu(const QPoint&)",
+ "init()",
+ "destroy()",
+ "deleteLater()",
+ 0
+};
+
+static const char *const ignore_signals[] = {
+ "destroyed()",
+ "destroyed(QObject*)",
+ "accessibilityChanged(int)",
+ "accessibilityChanged(int,int)",
+ 0
+};
+
+
+ConnectionEditor::ConnectionEditor(QWidget* parent, QObject* sndr, QObject* rcvr, FormWindow* fw)
+ : ConnectionEditorBase(parent, 0, true), m_formWindow(fw)
+{
+ if (!rcvr || rcvr == m_formWindow)
+ rcvr = m_formWindow->mainContainer();
+ if (!sndr || sndr == m_formWindow)
+ sndr = m_formWindow->mainContainer();
+ m_sender = sndr;
+ m_receiver = rcvr;
+
+ /* Create widget list */
+ QStringList lst;
+ lst << m_formWindow->name();
+ for (QPtrDictIterator<QWidget> it(*m_formWindow->widgets()); it.current(); ++it)
+ {
+ if (it.current()->isVisibleTo(this) &&
+ !it.current()->inherits("QLayoutWidget") &&
+ !it.current()->inherits("Spacer") &&
+ qstrcmp(it.current()->name(), "central widget") &&
+ !m_formWindow->isMainContainer(it.current()) &&
+ !lst.contains(it.current()->name()))
+ lst << it.current()->name();
+ }
+
+ // Fill receiver combos with widget list
+// fillWidgetList(comboReceiver, lst, m_receiver->name());
+
+ // Fill receiver combos with widget and action list
+ for (QPtrListIterator<QAction> it(m_formWindow->actionList()); it.current(); ++it)
+ lst << it.current()->name();
+ lst.sort();
+ fillWidgetList(comboReceiver, lst, m_receiver->name());
+ fillWidgetList(comboSender, lst, m_sender->name());
+ senderChanged(m_sender->name());
+ fillConnectionsList();
+ updateConnectButton();
+ updateDisconnectButton();
+
+ // Connections
+ connect(comboSender, SIGNAL(activated(const QString&)), SLOT(senderChanged(const QString&)));
+ connect(comboReceiver, SIGNAL(activated(const QString&)), SLOT(receiverChanged(const QString&)));
+ connect(signalBox, SIGNAL(selectionChanged()), SLOT(updateConnectButton()));
+ connect(slotBox, SIGNAL(selectionChanged()), SLOT(updateConnectButton()));
+ connect(connectButton, SIGNAL(clicked()), SLOT(connectClicked()));
+ connect(disconnectButton, SIGNAL(clicked()), SLOT(disconnectClicked()));
+ connect(okButton, SIGNAL(clicked()), SLOT(okClicked()));
+ connect(cancelButton, SIGNAL(clicked()), SLOT(cancelClicked()));
+ connect(signalBox, SIGNAL(doubleClicked(QListBoxItem*)), SLOT(connectClicked()));
+ connect(slotBox, SIGNAL(doubleClicked(QListBoxItem*)), SLOT(connectClicked()));
+}
+
+ConnectionEditor::~ConnectionEditor()
+{
+}
+
+bool ConnectionEditor::isSignalIgnored(const char *signal) const
+{
+ for (int i = 0; ignore_signals[i]; i++)
+ if (!qstrcmp(signal, ignore_signals[i]))
+ return true;
+ return false;
+}
+
+bool ConnectionEditor::isSlotIgnored(const QMetaData* md)
+{
+ if (md->access != QMetaData::Public && (md->access != QMetaData::Protected ||
+ !m_formWindow->isMainContainer((QWidget*)m_receiver)))
+ return true;
+ for (int i = 0; ignore_slots[i]; i++)
+ if (!qstrcmp(md->name, ignore_slots[i]))
+ return true;
+ if (!m_formWindow->isMainContainer((QWidget *)m_receiver) && !qstrcmp(md->name, "close()"))
+ return true;
+ if (!qstrcmp(md->name, "setFocus()") && m_receiver->isWidgetType() &&
+ ((QWidget*)m_receiver)->focusPolicy() == QWidget::NoFocus)
+ return true;
+ for (int i = 0; i<comboSender->count(); i++)
+ if (checkConnectArgs(MetaDataBase::normalizeSlot(signalBox->text(i)).latin1(), m_receiver, md->name))
+ return false;
+ return true;
+}
+
+QObject* ConnectionEditor::objectByName(const QString& s) const
+{
+ for (QPtrDictIterator <QWidget> it(*m_formWindow->widgets()); it.current(); ++it)
+ if (QString(it.current()->name()) == s)
+ return it.current();
+
+ for (QPtrListIterator<QAction> it(m_formWindow->actionList()); it.current(); ++it)
+ if (QString(it.current()->name()) == s)
+ return it.current();
+
+ return 0;
+}
+
+
+void ConnectionEditor::connectClicked()
+{
+ if (signalBox->currentItem() == -1 || slotBox->currentItem() == -1)
+ return;
+ if (hasConnection(m_sender->name(), signalBox->currentText(), m_receiver->name(),
+ slotBox->currentText()))
+ return;
+ MetaDataBase::Connection conn;
+ conn.sender = m_sender;
+ conn.signal = signalBox->currentText();
+ conn.slot = slotBox->currentText();
+ conn.receiver = m_receiver;
+ KListViewItem *i = new KListViewItem(connectionView, m_sender->name(), conn.signal, m_receiver->name(),
+ conn.slot);
+ i->setPixmap(0, PixmapChooser::loadPixmap("connecttool.xpm"));
+ connectionView->setCurrentItem(i);
+ connectionView->setSelected(i, true);
+ m_connections.insert(i, conn);
+ connectButton->setEnabled(false);
+ updateDisconnectButton();
+}
+
+void ConnectionEditor::disconnectClicked()
+{
+ QListViewItem *p_item = connectionView->currentItem();
+ if (!p_item)
+ return;
+
+ QMap <QListViewItem*, MetaDataBase::Connection>::Iterator it = m_connections.find(p_item);
+ if (it != m_connections.end())
+ m_connections.remove(it);
+ delete p_item;
+ if (connectionView->currentItem())
+ connectionView->setSelected(connectionView->currentItem(), true);
+ updateConnectButton();
+ updateDisconnectButton();
+}
+
+void ConnectionEditor::okClicked()
+{
+ MacroCommand* rmConn = 0, *addConn = 0;
+ QString n = i18n("Connect/Disconnect the signals and slots of '%1' and '%2'").arg(m_sender->name()).
+ arg(m_receiver->name());
+ QValueList <MetaDataBase::Connection>::Iterator cit;
+ if (!m_oldConnections.isEmpty())
+ {
+ QPtrList <Command> commands;
+ for (cit = m_oldConnections.begin(); cit != m_oldConnections.end(); ++cit)
+ commands.append(new RemoveConnectionCommand(i18n("Remove Connection"), m_formWindow, *cit));
+ rmConn = new MacroCommand(i18n("Remove Connections"), m_formWindow, commands);
+ }
+ if (!m_connections.isEmpty())
+ {
+ QMap<QListViewItem*, MetaDataBase::Connection>::Iterator it = m_connections.begin();
+ QPtrList<Command> commands;
+ for (; it != m_connections.end(); ++it)
+ {
+ MetaDataBase::Connection conn = *it;
+ commands.append(new AddConnectionCommand(i18n("Add Connection"), m_formWindow, conn));
+ }
+ addConn = new MacroCommand(i18n("Add Connections"), m_formWindow, commands);
+ }
+
+ if (rmConn || addConn)
+ {
+ QPtrList < Command > commands;
+ if (rmConn)
+ commands.append(rmConn);
+ if (addConn)
+ commands.append(addConn);
+ MacroCommand *cmd = new MacroCommand(n, m_formWindow, commands);
+ m_formWindow->commandHistory()->addCommand(cmd);
+ cmd->execute();
+ }
+
+ accept();
+}
+
+void ConnectionEditor::cancelClicked()
+{
+ reject();
+}
+
+void ConnectionEditor::senderChanged(const QString& s)
+{
+ QObject* p_object = objectByName(s);
+ if (!p_object)
+ return;
+ m_sender = p_object;
+ QStrList p_sigs = m_sender->metaObject()->signalNames(true);
+ signalBox->clear();
+ for (QStrListIterator it(p_sigs); it.current(); ++it)
+ if (!isSignalIgnored(it.current()) && !signalBox->findItem(it.current(), Qt::ExactMatch))
+ signalBox->insertItem(it.current());
+ if (m_sender == m_formWindow->mainContainer())
+ signalBox->insertStringList(MetaDataBase::signalList(m_formWindow));
+ signalBox->sort();
+ signalBox->setCurrentItem(signalBox->firstItem());
+ // Update slots - some may (not) have their signal equivalents now.
+ receiverChanged(m_receiver->name());
+}
+
+void ConnectionEditor::receiverChanged(const QString& s)
+{
+ QObject* p_object = objectByName(s);
+ if (!p_object)
+ return;
+ m_receiver = p_object;
+ int n = m_receiver->metaObject()->numSlots(true);
+ slotBox->clear();
+ for (int i = 0; i < n; ++i)
+ {
+ const QMetaData* md = m_receiver->metaObject()->slot(i, true);
+ if (!isSlotIgnored(md) && !slotBox->findItem(md->name, Qt::ExactMatch))
+ slotBox->insertItem(md->name);
+ }
+ slotBox->sort();
+ slotBox->setCurrentItem(slotBox->firstItem());
+ updateConnectButton();
+}
+
+void ConnectionEditor::updateConnectButton()
+{
+ bool itemsSelected = signalBox->currentItem() != -1 && slotBox->currentItem() != -1;
+ bool notConnected = !itemsSelected || !hasConnection(m_sender->name(), signalBox->currentText(),
+ m_receiver->name(), slotBox->currentText());
+ bool connectionAllowed = notConnected && checkConnectArgs(MetaDataBase::normalizeSlot(signalBox->currentText()).latin1(),
+ m_receiver, MetaDataBase::normalizeSlot(slotBox->currentText()).latin1());
+ connectButton->setEnabled(itemsSelected && notConnected && connectionAllowed);
+}
+
+void ConnectionEditor::updateDisconnectButton()
+{
+ disconnectButton->setEnabled((connectionView->currentItem()));
+}
+
+bool ConnectionEditor::hasConnection(const QString& snder, const QString& signal,
+ const QString& rcvr, const QString& slot) const
+{
+ for (QListViewItemIterator it(connectionView); it.current(); ++it)
+ if (it.current()->text(0) == snder &&
+ it.current()->text(1) == signal &&
+ it.current()->text(2) == rcvr && it.current()->text(3) == slot)
+ return true;
+ return false;
+}
+
+void ConnectionEditor::fillConnectionsList()
+{
+ connectionView->clear();
+ m_connections.clear();
+ m_oldConnections = MetaDataBase::connections(m_formWindow);
+ if (!m_oldConnections.isEmpty())
+ {
+ QValueList <MetaDataBase::Connection>::Iterator it = m_oldConnections.begin();
+ for (; it != m_oldConnections.end(); ++it)
+ {
+ if (m_formWindow->isMainContainer((QWidget*)(*it).receiver) &&
+ !MetaDataBase::hasSlot(m_formWindow, MetaDataBase::normalizeSlot((*it).slot).latin1()))
+ continue;
+ MetaDataBase::Connection conn = *it;
+ KListViewItem *i = new KListViewItem(connectionView, conn.sender->name(), conn.signal,
+ conn.receiver->name(), conn.slot);
+ i->setPixmap(0, PixmapChooser::loadPixmap("connecttool.xpm"));
+ m_connections.insert(i, conn);
+ }
+ }
+ connectionView->setCurrentItem(connectionView->firstChild());
+ if (connectionView->currentItem())
+ connectionView->setSelected(connectionView->currentItem(), true);
+}
+
+void ConnectionEditor::fillWidgetList(KComboBox* a_combo, const QStringList& items, const QString& defaultWidget)
+{
+ a_combo->insertStringList(items);
+ for (int i = 0; i < a_combo->count(); ++i)
+ if (a_combo->text(i) == defaultWidget)
+ {
+ a_combo->setCurrentItem(i);
+ return;
+ }
+ if (a_combo->count())
+ a_combo->setCurrentItem(0);
+}
+
+#include "connectioneditorimpl.moc"
diff --git a/kommander/editor/connectioneditorimpl.h b/kommander/editor/connectioneditorimpl.h
new file mode 100644
index 00000000..95c6887b
--- /dev/null
+++ b/kommander/editor/connectioneditorimpl.h
@@ -0,0 +1,76 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef CONNECTIONEDITORIMPL_H
+#define CONNECTIONEDITORIMPL_H
+
+#include "connectioneditor.h"
+#include "metadatabase.h"
+
+#include <qmap.h>
+
+class QListViewItem;
+class FormWindow;
+
+class ConnectionEditor : public ConnectionEditorBase
+{
+Q_OBJECT public:
+ ConnectionEditor(QWidget* parent, QObject* sender, QObject* receiver, FormWindow* fw);
+ ~ConnectionEditor();
+
+protected slots:
+ // Add current pair <signal, slot> to the list
+ void connectClicked();
+ // Remove current pair <signal, slot> to the list
+ void disconnectClicked();
+ // Lists all connections defined in current dialog
+ void fillConnectionsList();
+ // Lists all widgets in sender or receiver combo
+ void fillWidgetList(KComboBox* a_combo, const QStringList& items, const QString& defaultWidget);
+ // Sender widget was changed - update signal list
+ void senderChanged(const QString & s);
+ // Receiver widget was changed - update slot list
+ void receiverChanged(const QString & s);
+ // Enable/disable 'Connect' button when pair <signal,slot> changes
+ void updateConnectButton();
+ // Enable/disable 'Disconnect' button when selection changes
+ void updateDisconnectButton();
+ // Accept and close button
+ void okClicked();
+ // Cancel and close button
+ void cancelClicked();
+
+private:
+ // Whether given signal should appear in the signal list
+ bool isSignalIgnored(const char*) const;
+ // Whether given slot should appear in the slot list
+ bool isSlotIgnored(const QMetaData* md);
+ // Finds widget by name
+ QObject* objectByName(const QString& s) const;
+ bool hasConnection(const QString & snder, const QString & signal,
+ const QString & rcvr, const QString & slot) const;
+ QMap <QListViewItem*, MetaDataBase::Connection> m_connections;
+ QValueList <MetaDataBase::Connection> m_oldConnections;
+ QObject* m_sender;
+ QObject* m_receiver;
+ FormWindow* m_formWindow;
+};
+
+#endif
diff --git a/kommander/editor/createtemplate.ui b/kommander/editor/createtemplate.ui
new file mode 100644
index 00000000..a6034d03
--- /dev/null
+++ b/kommander/editor/createtemplate.ui
@@ -0,0 +1,222 @@
+<!DOCTYPE UI><UI>
+<class>CreateTemplate</class><comment>*********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+*********************************************************************</comment>
+<widget>
+ <class>QDialog</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>CreateTemplate</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>347</width>
+ <height>248</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Create Template</string>
+ </property>
+ <property stdset="1">
+ <name>sizeGripEnabled</name>
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget row="0" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Template &amp;name:</string>
+ </property>
+ <property>
+ <name>buddy</name>
+ <cstring>editName</cstring>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>editName</cstring>
+ </property>
+ <property>
+ <name>toolTip</name>
+ <string>Name of the new template</string>
+ </property>
+ <property>
+ <name>whatsThis</name>
+ <string>Enter the name of the new template</string>
+ </property>
+ </widget>
+ <widget row="1" column="1" rowspan="2" colspan="1" >
+ <class>QListBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>listClass</cstring>
+ </property>
+ <property>
+ <name>toolTip</name>
+ <string>Class of the new template</string>
+ </property>
+ <property>
+ <name>whatsThis</name>
+ <string>Enter the name of the class which should be used as the template's base class</string>
+ </property>
+ </widget>
+ <widget row="3" column="0" rowspan="1" colspan="2" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer1</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>buttonCreate</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>C&amp;reate</string>
+ </property>
+ <property stdset="1">
+ <name>default</name>
+ <bool>true</bool>
+ </property>
+ <property>
+ <name>whatsThis</name>
+ <string>Creates the new template</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton1</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&amp;Cancel</string>
+ </property>
+ <property>
+ <name>whatsThis</name>
+ <string>Closes the Dialog</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget row="1" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&amp;Baseclass for template:</string>
+ </property>
+ <property>
+ <name>buddy</name>
+ <cstring>listClass</cstring>
+ </property>
+ </widget>
+ <spacer row="2" column="0" >
+ <property>
+ <name>name</name>
+ <cstring>Spacer2</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Vertical</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonCreate</sender>
+ <signal>clicked()</signal>
+ <receiver>CreateTemplate</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>PushButton1</sender>
+ <signal>clicked()</signal>
+ <receiver>CreateTemplate</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+</UI>
diff --git a/kommander/editor/defs.cpp b/kommander/editor/defs.cpp
new file mode 100644
index 00000000..fdf06ce9
--- /dev/null
+++ b/kommander/editor/defs.cpp
@@ -0,0 +1,78 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "defs.h"
+
+int size_type_to_int( QSizePolicy::SizeType t )
+{
+ if ( t == QSizePolicy::Fixed )
+ return 0;
+ if ( t == QSizePolicy::Minimum )
+ return 1;
+ if ( t == QSizePolicy::Maximum )
+ return 2;
+ if ( t == QSizePolicy::Preferred )
+ return 3;
+ if ( t == QSizePolicy::MinimumExpanding )
+ return 4;
+ if ( t == QSizePolicy::Expanding )
+ return 5;
+ if ( t == QSizePolicy::Ignored )
+ return 6;
+ return 0;
+}
+
+QString size_type_to_string( QSizePolicy::SizeType t )
+{
+ if ( t == QSizePolicy::Fixed )
+ return "Fixed";
+ if ( t == QSizePolicy::Minimum )
+ return "Minimum";
+ if ( t == QSizePolicy::Maximum )
+ return "Maximum";
+ if ( t == QSizePolicy::Preferred )
+ return "Preferred";
+ if ( t == QSizePolicy::MinimumExpanding )
+ return "MinimumExpanding";
+ if ( t == QSizePolicy::Expanding )
+ return "Expanding";
+ if ( t == QSizePolicy::Ignored )
+ return "Ignored";
+ return 0;
+}
+
+QSizePolicy::SizeType int_to_size_type( int i )
+{
+ if ( i == 0 )
+ return QSizePolicy::Fixed;
+ if ( i == 1 )
+ return QSizePolicy::Minimum;
+ if ( i == 2 )
+ return QSizePolicy::Maximum;
+ if ( i == 3 )
+ return QSizePolicy::Preferred;
+ if ( i == 4 )
+ return QSizePolicy::MinimumExpanding;
+ if ( i == 5 )
+ return QSizePolicy::Expanding;
+ if ( i == 6 )
+ return QSizePolicy::Ignored;
+ return QSizePolicy::Preferred;
+}
diff --git a/kommander/editor/defs.h b/kommander/editor/defs.h
new file mode 100644
index 00000000..ade3fa4b
--- /dev/null
+++ b/kommander/editor/defs.h
@@ -0,0 +1,35 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef DEFS_H
+#define DEFS_H
+
+#include <qsizepolicy.h>
+#include <qstring.h>
+
+#define POINTER_TOOL 32000
+#define CONNECT_TOOL 32001
+#define ORDER_TOOL 32002
+
+int size_type_to_int( QSizePolicy::SizeType t );
+QString size_type_to_string( QSizePolicy::SizeType t );
+QSizePolicy::SizeType int_to_size_type( int i );
+
+#endif
diff --git a/kommander/editor/filechooser.cpp b/kommander/editor/filechooser.cpp
new file mode 100644
index 00000000..14bedb95
--- /dev/null
+++ b/kommander/editor/filechooser.cpp
@@ -0,0 +1,63 @@
+#include "filechooser.h"
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <kfiledialog.h>
+#include <qlayout.h>
+
+FileChooser::FileChooser( QWidget *parent, const char *name )
+ : QWidget( parent, name ), md( File )
+{
+ QHBoxLayout *layout = new QHBoxLayout( this );
+ layout->setMargin( 0 );
+
+ lineEdit = new QLineEdit( this, "filechooser_lineedit" );
+ layout->addWidget( lineEdit );
+
+ connect( lineEdit, SIGNAL( textChanged( const QString & ) ),
+ this, SIGNAL( fileNameChanged( const QString & ) ) );
+
+ button = new QPushButton( "...", this, "filechooser_button" );
+ button->setFixedWidth( button->fontMetrics().width( " ... " ) );
+ layout->addWidget( button );
+
+ connect( button, SIGNAL( clicked() ),
+ this, SLOT( chooseFile() ) );
+
+ setFocusProxy( lineEdit );
+}
+
+void FileChooser::setMode( Mode m )
+{
+ md = m;
+}
+
+FileChooser::Mode FileChooser::mode() const
+{
+ return md;
+}
+
+void FileChooser::setFileName( const QString &fn )
+{
+ lineEdit->setText( fn );
+}
+
+QString FileChooser::fileName() const
+{
+ return lineEdit->text();
+}
+
+void FileChooser::chooseFile()
+{
+ QString fn;
+ if ( mode() == File )
+ fn = KFileDialog::getOpenFileName( lineEdit->text(), QString::null, this );
+ else
+ fn = KFileDialog::getExistingDirectory( lineEdit->text(),this );
+
+ if ( !fn.isEmpty() ) {
+ lineEdit->setText( fn );
+ emit fileNameChanged( fn );
+ }
+}
+
+#include "filechooser.moc"
diff --git a/kommander/editor/filechooser.h b/kommander/editor/filechooser.h
new file mode 100644
index 00000000..e6bc98e3
--- /dev/null
+++ b/kommander/editor/filechooser.h
@@ -0,0 +1,42 @@
+#ifndef FILECHOOSER_H
+#define FILECHOOSER_H
+
+#include <qwidget.h>
+
+class QLineEdit;
+class QPushButton;
+
+class FileChooser : public QWidget
+{
+ Q_OBJECT
+
+ Q_ENUMS( Mode )
+ Q_PROPERTY( Mode mode READ mode WRITE setMode )
+ Q_PROPERTY( QString fileName READ fileName WRITE setFileName )
+
+public:
+ FileChooser( QWidget *parent = 0, const char *name = 0);
+
+ enum Mode { File, Directory };
+
+ QString fileName() const;
+ Mode mode() const;
+
+public slots:
+ void setFileName( const QString &fn );
+ void setMode( Mode m );
+
+signals:
+ void fileNameChanged( const QString & );
+
+private slots:
+ void chooseFile();
+
+private:
+ QLineEdit *lineEdit;
+ QPushButton *button;
+ Mode md;
+
+};
+
+#endif
diff --git a/kommander/editor/formfile.cpp b/kommander/editor/formfile.cpp
new file mode 100644
index 00000000..645b04ef
--- /dev/null
+++ b/kommander/editor/formfile.cpp
@@ -0,0 +1,302 @@
+/**********************************************************************
+ This file is based on Qt Designer, Copyright (C) 2000 Trolltech AS. All rights reserved.
+
+ This file may be distributed and/or modified under the terms of the
+ GNU General Public License version 2 as published by the Free Software
+ Foundation and appearing in the file LICENSE.GPL included in the
+ packaging of this file.
+
+ This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+ See http://www.trolltech.com/gpl/ for GPL licensing information.
+
+ Modified for Kommander:
+ (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+
+**********************************************************************/
+
+// Other includes
+#include "formfile.h"
+#include "timestamp.h"
+#include "formwindow.h"
+#include "command.h"
+#include "mainwindow.h"
+#include "resource.h"
+#include "workspace.h"
+
+// Qt includes
+#include <qfile.h>
+#include <qregexp.h>
+#include <qstatusbar.h>
+#include <qtimer.h>
+
+// KDE includes
+#include <kdebug.h>
+#include <kfiledialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kstatusbar.h>
+#include <kstdguiitem.h>
+
+#include <sys/stat.h>
+
+FormFile::FormFile(const QString &fn, bool temp)
+ : filename(fn), fileNameTemp(temp), fw(0)
+{
+ QTimer::singleShot(0, this, SLOT(init()));
+}
+
+void FormFile::init()
+{
+ connect(this, SIGNAL(addedFormFile(FormFile *)), MainWindow::self->workspace(),
+ SLOT(formFileAdded(FormFile*)));
+ connect(this, SIGNAL(removedFormFile(FormFile *)), MainWindow::self->workspace(),
+ SLOT(formFileRemoved(FormFile*)));
+ emit addedFormFile(this);
+}
+
+FormFile::~FormFile()
+{
+ if (formWindow())
+ formWindow()->setFormFile(0);
+}
+
+void FormFile::setFormWindow(FormWindow *f)
+{
+ if (f == fw)
+ return;
+ if (fw)
+ fw->setFormFile(0);
+ fw = f;
+ if (fw)
+ fw->setFormFile(this);
+}
+
+void FormFile::setFileName(const QString &fn)
+{
+ if (fn == filename)
+ return;
+ if (fn.isEmpty()) {
+ fileNameTemp = true;
+ if (filename.find("unnamed"))
+ filename = createUnnamedFileName();
+ return;
+ }
+ filename = fn;
+}
+
+FormWindow *FormFile::formWindow() const
+{
+ return fw;
+}
+
+QString FormFile::fileName() const
+{
+ return filename;
+}
+
+QString FormFile::absFileName() const
+{
+ return filename;
+}
+
+
+bool FormFile::save(bool withMsgBox)
+{
+ if (!formWindow())
+ return true;
+ if (fileNameTemp)
+ return saveAs();
+ if (!isModified())
+ return true;
+ else if (withMsgBox && !formWindow()->checkCustomWidgets())
+ return false;
+
+ Resource resource(MainWindow::self);
+ resource.setWidget(formWindow());
+ if (!resource.save(filename, false))
+ {
+ if (KMessageBox::questionYesNo(MainWindow::self, i18n("Failed to save file '%1'.\n"
+ "Do you want to use another file name?").arg(filename), QString::null, i18n("Try Another"), i18n("Do Not Try")) == KMessageBox::Yes)
+ return saveAs();
+ else
+ return false;
+ }
+ MainWindow::self->statusBar()->message(i18n("'%1' saved.").arg(filename), 3000);
+ ::chmod(filename.local8Bit(), S_IRWXU);
+ setModified(false);
+ return true;
+}
+
+bool FormFile::saveAs()
+{
+ QString f = fileName();
+ if(fileNameTemp)
+ f = QString(formWindow()->name()).lower() + ".kmdr";
+ bool saved = false;
+ while (!saved) {
+ QString fn = KFileDialog::getSaveFileName(QString::null,
+ i18n("*.kmdr|Kommander Files"), MainWindow::self,
+ i18n("Save Form '%1' As").arg(formWindow()->name()));
+ if (fn.isEmpty())
+ return false;
+ QFileInfo fi(fn);
+ if (fi.extension() != "kmdr")
+ fn += ".kmdr";
+ fileNameTemp = false;
+ filename = fn;
+
+ QFileInfo relfi(filename);
+ if (relfi.exists()) {
+ if (KMessageBox::warningContinueCancel(MainWindow::self,
+ i18n("The file already exists. Do you wish to overwrite it?"),
+ i18n("Overwrite File?"), i18n("Overwrite")) == KMessageBox::Continue)
+ saved = true;
+ else
+ filename = f;
+ }
+ else
+ saved = true;
+ }
+ setModified(true);
+ return save();
+}
+
+bool FormFile::close()
+{
+ if (formWindow())
+ return formWindow()->close();
+ return true;
+}
+
+bool FormFile::closeEvent()
+{
+ if (!isModified())
+ {
+ emit removedFormFile(this);
+ QFile f(filename + ".backup");
+ f.remove();
+ return true;
+ }
+
+ switch (KMessageBox::warningYesNoCancel(MainWindow::self, i18n("Dialog '%1' was modified."
+ "Do you want to save it?").arg(filename), i18n("Save File?"), KStdGuiItem::save(), KStdGuiItem::discard())) {
+ case KMessageBox::Yes:
+ if (!save())
+ return false;
+ case KMessageBox::No: //fall through
+ MainWindow::self->workspace()->update();
+ break;
+ case KMessageBox::Cancel:
+ return false;
+ default:
+ break;
+ }
+
+ emit removedFormFile(this);
+ setModified(false);
+ QFile f(filename + ".backup");
+ f.remove();
+ return true;
+}
+
+void FormFile::setModified(bool m)
+{
+ setFormWindowModified(m);
+}
+
+bool FormFile::isModified()
+{
+ return isFormWindowModified();
+}
+
+bool FormFile::isFormWindowModified() const
+{
+ if (!formWindow() || !formWindow()->commandHistory())
+ return false;
+ return formWindow()->commandHistory()->isModified();
+}
+
+void FormFile::setFormWindowModified(bool m)
+{
+ if (m == isFormWindowModified() || !formWindow() || !formWindow()->commandHistory())
+ return;
+ formWindow()->commandHistory()->setModified(m);
+ emit somethingChanged(this);
+}
+
+void FormFile::showFormWindow()
+{
+ if (formWindow())
+ {
+ formWindow()->setFocus();
+ return;
+ }
+ MainWindow::self->openFormWindow(filename, true, this);
+}
+
+
+static int ui_counter = 0;
+QString FormFile::createUnnamedFileName()
+{
+ return i18n("unnamed") + QString::number(++ui_counter) + QString(".kmdr");
+}
+
+QString FormFile::formName() const
+{
+ FormFile* that = (FormFile*) this;
+ if (formWindow()) {
+ that->cachedFormName = formWindow()->name();
+ return cachedFormName;
+ }
+ if (!cachedFormName.isNull())
+ return cachedFormName;
+ QFile f(filename);
+ if (f.open(IO_ReadOnly))
+ {
+ QTextStream ts(&f);
+ QString line;
+ QString className;
+ while (!ts.eof())
+ {
+ line = ts.readLine();
+ if (!className.isEmpty())
+ {
+ int end = line.find("</class>");
+ if (end == -1)
+ className += line;
+ else
+ {
+ className += line.left(end);
+ break;
+ }
+ continue;
+ }
+ int start;
+ if ((start = line.find("<class>")) != -1)
+ {
+ int end = line.find("</class>");
+ if (end == -1)
+ className = line.mid(start + 7);
+ else
+ {
+ className = line.mid(start + 7, end - (start + 7));
+ break;
+ }
+ }
+ }
+ that->cachedFormName = className;
+ }
+ if (cachedFormName.isEmpty())
+ that->cachedFormName = filename;
+ return cachedFormName;
+}
+
+void FormFile::formWindowChangedSomehow()
+{
+ emit somethingChanged(this);
+}
+
+#include "formfile.moc"
diff --git a/kommander/editor/formfile.h b/kommander/editor/formfile.h
new file mode 100644
index 00000000..39fecc67
--- /dev/null
+++ b/kommander/editor/formfile.h
@@ -0,0 +1,74 @@
+/**********************************************************************
+ This file is based on Qt Designer, Copyright (C) 2000 Trolltech AS. �All rights reserved.
+
+ This file may be distributed and/or modified under the terms of the
+ GNU General Public License version 2 as published by the Free Software
+ Foundation and appearing in the file LICENSE.GPL included in the
+ packaging of this file.
+
+ This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+ See http://www.trolltech.com/gpl/ for GPL licensing information.
+
+ Modified for Kommander:
+ (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+
+**********************************************************************/
+
+#ifndef FORMFILE_H
+#define FORMFILE_H
+
+#include <qobject.h>
+#include "timestamp.h"
+#include "metadatabase.h"
+
+class FormWindow;
+
+class FormFile : public QObject
+{
+ Q_OBJECT
+
+public:
+ FormFile(const QString &fn, bool temp);
+ ~FormFile();
+
+ void setFormWindow( FormWindow *f );
+ void setFileName( const QString &fn );
+ void setModified(bool m);
+ FormWindow *formWindow() const;
+ QString fileName() const;
+ QString absFileName() const;
+ bool save( bool withMsgBox = TRUE );
+ bool saveAs();
+ bool close();
+ bool closeEvent();
+ bool isModified();
+ void showFormWindow();
+ static QString createUnnamedFileName();
+ QString formName() const;
+ bool hasTempFileName() const {return fileNameTemp;}
+
+signals:
+ void addedFormFile(FormFile*);
+ void removedFormFile(FormFile*);
+ void somethingChanged(FormFile*);
+
+private slots:
+ void formWindowChangedSomehow();
+ void init();
+
+private:
+ bool isFormWindowModified() const;
+ void setFormWindowModified( bool m );
+
+private:
+ QString filename;
+ bool fileNameTemp;
+ FormWindow *fw;
+ QString cachedFormName;
+
+};
+
+#endif
diff --git a/kommander/editor/formsettings.ui b/kommander/editor/formsettings.ui
new file mode 100644
index 00000000..321de024
--- /dev/null
+++ b/kommander/editor/formsettings.ui
@@ -0,0 +1,338 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>FormSettingsBase</class>
+<comment>*********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+*********************************************************************</comment>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>FormSettingsBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>497</width>
+ <height>490</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Form Settings</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;b&gt;Form Settings&lt;/b&gt;&lt;p&gt;Change settings for the form. Settings like &lt;b&gt;Comment&lt;/b&gt; and &lt;b&gt;Author&lt;/b&gt; are for your own use and are not required.&lt;/p&gt;</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Horizontal Spacing2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Close the dialog and apply all the changes.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Close the dialog and discard any changes.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>GroupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>La&amp;youts</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QSpinBox" row="0" column="1">
+ <property name="name">
+ <cstring>spinMargin</cstring>
+ </property>
+ <property name="value">
+ <number>11</number>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="1" column="1">
+ <property name="name">
+ <cstring>spinSpacing</cstring>
+ </property>
+ <property name="value">
+ <number>6</number>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Default mar&amp;gin:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>spinMargin</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>D&amp;efault spacing:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>spinSpacing</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>GroupBox1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="title">
+ <string>&amp;Settings</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QMultiLineEdit" row="3" column="1" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>editComment</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Enter a comment about the form.</string>
+ </property>
+ </widget>
+ <spacer row="4" column="0">
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>130</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Co&amp;mment:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>editComment</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>TextLabel1_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;License:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>editAuthor</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>editLicense</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Enter your name</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Enter your name.</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel1_2_3</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Version:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>editAuthor</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>A&amp;uthor:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>editAuthor</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>editAuthor</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Enter your name</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Enter your name.</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>editVersion</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Enter your name</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Enter your name.</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSettingsBase</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSettingsBase</receiver>
+ <slot>okClicked()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>editAuthor</tabstop>
+ <tabstop>editVersion</tabstop>
+ <tabstop>editLicense</tabstop>
+ <tabstop>editComment</tabstop>
+ <tabstop>spinMargin</tabstop>
+ <tabstop>spinSpacing</tabstop>
+ <tabstop>buttonOk</tabstop>
+ <tabstop>buttonCancel</tabstop>
+</tabstops>
+<slots>
+ <slot>okClicked()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/kommander/editor/formsettingsimpl.cpp b/kommander/editor/formsettingsimpl.cpp
new file mode 100644
index 00000000..4daec8ba
--- /dev/null
+++ b/kommander/editor/formsettingsimpl.cpp
@@ -0,0 +1,58 @@
+/**********************************************************************
+ This file is based on Qt Designer, Copyright (C) 2000 Trolltech AS. All rights reserved.
+
+ This file may be distributed and/or modified under the terms of the
+ GNU General Public License version 2 as published by the Free Software
+ Foundation and appearing in the file LICENSE.GPL included in the
+ packaging of this file.
+
+ This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+ See http://www.trolltech.com/gpl/ for GPL licensing information.
+
+ Modified for Kommander:
+ (C) 2005 Michal Rudolf <mrudolf@kdewebdev.org>
+
+**********************************************************************/
+
+#include "formsettingsimpl.h"
+#include "formwindow.h"
+#include "metadatabase.h"
+#include "command.h"
+#include "asciivalidator.h"
+#include "mainwindow.h"
+
+#include <qmultilineedit.h>
+#include <klineedit.h>
+#include <qspinbox.h>
+
+FormSettings::FormSettings( QWidget *parent, FormWindow *fw )
+ : FormSettingsBase( parent, 0, true ), formwindow( fw )
+{
+ MetaDataBase::MetaInfo info = MetaDataBase::metaInfo(fw);
+ editAuthor->setText(info.author);
+ editVersion->setText(info.version);
+ editLicense->setText(info.license);
+ editComment->setText(info.comment);
+ spinSpacing->setValue(formwindow->layoutDefaultSpacing());
+ spinMargin->setValue(formwindow->layoutDefaultMargin());
+}
+
+void FormSettings::okClicked()
+{
+ MetaDataBase::MetaInfo info;
+ info.author = editAuthor->text();
+ info.version = editVersion->text();
+ info.license = editLicense->text();
+ info.comment = editComment->text();
+ MetaDataBase::setMetaInfo(formwindow, info);
+ formwindow->commandHistory()->setModified(true);
+
+ formwindow->setLayoutDefaultSpacing(spinSpacing->value());
+ formwindow->setLayoutDefaultMargin(spinMargin->value());
+ accept();
+}
+
+#include "formsettingsimpl.moc"
+
diff --git a/kommander/editor/formsettingsimpl.h b/kommander/editor/formsettingsimpl.h
new file mode 100644
index 00000000..f33c2194
--- /dev/null
+++ b/kommander/editor/formsettingsimpl.h
@@ -0,0 +1,43 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef FORMSETTINGSIMPL_H
+#define FORMSETTINGSIMPL_H
+
+#include "formsettings.h"
+
+class FormWindow;
+
+class FormSettings : public FormSettingsBase
+{
+ Q_OBJECT
+
+public:
+ FormSettings( QWidget *parent, FormWindow *fw );
+
+protected slots:
+ void okClicked();
+
+private:
+ FormWindow *formwindow;
+
+};
+
+#endif
diff --git a/kommander/editor/formwindow.cpp b/kommander/editor/formwindow.cpp
new file mode 100644
index 00000000..0aa9b122
--- /dev/null
+++ b/kommander/editor/formwindow.cpp
@@ -0,0 +1,2609 @@
+/**********************************************************************
+ This file is based on Qt Designer, Copyright (C) 2000 Trolltech AS. All rights reserved.
+
+ This file may be distributed and/or modified under the terms of the
+ GNU General Public License version 2 as published by the Free Software
+ Foundation and appearing in the file LICENSE.GPL included in the
+ packaging of this file.
+
+ This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+ See http://www.trolltech.com/gpl/ for GPL licensing information.
+
+ Modified for Kommander:
+ (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+
+**********************************************************************/
+
+// Qt includes
+#include <qaccel.h>
+#include <qapplication.h>
+#include <qbitmap.h>
+#include <qevent.h>
+#include <qfeatures.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qmap.h>
+#include <qmetaobject.h>
+#include <qobjectlist.h>
+#include <qpainter.h>
+#include <qpalette.h>
+#include <qpen.h>
+#include <qpixmapcache.h>
+#include <qpopupmenu.h>
+#include <qpushbutton.h>
+#include <qsizegrip.h>
+#include <qspinbox.h>
+#include <qstatusbar.h>
+#include <qtimer.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+// KDE includes
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kstatusbar.h>
+
+// Other includes
+#include "formwindow.h"
+#include "defs.h"
+#include "mainwindow.h"
+#include "widgetfactory.h"
+#include "sizehandle.h"
+#include "metadatabase.h"
+#include "resource.h"
+#include "layout.h"
+#include "connectioneditorimpl.h"
+#include "widgetdatabase.h"
+#include "pixmapchooser.h"
+#include "orderindicator.h"
+#include "hierarchyview.h"
+
+#include "globaldefs.h"
+#include "formfile.h"
+
+#include <stdlib.h>
+
+
+static void setCursorToAll(const QCursor &c, QWidget *start)
+{
+ start->setCursor(c);
+ QObjectList *l = (QObjectList*)start->children();
+ if (l)
+ for (QObject *o = l->first(); o; o = l->next())
+ {
+ if (o->isWidgetType() && !o->inherits("SizeHandle"))
+ setCursorToAll(c, ((QWidget*)o));
+ }
+}
+
+static void restoreCursors(QWidget *start, FormWindow *fw)
+{
+ if (fw->widgets()->find(start))
+ start->setCursor(MetaDataBase::cursor(start));
+ else
+ start->setCursor(Qt::ArrowCursor);
+ QObjectList *l = (QObjectList*)start->children();
+ if (l)
+ for (QObject *o = l->first(); o; o = l->next())
+ {
+ if (o->isWidgetType() && !o->inherits("SizeHandle"))
+ restoreCursors(((QWidget*)o), fw);
+ }
+}
+
+
+/*
+ The FormWindow is the widget which is used as editor for forms. It
+ handles inserting, deleting, moving, resizing, etc. of widgets.
+
+ Normally multiple formwindows are used at the same time in the
+ Designer. So each formwindow has its own undo/redo buffer, etc.
+
+ Also the formwindow has some signals to inform e.g. about selection
+ changes which is interesting for the PropertyEditor.
+
+ For handling the events of the child widgets (moving, etc.) the
+ handleMousePress(), etc. functions are called from the application
+ event filter which is implemented in MainWindow::eventFilter().
+*/
+
+FormWindow::FormWindow(FormFile *f, MainWindow *mw, QWidget *parent, const char *name)
+ : QWidget(parent, name, WDestructiveClose), mainwindow(mw),
+ commands(100), pixInline(true)
+{
+ ff = f;
+ init();
+ initSlots();
+}
+
+FormWindow::FormWindow(FormFile *f, QWidget *parent, const char *name)
+ : QWidget(parent, name, WDestructiveClose), mainwindow(0),
+ commands(100), pixInline(true)
+{
+ ff = f;
+ init();
+}
+
+void FormWindow::init()
+{
+ MetaDataBase::addEntry(this);
+ ff->setFormWindow(this);
+ propertyWidget = 0;
+ toolFixed = false;
+ checkedSelectionsForMove = false;
+ mContainer = 0;
+ connectSender = connectReceiver = 0;
+ currTool = POINTER_TOOL;
+ unclippedPainter = 0;
+ widgetPressed = false;
+ drawRubber = false;
+ setFocusPolicy(ClickFocus);
+ sizePreviewLabel = 0;
+ checkSelectionsTimer = new QTimer(this, "checkSelectionsTimer");
+ connect(checkSelectionsTimer, SIGNAL(timeout()),
+ this, SLOT(invalidCheckedSelections()));
+ updatePropertiesTimer = new QTimer(this);
+ connect(updatePropertiesTimer, SIGNAL(timeout()),
+ this, SLOT(updatePropertiesTimerDone()));
+ showPropertiesTimer = new QTimer(this);
+ connect(showPropertiesTimer, SIGNAL(timeout()),
+ this, SLOT(showPropertiesTimerDone()));
+ selectionChangedTimer = new QTimer(this);
+ connect(selectionChangedTimer, SIGNAL(timeout()),
+ this, SLOT(selectionChangedTimerDone()));
+ insertParent = 0;
+ connect(&commands, SIGNAL(undoRedoChanged(bool, bool, const QString &, const QString &)),
+ this, SIGNAL(undoRedoChanged(bool, bool, const QString &, const QString &)));
+ propShowBlocked = false;
+
+ setIcon(PixmapChooser::loadPixmap("form.xpm", PixmapChooser::Mini));
+
+ connect(&commands, SIGNAL(modificationChanged(bool)),
+ this, SLOT(modificationChanged(bool)));
+ buffer = 0;
+
+ QWidget *w = WidgetFactory::create(WidgetDatabase::idFromClassName("QFrame"), this);
+ setMainContainer(w);
+ propertyWidget = w;
+ targetContainer = 0;
+ hadOwnPalette = false;
+
+ defSpacing = BOXLAYOUT_DEFAULT_SPACING;
+ defMargin = BOXLAYOUT_DEFAULT_MARGIN;
+}
+
+void FormWindow::setMainWindow(MainWindow *w)
+{
+ mainwindow = w;
+ MetaDataBase::addEntry(this);
+ initSlots();
+}
+
+void FormWindow::initSlots()
+{
+}
+
+FormWindow::~FormWindow()
+{
+ if (MainWindow::self->objectHierarchy()->formWindow() == this)
+ MainWindow::self->objectHierarchy()->setFormWindow(0, 0);
+ MetaDataBase::clear(this);
+ if (ff)
+ ff->setFormWindow(0);
+}
+
+void FormWindow::closeEvent(QCloseEvent *e)
+{
+ if (ff->closeEvent() && mainwindow->unregisterClient(this))
+ e->accept();
+ else
+ e->ignore();
+}
+
+void FormWindow::paintGrid(QWidget *w, QPaintEvent *e)
+{
+ if (!mainWindow()->showGrid())
+ return;
+ QPixmap grid;
+ QString grid_name;
+ grid_name.sprintf("FormWindowGrid_%d_%d", mainWindow()->grid().x(), mainWindow()->grid().y());
+ if(!QPixmapCache::find(grid_name, grid)) {
+ grid = QPixmap(350 + (350 % mainWindow()->grid().x()), 350 + (350 % mainWindow()->grid().y()));
+ grid.fill(colorGroup().color(QColorGroup::Foreground));
+ QBitmap mask(grid.width(), grid.height());
+ mask.fill(color0);
+ QPainter p(&mask);
+ p.setPen(color1);
+ for (int y = 0; y < grid.width(); y += mainWindow()->grid().y())
+ for (int x = 0; x < grid.height(); x += mainWindow()->grid().x())
+ p.drawPoint(x, y);
+ grid.setMask(mask);
+ QPixmapCache::insert(grid_name, grid);
+ }
+ QPainter p(w);
+ p.setClipRegion(e->rect());
+ p.drawTiledPixmap(QRect(0, 0, width(), height()), grid);
+}
+
+
+/*For operations like drawing a rubber band or drawing the rect
+ when inserting a new widget, a unclipped painter (which draws also
+ on child widgets) is needed. This method does all the initialization.
+*/
+
+void FormWindow::beginUnclippedPainter(bool doNot)
+{
+ endUnclippedPainter();
+ bool unclipped = testWFlags(WPaintUnclipped);
+ setWFlags(WPaintUnclipped);
+ unclippedPainter = new QPainter;
+ unclippedPainter->begin(this);
+ if (!unclipped)
+ clearWFlags(WPaintUnclipped);
+ if (doNot)
+ {
+ unclippedPainter->setPen(QPen(color0, 2));
+ unclippedPainter->setRasterOp(NotROP);
+ }
+}
+
+void FormWindow::endUnclippedPainter()
+{
+ if (unclippedPainter)
+ unclippedPainter->end();
+ delete unclippedPainter;
+ unclippedPainter = 0;
+}
+
+QPoint FormWindow::gridPoint(const QPoint &p)
+{
+ return QPoint((p.x() / grid().x()) * grid().x(),
+ (p.y() / grid().y()) * grid().y());
+}
+
+void FormWindow::drawSizePreview(const QPoint &pos, const QString& text)
+{
+ unclippedPainter->save();
+ unclippedPainter->setPen(QPen(colorGroup().foreground(), 1 ));
+ unclippedPainter->setRasterOp(CopyROP);
+ if (!sizePreviewPixmap.isNull())
+ unclippedPainter->drawPixmap(sizePreviewPos, sizePreviewPixmap);
+ if (text.isNull()) {
+ sizePreviewPixmap = QPixmap(); // set null again
+ unclippedPainter->restore();
+ return;
+ }
+ QRect r = fontMetrics().boundingRect(0, 0, 0, 0, AlignCenter, text);
+ r = QRect(pos + QPoint(10, 10), r.size() + QSize(5, 5));
+
+ checkPreviewGeometry(r);
+
+ sizePreviewPos = r.topLeft();
+ sizePreviewPixmap = QPixmap::grabWindow(winId(), r.x(), r.y(), r.width(), r.height());
+ unclippedPainter->setBrush(QColor(255, 255, 128));
+ unclippedPainter->drawRect(r);
+ unclippedPainter->drawText(r, AlignCenter, text);
+ unclippedPainter->restore();
+}
+
+void FormWindow::insertWidget()
+{
+ if (!insertParent || currTool == POINTER_TOOL)
+ return;
+
+ bool useSizeHint = !oldRectValid || (currRect.width() < 2 && currRect.height() < 2);
+ Orientation orient = Horizontal;
+ QString n = WidgetDatabase::className(currTool);
+ if (useSizeHint && (n == "Spacer" || n == "QSlider" || n == "Line" || n == "QScrollBar")) {
+ QPopupMenu m(mainWindow());
+ m.insertItem(i18n("&Horizontal"));
+ int ver = m.insertItem(i18n("&Vertical"));
+ int r = m.exec(QCursor::pos());
+ if (r == ver)
+ orient = Vertical;
+ }
+
+ QWidget *w = WidgetFactory::create(currTool, insertParent, 0, true, &currRect, orient);
+ if (!w)
+ return;
+
+ if (!savePixmapInline() && currTool == WidgetDatabase::idFromClassName("PixmapLabel"))
+ ((QLabel*)w)->setPixmap(PixmapChooser::loadPixmap("image.xpm"));
+ int id = WidgetDatabase::idFromClassName(WidgetFactory::classNameOf(w));
+ if (WidgetDatabase::isCustomWidget(id)) {
+ QWhatsThis::add(w, i18n("<b>A %1 (custom widget)</b> "
+ "<p>Click <b>Edit Custom Widgets...</b> in the <b>Tools|Custom</b> "
+ "menu to add and change custom widgets. You can add "
+ "properties as well as signals and slots to integrate custom widgets into "
+ "<i>Qt Designer</i>, and provide a pixmap which will be used to represent "
+ "the widget on the form.</p>")
+ .arg(WidgetDatabase::toolTip(id)));
+ QToolTip::add(w, i18n("A %1 (custom widget)").arg(WidgetDatabase::toolTip(id)));
+ }
+ else
+ {
+ QString tt = WidgetDatabase::toolTip(id);
+ QString wt = WidgetDatabase::whatsThis(id);
+ if (!wt.isEmpty() && !tt.isEmpty())
+ QWhatsThis::add(w, i18n("<b>A %1</b><p>%2</p>").arg(tt).arg(wt));
+ }
+
+ QString s = w->name();
+ unify(w, s, true);
+ w->setName(s);
+ insertWidget(w);
+ QRect r(currRect);
+ if (!oldRectValid || (currRect.width() < 2 && currRect.height() < 2))
+ r = QRect(rectAnchor, QSize(0, 0));
+
+ QPoint p = r.topLeft();
+ p = mapToGlobal(p);
+ p = insertParent->mapFromGlobal(p);
+ r = QRect(p, r.size());
+ if (useSizeHint)
+ {
+ r.setWidth(w->sizeHint().width());
+ r.setHeight(w->sizeHint().height());
+ }
+
+ if (r.width() < 2 * grid().x())
+ r.setWidth(2 * grid().x());
+ if (r.height() < 2 * grid().y())
+ r.setHeight(2 * grid().y());
+
+ const QObjectList *l = insertParent->children();
+ QObjectListIt it(*l);
+ QWidgetList lst;
+ if (WidgetDatabase::isContainer(WidgetDatabase::idFromClassName(WidgetFactory::classNameOf(w))))
+ for (; it.current();) {
+ QObject *o = it.current();
+ ++it;
+ if (o->isWidgetType() && ((QWidget*)o)->isVisibleTo(this) &&
+ insertedWidgets.find((QWidget*)o) && o != w)
+ {
+ QRect r2(((QWidget*)o)->pos(), ((QWidget*)o)->size());
+ if (r.contains(r2))
+ lst.append((QWidget*)o);
+ }
+ }
+
+ if (!lst.isEmpty())
+ {
+ QWidget *pw = WidgetFactory::containerOfWidget(w);
+ QValueList<QPoint> op, np;
+ for (QWidget *i = lst.first(); i; i = lst.next())
+ {
+ op.append(i->pos());
+ QPoint pos = pw->mapFromGlobal(i->mapToGlobal(QPoint(0, 0)));
+ pos -= r.topLeft();
+ np.append(pos);
+ }
+ MoveCommand *mv = new MoveCommand(i18n("Reparent Widgets"), this, lst, op, np, insertParent, pw);
+ if (!toolFixed)
+ mainwindow->resetTool();
+ else
+ setCursorToAll(CrossCursor, w);
+
+ InsertCommand *cmd = new InsertCommand(i18n("Insert %1").arg(w->name()), this, w, r);
+
+ QPtrList<Command> commands;
+ commands.append(mv);
+ commands.append(cmd);
+
+ MacroCommand *mc = new MacroCommand(i18n("Insert %1").arg(w->name()), this, commands);
+ commandHistory()->addCommand(mc);
+ mc->execute();
+ }
+ else
+ {
+ if (!toolFixed)
+ mainwindow->resetTool();
+ else
+ setCursorToAll(CrossCursor, w);
+
+ InsertCommand *cmd = new InsertCommand(i18n("Insert %1").arg(w->name()), this, w, r);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+ }
+}
+
+void FormWindow::insertWidget(QWidget *w, bool checkName)
+{
+ if (checkName) {
+ QString s = w->name();
+ unify(w, s, true);
+ w->setName(s);
+ }
+
+ MetaDataBase::addEntry(w);
+ int id = WidgetDatabase::idFromClassName(WidgetFactory::classNameOf(w));
+ if (WidgetDatabase::isCustomWidget(id))
+ {
+ QWhatsThis::add(w, i18n("<b>A %1 (custom widget)</b> "
+ "<p>Click <b>Edit Custom Widgets...</b> in the <b>Tools|Custom</b> "
+ "menu to add and change custom widgets. You can add "
+ "properties as well as signals and slots to integrate custom widgets into "
+ "<i>Qt Designer</i>, and provide a pixmap which will be used to represent "
+ "the widget on the form.</p>")
+ .arg(WidgetDatabase::toolTip(id)));
+ QToolTip::add(w, i18n("A %1 (custom widget)").arg(WidgetDatabase::toolTip(id)));
+ }
+ else
+ {
+ QString tt = WidgetDatabase::toolTip(id);
+ QString wt = WidgetDatabase::whatsThis(id);
+ if (!wt.isEmpty() && !tt.isEmpty())
+ QWhatsThis::add(w, i18n("<b>A %1</b><p>%2</p>").arg(tt).arg(wt));
+ }
+
+ restoreCursors(w, this);
+ widgets()->insert(w, w);
+ w->show();
+}
+
+void FormWindow::removeWidget(QWidget *w)
+{
+ MetaDataBase::removeEntry(w);
+ widgets()->take(w);
+}
+
+void FormWindow::handleContextMenu(QContextMenuEvent *e, QWidget *w)
+{
+ switch (currTool) {
+ case POINTER_TOOL:
+ if (!isMainContainer(w) && qstrcmp(w->name(), "central widget"))
+ { // press on a child widget
+ raiseChildSelections(w); // raise selections and select widget
+ selectWidget(w);
+ // if widget is laid out, find the first non-laid out super-widget
+ QWidget *realWidget = w; // but store the original one
+ while (w->parentWidget() && (WidgetFactory::layoutType(w->parentWidget()) !=
+ WidgetFactory::NoLayout || !insertedWidgets.find(w)))
+ w = w->parentWidget();
+ if (mainContainer()->inherits("QMainWindow") &&
+ ((QMainWindow*)mainContainer())->centralWidget() == realWidget)
+ {
+ e->accept();
+ mainwindow->popupFormWindowMenu(e->globalPos(), this);
+ }
+ else
+ {
+ e->accept();
+ mainwindow->popupWidgetMenu(e->globalPos(), this, realWidget);
+ }
+ }
+ else
+ {
+ e->accept();
+ clearSelection();
+ mainwindow->popupFormWindowMenu(e->globalPos(), this);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void FormWindow::handleMousePress(QMouseEvent *e, QWidget *w)
+{
+ checkedSelectionsForMove = false;
+ checkSelectionsTimer->stop();
+ if (!sizePreviewLabel) {
+ sizePreviewLabel = new QLabel(this);
+ sizePreviewLabel->hide();
+ sizePreviewLabel->setBackgroundColor(QColor(255, 255, 128));
+ sizePreviewLabel->setFrameStyle(QFrame::Plain | QFrame::Box);
+ }
+
+ switch (currTool) {
+ case POINTER_TOOL:
+ if (!isMainContainer(w) && qstrcmp(w->name(), "central widget") != 0)
+ { // press on a child widget
+ // if the clicked widget is not in a layout, raise it
+ if (!w->parentWidget() || WidgetFactory::layoutType(w->parentWidget()) == WidgetFactory::NoLayout)
+ w->raise();
+ if ((e->state() & ControlButton))
+ { // with control pressed, always start rubber band selection
+ drawRubber = true;
+ currRect = QRect(0, 0, -1, -1);
+ startRectDraw(mapFromGlobal(e->globalPos()), e->globalPos(), this, Rubber);
+ break;
+ }
+
+ bool sel = isWidgetSelected(w);
+ if (!((e->state() & ControlButton) || (e->state() & ShiftButton)))
+ { // control not pressed...
+ if (!sel) // ...and widget no selectted: unselect all
+ clearSelection(false);
+ else
+ { // ...widget selected
+ // only if widget has a layout (it is a layout meta widget or a laid out container!),
+ // unselect its childs
+ if (WidgetFactory::layoutType(w) != WidgetFactory::NoLayout)
+ {
+ QObjectList *l = w->queryList("QWidget");
+ setPropertyShowingBlocked(true);
+ for (QObject *o = l->first(); o; o = l->next())
+ {
+ if (!o->isWidgetType())
+ continue;
+ if (insertedWidgets.find((QWidget*)o))
+ selectWidget((QWidget*)o, false);
+ }
+ setPropertyShowingBlocked(false);
+ delete l;
+ }
+ }
+ qApp->processEvents();
+ }
+ if (((e->state() & ControlButton) || (e->state() & ShiftButton)) &&
+ sel && e->button() == LeftButton)
+ { // control pressed and selected, unselect widget
+ selectWidget(w, false);
+ break;
+ }
+
+ raiseChildSelections(w); // raise selections and select widget
+ selectWidget(w);
+
+ // if widget is laid out, find the first non-laid out super-widget
+ while (w->parentWidget() &&
+ (WidgetFactory::layoutType(w->parentWidget()) != WidgetFactory::NoLayout
+ || !insertedWidgets.find(w)))
+ w = w->parentWidget();
+
+ if (e->button() == LeftButton)
+ { // left button: store original geometry and more as the widget might start moving
+ widgetPressed = true;
+ widgetGeom = QRect(w->pos(), w->size());
+ oldPressPos = w->mapFromGlobal(e->globalPos());
+ origPressPos = oldPressPos;
+ checkedSelectionsForMove = false;
+ moving.clear();
+ if (w->parentWidget() && !isMainContainer(w->parentWidget()) &&
+ !isCentralWidget(w->parentWidget()))
+ {
+ targetContainer = w->parentWidget();
+ hadOwnPalette = w->parentWidget()->ownPalette();
+ restorePalette = w->parentWidget()->palette();
+ }
+ }
+ }
+ else
+ { // press was on the formwindow
+ if (e->button() == LeftButton)
+ { // left button: start rubber selection and show formwindow properties
+ drawRubber = true;
+ if (!((e->state() & ControlButton) || (e->state() & ShiftButton)))
+ {
+ clearSelection(false);
+ QObject *opw = propertyWidget;
+ propertyWidget = mainContainer();
+ if (opw->isWidgetType())
+ repaintSelection((QWidget*)opw);
+ }
+ currRect = QRect(0, 0, -1, -1);
+ startRectDraw(mapFromGlobal(e->globalPos()), e->globalPos(), this, Rubber);
+ }
+ }
+ break;
+ case CONNECT_TOOL:
+ if (e->button() != LeftButton)
+ break;
+ saveBackground();
+ mainWindow()->statusBar()->message(i18n("Connect '%1' with...").arg(w->name()));
+ connectStartPos = mapFromGlobal(e->globalPos());
+ currentConnectPos = mapFromGlobal(e->globalPos());
+ connectSender = designerWidget(w);
+ connectReceiver = connectableObject(designerWidget(w), connectReceiver);
+ beginUnclippedPainter(false);
+ drawConnectLine();
+ break;
+ case ORDER_TOOL:
+ if (!isMainContainer(w))
+ { // press on a child widget
+ orderedWidgets.removeRef(w);
+ orderedWidgets.append(w);
+ for (QWidget *wid = orderedWidgets.last(); wid; wid = orderedWidgets.prev())
+ {
+ int i = stackedWidgets.findRef(wid);
+ if (i != -1)
+ {
+ stackedWidgets.removeRef(wid);
+ stackedWidgets.insert(0, wid);
+ }
+ }
+ QWidgetList oldl = MetaDataBase::tabOrder(this);
+ TabOrderCommand *cmd = new TabOrderCommand(i18n("Change Tab Order"), this,
+ oldl, stackedWidgets);
+ cmd->execute();
+ commandHistory()->addCommand(cmd, true);
+ updateOrderIndicators();
+ }
+ break;
+ default: // any insert widget tool
+ if (e->button() == LeftButton)
+ {
+ insertParent = WidgetFactory::containerOfWidget(mainContainer());
+ // default parent for new widget is the formwindow
+ if (!isMainContainer(w))
+ { // press was not on formwindow, check if we can find another parent
+ QWidget *wid = w;
+ for (;;)
+ {
+ int id = WidgetDatabase::idFromClassName(WidgetFactory::classNameOf(wid));
+ if ((WidgetDatabase::isContainer(id) || wid == mainContainer()) &&
+ !wid->inherits("QLayoutWidget") && !wid->inherits("QSplitter"))
+ {
+ insertParent = WidgetFactory::containerOfWidget(wid); // found another parent, store it
+ break;
+ }
+ else
+ {
+ wid = wid->parentWidget();
+ if (!wid)
+ break;
+ }
+ }
+ }
+ startRectDraw(w->mapFromGlobal(e->globalPos()), e->globalPos(), w, Insert);
+ }
+ break;
+ }
+}
+
+void FormWindow::handleMouseDblClick(QMouseEvent *, QWidget *w)
+{
+ switch (currTool) {
+ case ORDER_TOOL:
+ if (!isMainContainer(w))
+ { // press on a child widget
+ orderedWidgets.clear();
+ orderedWidgets.append(w);
+ for (QWidget *wid = orderedWidgets.last(); wid; wid = orderedWidgets.prev())
+ {
+ int i = stackedWidgets.findRef(wid);
+ if (i != -1)
+ {
+ stackedWidgets.removeRef(wid);
+ stackedWidgets.insert(0, wid);
+ }
+ }
+ QWidgetList oldl = MetaDataBase::tabOrder(this);
+ TabOrderCommand *cmd = new TabOrderCommand(i18n("Change Tab Order"), this, oldl, stackedWidgets);
+ cmd->execute();
+ commandHistory()->addCommand(cmd, true);
+ updateOrderIndicators();
+ }
+ default:
+ break;
+ }
+}
+
+void FormWindow::handleMouseMove(QMouseEvent *e, QWidget *w)
+{
+ if ((e->state() & LeftButton) != LeftButton)
+ return;
+
+ QWidget *newReceiver = (QWidget*)connectReceiver, *oldReceiver = (QWidget*)connectReceiver, *wid;
+ bool drawRecRect;
+ switch (currTool) {
+ case POINTER_TOOL:
+ if (widgetPressed && allowMove(w))
+ { // we are prepated for a move
+ // if widget is laid out, find the first non-laid out super-widget
+ while (w->parentWidget() && (WidgetFactory::layoutType(w->parentWidget()) !=
+ WidgetFactory::NoLayout || !insertedWidgets.find(w)))
+ w = w->parentWidget();
+ // calc correct position
+ QPoint pos = w->mapFromGlobal(e->globalPos());
+ // calc move distance and store it
+ QPoint d = oldPressPos - pos;
+ if (QABS(d.x()) < grid().x())
+ d.setX(0);
+ if (QABS(d.y()) < grid().y())
+ d.setY(0);
+ if (d.x() == 0)
+ pos.setX(oldPressPos.x());
+ if (d.y() == 0)
+ pos.setY(oldPressPos.y());
+ oldPressPos = pos;
+ // snap to grid
+ int x = widgetGeom.x() - d.x();
+ widgetGeom.setX(x);
+ x = (x / grid().x()) * grid().x();
+ int y = widgetGeom.y() - d.y();
+ widgetGeom.setY(y);
+ y = (y / grid().y()) * grid().y();
+ QPoint p = w->pos();
+
+ if (x - p.x() || y - p.y())
+ { // if we actually have to move
+ if (!checkedSelectionsForMove)
+ { // if not checked yet, check if the correct widget are selected...
+ if (!isWidgetSelected(w))
+ { // and unselect others. Only siblings can be moved at the same time
+ setPropertyShowingBlocked(true);
+ selectWidget(w);
+ setPropertyShowingBlocked(false);
+ }
+ checkSelectionsForMove(w);
+ }
+ // check whether we would have to reparent the selection and
+ // highlight the possible new parent container
+ QMapConstIterator<ulong, QPoint> it = moving.begin();
+ QWidget* wa = containerAt(e->globalPos(), ((QWidget*)it.key()));
+ if (wa && !isMainContainer(wa) && !isCentralWidget(wa))
+ {
+ wa = WidgetFactory::containerOfWidget(wa);
+ // ok, looks like we moved onto a container
+
+ if (wa != targetContainer)
+ {
+ if (targetContainer)
+ {
+ if (hadOwnPalette)
+ targetContainer->setPalette(restorePalette);
+ else
+ targetContainer->unsetPalette();
+ }
+ targetContainer = wa;
+ hadOwnPalette = wa->ownPalette();
+ restorePalette = wa->palette();
+ wa->setPaletteBackgroundColor(wa->colorGroup().midlight());
+ }
+ }
+ else if (targetContainer)
+ {
+ if(hadOwnPalette)
+ targetContainer->setPalette(restorePalette);
+ else
+ targetContainer->unsetPalette();
+ targetContainer = 0;
+ }
+
+ // finally move the selected widgets and show/update preview label
+ moveSelectedWidgets(x - p.x(), y - p.y());
+ sizePreviewLabel->setText(QString("%1/%2").arg(w->pos().x()).arg(w->pos().y()));
+ sizePreviewLabel->adjustSize();
+ QRect lg(mapFromGlobal(e->globalPos()) + QPoint(16, 16), sizePreviewLabel->size());
+ checkPreviewGeometry(lg);
+ sizePreviewLabel->setGeometry(lg);
+ sizePreviewLabel->raise();
+ sizePreviewLabel->show();
+ }
+ else
+ { // if we don't need to move, do some indication
+ QRect lg(mapFromGlobal(e->globalPos()) + QPoint(16, 16), sizePreviewLabel->size());
+ checkPreviewGeometry(lg);
+ sizePreviewLabel->move(lg.x(), lg.y());
+ }
+
+ oldPressPos += (p - w->pos());
+ }
+ else if (drawRubber)
+ // draw rubber if we are in rubber-selection mode
+ continueRectDraw(mapFromGlobal(e->globalPos()), e->globalPos(), this, Rubber);
+ break;
+ case CONNECT_TOOL:
+ restoreConnectionLine();
+ wid = qApp->widgetAt(e->globalPos(), true);
+ if (wid)
+ wid = designerWidget(wid);
+ if (wid && (isMainContainer(wid) || insertedWidgets.find(wid)) && wid->isVisibleTo(this))
+ newReceiver = wid;
+ if (newReceiver && (newReceiver->inherits("QLayoutWidget")
+ || newReceiver->inherits("Spacer")))
+ newReceiver = (QWidget*)connectReceiver;
+ drawRecRect = newReceiver != connectReceiver;
+ currentConnectPos = mapFromGlobal(e->globalPos());
+ if (newReceiver && (isMainContainer(newReceiver)
+ || insertedWidgets.find(newReceiver)) && !isCentralWidget(newReceiver))
+ connectReceiver = connectableObject(newReceiver, connectReceiver);
+ mainWindow()->statusBar()->message(i18n("Connect '%1' to '%2'").arg(connectSender->name()).
+ arg(connectReceiver->name()));
+ qApp->processEvents();
+ if (drawRecRect)
+ restoreRect(QRect(mapToForm(((QWidget*)oldReceiver)->parentWidget(),
+ ((QWidget*)oldReceiver)->pos()), ((QWidget*)oldReceiver)->size()));
+ drawConnectLine();
+ break;
+ case ORDER_TOOL:
+ break;
+ default: // we are in an insert-widget tool
+ if (insertParent) // draw insert rect
+ continueRectDraw(w->mapFromGlobal(e->globalPos()), e->globalPos(), w, Insert);
+ break;
+ }
+}
+
+void FormWindow::handleMouseRelease(QMouseEvent * e, QWidget * w)
+{
+ if (e->button() != LeftButton)
+ return;
+
+ switch (currTool)
+ {
+ case POINTER_TOOL:
+ if (widgetPressed && allowMove(w))
+ { // we moved the widget
+ sizePreviewLabel->hide();
+
+ if (moving.isEmpty() || w->pos() == *moving.find((ulong) w))
+ break;
+
+ // restore targetContainer
+ if (targetContainer)
+ {
+ if (hadOwnPalette)
+ targetContainer->setPalette(restorePalette);
+ else
+ targetContainer->unsetPalette();
+ }
+ // tell property editor to update
+ if (propertyWidget && propertyWidget->isWidgetType() && !isMainContainer(propertyWidget))
+ emitUpdateProperties(propertyWidget);
+
+ QMapConstIterator < ulong, QPoint > it = moving.begin();
+ QWidget *oldParent = ((QWidget *) it.key())->parentWidget();
+ QWidget *newParent = oldParent;
+ // check whether we have to reparent the selection
+ QWidget *wa = containerAt(e->globalPos(), ((QWidget *) it.key()));
+ if (wa)
+ {
+ wa = WidgetFactory::containerOfWidget(wa);
+ // ok, looks like we moved onto a container
+
+ // check whether we really have different parents.
+ if (wa == ((QWidget *) it.key())->parentWidget())
+ goto make_move_command;
+
+ // break layout if necessary
+ if (WidgetFactory::layoutType(wa) != WidgetFactory::NoLayout)
+ {
+ if (KMessageBox::questionYesNo(mainWindow(),
+ i18n("You tried to insert a widget into the "
+ "layout Container Widget '%1'.\n"
+ "This is not possible. "
+ "In order to insert the widget, the layout of '%1'\n"
+ "must first be broken.\n"
+ "Break the layout or cancel the operation?").
+ arg(wa->name()).arg(wa->name()), i18n("Inserting Widget"),
+ i18n("&Break Layout"), KStdGuiItem::cancel()) == KMessageBox::No)
+ goto make_move_command; // cancel
+ breakLayout(wa);
+ }
+ // doesn't need to be a command, the MoveCommand does reparenting too
+ bool emitSelChanged = false;
+ for (QMap < ulong, QPoint >::Iterator it = moving.begin(); it != moving.end(); ++it)
+ {
+ QWidget *i = (QWidget *) it.key();
+ if (!emitSelChanged && i->inherits("QButton"))
+ {
+ if (i->parentWidget() && i->parentWidget()->inherits("QButtonGroup") ||
+ wa->inherits("QButtonGroup"))
+ emitSelChanged = true;
+ if (!wa->inherits("QButtonGroup"))
+ {
+ MetaDataBase::setPropertyChanged(i, "buttonGroupId", false);
+ if (i->parentWidget() && i->parentWidget()->inherits("QButtonGroup"))
+ ((QButtonGroup *) i->parentWidget())->remove((QButton *) i);
+ }
+ }
+ QPoint pos = wa->mapFromGlobal(i->mapToGlobal(QPoint(0, 0)));
+ i->reparent(wa, pos, true);
+ raiseSelection(i);
+ raiseChildSelections(i);
+ widgetChanged(i);
+ mainWindow()->objectHierarchy()->widgetRemoved(i);
+ mainWindow()->objectHierarchy()->widgetInserted(i);
+ }
+ if (emitSelChanged)
+ {
+ emit showProperties(wa);
+ emit showProperties(propertyWidget);
+ }
+ newParent = wa;
+ }
+
+ make_move_command:
+ QWidgetList widgets; // collect the widgets and its old and new positions which have been moved
+ QValueList < QPoint > oldPos, newPos;
+ for (it = moving.begin(); it != moving.end(); ++it)
+ {
+ widgets.append((QWidget *) it.key());
+ oldPos.append(*it);
+ newPos.append(((QWidget *) it.key())->pos());
+ }
+ // add move command, don't execute it, this is just a summary of the operations we did during the move-event handling
+ commandHistory()->addCommand(new MoveCommand(i18n("Move"),
+ this, widgets, oldPos, newPos, oldParent, newParent));
+ } else if (drawRubber)
+ { // we were drawing a rubber selection
+ endRectDraw(); // get rid of the rectangle
+ blockSignals(true);
+ selectWidgets(); // select widgets which intersect the rect
+ blockSignals(false);
+ emitSelectionChanged(); // inform about selection changes
+ if (propertyWidget)
+ emitShowProperties(propertyWidget);
+ }
+ break;
+ case CONNECT_TOOL:
+ restoreConnectionLine();
+ if (connectSender)
+ restoreRect(QRect(mapToForm(((QWidget *) connectSender)->parentWidget(),
+ ((QWidget *) connectSender)->pos()), ((QWidget *) connectSender)->size()));
+ if (connectReceiver)
+ restoreRect(QRect(mapToForm(((QWidget *) connectReceiver)->parentWidget(),
+ ((QWidget *) connectReceiver)->pos()), ((QWidget *) connectReceiver)->size()));
+ endUnclippedPainter();
+ qApp->processEvents();
+ if (connectSender && connectReceiver)
+ editConnections();
+ break;
+ case ORDER_TOOL:
+ break;
+ default: // any insert widget tool is active
+ if (insertParent)
+ { // we should insert the new widget now
+ endRectDraw();
+ if (WidgetFactory::layoutType(insertParent) != WidgetFactory::NoLayout)
+ {
+ if (KMessageBox::questionYesNo(mainWindow(),
+ i18n("You tried to insert a widget into the "
+ "layout Container Widget '%1'.\n"
+ "This is not possible. "
+ "In order to insert the widget, the layout of '%1'\n"
+ "must first be broken.\n"
+ "Break the layout or cancel the operation?").
+ arg(insertParent->name()).
+ arg(insertParent->name()), i18n("Inserting Widget"),
+ i18n("&Break Layout"), KStdGuiItem::cancel()) == KMessageBox::Yes)
+ {
+ breakLayout(insertParent);
+ } else
+ {
+ if (!toolFixed)
+ mainWindow()->resetTool();
+ break;
+ }
+ }
+ insertWidget(); // so do it
+ }
+ break;
+ }
+ widgetPressed = false;
+ drawRubber = false;
+ insertParent = 0;
+ delete buffer;
+ buffer = 0;
+}
+
+void FormWindow::handleKeyPress(QKeyEvent * e, QWidget * w)
+{
+ e->ignore();
+ checkSelectionsTimer->stop();
+ if (!checkedSelectionsForMove &&
+ (e->key() == Key_Left ||
+ e->key() == Key_Right ||
+ e->key() == Key_Up || e->key() == Key_Down) && propertyWidget->isWidgetType())
+ checkSelectionsForMove((QWidget *) propertyWidget);
+ checkSelectionsTimer->start(1000, true);
+ if (e->key() == Key_Left || e->key() == Key_Right || e->key() == Key_Up || e->key() == Key_Down)
+ {
+ QWidgetList widgets;
+ QValueList < QPoint > oldPos, newPos;
+ for (WidgetSelection * s = selections.first(); s; s = selections.next())
+ {
+ if (s->isUsed())
+ {
+ int dx = 0, dy = 0;
+ bool control = e->state() & ControlButton;
+
+ switch (e->key())
+ {
+ case Key_Left:
+ {
+ e->accept();
+ if (control)
+ dx = -1;
+ else
+ dx = -grid().x();
+ }
+ break;
+ case Key_Right:
+ {
+ e->accept();
+ if (control)
+ dx = 1;
+ else
+ dx = grid().x();
+ }
+ break;
+ case Key_Up:
+ {
+ e->accept();
+ if (control)
+ dy = -1;
+ else
+ dy = -grid().y();
+ }
+ break;
+ case Key_Down:
+ {
+ e->accept();
+ if (control)
+ dy = 1;
+ else
+ dy = grid().y();
+ }
+ break;
+ default:
+ break;
+ }
+
+ widgets.append(s->widget());
+ oldPos.append(s->widget()->pos());
+ newPos.append(s->widget()->pos() + QPoint(dx, dy));
+ }
+ }
+ if (!widgets.isEmpty())
+ {
+ MoveCommand *cmd = new MoveCommand(i18n("Move"), this,
+ widgets, oldPos, newPos, 0, 0);
+ commandHistory()->addCommand(cmd, true);
+ cmd->execute();
+ }
+ }
+ if (!e->isAccepted())
+ {
+ QObjectList *l = queryList("QWidget");
+ if (!l)
+ return;
+ if (l->find(w) != -1)
+ e->accept();
+ delete l;
+ }
+
+}
+
+void FormWindow::handleKeyRelease(QKeyEvent * e, QWidget *)
+{
+ e->ignore();
+}
+
+void FormWindow::selectWidget(QObject * o, bool select)
+{
+ if (!o->isWidgetType())
+ {
+ // ########### do QObject stuff
+ return;
+ }
+
+ QWidget *w = (QWidget *) o;
+
+ if (isMainContainer(w))
+ {
+ QObject *opw = propertyWidget;
+ propertyWidget = mainContainer();
+ if (opw->isWidgetType())
+ repaintSelection((QWidget *) opw);
+ emitShowProperties(propertyWidget);
+ return;
+ }
+
+ if (mainContainer()->inherits("QMainWindow") &&
+ w == ((QMainWindow *) mainContainer())->centralWidget())
+ {
+ QObject *opw = propertyWidget;
+ propertyWidget = mainContainer();
+ if (opw->isWidgetType())
+ repaintSelection((QWidget *) opw);
+ emitShowProperties(propertyWidget);
+ return;
+ }
+
+ if (o->inherits("QDesignerToolBar") || o->inherits("QDesignerMenuBar"))
+ return;
+
+ if (select)
+ {
+ QObject *opw = propertyWidget;
+ propertyWidget = w;
+ if (opw->isWidgetType())
+ repaintSelection((QWidget *) opw);
+ if (!isPropertyShowingBlocked())
+ emitShowProperties(propertyWidget);
+ WidgetSelection *s = usedSelections.find(w);
+ if (s)
+ {
+ s->show();
+ return;
+ }
+
+ for (WidgetSelection * s2 = selections.first(); s2; s2 = selections.next())
+ {
+ if (!s2->isUsed())
+ {
+ s = s2;
+ }
+ }
+
+ if (!s)
+ {
+ s = new WidgetSelection(this, &usedSelections);
+ selections.append(s);
+ }
+
+ s->setWidget(w);
+ emitSelectionChanged();
+ } else
+ {
+ WidgetSelection *s = usedSelections.find(w);
+ if (s)
+ s->setWidget(0);
+ QObject *opw = propertyWidget;
+ if (!usedSelections.isEmpty())
+ propertyWidget = QPtrDictIterator < WidgetSelection > (usedSelections).current()->widget();
+ else
+ propertyWidget = mainContainer();
+ if (opw->isWidgetType())
+ repaintSelection((QWidget *) opw);
+ if (!isPropertyShowingBlocked())
+ emitShowProperties(propertyWidget);
+ emitSelectionChanged();
+ }
+}
+
+QPoint FormWindow::grid() const
+{
+ if (!mainWindow()->snapGrid())
+ return QPoint(1, 1);
+ return mainWindow()->grid();
+}
+
+void FormWindow::updateSelection(QWidget * w)
+{
+ WidgetSelection *s = usedSelections.find(w);
+ if (!w->isVisibleTo(this))
+ selectWidget(w, false);
+ else if (s)
+ s->updateGeometry();
+}
+
+void FormWindow::raiseSelection(QWidget * w)
+{
+ WidgetSelection *s = usedSelections.find(w);
+ if (s)
+ s->show();
+}
+
+void FormWindow::repaintSelection(QWidget * w)
+{
+ WidgetSelection *s = usedSelections.find(w);
+ if (s)
+ s->update();
+}
+
+void FormWindow::clearSelection(bool changePropertyDisplay)
+{
+ QPtrDictIterator < WidgetSelection > it(usedSelections);
+ for (; it.current(); ++it)
+ it.current()->setWidget(0, false);
+
+ usedSelections.clear();
+ if (changePropertyDisplay)
+ {
+ QObject *opw = propertyWidget;
+ propertyWidget = mainContainer();
+ if (opw->isWidgetType())
+ repaintSelection((QWidget *) opw);
+ emitShowProperties(propertyWidget);
+ }
+ emitSelectionChanged();
+}
+
+void FormWindow::startRectDraw(const QPoint & p, const QPoint & global, QWidget *, RectType t)
+{
+ QPoint pos(p);
+ pos = mapFromGlobal(global);
+ oldRectValid = false;
+ beginUnclippedPainter(true);
+ if (t == Rubber)
+ unclippedPainter->setPen(QPen(color0, 1));
+ if (t == Insert)
+ rectAnchor = gridPoint(pos);
+ else if (t == Rubber)
+ rectAnchor = pos;
+ currRect = QRect(rectAnchor, QPoint(0, 0));
+ if (t == Insert)
+ drawSizePreview(pos, i18n("Use Size Hint"));
+}
+
+void FormWindow::continueRectDraw(const QPoint & p, const QPoint & global, QWidget *, RectType t)
+{
+ QPoint pos = p;
+ pos = mapFromGlobal(global);
+ QPoint p2;
+ if (t == Insert)
+ p2 = gridPoint(pos);
+ else if (t == Rubber)
+ p2 = pos;
+ QRect r(rectAnchor, p2);
+ r = r.normalize();
+
+ if (currRect == r)
+ {
+ QString t("%1/%2");
+ t = t.arg(r.width() - 1).arg(r.height() - 1);
+ drawSizePreview(pos, t);
+ return;
+ }
+
+ if (oldRectValid)
+ unclippedPainter->drawRect(currRect);
+ if (r.width() > 1 || r.height() > 1)
+ {
+ oldRectValid = true;
+ currRect = r;
+ if (t == Insert)
+ {
+ QString t("%1/%2");
+ t = t.arg(r.width() - 1).arg(r.height() - 1);
+ drawSizePreview(pos, t);
+ }
+ unclippedPainter->setClipRegion(QRegion(rect()).subtract(QRect(sizePreviewPos,
+ sizePreviewPixmap.size())));
+ unclippedPainter->drawRect(currRect);
+ unclippedPainter->setClipping(false);
+ } else
+ {
+ oldRectValid = false;
+ if (t == Insert)
+ drawSizePreview(pos, i18n("Use Size Hint"));
+ }
+}
+
+void FormWindow::endRectDraw()
+{
+ if (!unclippedPainter)
+ return;
+
+ if (oldRectValid)
+ unclippedPainter->drawRect(currRect);
+ drawSizePreview(QPoint(-1, -1), QString::null);
+ endUnclippedPainter();
+}
+
+void FormWindow::selectWidgets()
+{
+ QObjectList *l = mainContainer()->queryList("QWidget");
+ if (l)
+ {
+ for (QObject * o = l->first(); o; o = l->next())
+ {
+ if (((QWidget *) o)->isVisibleTo(this) && insertedWidgets[(void *) o])
+ {
+ QPoint p = ((QWidget *) o)->mapToGlobal(QPoint(0, 0));
+ p = mapFromGlobal(p);
+ QRect r(p, ((QWidget *) o)->size());
+ if (r.intersects(currRect) && !r.contains(currRect))
+ selectWidget((QWidget *) o);
+ }
+ }
+ delete l;
+ }
+ emitSelectionChanged();
+}
+
+bool FormWindow::isWidgetSelected(QObject * w)
+{
+ if (w->isWidgetType())
+ return usedSelections.find((QWidget *) w) != 0;
+ return false; // #### do stuff for QObjects
+}
+
+void FormWindow::moveSelectedWidgets(int dx, int dy)
+{
+ QPtrDictIterator < WidgetSelection > it(usedSelections);
+ for (; it.current(); ++it)
+ {
+ WidgetSelection *s = it.current();
+ QWidget *w = s->widget();
+ if (w->parentWidget()
+ && WidgetFactory::layoutType(w->parentWidget()) != WidgetFactory::NoLayout)
+ continue;
+ w->move(w->x() + dx, w->y() + dy);
+ s->updateGeometry();
+ updateChildSelections(w);
+ }
+}
+
+CommandHistory *FormWindow::commandHistory()
+{
+ return &commands;
+}
+
+void FormWindow::undo()
+{
+ commandHistory()->undo();
+}
+
+void FormWindow::redo()
+{
+ commandHistory()->redo();
+}
+
+void FormWindow::raiseChildSelections(QWidget * w)
+{
+ QObjectList *l = w->queryList("QWidget");
+ if (!l || !l->first())
+ {
+ delete l;
+ return;
+ }
+
+ QPtrDictIterator < WidgetSelection > it(usedSelections);
+ for (; it.current(); ++it)
+ {
+ if (l->findRef(it.current()->widget()) != -1)
+ it.current()->show();
+ }
+ delete l;
+}
+
+void FormWindow::updateChildSelections(QWidget * w)
+{
+ QObjectList *l = w->queryList("QWidget");
+ if (l)
+ {
+ for (QObject * o = l->first(); o; o = l->next())
+ {
+ if (o->isWidgetType() && insertedWidgets.find((QWidget *) o))
+ updateSelection((QWidget *) o);
+ }
+ delete l;
+ }
+}
+
+void FormWindow::checkSelectionsForMove(QWidget * w)
+{
+ checkedSelectionsForMove = true;
+
+ QObjectList *l = w->parentWidget()->queryList("QWidget", 0, false, false);
+ moving.clear();
+ if (l)
+ {
+ QPtrDictIterator < WidgetSelection > it(usedSelections);
+ WidgetSelection *sel;
+ while ((sel = it.current()) != 0)
+ {
+ if (it.current()->widget() == mainContainer())
+ continue;
+ ++it;
+ if (l->find(sel->widget()) == -1)
+ {
+ if (WidgetFactory::layoutType(w) == WidgetFactory::NoLayout)
+ sel->setWidget(0);
+ } else
+ {
+ if (WidgetFactory::layoutType(sel->widget()->parentWidget()) == WidgetFactory::NoLayout)
+ {
+ moving.insert((ulong) sel->widget(), sel->widget()->pos());
+ sel->widget()->raise();
+ raiseChildSelections(sel->widget());
+ raiseSelection(sel->widget());
+ }
+ }
+ }
+ delete l;
+ }
+}
+
+void FormWindow::deleteWidgets()
+{
+ QWidgetList widgets;
+ QPtrDictIterator < WidgetSelection > it(usedSelections);
+ for (; it.current(); ++it)
+ {
+ QWidget *tb = 0;
+ if (!(tb = mainWindow()->isAToolBarChild(it.current()->widget())))
+ widgets.append(it.current()->widget());
+ else
+ ((QDesignerToolBar *) tb)->removeWidget(it.current()->widget());
+ }
+
+ if (widgets.isEmpty())
+ return;
+
+ DeleteCommand *cmd = new DeleteCommand(i18n("Delete"), this, widgets);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+}
+
+void FormWindow::editAdjustSize()
+{
+ QPtrList < Command > commands;
+ QWidgetList widgets = selectedWidgets();
+ if (widgets.isEmpty())
+ {
+ QRect oldr = geometry();
+ mainContainer()->adjustSize();
+ resize(mainContainer()->size());
+ // check whether our own size constraint hit us
+ if (size() != mainContainer()->size())
+ mainContainer()->resize(size());
+ QRect nr = geometry();
+ if (oldr != nr)
+ {
+ ResizeCommand *cmd = new ResizeCommand(i18n("Adjust Size"), this, this, oldr, nr);
+ commandHistory()->addCommand(cmd);
+ }
+ return;
+ }
+ for (QWidget * w = widgets.first(); w; w = widgets.next())
+ {
+ if (w->parentWidget()
+ && WidgetFactory::layoutType(w->parentWidget()) != WidgetFactory::NoLayout)
+ continue;
+ QRect oldr = w->geometry();
+ w->adjustSize();
+ QRect nr = w->geometry();
+ if (oldr != nr)
+ commands.append(new ResizeCommand(i18n("Adjust Size"), this, w, oldr, nr));
+ }
+
+ if (commands.isEmpty())
+ return;
+ for (WidgetSelection * s = selections.first(); s; s = selections.next())
+ s->updateGeometry();
+
+ MacroCommand *cmd = new MacroCommand(i18n("Adjust Size"), this, commands);
+ commandHistory()->addCommand(cmd);
+}
+
+
+QWidgetList FormWindow::selectedWidgets() const
+{
+ QWidgetList widgets;
+ for (QPtrDictIterator<WidgetSelection> it(usedSelections); it.current(); ++it)
+ widgets.append(it.current()->widget());
+ return widgets;
+}
+
+void FormWindow::widgetChanged(QObject *w)
+{
+ if (w->isWidgetType())
+ updateSelection((QWidget*)w);
+}
+
+QLabel *FormWindow::sizePreview() const
+{
+ if (!sizePreviewLabel)
+ {
+ ((FormWindow*)this)->sizePreviewLabel = new QLabel((FormWindow*)this);
+ ((FormWindow*)this)->sizePreviewLabel->hide();
+ ((FormWindow*)this)->sizePreviewLabel->setBackgroundColor(QColor(255, 255, 128));
+ ((FormWindow*)this)->sizePreviewLabel->setFrameStyle(QFrame::Plain | QFrame::Box);
+ }
+ return sizePreviewLabel;
+}
+
+void FormWindow::invalidCheckedSelections()
+{
+ checkedSelectionsForMove = false;
+}
+
+void FormWindow::checkPreviewGeometry(QRect & r)
+{
+ if (rect().contains(r))
+ return;
+ if (r.left() < rect().left())
+ r.moveTopLeft(QPoint(0, r.top()));
+ if (r.right() > rect().right())
+ r.moveBottomRight(QPoint(rect().right(), r.bottom()));
+ if (r.top() < rect().top())
+ r.moveTopLeft(QPoint(r.left(), rect().top()));
+ if (r.bottom() > rect().bottom())
+ r.moveBottomRight(QPoint(r.right(), rect().bottom()));
+}
+
+void FormWindow::focusInEvent(QFocusEvent *)
+{
+ if (mContainer)
+ {
+ QVariant prop = mContainer->property("useInternalParser");
+ KommanderWidget::useInternalParser = prop.toBool();
+
+ }
+}
+
+void FormWindow::focusOutEvent(QFocusEvent *)
+{
+ if (propertyWidget && !isMainContainer(propertyWidget) && !isWidgetSelected(propertyWidget))
+ {
+ QObject *opw = propertyWidget;
+ propertyWidget = mainContainer();
+ if (opw->isWidgetType())
+ repaintSelection((QWidget *) opw);
+ }
+}
+
+void FormWindow::resizeEvent(QResizeEvent * e)
+{
+ QWidget::resizeEvent(e);
+ if (currTool == ORDER_TOOL)
+ repositionOrderIndicators();
+ if (isVisible())
+ formFile()->setModified(true);
+}
+
+QPtrDict < QWidget > *FormWindow::widgets()
+{
+ return &insertedWidgets;
+}
+
+QWidget *FormWindow::designerWidget(QObject * o) const
+{
+ if (!o || !o->isWidgetType())
+ return 0;
+ QWidget *w = (QWidget *) o;
+ while (w && !isMainContainer(w) && !insertedWidgets[(void *) w] || isCentralWidget(w))
+ w = (QWidget *) w->parent();
+ return w;
+}
+
+void FormWindow::emitShowProperties(QObject * w)
+{
+ if (w)
+ {
+ QObject *opw = propertyWidget;
+ propertyWidget = w;
+ if (opw->isWidgetType())
+ repaintSelection((QWidget *) opw);
+ }
+ showPropertiesTimer->stop();
+ showPropertiesTimer->start(0, true);
+}
+
+void FormWindow::emitUpdateProperties(QObject * w)
+{
+ if (w == propertyWidget)
+ {
+ updatePropertiesTimer->stop();
+ updatePropertiesTimer->start(0, true);
+ }
+}
+
+void FormWindow::emitSelectionChanged()
+{
+ selectionChangedTimer->stop();
+ selectionChangedTimer->start(0, true);
+}
+
+void FormWindow::updatePropertiesTimerDone()
+{
+ if (propertyWidget && mainWindow()->formWindow() == this)
+ emit updateProperties(propertyWidget);
+}
+
+void FormWindow::showPropertiesTimerDone()
+{
+ if (propertyWidget && mainWindow()->formWindow() == this)
+ emit showProperties(propertyWidget);
+}
+
+void FormWindow::selectionChangedTimerDone()
+{
+ emit selectionChanged();
+}
+
+void FormWindow::currentToolChanged()
+{
+ toolFixed = false;
+ int t = mainwindow->currentTool();
+ if (currTool == t && t != ORDER_TOOL)
+ return;
+
+ // tool cleanup
+ switch (currTool)
+ {
+ case ORDER_TOOL:
+ hideOrderIndicators();
+ break;
+ case CONNECT_TOOL:
+ restoreConnectionLine();
+ if (connectSender)
+ restoreRect(QRect(mapToForm(((QWidget *) connectSender)->parentWidget(),
+ ((QWidget *) connectSender)->pos()), ((QWidget *) connectSender)->size()));
+ if (connectReceiver)
+ restoreRect(QRect(mapToForm(((QWidget *) connectReceiver)->parentWidget(),
+ ((QWidget *) connectReceiver)->pos()), ((QWidget *) connectReceiver)->size()));
+ endUnclippedPainter();
+ break;
+ case POINTER_TOOL:
+ break;
+ default:
+ if (insertParent)
+ endRectDraw();
+ break;
+ }
+
+ connectSender = connectReceiver = 0;
+ widgetPressed = false;
+ drawRubber = false;
+ insertParent = 0;
+ delete buffer;
+ buffer = 0;
+
+ currTool = t;
+
+ if (hasFocus())
+ clearSelection(false);
+
+ mainWindow()->statusBar()->clear();
+
+ // tool setup
+ switch (currTool)
+ {
+ case POINTER_TOOL:
+ if (propertyWidget && !isMainContainer(propertyWidget) && !isWidgetSelected(propertyWidget))
+ emitShowProperties(mainContainer());
+ restoreCursors(this, this);
+ break;
+ case ORDER_TOOL:
+ if (mainWindow()->formWindow() == this)
+ {
+ mainWindow()->statusBar()->message(i18n("Click widgets to change the tab order..."));
+ orderedWidgets.clear();
+ showOrderIndicators();
+ if (mainWindow()->formWindow() == this)
+ emitShowProperties(mainContainer());
+ setCursorToAll(ArrowCursor, this);
+ }
+ break;
+ case CONNECT_TOOL:
+ mainWindow()->statusBar()->message(i18n("Drag a line to create a connection..."));
+ setCursorToAll(CrossCursor, this);
+ if (mainWindow()->formWindow() == this)
+ emitShowProperties(mainContainer());
+ break;
+ default:
+ mainWindow()->statusBar()->message(i18n("Click on the form to insert a %1...").
+ arg(WidgetDatabase::toolTip(currTool).lower()));
+ setCursorToAll(CrossCursor, this);
+ if (mainWindow()->formWindow() == this)
+ emitShowProperties(mainContainer());
+ break;
+ }
+}
+
+void FormWindow::showOrderIndicators()
+{
+ hideOrderIndicators();
+ orderIndicators.setAutoDelete(true);
+ QObjectList *l = mainContainer()->queryList("QWidget");
+ stackedWidgets = MetaDataBase::tabOrder(this);
+ if (l)
+ {
+ int order = 1;
+ for (QObject * o = l->first(); o; o = l->next())
+ {
+ QWidget *w = (QWidget *) o;
+ if (w->isVisibleTo(w->parentWidget()) &&
+ insertedWidgets[(void *) w] && w->focusPolicy() != NoFocus)
+ {
+ OrderIndicator *ind = new OrderIndicator(order++, w, this);
+ orderIndicators.append(ind);
+ if (stackedWidgets.findRef(w) == -1)
+ stackedWidgets.append(w);
+ }
+ }
+ delete l;
+ }
+ updateOrderIndicators();
+}
+
+void FormWindow::hideOrderIndicators()
+{
+ orderIndicators.clear();
+}
+
+void FormWindow::updateOrderIndicators()
+{
+ int order = 1;
+ for (QWidget * w = stackedWidgets.first(); w; w = stackedWidgets.next())
+ {
+ for (OrderIndicator * i = orderIndicators.first(); i; i = orderIndicators.next())
+ i->setOrder(order, w);
+ order++;
+ }
+}
+
+void FormWindow::repositionOrderIndicators()
+{
+ for (OrderIndicator * i = orderIndicators.first(); i; i = orderIndicators.next())
+ i->reposition();
+}
+
+void FormWindow::updateUndoInfo()
+{
+ commandHistory()->emitUndoRedo();
+}
+
+bool FormWindow::checkCustomWidgets()
+{
+ QStringList missingCustomWidgets;
+ QPtrDictIterator < QWidget > it(insertedWidgets);
+ for (; it.current(); ++it)
+ {
+ if (it.current()->isA("CustomWidget"))
+ {
+ QString className = WidgetFactory::classNameOf(it.current());
+ if (!MetaDataBase::hasCustomWidget(className))
+ missingCustomWidgets << className;
+ }
+ }
+ return true;
+}
+
+void FormWindow::setPropertyShowingBlocked(bool b)
+{
+ propShowBlocked = b;
+}
+
+bool FormWindow::isPropertyShowingBlocked() const
+{
+ return propShowBlocked;
+}
+
+
+int FormWindow::numSelectedWidgets() const
+{
+ return usedSelections.count();
+}
+
+QString FormWindow::copy()
+{
+ Resource resource(mainWindow());
+ resource.setWidget(this);
+ return resource.copy();
+}
+
+void FormWindow::lowerWidgets()
+{
+ QWidgetList widgets;
+ QPtrDictIterator < WidgetSelection > it(usedSelections);
+ for (; it.current(); ++it)
+ widgets.append(it.current()->widget());
+
+ LowerCommand *cmd = new LowerCommand(i18n("Lower"), this, widgets);
+ cmd->execute();
+ commandHistory()->addCommand(cmd);
+}
+
+static void find_accel(const QString & txt, QMap < QChar, QWidgetList > &accels, QWidget * w)
+{
+ int i = txt.find("&");
+ if (i == -1)
+ return;
+ QChar c = txt[i + 1];
+ if (c.isNull() || c == '&')
+ return;
+ c = c.lower();
+ QMap < QChar, QWidgetList >::Iterator it = accels.find(c);
+ if (it == accels.end())
+ {
+ QWidgetList wl;
+ wl.append(w);
+ accels.insert(c, wl);
+ } else
+ {
+ QWidgetList *wl = &*it;
+ wl->append(w);
+ }
+}
+
+void FormWindow::checkAccels()
+{
+ QMap < QChar, QWidgetList > accels;
+ QObjectList *l = mainContainer()->queryList("QWidget");
+ if (l)
+ {
+ for (QObject * o = l->first(); o; o = l->next())
+ {
+ if (((QWidget *) o)->isVisibleTo(this) && insertedWidgets[(void *) o])
+ {
+ QWidget *w = (QWidget *) o;
+ const QMetaProperty *text =
+ w->metaObject()->property(w->metaObject()->findProperty("text", true), true);
+ const QMetaProperty *title =
+ w->metaObject()->property(w->metaObject()->findProperty("title", true), true);
+ const QMetaProperty *pageTitle =
+ w->metaObject()->property(w->metaObject()->findProperty("pageTitle", true), true);
+ if (text)
+ find_accel(w->property("text").toString(), accels, w);
+ if (title)
+ find_accel(w->property("title").toString(), accels, w);
+ if (pageTitle)
+ find_accel(w->property("pageTitle").toString(), accels, w);
+ }
+ }
+ delete l;
+ }
+
+ bool ok = true;
+ QWidget *wid;
+ for (QMap < QChar, QWidgetList >::Iterator it = accels.begin(); it != accels.end(); ++it)
+ {
+ if ((*it).count() > 1)
+ {
+ ok = false;
+ if (KMessageBox::questionYesNo(mainWindow(),
+ i18n("Accelerator '%1' is used %2 times.").arg(it.key().upper()).arg((*it).count()),
+ i18n("Check Accelerators"), i18n("&Select"), KStdGuiItem::cancel()) == KMessageBox::Yes)
+ {
+ clearSelection(false);
+ for (wid = (*it).first(); wid; wid = (*it).next())
+ selectWidget(wid, true);
+ }
+ return;
+ }
+ }
+
+ if (ok)
+ KMessageBox::information(mainWindow(), i18n("No accelerator is used more than once."),
+ i18n("Check Accelerators"));
+}
+
+void FormWindow::raiseWidgets()
+{
+ QWidgetList widgets;
+ QPtrDictIterator < WidgetSelection > it(usedSelections);
+ for (; it.current(); ++it)
+ widgets.append(it.current()->widget());
+
+ RaiseCommand *cmd = new RaiseCommand(i18n("Raise"), this, widgets);
+ cmd->execute();
+ commandHistory()->addCommand(cmd);
+}
+
+void FormWindow::paste(const QString & cb, QWidget * parent)
+{
+ Resource resource(mainWindow());
+ resource.setWidget(this);
+ resource.paste(cb, parent);
+}
+
+void FormWindow::selectAll()
+{
+ checkedSelectionsForMove = false;
+ blockSignals(true);
+ QObjectList *l = mainContainer()->queryList("QWidget");
+ if (l)
+ {
+ for (QObject * o = l->first(); o; o = l->next())
+ {
+ if (((QWidget *) o)->isVisibleTo(this) && insertedWidgets[(void *) o])
+ {
+ selectWidget((QWidget *) o);
+ }
+ }
+ delete l;
+ }
+
+ blockSignals(false);
+ emitSelectionChanged();
+ if (propertyWidget)
+ emitShowProperties(propertyWidget);
+ emitSelectionChanged();
+}
+
+void FormWindow::layoutHorizontal()
+{
+ QWidgetList widgets(selectedWidgets());
+ LayoutHorizontalCommand *cmd = new LayoutHorizontalCommand(i18n("Lay Out Horizontally"),
+ this, mainContainer(), 0, widgets);
+ clearSelection(false);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+}
+
+void FormWindow::layoutVertical()
+{
+ QWidgetList widgets(selectedWidgets());
+ LayoutVerticalCommand *cmd = new LayoutVerticalCommand(i18n("Lay Out Vertically"),
+ this, mainContainer(), 0, widgets);
+ clearSelection(false);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+}
+
+void FormWindow::layoutHorizontalSplit()
+{
+ QWidgetList widgets(selectedWidgets());
+ LayoutHorizontalSplitCommand *cmd =
+ new LayoutHorizontalSplitCommand(i18n("Lay Out Horizontally (in splitter)"),
+ this, mainContainer(), 0, widgets);
+ clearSelection(false);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+}
+
+void FormWindow::layoutVerticalSplit()
+{
+ QWidgetList widgets(selectedWidgets());
+ LayoutVerticalSplitCommand *cmd =
+ new LayoutVerticalSplitCommand(i18n("Lay Out Vertically (in splitter)"),
+ this, mainContainer(), 0, widgets);
+ clearSelection(false);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+}
+
+void FormWindow::layoutGrid()
+{
+ int xres = grid().x();
+ int yres = grid().y();
+
+ QWidgetList widgets(selectedWidgets());
+ LayoutGridCommand *cmd = new LayoutGridCommand(i18n("Lay Out in a Grid"),
+ this, mainContainer(), 0, widgets, xres, yres);
+ clearSelection(false);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+}
+
+void FormWindow::layoutHorizontalContainer(QWidget * w)
+{
+ if (w == this)
+ w = mainContainer();
+ QObjectList *l = (QObjectList *) WidgetFactory::containerOfWidget(w)->children();
+ if (!l)
+ return;
+ QWidgetList widgets;
+ for (QObject * o = l->first(); o; o = l->next())
+ {
+ if (o->isWidgetType() &&
+ ((QWidget *) o)->isVisibleTo(this) && insertedWidgets.find((QWidget *) o))
+ widgets.append((QWidget *) o);
+ }
+ LayoutHorizontalCommand *cmd = new LayoutHorizontalCommand(i18n("Lay Out Children Horizontally"),
+ this, mainContainer(), w, widgets);
+ clearSelection(false);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+}
+
+void FormWindow::layoutVerticalContainer(QWidget * w)
+{
+ if (w == this)
+ w = mainContainer();
+ QObjectList *l = (QObjectList *) WidgetFactory::containerOfWidget(w)->children();
+ if (!l)
+ return;
+ QWidgetList widgets;
+ for (QObject * o = l->first(); o; o = l->next())
+ {
+ if (o->isWidgetType() &&
+ ((QWidget *) o)->isVisibleTo(this) && insertedWidgets.find((QWidget *) o))
+ widgets.append((QWidget *) o);
+ }
+ LayoutVerticalCommand *cmd = new LayoutVerticalCommand(i18n("Lay Out Children Vertically"),
+ this, mainContainer(), w, widgets);
+ clearSelection(false);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+}
+
+void FormWindow::layoutGridContainer(QWidget * w)
+{
+ if (w == this)
+ w = mainContainer();
+ int xres = grid().x();
+ int yres = grid().y();
+
+ QObjectList *l = (QObjectList *) WidgetFactory::containerOfWidget(w)->children();
+ if (!l)
+ return;
+ QWidgetList widgets;
+ for (QObject * o = l->first(); o; o = l->next())
+ {
+ if (o->isWidgetType() &&
+ ((QWidget *) o)->isVisibleTo(this) && insertedWidgets.find((QWidget *) o))
+ widgets.append((QWidget *) o);
+ }
+ LayoutGridCommand *cmd = new LayoutGridCommand(i18n("Lay Out Children in a Grid"),
+ this, mainContainer(), w, widgets, xres, yres);
+ clearSelection(false);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+}
+
+void FormWindow::breakLayout(QWidget * w)
+{
+ if (w == this)
+ w = mainContainer();
+ w = WidgetFactory::containerOfWidget(w);
+ QPtrList < Command > commands;
+
+ for (;;)
+ {
+ if (!w || w == this)
+ break;
+ if (WidgetFactory::layoutType(w) != WidgetFactory::NoLayout &&
+ WidgetDatabase::isContainer(WidgetDatabase::idFromClassName(WidgetFactory::classNameOf(w))))
+ {
+ Command *cmd = breakLayoutCommand(w);
+ if (cmd)
+ commands.insert(0, cmd);
+ if (!w->inherits("QLayoutWidget") && !w->inherits("QSplitter"))
+ break;
+ }
+ w = w->parentWidget();
+ }
+
+ if (commands.isEmpty())
+ return;
+
+ clearSelection(false);
+ MacroCommand *cmd = new MacroCommand(i18n("Break Layout"), this, commands);
+ commandHistory()->addCommand(cmd);
+ cmd->execute();
+}
+
+BreakLayoutCommand *FormWindow::breakLayoutCommand(QWidget * w)
+{
+ QObjectList *l = (QObjectList *) w->children();
+ if (!l)
+ return 0;
+
+ QWidgetList widgets;
+ for (QObject * o = l->first(); o; o = l->next())
+ {
+ if (o->isWidgetType() &&
+ !mainWindow()->isAToolBarChild((QWidget *) o) &&
+ ((QWidget *) o)->isVisibleTo(this) && insertedWidgets.find((QWidget *) o))
+ widgets.append((QWidget *) o);
+ }
+ return new BreakLayoutCommand(i18n("Break Layout"), this,
+ WidgetFactory::widgetOfContainer(w), widgets);
+}
+
+int FormWindow::numVisibleWidgets() const
+{
+ QPtrDictIterator < QWidget > it(insertedWidgets);
+ int visible = 0;
+ for (; it.current(); ++it)
+ {
+ if (it.current()->isVisibleTo((FormWindow *) this))
+ visible++;
+ }
+ return visible;
+}
+
+bool FormWindow::hasInsertedChildren(QWidget *w) const
+{
+ if (!w)
+ return false;
+ w = WidgetFactory::containerOfWidget(w);
+ if (!w)
+ return false;
+ QObjectList *l = w->queryList("QWidget");
+ if (!l || !l->first())
+ {
+ delete l;
+ return false;
+ }
+
+ for (QObject *o = l->first(); o; o = l->next())
+ if (o->isWidgetType() && ((QWidget*)o)->isVisibleTo((FormWindow*)this) &&
+ insertedWidgets.find((QWidget*)o))
+ {
+ delete l;
+ return true;
+ }
+ delete l;
+ return false;
+}
+
+bool FormWindow::allowMove(QWidget *w)
+{
+ w = w->parentWidget();
+ while (w)
+ {
+ if ((isMainContainer(w) || insertedWidgets.find(w)) && WidgetFactory::layoutType(w) ==
+ WidgetFactory::NoLayout)
+ return true;
+ w = w->parentWidget();
+ }
+ return false;
+}
+
+
+void FormWindow::editConnections()
+{
+ buffer = 0;
+ if (!connectSender || !connectReceiver)
+ return;
+ mainWindow()->statusBar()->clear();
+ ConnectionEditor editor(mainwindow, connectSender, connectReceiver, this);
+ mainWindow()->statusBar()->message(i18n("Edit connections..."));
+ editor.exec();
+ mainWindow()->statusBar()->clear();
+ if (!toolFixed)
+ mainwindow->resetTool();
+ connectSender = connectReceiver = 0;
+}
+
+void FormWindow::saveBackground()
+{
+ delete buffer;
+ buffer = new QPixmap(width(), height());
+ *buffer = QPixmap::grabWindow(winId());
+}
+
+void FormWindow::restoreConnectionLine()
+{
+ if (!unclippedPainter || !buffer)
+ return;
+
+ int a =QABS(connectStartPos.x() - currentConnectPos.x());
+ int b = QABS(connectStartPos.y() - currentConnectPos.y());
+ QRect r(connectStartPos, currentConnectPos);
+
+ if (a < 32 || b < 32)
+ { // special case: vertical or horizontal line
+ r = r.normalize();
+ unclippedPainter->drawPixmap(r.x() - 2, r.y() - 2, *buffer,
+ r.x() - 2, r.y() - 2, r.width() + 4, r.height() + 4);
+ return;
+ }
+
+ if (a <= 0)
+ a = 1;
+ if (b <= 0)
+ b = 1;
+ int w, h;
+ if (b > a)
+ {
+ h = 64;
+ w = (a * h) / b;
+ }
+ else
+ {
+ w = 64;
+ h = (b * w) / a;
+ }
+ int dx = 2 * w / 3;
+ int dy = 2 * h / 3;
+ QPoint p(connectStartPos);
+
+ if (r.x() > r.right())
+ {
+ dx = dx * -1;
+ p.setX(p.x() - 64);
+ r.moveBy(-64, 0);
+ }
+ if (r.y() > r.bottom()) {
+ dy = dy * -1;
+ p.setY(p.y() - 64);
+ r.moveBy(0, -64);
+ }
+
+ w = h = 64;
+ r = r.normalize();
+ while (r.contains(p))
+ {
+ unclippedPainter->drawPixmap(p, *buffer, QRect(p, QSize(w, h)));
+ unclippedPainter->setPen(red);
+ p.setX(p.x() + dx);
+ p.setY(p.y() + dy);
+ }
+
+ unclippedPainter->drawPixmap(connectStartPos.x() - 10, connectStartPos.y() - 10, *buffer,
+ connectStartPos.x() - 10, connectStartPos.y() - 10, 20, 20);
+}
+
+void FormWindow::restoreRect(const QRect &rect)
+{
+ if (!unclippedPainter)
+ return;
+ QRect r(rect);
+ r = r.normalize();
+ r = QRect(r.x() + 2, r.y() + 2, r.width() - 4, r.height() - 4);
+ unclippedPainter->drawPixmap(r.x() - 2, r.y() - 2, *buffer, r.x() - 2, r.y() - 2, r.width() + 4, 4);
+ unclippedPainter->drawPixmap(r.x() - 2, r.y() - 2, *buffer, r.x() - 2, r.y() - 2, 4, r.height() + 4);
+ unclippedPainter->drawPixmap(r.x() - 2, r.y() + r.height() - 3, *buffer, r.x() - 2,
+ r.y() + r.height() - 3, r.width() + 4, 5);
+ unclippedPainter->drawPixmap(r.x() + r.width() - 2, r.y(), *buffer, r.x() + r.width() - 2,
+ r.y(), 4, r.height() + 4);
+}
+
+void FormWindow::drawConnectLine()
+{
+ if (!unclippedPainter)
+ return;
+ unclippedPainter->setPen(QPen(white, 2));
+ unclippedPainter->drawLine(connectStartPos, currentConnectPos);
+ unclippedPainter->setPen(QPen(darkCyan, 1));
+ unclippedPainter->drawLine(connectStartPos, currentConnectPos);
+
+ unclippedPainter->setPen(QPen(magenta, 1));
+ if (connectSender)
+ {
+ QWidget *w = (QWidget*)connectSender;
+ QPoint p = mapToForm(w, QPoint(0,0));
+ unclippedPainter->drawRect(QRect(p + QPoint(2, 2), w->size() - QSize(4, 4)));
+ }
+ if (connectReceiver)
+ {
+ QWidget *w = (QWidget*)connectReceiver;
+ QPoint p = mapToForm(w, QPoint(0,0));
+ unclippedPainter->drawRect(QRect(p + QPoint(2, 2), w->size() - QSize(4, 4)));
+ }
+}
+
+QString FormWindow::fileName() const
+{
+ return ff->absFileName();
+}
+
+void FormWindow::setFileName(const QString &fn)
+{
+ ff->setFileName(fn);
+ emit fileNameChanged(ff->fileName(), this);
+}
+
+void FormWindow::modificationChanged(bool m)
+{
+ emit modificationChanged(m, this);
+ emit modificationChanged(m, ff->fileName());
+}
+
+bool FormWindow::unify(QObject *w, QString &s, bool changeIt)
+{
+ bool found = !isMainContainer(w) && !qstrcmp(name(), s.latin1());
+ if (!found)
+ {
+ QString orig = s;
+ int num = 1;
+ QPtrDictIterator<QWidget> it(insertedWidgets);
+ for (; it.current();)
+ if (it.current() != w && !qstrcmp(it.current()->name(), s.latin1()))
+ {
+ found = true;
+ if (!changeIt)
+ break;
+ s = orig + "_" + QString::number(++num);
+ it.toFirst();
+ }
+ else
+ ++it;
+
+ if (!found)
+ {
+ QPtrList<QAction> al;
+ QAction *a = 0;
+ for (a = actions.first(); a; a = actions.next())
+ {
+ QObjectList *l = a->queryList("QAction");
+ al.append(a);
+ for (QObject *ao = l->first(); ao; ao = l->next())
+ al.append((QAction*)ao);
+ delete l;
+ }
+ for (a = al.first(); a; a = al.next())
+ {
+ if (a != w && !qstrcmp(a->name(), s.latin1()))
+ {
+ found = true;
+ if (!changeIt)
+ break;
+ s = orig + "_" + QString::number(++num);
+ a = actions.first();
+ }
+ }
+ }
+
+ if (mainContainer()->inherits("QMainWindow"))
+ {
+ if (!found)
+ {
+ QObjectList *l = mainContainer()->queryList("QDockWindow", 0, true);
+ for (QObject *o = l->first(); o; o = l->next())
+ if (o != w && !qstrcmp(o->name(), s.latin1()))
+ {
+ found = true;
+ if (!changeIt)
+ break;
+ s = orig + "_" + QString::number(++num);
+ o = l->first();
+ }
+ delete l;
+ }
+ if (!found)
+ {
+ QObjectList *l = mainContainer()->queryList("QDesignerPopupMenu", 0, true);
+ for (QObject *o = l->first(); o; o = l->next())
+ if (o != w && !qstrcmp(o->name(), s.latin1()))
+ {
+ found = true;
+ if (!changeIt)
+ break;
+ s = orig + "_" + QString::number(++num);
+ o = l->first();
+ }
+ delete l;
+ }
+ }
+ }
+ if (!found)
+ return true;
+ return false;
+}
+
+bool FormWindow::isCustomWidgetUsed(MetaDataBase::CustomWidget *w)
+{
+ QPtrDictIterator<QWidget> it(insertedWidgets);
+ for (; it.current(); ++it)
+ if (it.current()->isA("CustomWidget") && !qstrcmp(WidgetFactory::classNameOf(it.current()),
+ w->className.utf8()))
+ return true;
+ return false;
+}
+
+bool FormWindow::isDatabaseWidgetUsed() const
+{
+#ifndef QT_NO_SQL
+ QStringList dbClasses;
+ dbClasses << "QDataTable"; // add more here
+ QPtrDictIterator<QWidget> it(insertedWidgets);
+ for (; it.current(); ++it)
+ {
+ QString c(it.current()->className());
+ if (dbClasses.contains(c) > 0)
+ return true;
+ }
+#endif
+ return false;
+}
+
+bool FormWindow::isDatabaseAware() const
+{
+#ifndef QT_NO_SQL
+ if (QString(mContainer->className()) == "QDesignerDataBrowser" ||
+ QString(mContainer->className()) == "QDesignerDataView")
+ return true;
+ return isDatabaseWidgetUsed();
+#else
+ return false;
+#endif
+}
+
+void FormWindow::visibilityChanged()
+{
+ if (currTool != ORDER_TOOL)
+ emitUpdateProperties(currentWidget());
+ else
+ {
+ updateOrderIndicators();
+ repositionOrderIndicators();
+ }
+}
+
+
+/*
+ Maps a pos in a w's coordinates to the form's coordinate system.
+
+ This is the equivalent to mapFromGlobal(w->mapToGlobal(pos)) but
+ avoids the two roundtrips to the X-Server on Unix/X11.
+ */
+QPoint FormWindow::mapToForm(const QWidget* w, const QPoint& pos) const
+{
+ QPoint p = pos;
+ const QWidget* i = w;
+ while (i && !i->isTopLevel() && !isMainContainer((QWidget*)i))
+ {
+ p = i->mapToParent(p);
+ i = i->parentWidget();
+ }
+ return mapFromGlobal(w->mapToGlobal(pos));
+}
+
+static int widgetDepth(QWidget *w)
+{
+ int d = -1;
+ while (w && !w->isTopLevel())
+ {
+ d++;
+ w = w->parentWidget();
+ }
+
+ return d;
+}
+
+static bool isChildOf(QWidget *c, QWidget *p)
+{
+ while (c && !c->isTopLevel())
+ {
+ if (c == p)
+ return true;
+ c = c->parentWidget();
+ }
+ return false;
+}
+
+QWidget *FormWindow::containerAt(const QPoint &pos, QWidget *notParentOf)
+{
+ QPtrDictIterator<QWidget> it(insertedWidgets);
+ QWidget *container = 0;
+ int depth = -1;
+ QWidgetList selected = selectedWidgets();
+ if (rect().contains(mapFromGlobal(pos)))
+ {
+ container = mainContainer();
+ depth = widgetDepth(container);
+ }
+
+ for (; it.current(); ++it) {
+ if (it.current()->inherits("QLayoutWidget"))
+ continue;
+ if (it.current()->inherits("QSplitter"))
+ continue;
+ if (!it.current()->isVisibleTo(this))
+ continue;
+ if (selected.find(it.current()) != -1)
+ continue;
+ if (!WidgetDatabase::isContainer(WidgetDatabase::idFromClassName(
+ WidgetFactory::classNameOf(it.current()))) && it.current() != mainContainer())
+ continue;
+
+ // the rectangles of all ancestors of the container must contain the insert position
+ QWidget *w = it.current();
+ while (w && !w->isTopLevel())
+ {
+ if (!w->rect().contains((w->mapFromGlobal(pos))))
+ break;
+ w = w->parentWidget();
+ }
+ if (w && !w->isTopLevel()) continue; // we did not get through the full while loop
+
+ int wd = widgetDepth(it.current());
+ if (wd == depth && container && ((QObjectList*)it.current()->parentWidget()->
+ children())->find(it.current()) >
+ ((QObjectList*)container->parentWidget()->children())->find(container))
+ wd++;
+ if (wd > depth && !isChildOf(it.current(), notParentOf)) {
+ depth = wd;
+ container = it.current();
+ }
+ }
+
+ return container;
+}
+
+bool FormWindow::isMainContainer(QObject *w) const
+{
+ return w && w->isWidgetType() && (w == (QWidget*)this || w == mainContainer());
+}
+
+void FormWindow::setMainContainer(QWidget *w)
+{
+ bool resetPropertyWidget = isMainContainer(propertyWidget);
+ if (mContainer)
+ insertedWidgets.remove(mContainer);
+ if (propertyWidget == mContainer)
+ propertyWidget = 0;
+ delete mContainer;
+ mContainer = w;
+ insertedWidgets.insert(mContainer, mContainer);
+ delete layout();
+ QHBoxLayout *l = new QHBoxLayout(this);
+ l->addWidget(w);
+ if (resetPropertyWidget)
+ {
+ QObject *opw = propertyWidget;
+ propertyWidget = mContainer;
+ if (opw && opw->isWidgetType())
+ repaintSelection((QWidget*)opw);
+ }
+}
+
+bool FormWindow::savePixmapInline() const
+{
+ return pixInline;
+}
+
+QString FormWindow::pixmapLoaderFunction() const
+{
+ return pixLoader;
+}
+
+void FormWindow::setSavePixmapInline(bool b)
+{
+ pixInline = b;
+}
+
+void FormWindow::setPixmapLoaderFunction(const QString &func)
+{
+ pixLoader = func;
+}
+
+void FormWindow::setActiveObject(QObject *o)
+{
+ emitShowProperties(o);
+ propertyWidget = o;
+}
+
+QAction *FormWindow::findAction(const QString &name)
+{
+ for (QAction *a = actionList().first(); a; a = actionList().next())
+ {
+ if (QString(a->name()) == name)
+ return a;
+ QAction *ac = (QAction*)a->child(name.latin1(), "QAction");
+ if (ac)
+ return ac;
+ }
+ return 0;
+}
+
+void FormWindow::killAccels(QObject *top)
+{
+ QObjectList *l = top->queryList("QAccel");
+ if (!l)
+ return;
+ for (QObject *o = l->first(); o; o = l->next())
+ ((QAccel*)o)->setEnabled(false);
+ delete l;
+}
+
+bool FormWindow::isCentralWidget(QObject *w) const
+{
+ if (!mainContainer()->inherits("QMainWindow"))
+ return false;
+ return w == ((QMainWindow*)mainContainer())->centralWidget();
+}
+
+QObject *FormWindow::connectableObject(QObject *w, QObject *)
+{
+ return w;
+}
+
+int FormWindow::layoutDefaultSpacing() const
+{
+ return defSpacing;
+}
+
+int FormWindow::layoutDefaultMargin() const
+{
+ return defMargin;
+}
+
+void FormWindow::setLayoutDefaultSpacing(int s)
+{
+ defSpacing = s;
+}
+
+void FormWindow::setLayoutDefaultMargin(int s)
+{
+ defMargin = s;
+}
+
+FormFile *FormWindow::formFile() const
+{
+ return ff;
+}
+
+void FormWindow::setFormFile(FormFile *f)
+{
+ ff = f;
+ if (ff)
+ connect(this, SIGNAL(modificationChanged(bool, const QString&)), ff, SLOT(formWindowChangedSomehow()));
+}
+#include "formwindow.moc"
diff --git a/kommander/editor/formwindow.h b/kommander/editor/formwindow.h
new file mode 100644
index 00000000..c6d871b0
--- /dev/null
+++ b/kommander/editor/formwindow.h
@@ -0,0 +1,292 @@
+/**********************************************************************
+ This file is based on Qt Designer, Copyright (C) 2000 Trolltech AS. All rights reserved.
+
+ This file may be distributed and/or modified under the terms of the
+ GNU General Public License version 2 as published by the Free Software
+ Foundation and appearing in the file LICENSE.GPL included in the
+ packaging of this file.
+
+ This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+ See http://www.trolltech.com/gpl/ for GPL licensing information.
+
+ Modified for Kommander:
+ (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+
+**********************************************************************/
+
+#ifndef FORMWINDOW_H
+#define FORMWINDOW_H
+
+#include "command.h"
+#include "metadatabase.h"
+#include "sizehandle.h"
+#include "actiondnd.h"
+
+
+#include <qwidget.h>
+#include <qmap.h>
+#include <qptrdict.h>
+#include <qpixmap.h>
+#include <qwidgetlist.h>
+#include <qmap.h>
+
+class QPaintEvent;
+class QMouseEvent;
+class QKeyEvent;
+class QPainter;
+class QLabel;
+class MainWindow;
+class QTimer;
+class QFocusEvent;
+class QCloseEvent;
+class Resource;
+class QResizeEvent;
+class BreakLayoutCommand;
+class QPixmap;
+class QSizeGrip;
+class FormFile;
+
+#if defined(Q_FULL_TEMPLATE_INSTANTIATION)
+#include "orderindicator.h"
+#else
+class OrderIndicator;
+#endif
+
+class FormWindow : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY( QString fileName READ fileName WRITE setFileName )
+
+public:
+ FormWindow( FormFile *f, MainWindow *mw, QWidget *parent, const char *name = 0 );
+ FormWindow( FormFile *f, QWidget *parent, const char *name = 0 );
+ ~FormWindow();
+
+ void init();
+ virtual void setMainWindow( MainWindow *w );
+
+ virtual QString fileName() const;
+ virtual void setFileName( const QString &fn );
+
+ virtual QPoint grid() const;
+ virtual QPoint gridPoint( const QPoint &p );
+
+ virtual CommandHistory *commandHistory();
+
+ virtual void undo();
+ virtual void redo();
+ virtual QString copy();
+ virtual void paste( const QString &cb, QWidget *parent );
+ virtual void lowerWidgets();
+ virtual void raiseWidgets();
+ virtual void checkAccels();
+
+ virtual void layoutHorizontal();
+ virtual void layoutVertical();
+ virtual void layoutHorizontalSplit();
+ virtual void layoutVerticalSplit();
+ virtual void layoutGrid();
+
+ virtual void layoutHorizontalContainer( QWidget *w );
+ virtual void layoutVerticalContainer( QWidget *w );
+ virtual void layoutGridContainer( QWidget *w );
+
+ virtual void breakLayout( QWidget *w );
+
+ virtual void selectWidget( QObject *w, bool select = TRUE );
+ virtual void selectAll();
+ virtual void updateSelection( QWidget *w );
+ virtual void raiseSelection( QWidget *w );
+ virtual void repaintSelection( QWidget *w );
+ virtual void clearSelection( bool changePropertyDisplay = TRUE );
+ virtual void selectWidgets();
+ bool isWidgetSelected( QObject *w );
+ virtual void updateChildSelections( QWidget *w );
+ virtual void raiseChildSelections( QWidget *w );
+
+ virtual void emitUpdateProperties( QObject *w );
+ virtual void emitShowProperties( QObject *w = 0 );
+ virtual void emitSelectionChanged();
+
+ virtual void setPropertyShowingBlocked( bool b );
+ bool isPropertyShowingBlocked() const;
+
+ virtual QLabel *sizePreview() const;
+ virtual void checkPreviewGeometry( QRect &r );
+
+ virtual QPtrDict<QWidget> *widgets();
+ virtual QWidgetList selectedWidgets() const;
+
+ virtual QWidget *designerWidget( QObject *o ) const;
+
+ virtual void handleContextMenu( QContextMenuEvent *e, QWidget *w );
+ virtual void handleMousePress( QMouseEvent *e, QWidget *w );
+ virtual void handleMouseRelease( QMouseEvent *e, QWidget *w );
+ virtual void handleMouseDblClick( QMouseEvent *e, QWidget *w );
+ virtual void handleMouseMove( QMouseEvent *e, QWidget *w );
+ virtual void handleKeyPress( QKeyEvent *e, QWidget *w );
+ virtual void handleKeyRelease( QKeyEvent *e, QWidget *w );
+
+ virtual void updateUndoInfo();
+
+ virtual MainWindow *mainWindow() const { return mainwindow; }
+
+ bool checkCustomWidgets();
+ virtual void insertWidget( QWidget *w, bool checkName = FALSE );
+ virtual void removeWidget( QWidget *w );
+ virtual void deleteWidgets();
+ virtual void editAdjustSize();
+ virtual void editConnections();
+
+ virtual int numSelectedWidgets() const;
+ virtual int numVisibleWidgets() const;
+
+ virtual bool hasInsertedChildren( QWidget *w ) const;
+
+ virtual QWidget *currentWidget() const
+ { return propertyWidget && propertyWidget->isWidgetType() ? (QWidget*)propertyWidget : 0; }
+ virtual bool unify( QObject *w, QString &s, bool changeIt );
+
+ virtual bool isCustomWidgetUsed( MetaDataBase::CustomWidget *w );
+ virtual bool isDatabaseWidgetUsed() const;
+ virtual bool isDatabaseAware() const;
+
+ virtual QPoint mapToForm( const QWidget* w, const QPoint& ) const;
+
+ bool isMainContainer( QObject *w ) const;
+ bool isCentralWidget( QObject *w ) const;
+ QWidget *mainContainer() const { return mContainer; }
+ void setMainContainer( QWidget *w );
+
+ void paintGrid( QWidget *w, QPaintEvent *e );
+
+ bool savePixmapInline() const;
+ QString pixmapLoaderFunction() const;
+ void setSavePixmapInline( bool b );
+ void setPixmapLoaderFunction( const QString &func );
+
+ void setToolFixed() { toolFixed = TRUE; }
+
+ void setActiveObject( QObject *o );
+
+ QPtrList<QAction> &actionList() { return actions; }
+ QAction *findAction( const QString &name );
+
+ void killAccels( QObject *top );
+
+ int layoutDefaultSpacing() const;
+ int layoutDefaultMargin() const;
+ void setLayoutDefaultSpacing( int s );
+ void setLayoutDefaultMargin( int s );
+
+ void initSlots();
+ FormFile *formFile() const;
+ void setFormFile( FormFile *f );
+
+public slots:
+ virtual void widgetChanged( QObject *w );
+ virtual void currentToolChanged();
+ virtual void visibilityChanged();
+ virtual void modificationChanged( bool m );
+
+signals:
+ void showProperties( QObject *w );
+ void updateProperties( QObject *w );
+ void undoRedoChanged( bool undoAvailable, bool redoAvailable, const QString &undoCmd,
+ const QString &redoCmd );
+ void selectionChanged();
+ void modificationChanged( bool m, FormWindow *fw );
+ void modificationChanged( bool m, const QString &s );
+ void fileNameChanged( const QString &s, FormWindow *fw );
+
+protected:
+ virtual void closeEvent( QCloseEvent *e );
+ virtual void focusInEvent( QFocusEvent *e );
+ virtual void focusOutEvent( QFocusEvent *e );
+ virtual void resizeEvent( QResizeEvent *e );
+ void mouseDoubleClickEvent( QMouseEvent *e )
+ { handleMouseDblClick( e, mainContainer() ); }
+
+private:
+ enum RectType { Insert, Rubber };
+
+ virtual void beginUnclippedPainter( bool doNot );
+ virtual void endUnclippedPainter();
+ virtual void drawConnectLine();
+ virtual void drawSizePreview( const QPoint &pos, const QString& text );
+
+ virtual void insertWidget();
+ virtual void moveSelectedWidgets( int dx, int dy );
+
+ virtual void startRectDraw( const QPoint &p, const QPoint &global, QWidget *w, RectType t );
+ virtual void continueRectDraw( const QPoint &p, const QPoint &global, QWidget *w, RectType t );
+ virtual void endRectDraw();
+
+ virtual void checkSelectionsForMove( QWidget *w );
+ virtual BreakLayoutCommand *breakLayoutCommand( QWidget *w );
+
+ virtual bool allowMove( QWidget *w );
+
+ virtual void saveBackground();
+ virtual void restoreConnectionLine();
+ virtual void restoreRect( const QRect &rect ) ;
+
+ virtual void showOrderIndicators();
+ virtual void updateOrderIndicators();
+ virtual void repositionOrderIndicators();
+ virtual void hideOrderIndicators();
+
+ virtual QWidget *containerAt( const QPoint &pos, QWidget *notParentOf );
+
+ QObject *connectableObject( QObject *w, QObject *fallback );
+
+private slots:
+ virtual void invalidCheckedSelections();
+ virtual void updatePropertiesTimerDone();
+ virtual void showPropertiesTimerDone();
+ virtual void selectionChangedTimerDone();
+
+private:
+ int currTool;
+ bool oldRectValid, widgetPressed, drawRubber, checkedSelectionsForMove;
+ QRect currRect;
+ QPoint rectAnchor;
+ QPainter *unclippedPainter;
+ QPoint sizePreviewPos;
+ QPixmap sizePreviewPixmap;
+ MainWindow *mainwindow;
+ QPtrList<WidgetSelection> selections;
+ QPtrDict<WidgetSelection> usedSelections;
+ QRect widgetGeom, rubber;
+ QPoint oldPressPos, origPressPos;
+ CommandHistory commands;
+ QMap<ulong, QPoint> moving;
+ QWidget *insertParent;
+ QObject *propertyWidget;
+ QLabel *sizePreviewLabel;
+ QTimer *checkSelectionsTimer;
+ QPtrDict<QWidget> insertedWidgets;
+ bool propShowBlocked;
+ QTimer* updatePropertiesTimer, *showPropertiesTimer, *selectionChangedTimer;
+ QPoint connectStartPos, currentConnectPos;
+ QObject *connectSender, *connectReceiver;
+ QPixmap *buffer;
+ QPtrList<OrderIndicator> orderIndicators;
+ QWidgetList orderedWidgets;
+ QWidgetList stackedWidgets;
+ QWidget *mContainer;
+ bool pixInline;
+ QString pixLoader;
+ bool toolFixed;
+ QPtrList<QAction> actions;
+ QWidget* targetContainer;
+ QPalette restorePalette;
+ bool hadOwnPalette;
+ int defSpacing, defMargin;
+ FormFile *ff;
+};
+
+#endif
diff --git a/kommander/editor/functions.ui b/kommander/editor/functions.ui
new file mode 100644
index 00000000..48616099
--- /dev/null
+++ b/kommander/editor/functions.ui
@@ -0,0 +1,722 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>FunctionsDialogBase</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>FunctionsDialogBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>638</width>
+ <height>670</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Function Browser</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="2">
+ <property name="name">
+ <cstring>layout7_2</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Description:</string>
+ </property>
+ </widget>
+ <widget class="KTextBrowser">
+ <property name="name">
+ <cstring>descriptionText</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Group:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>groupComboBox</cstring>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>groupComboBox</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>150</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Function:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>functionListBox</cstring>
+ </property>
+ </widget>
+ <widget class="KListBox">
+ <property name="name">
+ <cstring>functionListBox</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox" row="0" column="1">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>250</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>&amp;Parameters</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="6" column="0">
+ <property name="name">
+ <cstring>argLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Arg3</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="10" column="0">
+ <property name="name">
+ <cstring>argLabel5</cstring>
+ </property>
+ <property name="text">
+ <string>Arg5</string>
+ </property>
+ </widget>
+ <spacer row="14" column="0">
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton" row="15" column="0">
+ <property name="name">
+ <cstring>copyButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32767</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Insert function</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="8" column="0">
+ <property name="name">
+ <cstring>argLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Arg4</string>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="1" column="0">
+ <property name="name">
+ <cstring>widgetComboBox</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="0">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>arg1Edit</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>quote1</cstring>
+ </property>
+ <property name="text">
+ <string>Quote</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>combo1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>argLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Arg1</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="5" column="0">
+ <property name="name">
+ <cstring>layout12</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>arg2Edit</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>quote2</cstring>
+ </property>
+ <property name="text">
+ <string>Quote</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>combo2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="7" column="0">
+ <property name="name">
+ <cstring>layout13</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>arg3Edit</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>quote3</cstring>
+ </property>
+ <property name="text">
+ <string>Quote</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>combo3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>widgetLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Widget:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="9" column="0">
+ <property name="name">
+ <cstring>layout14</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>arg4Edit</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>quote4</cstring>
+ </property>
+ <property name="text">
+ <string>Quote</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>combo4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="11" column="0">
+ <property name="name">
+ <cstring>layout15</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>arg5Edit</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>quote5</cstring>
+ </property>
+ <property name="text">
+ <string>Quote</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>combo5</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="13" column="0">
+ <property name="name">
+ <cstring>layout16</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>arg6Edit</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>quote6</cstring>
+ </property>
+ <property name="text">
+ <string>Quote</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>combo6</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="12" column="0">
+ <property name="name">
+ <cstring>argLabel6</cstring>
+ </property>
+ <property name="text">
+ <string>Arg6</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>argLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Arg2</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>100</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>100</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>layout12</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>clearButton</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32767</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Clear edited text</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Inserted &amp;text:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>insertedText</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="KTextEdit">
+ <property name="name">
+ <cstring>insertedText</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="focusPolicy">
+ <enum>StrongFocus</enum>
+ </property>
+ <property name="textFormat">
+ <enum>PlainText</enum>
+ </property>
+ <property name="linkUnderline">
+ <bool>false</bool>
+ </property>
+ <property name="autoFormatting">
+ <set>AutoAll</set>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>FunctionsDialogBase</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>FunctionsDialogBase</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>groupComboBox</tabstop>
+ <tabstop>functionListBox</tabstop>
+ <tabstop>widgetComboBox</tabstop>
+ <tabstop>arg1Edit</tabstop>
+ <tabstop>arg2Edit</tabstop>
+ <tabstop>arg3Edit</tabstop>
+ <tabstop>arg4Edit</tabstop>
+ <tabstop>arg5Edit</tabstop>
+ <tabstop>arg6Edit</tabstop>
+ <tabstop>copyButton</tabstop>
+ <tabstop>descriptionText</tabstop>
+ <tabstop>clearButton</tabstop>
+ <tabstop>buttonOk</tabstop>
+ <tabstop>buttonCancel</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>ktextbrowser.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klistbox.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>ktextedit.h</includehint>
+</includehints>
+</UI>
diff --git a/kommander/editor/functionsimpl.cpp b/kommander/editor/functionsimpl.cpp
new file mode 100644
index 00000000..ad4924e5
--- /dev/null
+++ b/kommander/editor/functionsimpl.cpp
@@ -0,0 +1,392 @@
+/***************************************************************************
+ functionsimpl.cpp - Function browser implementation
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or mody *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/* QT INCLUDES */
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qmetaobject.h>
+#include <qstringlist.h>
+#include <qregexp.h>
+
+/* KDE INCLUDES */
+#include <kcombobox.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klistbox.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <kpushbutton.h>
+#include <ktextedit.h>
+#include <ktextbrowser.h>
+#include <kdebug.h>
+
+/* OTHER INCLUDES */
+#include "functionsimpl.h"
+#include "kommanderwidget.h"
+#include "invokeclass.h"
+#include "widgetdatabase.h"
+
+const int MaxFunctionArgs = 6;
+
+
+FunctionsDialog::FunctionsDialog(QWidget* a_parent, const QDict<QWidget>& a_widgetList, bool useInternalParser, char* a_name,
+ bool a_modal)
+ : FunctionsDialogBase(a_parent, a_name, a_modal), m_widgetList(a_widgetList), m_useInternalParser(useInternalParser)
+{
+ clearButton->setPixmap(KGlobal::iconLoader()->loadIcon("locationbar_erase", KIcon::Toolbar));
+ copyButton->setPixmap(KGlobal::iconLoader()->loadIcon("1downarrow", KIcon::Toolbar));
+
+ groupComboBox->insertStringList(SpecialInformation::groups());
+ connect(groupComboBox, SIGNAL(activated(int)), SLOT(groupChanged(int)));
+ connect(widgetComboBox, SIGNAL(activated(int)), SLOT(groupChanged(int)));
+ connect(functionListBox, SIGNAL(highlighted(int)), SLOT(functionChanged(int)));
+ connect(copyButton, SIGNAL(clicked()), SLOT(copyText()));
+ connect(clearButton, SIGNAL(clicked()), insertedText, SLOT(clear()));
+
+ // build widget name list
+ for (QDictIterator<QWidget> It(m_widgetList); It.current(); ++It)
+ m_widgetNames.append(It.currentKey());
+ m_widgetNames.sort();
+ widgetComboBox->insertStringList(m_widgetNames);
+
+ for (int j = 0; j < WidgetDatabase::count(); j++)
+ {
+ QString group = WidgetDatabase::group(j);
+ if (group == "Kommander" || group == "Custom")
+ m_widgetTypes << WidgetDatabase::className(j);
+ }
+ m_widgetTypes.sort();
+
+//TODO: Insert either the generic widget types or parse for on the fly created widget
+//names. The problem is that the rest of the code depends on the fact that the widget
+//from the widgetComboBox exists
+// widgetComboBox->insertStringList(m_widgetTypes);
+
+ m_acceptedSlots = InvokeClass::acceptedSlots();
+
+ m_DCOP = -1; // Select DCOP functions by default
+ m_Slots = -1;
+ for (int i=0; i<groupComboBox->count(); i++)
+ {
+ if (groupComboBox->text(i) == i18n("Slots"))
+ {
+ m_Slots = i;
+ break;
+ }
+ }
+ if (!useInternalParser)
+ {
+ groupComboBox->removeItem(m_Slots);
+ m_Slots = -1;
+ }
+ for (int i=0; i<groupComboBox->count(); i++)
+ {
+ if (groupComboBox->text(i) == "DCOP")
+ {
+ m_DCOP = i;
+ break;
+ }
+ }
+ groupComboBox->changeItem(i18n("Functions"), m_DCOP); //this is a quick way to rename this group in the UI
+ groupComboBox->setCurrentItem(m_DCOP);
+ groupChanged(groupComboBox->currentItem());
+}
+
+FunctionsDialog::~FunctionsDialog()
+{
+}
+
+QString FunctionsDialog::functionText() const
+{
+ return insertedText->text();
+}
+
+QString FunctionsDialog::currentFunctionText()
+{
+ QString prefix, function;
+ int index = groupComboBox->currentItem();
+ QString s = (index != m_DCOP ) ? groupComboBox->text(index) : "DCOP";
+ if (m_useInternalParser)
+ {
+ function = SpecialInformation::parserGroupName(s);
+ if (!function.isEmpty())
+ function += "_";
+ }
+ else
+ {
+ prefix = "@";
+ function = s + ".";
+ }
+ if (groupComboBox->currentText() == "Kommander")
+ return QString("%1%2%3").arg(prefix).arg(functionListBox->currentText()).arg(params());
+ else if (groupComboBox->currentItem() == m_DCOP || groupComboBox->currentItem() == m_Slots)
+ return QString("%1%2.%3%4").arg(prefix).arg(widgetComboBox->currentText().section(' ', 0, 0))
+ .arg(functionListBox->currentText().left(functionListBox->currentText().find('('))).arg(params());
+ else
+ return QString("%1%2%3%4").arg(prefix).arg(function)
+ .arg(functionListBox->currentText()).arg(params());
+}
+
+void FunctionsDialog::groupChanged(int index)
+{
+ index = groupComboBox->currentItem();
+ functionListBox->clear();
+ m_slotList.clear();
+ if (index == m_Slots)
+ {
+ KommanderWidget* a_atw = dynamic_cast<KommanderWidget *>(m_widgetList[widgetComboBox->currentText()]);
+ QStringList pFunctions = QStringList::fromStrList(a_atw->object()->metaObject()->slotNames(true));
+ for (uint i=0; i<pFunctions.count(); i++)
+ {
+ QString slot = pFunctions[i];
+ QString slotArgStr = slot.section(QRegExp("\\(|\\)"), 1);
+ if (slotArgStr.isEmpty() || m_acceptedSlots.contains(slotArgStr))
+ {
+ QString name = slot.remove("()");
+ if (!m_slotList.contains(name))
+ {
+ m_slotList[name] = slot;
+ functionListBox->insertItem(name);
+ }
+ }
+ }
+ } else
+ {
+ QString s = (index != m_DCOP ) ? groupComboBox->text(index) : "DCOP";
+ QStringList pFunctions = SpecialInformation::functions(s);
+ KommanderWidget* a_atw = 0;
+ if (index == m_DCOP)
+ a_atw = dynamic_cast<KommanderWidget *>(m_widgetList[widgetComboBox->currentText()]);
+ int pGroup = SpecialInformation::group(s);
+ SpecialFunction::ParserType pType = m_useInternalParser
+ ? SpecialFunction::InternalParser : SpecialFunction::MacroParser;
+
+ for (uint i=0; i<pFunctions.count(); i++)
+ {
+ int pFunction = SpecialInformation::function(pGroup, pFunctions[i]);
+ if (!SpecialInformation::isValid(pGroup, pFunction, pType))
+ continue;
+ if (a_atw && !a_atw->isFunctionSupported(pFunction) && !a_atw->isCommonFunction(pFunction))
+ continue;
+ functionListBox->insertItem(pFunctions[i]);
+ }
+ }
+
+ functionListBox->sort();
+ functionListBox->setCurrentItem(0);
+ functionChanged(functionListBox->currentItem());
+}
+
+void FunctionsDialog::functionChanged(int)
+{
+ if (groupComboBox->currentItem() == m_Slots)
+ {
+ KommanderWidget* w = dynamic_cast<KommanderWidget *>(m_widgetList[widgetComboBox->currentText()]);
+ QObject *o = w->object();
+ QString slotHelp = i18n("To learn more about the slot, look at the documentation of the base Qt/KDE class, most probably <i>%1</i>.").arg(o->metaObject()->superClassName() ? QString(o->metaObject()->superClassName()) : QString(o->className()) );
+ QString slotName = functionListBox->currentText();
+ QString slot = m_slotList[slotName];
+ descriptionText->clear();
+ descriptionText->setText(i18n("<qt><h3>%1</h3>"
+ "<p><b>Description:</b> %2\n<p><b>Syntax:</b> <i>%3</i>%4</qt>")
+ .arg(slotName).arg(slotHelp).arg(slot).arg(""));
+ } else
+ {
+ int index = groupComboBox->currentItem();
+ QString s = (index != m_DCOP ) ? groupComboBox->text(index) : "DCOP";
+ m_function = SpecialInformation::functionObject(s,
+ functionListBox->currentText());
+ QString defArgs;
+ if (m_function.minArg() < m_function.argumentCount())
+ if (!m_function.minArg())
+ defArgs = i18n("<p>Parameters are not obligatory.");
+ else
+ defArgs = i18n("<p>Only first argument is obligatory.",
+ "<p>Only first %n arguments are obligatory.",
+ m_function.minArg());
+
+ uint pflags = SpecialFunction::ShowArgumentNames;
+ if (m_function.maxArg() && m_function.argumentName(0) == "widget")
+ pflags = pflags | SpecialFunction::SkipFirstArgument;
+
+ descriptionText->clear();
+ descriptionText->setText(i18n("<qt><h3>%1</h3>"
+ "<p><b>Description:</b> %2\n<p><b>Syntax:</b> <i>%3</i>%4</qt>")
+ .arg(functionListBox->currentText()).arg(m_function.description())
+ .arg(m_function.prototype(pflags)).arg(defArgs));
+
+ }
+ showParameters();
+}
+
+void FunctionsDialog::copyText()
+{
+ QString text = currentFunctionText();
+ int para, i;
+ insertedText->getCursorPosition(&para, &i);
+// int cursorPos = insertedText->cursorPosition();
+ insertedText->insert(text);
+ insertedText->setCursorPosition(para, i + text.find('(') + 1);
+}
+
+void FunctionsDialog::showParameters()
+{
+ KLineEdit* edits[MaxFunctionArgs] = {arg1Edit, arg2Edit, arg3Edit, arg4Edit, arg5Edit, arg6Edit};
+ QLabel* labels[MaxFunctionArgs] = {argLabel1, argLabel2, argLabel3, argLabel4, argLabel5, argLabel6};
+ KComboBox* combos[MaxFunctionArgs] = {combo1, combo2, combo3, combo4, combo5, combo6};
+ QCheckBox* quotes[MaxFunctionArgs] = {quote1, quote2, quote3, quote4, quote5, quote6};
+
+ if (groupComboBox->currentItem() == m_Slots)
+ {
+ widgetComboBox->setShown(true);
+ widgetLabel->setShown(true);
+ QString slot = m_slotList[functionListBox->currentText()];
+ QStringList slotArgs = QStringList::split(',', slot.section(QRegExp("\\(|\\)"), 1), false);
+ int argsCount = slotArgs.count();
+ for (int i = 0; i < MaxFunctionArgs; i++)
+ {
+ labels[i]->setShown(i < argsCount);
+ QString type;
+ if (i < argsCount)
+ {
+ type = slotArgs[i].remove(QRegExp("\\*|\\&|const\\s"));
+ labels[i]->setText(QString("%1:").arg(type));
+ }
+ quotes[i]->setChecked(true);
+ quotes[i]->setShown(false);
+ if (type == "bool")
+ {
+ edits[i]->setShown(false);
+ combos[i]->setShown(i < argsCount);
+ combos[i]->clear();
+ combos[i]->setEditable(false);
+ combos[i]->insertItem("true");
+ combos[i]->insertItem("false");
+ } else
+ {
+ combos[i]->setShown(false);
+ edits[i]->setShown(i < argsCount);
+ edits[i]->clear();
+ if (type == "QString")
+ {
+ quotes[i]->setShown(i < argsCount);
+ }
+ }
+ }
+ } else
+ {
+ int start = (m_function.argumentCount() && m_function.argumentName(0) == "widget");
+
+ widgetComboBox->setShown(start);
+ widgetLabel->setShown(start);
+ if (start)
+ {
+ arg1Edit->setShown(false);
+ argLabel1->setShown(false);
+ combo1->setShown(false);
+ quote1->setShown(false);
+ }
+ int argsCount = m_function.argumentCount();
+ for (int i=start; i<MaxFunctionArgs; i++)
+ {
+ labels[i]->setShown(i < argsCount);
+ if (i < argsCount)
+ labels[i]->setText(QString("%1:").arg(m_function.argumentName(i)));
+ quotes[i]->setChecked(true);
+ quotes[i]->setShown(false);
+ if (m_function.argumentType(i) == "bool")
+ {
+ edits[i]->setShown(false);
+ combos[i]->setShown(i < argsCount);
+ combos[i]->setEditable(false);
+ combos[i]->clear();
+ combos[i]->insertItem("true");
+ combos[i]->insertItem("false");
+ } else
+ {
+//FIXME: big hack to show a combo for createWidgets. Good solution: extra flag for arguments telling if it is a file/widget/etc.
+ if (m_function.name() == "createWidget" && ( i == 1 || i == 2))
+ {
+ combos[i]->clear();
+ combos[i]->setEditable(true);
+ if ( i == 1)
+ {
+ combos[i]->insertStringList(m_widgetTypes);
+ } else
+ {
+ combos[i]->insertItem("");
+ combos[i]->insertStringList(m_widgetNames);
+ }
+ edits[i]->setShown(false);
+ combos[i]->setShown(true);
+ } else
+ {
+ combos[i]->setShown(false);
+ edits[i]->setShown(i < argsCount);
+ edits[i]->clear();
+ if (m_function.argumentType(i) == "QString")
+ {
+ quotes[i]->setShown(i < argsCount);
+ }
+ }
+ }
+ }
+ }
+}
+
+QString FunctionsDialog::params()
+{
+ QLabel* labels[MaxFunctionArgs] = {argLabel1, argLabel2, argLabel3, argLabel4, argLabel5, argLabel6};
+ KLineEdit* edits[MaxFunctionArgs] = {arg1Edit, arg2Edit, arg3Edit, arg4Edit, arg5Edit, arg6Edit};
+ KComboBox* combos[MaxFunctionArgs] = {combo1, combo2, combo3, combo4, combo5, combo6};
+ QStringList pars;
+ QCheckBox* quotes[MaxFunctionArgs] = {quote1, quote2, quote3, quote4, quote5, quote6};
+ bool params = false;
+ bool slotsShown = (groupComboBox->currentItem() == m_Slots);
+ for (int i=0; i<MaxFunctionArgs; i++)
+ {
+ if (edits[i]->isShown())
+ {
+ QString s = edits[i]->text();
+ if (!s.isEmpty() || i < m_function.minArg())
+ {
+ if (quotes[i]->isChecked() && ( (!slotsShown && m_function.argumentType(i) == "QString")
+ || (slotsShown && labels[i]->text().startsWith("QString")) ) )
+ s = '"' + s + '"';
+ pars.append(s);
+ }
+ params = true;
+ } else
+ if (combos[i]->isShown())
+ {
+ QString s = combos[i]->currentText();
+ if (!s.isEmpty() || i < m_function.minArg())
+ {
+ if (s != "true" && s !="false")
+ s = '"' + s + '"';
+ pars.append(s);
+ }
+ params = true;
+ }
+ }
+ QString a_param = pars.join(", ");
+ if (params)
+ return QString("(%1)").arg(a_param);
+ else
+ return a_param;
+}
+
+
+#include "functionsimpl.moc"
diff --git a/kommander/editor/functionsimpl.h b/kommander/editor/functionsimpl.h
new file mode 100644
index 00000000..fab8661d
--- /dev/null
+++ b/kommander/editor/functionsimpl.h
@@ -0,0 +1,61 @@
+/***************************************************************************
+ functionsimpl.h - Function browser implementation
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_FUNCTIONSIMPL_H_
+#define _HAVE_FUNCTIONSIMPL_H_
+
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qwidget.h>
+#include <qdict.h>
+
+#include "functions.h"
+#include "specialinformation.h"
+
+class FunctionsDialog : public FunctionsDialogBase
+{
+ Q_OBJECT
+public:
+ FunctionsDialog(QWidget*, const QDict<QWidget>&, bool m_useInternalParser, char* = 0, bool = true);
+ ~FunctionsDialog();
+ // Return current content of text box
+ QString functionText() const;
+ // Return current function and parameters
+ QString currentFunctionText();
+public slots:
+ // Update list of function availabe for given group
+ void groupChanged(int);
+ // Update syntax of chosen function
+ void functionChanged(int);
+ // Copy current function and parameters into text box
+ void copyText();
+ // Show widgets for current function's parameters
+ void showParameters();
+private:
+ // Calculate current parameters
+ QString params();
+ SpecialFunction m_function;
+ int m_DCOP;
+ int m_Slots;
+ const QDict<QWidget> m_widgetList;
+ QStringList m_widgetNames;
+ QStringList m_widgetTypes;
+ bool m_useInternalParser;
+ QStringList m_acceptedSlots;
+ QMap<QString, QString> m_slotList;
+};
+
+
+#endif
+
diff --git a/kommander/editor/globaldefs.h b/kommander/editor/globaldefs.h
new file mode 100644
index 00000000..cc6ed400
--- /dev/null
+++ b/kommander/editor/globaldefs.h
@@ -0,0 +1,45 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef GLOBALDEFS_H
+#define GLOBALDEFS_H
+
+#include <qcolor.h>
+
+#define BOXLAYOUT_DEFAULT_MARGIN 11
+#define BOXLAYOUT_DEFAULT_SPACING 6
+
+#ifndef NO_STATIC_COLORS
+static QColor *backColor1 = 0;
+static QColor *backColor2 = 0;
+static QColor *selectedBack = 0;
+
+static void init_colors()
+{
+ if ( backColor1 )
+ return;
+ backColor1 = new QColor( 236, 245, 255 );
+ backColor2 = new QColor( 250, 250, 250 );
+ selectedBack = new QColor( 221, 221, 221 );
+}
+
+#endif
+
+#endif
diff --git a/kommander/editor/hierarchyview.cpp b/kommander/editor/hierarchyview.cpp
new file mode 100644
index 00000000..b3f17713
--- /dev/null
+++ b/kommander/editor/hierarchyview.cpp
@@ -0,0 +1,724 @@
+/**********************************************************************
+** Copyright (C) 2000-2001 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "globaldefs.h"
+#include "hierarchyview.h"
+#include "formwindow.h"
+#include "mainwindow.h"
+#include "command.h"
+#include "widgetfactory.h"
+#include "widgetdatabase.h"
+#include "pixmapchooser.h"
+#include "propertyeditor.h"
+#include "listeditor.h"
+
+#include <qpalette.h>
+#include <qobjectlist.h>
+#include <qheader.h>
+#include <qpopupmenu.h>
+#include <qtabwidget.h>
+#include <qwizard.h>
+#include <qwidgetstack.h>
+#include <qtabbar.h>
+#include <qfeatures.h>
+#include <qapplication.h>
+#include <qtimer.h>
+#include <qworkspace.h>
+#include <qaccel.h>
+
+#include <klocale.h>
+
+#include <stdlib.h>
+
+static const char * const folder_xpm[]={
+ "16 16 6 1",
+ ". c None",
+ "b c #ffff00",
+ "d c #000000",
+ "* c #999999",
+ "a c #cccccc",
+ "c c #ffffff",
+ "................",
+ "................",
+ "..*****.........",
+ ".*ababa*........",
+ "*abababa******..",
+ "*cccccccccccc*d.",
+ "*cbababababab*d.",
+ "*cabababababa*d.",
+ "*cbababababab*d.",
+ "*cabababababa*d.",
+ "*cbababababab*d.",
+ "*cabababababa*d.",
+ "*cbababababab*d.",
+ "**************d.",
+ ".dddddddddddddd.",
+ "................"};
+
+QListViewItem *newItem = 0;
+
+HierarchyItem::HierarchyItem( Type type, QListViewItem *parent,
+ const QString &txt1, const QString &txt2, const QString &txt3 )
+ : QListViewItem( parent, txt1, txt2, txt3 ), typ( type )
+{
+}
+
+HierarchyItem::HierarchyItem( Type type, QListView *parent,
+ const QString &txt1, const QString &txt2, const QString &txt3 )
+ : QListViewItem( parent, txt1, txt2, txt3 ), typ( type )
+{
+}
+
+void HierarchyItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
+{
+ QColorGroup g( cg );
+ g.setColor( QColorGroup::Base, backgroundColor() );
+ g.setColor( QColorGroup::Foreground, Qt::black );
+ g.setColor( QColorGroup::Text, Qt::black );
+ QString txt = text( 0 );
+ if ( rtti() == Slot &&
+ ( txt == "init()" || txt == "destroy()" ) ) {
+ listView()->setUpdatesEnabled( false );
+ if ( txt == "init()" )
+ setText( 0, txt + " " + i18n( "(Constructor)" ) );
+ else
+ setText( 0, txt + " " + i18n( "(Destructor)" ) );
+ QListViewItem::paintCell( p, g, column, width, align );
+ setText( 0, txt );
+ listView()->setUpdatesEnabled( true );
+ } else {
+ QListViewItem::paintCell( p, g, column, width, align );
+ }
+ p->save();
+ p->setPen( QPen( cg.dark(), 1 ) );
+ if ( column == 0 )
+ p->drawLine( 0, 0, 0, height() - 1 );
+ if ( listView()->firstChild() != this ) {
+ if ( nextSibling() != itemBelow() && itemBelow()->depth() < depth() ) {
+ int d = depth() - itemBelow()->depth();
+ p->drawLine( -listView()->treeStepSize() * d, height() - 1, 0, height() - 1 );
+ }
+ }
+ p->drawLine( 0, height() - 1, width, height() - 1 );
+ p->drawLine( width - 1, 0, width - 1, height() );
+ p->restore();
+}
+
+QColor HierarchyItem::backgroundColor()
+{
+ updateBackColor();
+ return backColor;
+}
+
+void HierarchyItem::updateBackColor()
+{
+ if ( listView()->firstChild() == this ) {
+ backColor = *backColor1;
+ return;
+ }
+
+ QListViewItemIterator it( this );
+ --it;
+ if ( it.current() ) {
+ if ( ( ( HierarchyItem*)it.current() )->backColor == *backColor1 )
+ backColor = *backColor2;
+ else
+ backColor = *backColor1;
+ } else {
+ backColor = *backColor1;
+ }
+}
+
+void HierarchyItem::setWidget( QWidget *w )
+{
+ wid = w;
+}
+
+QWidget *HierarchyItem::widget() const
+{
+ return wid;
+}
+
+void HierarchyItem::okRename( int col )
+{
+ if ( newItem == this )
+ newItem = 0;
+ QListViewItem::okRename( col );
+}
+
+void HierarchyItem::cancelRename( int col )
+{
+ if ( newItem == this ) {
+ newItem = 0;
+ QListViewItem::cancelRename( col );
+ delete this;
+ return;
+ }
+ QListViewItem::cancelRename( col );
+}
+
+
+
+
+HierarchyList::HierarchyList( QWidget *parent, FormWindow *fw, bool doConnects )
+ : QListView( parent ), formWindow( fw )
+{
+ init_colors();
+
+ setDefaultRenameAction( Accept );
+ header()->setMovingEnabled( false );
+ header()->setStretchEnabled( true );
+ normalMenu = 0;
+ tabWidgetMenu = 0;
+ addColumn( i18n("Name" ) );
+ addColumn( i18n("Class" ) );
+ QPalette p( palette() );
+ p.setColor( QColorGroup::Base, QColor( *backColor2 ) );
+ (void)*selectedBack; // hack
+ setPalette( p );
+ disconnect( header(), SIGNAL( sectionClicked( int ) ),
+ this, SLOT( changeSortColumn( int ) ) );
+ setSorting( -1 );
+ setHScrollBarMode( AlwaysOff );
+ setVScrollBarMode( AlwaysOn );
+ if ( doConnects ) {
+ connect( this, SIGNAL( clicked( QListViewItem * ) ),
+ this, SLOT( objectClicked( QListViewItem * ) ) );
+ connect( this, SIGNAL( returnPressed( QListViewItem * ) ),
+ this, SLOT( objectClicked( QListViewItem * ) ) );
+ connect( this, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint&, int ) ),
+ this, SLOT( showRMBMenu( QListViewItem *, const QPoint & ) ) );
+ }
+ deselect = true;
+ setColumnWidthMode( 1, Manual );
+}
+
+void HierarchyList::keyPressEvent( QKeyEvent *e )
+{
+ if ( e->key() == Key_Shift || e->key() == Key_Control )
+ deselect = false;
+ else
+ deselect = true;
+ QListView::keyPressEvent( e );
+}
+
+void HierarchyList::keyReleaseEvent( QKeyEvent *e )
+{
+ deselect = true;
+ QListView::keyReleaseEvent( e );
+}
+
+void HierarchyList::viewportMousePressEvent( QMouseEvent *e )
+{
+ if ( e->state() & ShiftButton || e->state() & ControlButton )
+ deselect = false;
+ else
+ deselect = true;
+ QListView::viewportMousePressEvent( e );
+}
+
+void HierarchyList::viewportMouseReleaseEvent( QMouseEvent *e )
+{
+ QListView::viewportMouseReleaseEvent( e );
+}
+
+void HierarchyList::objectClicked( QListViewItem *i )
+{
+ if ( !i )
+ return;
+
+ QWidget *w = findWidget( i );
+ if ( !w )
+ return;
+ if ( formWindow == w ) {
+ if ( deselect )
+ formWindow->clearSelection( false );
+ formWindow->emitShowProperties( formWindow );
+ return;
+ }
+
+ if ( !formWindow->widgets()->find( w ) ) {
+ if ( w->parent() && w->parent()->inherits( "QWidgetStack" ) &&
+ w->parent()->parent() &&
+ ( w->parent()->parent()->inherits( "QTabWidget" ) ||
+ w->parent()->parent()->inherits( "QWizard" ) ) ) {
+ if ( w->parent()->parent()->inherits( "QTabWidget" ) )
+ ( (QTabWidget*)w->parent()->parent() )->showPage( w );
+ else
+ ( (QDesignerWizard*)w->parent()->parent() )->setCurrentPage( ( (QDesignerWizard*)w->parent()->parent() )->pageNum( w ) );
+ w = (QWidget*)w->parent()->parent();
+ formWindow->emitUpdateProperties( formWindow->currentWidget() );
+ } else {
+ return;
+ }
+ }
+
+ if ( deselect )
+ formWindow->clearSelection( false );
+ if ( w->isVisibleTo( formWindow ) )
+ formWindow->selectWidget( w, true );
+}
+
+QWidget *HierarchyList::findWidget( QListViewItem *i )
+{
+ return ( (HierarchyItem*)i )->widget();
+}
+
+QListViewItem *HierarchyList::findItem( QWidget *w )
+{
+ QListViewItemIterator it( this );
+ while ( it.current() ) {
+ if ( ( (HierarchyItem*)it.current() )->widget() == w )
+ return it.current();
+ ++it;
+ }
+ return 0;
+}
+
+QWidget *HierarchyList::current() const
+{
+ if ( currentItem() )
+ return ( (HierarchyItem*)currentItem() )->widget();
+ return 0;
+}
+
+void HierarchyList::changeNameOf( QWidget *w, const QString &name )
+{
+ QListViewItem *item = findItem( w );
+ if ( !item )
+ return;
+ item->setText( 0, name );
+}
+
+
+void HierarchyList::changeDatabaseOf( QWidget *w, const QString & info )
+{
+#ifndef QT_NO_SQL
+ if ( !formWindow->isDatabaseAware() )
+ return;
+ QListViewItem *item = findItem( w );
+ if ( !item )
+ return;
+ item->setText( 2, info );
+#else
+ Q_UNUSED(w);
+ Q_UNUSED(info);
+#endif
+}
+
+void HierarchyList::setup()
+{
+ if ( !formWindow )
+ return;
+ clear();
+ QWidget *w = formWindow->mainContainer();
+#ifndef QT_NO_SQL
+ if ( formWindow->isDatabaseAware() ) {
+ if ( columns() == 2 ) {
+ addColumn( i18n("Database" ) );
+ header()->resizeSection( 0, 1 );
+ header()->resizeSection( 1, 1 );
+ header()->resizeSection( 2, 1 );
+ header()->adjustHeaderSize();
+ }
+ } else {
+ if ( columns() == 3 ) {
+ removeColumn( 2 );
+ }
+ }
+#endif
+ if ( w )
+ insertObject( w, 0 );
+}
+
+void HierarchyList::setOpen( QListViewItem *i, bool b )
+{
+ QListView::setOpen( i, b );
+}
+
+void HierarchyList::insertObject( QObject *o, QListViewItem *parent )
+{
+ bool fakeMainWindow = false;
+ if ( o && o->inherits( "QMainWindow" ) ) {
+ QObject *cw = ( (QMainWindow*)o )->centralWidget();
+ if ( cw ) {
+ o = cw;
+ fakeMainWindow = true;
+ }
+ }
+ QListViewItem *item = 0;
+ QString className = WidgetFactory::classNameOf( o );
+ if ( o->inherits( "QLayoutWidget" ) ) {
+ switch ( WidgetFactory::layoutType( (QWidget*)o ) ) {
+ case WidgetFactory::HBox:
+ className = "HBox";
+ break;
+ case WidgetFactory::VBox:
+ className = "VBox";
+ break;
+ case WidgetFactory::Grid:
+ className = "Grid";
+ break;
+ default:
+ break;
+ }
+ }
+
+ QString dbInfo;
+#ifndef QT_NO_SQL
+ dbInfo = MetaDataBase::fakeProperty( o, "database" ).toStringList().join(".");
+#endif
+
+ QString name = o->name();
+ if ( o->parent() && o->parent()->inherits( "QWidgetStack" ) &&
+ o->parent()->parent() ) {
+ if ( o->parent()->parent()->inherits( "QTabWidget" ) )
+ name = ( (QTabWidget*)o->parent()->parent() )->tabLabel( (QWidget*)o );
+ else if ( o->parent()->parent()->inherits( "QWizard" ) )
+ name = ( (QWizard*)o->parent()->parent() )->title( (QWidget*)o );
+ }
+
+ QToolBox *tb;
+ if ( o->parent() && o->parent()->parent() &&
+ (tb = ::qt_cast<QToolBox*>(o->parent()->parent()->parent())) )
+ name = tb->itemLabel( tb->indexOf((QWidget*)o) );
+
+
+ if ( fakeMainWindow ) {
+ name = o->parent()->name();
+ className = "QMainWindow";
+ }
+
+ if ( !parent )
+ item = new HierarchyItem( HierarchyItem::Widget, this, name, className, dbInfo );
+ else
+ item = new HierarchyItem( HierarchyItem::Widget, parent, name, className, dbInfo );
+ if ( !parent )
+ item->setPixmap( 0, PixmapChooser::loadPixmap( "form.xpm", PixmapChooser::Mini ) );
+ else if ( o->inherits( "QLayoutWidget") )
+ item->setPixmap( 0, PixmapChooser::loadPixmap( "layout.xpm", PixmapChooser::Small ) );
+ else
+ item->setPixmap( 0, WidgetDatabase::iconSet( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( o ) ) ).
+ pixmap( QIconSet::Small, QIconSet::Normal ) );
+ ( (HierarchyItem*)item )->setWidget( (QWidget*)o );
+
+ const QObjectList *l = o->children();
+ if ( !l )
+ return;
+ QObjectListIt it( *l );
+ it.toLast();
+ for ( ; it.current(); --it ) {
+ if ( !it.current()->isWidgetType() || ( (QWidget*)it.current() )->isHidden() )
+ continue;
+ if ( !formWindow->widgets()->find( (QWidget*)it.current() ) ) {
+ if ( it.current()->parent() &&
+ ( it.current()->parent()->inherits( "QTabWidget" ) ||
+ it.current()->parent()->inherits( "QWizard" ) ) &&
+ it.current()->inherits( "QWidgetStack" ) ) {
+ QObject *obj = it.current();
+ QObjectList *l2 = obj->queryList( "QWidget", 0, true, false );
+ QDesignerTabWidget *tw = 0;
+ QDesignerWizard *dw = 0;
+ if ( it.current()->parent()->inherits( "QTabWidget" ) )
+ tw = (QDesignerTabWidget*)it.current()->parent();
+ if ( it.current()->parent()->inherits( "QWizard" ) )
+ dw = (QDesignerWizard*)it.current()->parent();
+ QWidgetStack *stack = (QWidgetStack*)obj;
+ for ( obj = l2->last(); obj; obj = l2->prev() ) {
+ if ( qstrcmp( obj->className(), "QWidgetStackPrivate::Invisible" ) == 0 ||
+ ( tw && !tw->tabBar()->tab( stack->id( (QWidget*)obj ) ) ) ||
+ ( dw && dw->isPageRemoved( (QWidget*)obj ) ) )
+ continue;
+ insertObject( obj, item );
+ }
+ delete l2;
+ } else if ( ::qt_cast<QToolBox*>(it.current()->parent()) ) {
+ if ( !::qt_cast<QScrollView*>(it.current()) )
+ continue;
+ QToolBox *tb = (QToolBox*)it.current()->parent();
+ for ( int i = tb->count() - 1; i >= 0; --i )
+ insertObject( tb->item( i ), item );
+ }
+ continue;
+ }
+ insertObject( it.current(), item );
+ }
+
+ if ( item->firstChild() )
+ item->setOpen( true );
+}
+
+void HierarchyList::setCurrent( QWidget *w )
+{
+ QListViewItemIterator it( this );
+ while ( it.current() ) {
+ if ( ( (HierarchyItem*)it.current() )->widget() == w ) {
+ blockSignals( true );
+ setCurrentItem( it.current() );
+ ensureItemVisible( it.current() );
+ blockSignals( false );
+ return;
+ }
+ ++it;
+ }
+}
+
+void HierarchyList::showRMBMenu( QListViewItem *i, const QPoint & p )
+{
+ if ( !i )
+ return;
+
+
+ QWidget *w = findWidget( i );
+ if ( !w )
+ return;
+
+ if ( w != formWindow &&
+ !formWindow->widgets()->find( w ) )
+ return;
+
+ if ( w->isVisibleTo( formWindow ) ) {
+ if ( !w->inherits( "QTabWidget" ) && !w->inherits( "QWizard" ) ) {
+ if ( !normalMenu )
+ normalMenu = formWindow->mainWindow()->setupNormalHierarchyMenu( this );
+ normalMenu->popup( p );
+ } else {
+ if ( !tabWidgetMenu )
+ tabWidgetMenu =
+ formWindow->mainWindow()->setupTabWidgetHierarchyMenu( this, SLOT( addTabPage() ),
+ SLOT( removeTabPage() ) );
+ tabWidgetMenu->popup( p );
+ }
+ }
+}
+
+void HierarchyList::addTabPage()
+{
+ QWidget *w = current();
+ if ( !w )
+ return;
+ if ( w->inherits( "QTabWidget" ) ) {
+ QTabWidget *tw = (QTabWidget*)w;
+ AddTabPageCommand *cmd = new AddTabPageCommand( i18n("Add Page to %1" ).arg( tw->name() ), formWindow,
+ tw, "Tab" );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ } else if ( w->inherits( "QWizard" ) ) {
+ QWizard *wiz = (QWizard*)formWindow->mainContainer();
+ AddWizardPageCommand *cmd = new AddWizardPageCommand( i18n("Add Page to %1" ).arg( wiz->name() ), formWindow,
+ wiz, "Page" );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ }
+}
+
+void HierarchyList::removeTabPage()
+{
+ QWidget *w = current();
+ if ( !w )
+ return;
+ if ( w->inherits( "QTabWidget" ) ) {
+ QTabWidget *tw = (QTabWidget*)w;
+ if ( tw->currentPage() ) {
+ QDesignerTabWidget *dtw = (QDesignerTabWidget*)tw;
+ DeleteTabPageCommand *cmd = new DeleteTabPageCommand( i18n("Delete Page %1 of %2" ).
+ arg( dtw->pageTitle() ).arg( tw->name() ),
+ formWindow, tw, tw->currentPage() );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ }
+ } else if ( w->inherits( "QWizard" ) ) {
+ QWizard *wiz = (QWizard*)formWindow->mainContainer();
+ if ( wiz->currentPage() ) {
+ QDesignerWizard *dw = (QDesignerWizard*)wiz;
+ DeleteWizardPageCommand *cmd = new DeleteWizardPageCommand( i18n("Delete Page %1 of %2" ).
+ arg( dw->pageTitle() ).arg( wiz->name() ),
+ formWindow, wiz,
+ wiz->indexOf( wiz->currentPage() ), true );
+ formWindow->commandHistory()->addCommand( cmd );
+ cmd->execute();
+ }
+ }
+}
+
+// ------------------------------------------------------------
+
+
+// ------------------------------------------------------------
+static HierarchyItem::Type getChildType( int type )
+{
+ switch ( (HierarchyItem::Type)type ) {
+ case HierarchyItem::Widget:
+ case HierarchyItem::SlotParent:
+ qWarning( "getChildType: Inserting childs dynamically to Widget or SlotParent is not allwowed!" );
+ return (HierarchyItem::Type)type;
+ case HierarchyItem::Public:
+ case HierarchyItem::Protected:
+ case HierarchyItem::Private:
+ case HierarchyItem::Slot:
+ return HierarchyItem::Slot;
+ case HierarchyItem::DefinitionParent:
+ case HierarchyItem::Definition:
+ return HierarchyItem::Definition;
+ case HierarchyItem::Event:
+ case HierarchyItem::EventFunction:
+ return HierarchyItem::Event;
+ }
+ return (HierarchyItem::Type)type;
+}
+
+void HierarchyList::insertEntry( QListViewItem *i, const QPixmap &pix, const QString &s )
+{
+ HierarchyItem *item = new HierarchyItem( getChildType( i->rtti() ), i, s,
+ QString::null, QString::null );
+ if ( !pix.isNull() )
+ item->setPixmap( 0, pix );
+ item->setRenameEnabled( 0, true );
+ setCurrentItem( item );
+ ensureItemVisible( item );
+ qApp->processEvents();
+ newItem = item;
+ item->startRename( 0 );
+}
+
+HierarchyView::HierarchyView( QWidget *parent )
+ : QTabWidget( parent, 0, WStyle_Customize | WStyle_NormalBorder | WStyle_Title |
+ WStyle_Tool |WStyle_MinMax | WStyle_SysMenu )
+{
+ formwindow = 0;
+ setIcon( PixmapChooser::loadPixmap( "logo" ) );
+ listview = new HierarchyList( this, formWindow() );
+ addTab( listview, i18n("Widgets" ) );
+}
+
+HierarchyView::~HierarchyView()
+{
+}
+
+void HierarchyView::clear()
+{
+ listview->clear();
+}
+
+void HierarchyView::setFormWindow( FormWindow *fw, QWidget *w )
+{
+ if (fw == 0 || w == 0)
+ {
+ listview->clear();
+ listview->setFormWindow(fw);
+ formwindow = 0;
+ }
+
+ if (fw == formwindow)
+ {
+ listview->setCurrent(w);
+ if (MainWindow::self->qWorkspace()->activeWindow() == fw)
+ showPage(listview);
+ return;
+ }
+
+ formwindow = fw;
+ listview->setFormWindow(fw);
+ listview->setup();
+ listview->setCurrent(w);
+
+ if (MainWindow::self->qWorkspace()->activeWindow() == fw)
+ showPage(listview);
+}
+
+FormWindow *HierarchyView::formWindow() const
+{
+ return formwindow;
+}
+
+void HierarchyView::closeEvent( QCloseEvent *e )
+{
+ emit hidden();
+ e->accept();
+}
+
+void HierarchyView::widgetInserted( QWidget * )
+{
+ listview->setup();
+}
+
+void HierarchyView::widgetRemoved( QWidget * )
+{
+ listview->setup();
+}
+
+void HierarchyView::widgetsInserted( const QWidgetList & )
+{
+ listview->setup();
+}
+
+void HierarchyView::widgetsRemoved( const QWidgetList & )
+{
+ listview->setup();
+}
+
+void HierarchyView::namePropertyChanged( QWidget *w, const QVariant & )
+{
+ QWidget *w2 = w;
+ if ( w->inherits( "QMainWindow" ) )
+ w2 = ( (QMainWindow*)w )->centralWidget();
+ listview->changeNameOf( w2, w->name() );
+}
+
+
+void HierarchyView::databasePropertyChanged( QWidget *w, const QStringList& info )
+{
+#ifndef QT_NO_SQL
+ QString i = info.join( "." );
+ listview->changeDatabaseOf( w, i );
+#else
+ Q_UNUSED(w);
+ Q_UNUSED(info);
+#endif
+}
+
+
+void HierarchyView::tabsChanged( QTabWidget * )
+{
+ listview->setup();
+}
+
+void HierarchyView::tabsChanged( QToolBox * )
+{
+ listview->setup();
+}
+
+void HierarchyView::pagesChanged( QWizard * )
+{
+ listview->setup();
+}
+
+void HierarchyView::rebuild()
+{
+ listview->setup();
+}
+
+void HierarchyView::closed( FormWindow *fw )
+{
+ if ( fw == formwindow )
+ listview->clear();
+}
+
+#include "hierarchyview.moc"
diff --git a/kommander/editor/hierarchyview.h b/kommander/editor/hierarchyview.h
new file mode 100644
index 00000000..54889ec2
--- /dev/null
+++ b/kommander/editor/hierarchyview.h
@@ -0,0 +1,161 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef HIRARCHYVIEW_H
+#define HIRARCHYVIEW_H
+
+#include <qvariant.h>
+#include <qlistview.h>
+#include <qtabwidget.h>
+#include <qguardedptr.h>
+#include <private/qcom_p.h>
+
+class FormWindow;
+class QCloseEvent;
+class QPopupMenu;
+class QKeyEvent;
+class QMouseEvent;
+class QWizard;
+class QToolBox;
+
+class HierarchyItem:public QListViewItem
+{
+public:
+ enum Type
+ {
+ Widget,
+ SlotParent,
+ Public,
+ Protected,
+ Private,
+ Slot,
+ DefinitionParent,
+ Definition,
+ Event,
+ EventFunction
+ };
+
+ HierarchyItem(Type type, QListViewItem * parent,
+ const QString & txt1, const QString & txt2, const QString & txt3);
+ HierarchyItem(Type type, QListView * parent,
+ const QString & txt1, const QString & txt2, const QString & txt3);
+
+ void paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align);
+ void updateBackColor();
+
+ void setWidget(QWidget * w);
+ QWidget *widget() const;
+
+ void setText(int col, const QString & txt) {if (!txt.isEmpty()) QListViewItem::setText(col, txt);}
+ int rtti() const { return (int) typ;}
+
+private:
+ void okRename(int col);
+ void cancelRename(int col);
+
+private:
+ QColor backgroundColor();
+ QColor backColor;
+ QWidget *wid;
+ Type typ;
+};
+
+class HierarchyList:public QListView
+{
+ Q_OBJECT
+public:
+ HierarchyList(QWidget * parent, FormWindow * fw, bool doConnects = TRUE);
+
+ virtual void setup();
+ virtual void setCurrent(QWidget * w);
+ void setOpen(QListViewItem * i, bool b);
+ void changeNameOf(QWidget * w, const QString & name);
+ void changeDatabaseOf(QWidget * w, const QString & info);
+ void setFormWindow(FormWindow * fw) {formWindow = fw;}
+ void drawContentsOffset(QPainter * p, int ox, int oy, int cx, int cy, int cw, int ch)
+ { setUpdatesEnabled(FALSE); triggerUpdate(); setUpdatesEnabled(TRUE);
+ QListView::drawContentsOffset(p, ox, oy, cx, cy, cw, ch); }
+ void insertEntry(QListViewItem * i, const QPixmap & pix = QPixmap(), const QString & s =
+ QString::null);
+
+protected:
+ void keyPressEvent(QKeyEvent * e);
+ void keyReleaseEvent(QKeyEvent * e);
+ void viewportMousePressEvent(QMouseEvent * e);
+ void viewportMouseReleaseEvent(QMouseEvent * e);
+
+public slots:
+ void addTabPage();
+ void removeTabPage();
+
+private:
+ void insertObject(QObject * o, QListViewItem * parent);
+ QWidget *findWidget(QListViewItem * i);
+ QListViewItem *findItem(QWidget * w);
+ QWidget *current() const;
+
+ private slots: virtual void objectClicked(QListViewItem * i);
+ virtual void showRMBMenu(QListViewItem *, const QPoint &);
+
+protected:
+ FormWindow * formWindow;
+ QPopupMenu *normalMenu, *tabWidgetMenu;
+ bool deselect;
+};
+
+class HierarchyView : public QTabWidget
+{
+ Q_OBJECT
+
+public:
+ HierarchyView( QWidget *parent );
+ ~HierarchyView();
+
+ void setFormWindow( FormWindow *fw, QWidget *w );
+ FormWindow *formWindow() const;
+ void clear();
+ void widgetInserted( QWidget *w );
+ void widgetRemoved( QWidget *w );
+ void widgetsInserted( const QWidgetList &l );
+ void widgetsRemoved( const QWidgetList &l );
+ void namePropertyChanged( QWidget *w, const QVariant &old );
+ void databasePropertyChanged( QWidget *w, const QStringList& info );
+ void tabsChanged( QTabWidget *w );
+ void tabsChanged( QToolBox *w );
+ void pagesChanged( QWizard *w );
+ void rebuild();
+ void closed( FormWindow *fw );
+
+protected slots:
+
+protected:
+ void closeEvent( QCloseEvent *e );
+
+signals:
+ void hidden();
+
+private:
+ FormWindow *formwindow;
+ HierarchyList *listview;
+
+};
+
+
+#endif
diff --git a/kommander/editor/iconvieweditor.ui b/kommander/editor/iconvieweditor.ui
new file mode 100644
index 00000000..afa18459
--- /dev/null
+++ b/kommander/editor/iconvieweditor.ui
@@ -0,0 +1,450 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>IconViewEditorBase</class>
+<comment>*********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+*********************************************************************</comment>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>IconViewEditorBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>567</width>
+ <height>321</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Edit Iconview</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;b&gt;Edit Iconview&lt;/b&gt;&lt;p&gt;Add, edit or delete items in the icon view.&lt;/p&gt;&lt;p&gt;Click the &lt;b&gt;New Item&lt;/b&gt;-button to create a new item, then enter text and choose a pixmap.&lt;/p&gt;&lt;p&gt;Select an item from the view and click the &lt;b&gt;Delete Item&lt;/b&gt;-button to remove the item from the iconview.&lt;/p&gt;</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QIconView">
+ <property name="name">
+ <cstring>preview</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>All items in the iconview.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout5</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>itemNew</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;New Item</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Add an item</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Create a new item for the iconview.</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>itemDelete</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Delete Item</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Delete item</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Delete the selected item.</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Vertical Spacing1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>GroupBox1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>&amp;Item Properties</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>Label1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Text:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>itemText</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>itemText</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Change text</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Change the text for the selected item.</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>Label2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Pixmap:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>itemChoosePixmap</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>itemPixmap</cstring>
+ </property>
+ <property name="text">
+ <string>Label4</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>itemDeletePixmap</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image0</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Delete Pixmap</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Delete the selected item's pixmap.</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>itemChoosePixmap</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Select a Pixmap</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Select a pixmap file for the current item.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonHelp</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Help</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Horizontal Spacing2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Close the dialog and apply all the changes.</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonApply</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Apply</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Apply all changes.</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Close the dialog and discard any changes.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<images>
+ <image name="image0">
+ <data format="XPM.GZ" length="409">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022630543251d2e253d856405bffcbc54105b19c856360003103711c6b53006ab440370316528264b4c198450c5808a94d1ed00aac214832b43124b544ec414d34b4c4c441103f11341120831309758313d0cf3b0840b7258d55a73010092c14eca</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>itemNew</sender>
+ <signal>clicked()</signal>
+ <receiver>IconViewEditorBase</receiver>
+ <slot>insertNewItem()</slot>
+ </connection>
+ <connection>
+ <sender>itemDelete</sender>
+ <signal>clicked()</signal>
+ <receiver>IconViewEditorBase</receiver>
+ <slot>deleteCurrentItem()</slot>
+ </connection>
+ <connection>
+ <sender>itemText</sender>
+ <signal>textChanged( const QString &amp; )</signal>
+ <receiver>IconViewEditorBase</receiver>
+ <slot>currentTextChanged(const QString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>IconViewEditorBase</receiver>
+ <slot>okClicked()</slot>
+ </connection>
+ <connection>
+ <sender>buttonApply</sender>
+ <signal>clicked()</signal>
+ <receiver>IconViewEditorBase</receiver>
+ <slot>applyClicked()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>IconViewEditorBase</receiver>
+ <slot>cancelClicked()</slot>
+ </connection>
+ <connection>
+ <sender>itemChoosePixmap</sender>
+ <signal>clicked()</signal>
+ <receiver>IconViewEditorBase</receiver>
+ <slot>choosePixmap()</slot>
+ </connection>
+ <connection>
+ <sender>preview</sender>
+ <signal>selectionChanged(QIconViewItem*)</signal>
+ <receiver>IconViewEditorBase</receiver>
+ <slot>currentItemChanged(QIconViewItem*)</slot>
+ </connection>
+ <connection>
+ <sender>preview</sender>
+ <signal>currentChanged(QIconViewItem*)</signal>
+ <receiver>IconViewEditorBase</receiver>
+ <slot>currentItemChanged(QIconViewItem*)</slot>
+ </connection>
+ <connection>
+ <sender>itemDeletePixmap</sender>
+ <signal>clicked()</signal>
+ <receiver>IconViewEditorBase</receiver>
+ <slot>deletePixmap()</slot>
+ </connection>
+ <slot access="protected" language="C++" returnType="void">init()</slot>
+ <slot access="protected" language="C++" returnType="void">destroy()</slot>
+ <slot access="protected" language="C++" returnType="void">applyClicked()</slot>
+ <slot access="protected" language="C++" returnType="void">cancelClicked()</slot>
+ <slot access="protected" language="C++" returnType="void">choosePixmap()</slot>
+ <slot access="protected" language="C++" returnType="void">currentItemChanged( QIconViewItem * )</slot>
+ <slot access="protected" language="C++" returnType="void">currentTextChanged( const QString &amp; )</slot>
+ <slot access="protected" language="C++" returnType="void">deleteCurrentItem()</slot>
+ <slot access="protected" language="C++" returnType="void">insertNewItem()</slot>
+ <slot access="protected" language="C++" returnType="void">deletePixmap()</slot>
+ <slot access="protected" language="C++" returnType="void">okClicked()</slot>
+</connections>
+<tabstops>
+ <tabstop>buttonOk</tabstop>
+ <tabstop>buttonCancel</tabstop>
+ <tabstop>preview</tabstop>
+ <tabstop>itemNew</tabstop>
+ <tabstop>itemDelete</tabstop>
+ <tabstop>itemText</tabstop>
+ <tabstop>itemDeletePixmap</tabstop>
+ <tabstop>itemChoosePixmap</tabstop>
+ <tabstop>buttonHelp</tabstop>
+ <tabstop>buttonApply</tabstop>
+</tabstops>
+</UI>
diff --git a/kommander/editor/iconvieweditorimpl.cpp b/kommander/editor/iconvieweditorimpl.cpp
new file mode 100644
index 00000000..f7552cee
--- /dev/null
+++ b/kommander/editor/iconvieweditorimpl.cpp
@@ -0,0 +1,158 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "iconvieweditorimpl.h"
+#include "formwindow.h"
+#include "mainwindow.h"
+#include "pixmapchooser.h"
+
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qiconview.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+
+#include <klocale.h>
+
+IconViewEditor::IconViewEditor( QWidget *parent, QWidget *editWidget, FormWindow *fw )
+ : IconViewEditorBase( parent, 0, true ), formwindow( fw )
+{
+ connect( buttonHelp, SIGNAL( clicked() ), MainWindow::self, SLOT( showDialogHelp() ) );
+ iconview = (QIconView*)editWidget;
+
+ itemText->setText( "" );
+ itemText->setEnabled( false );
+ itemPixmap->setText( "" );
+ itemChoosePixmap->setEnabled( false );
+ itemDeletePixmap->setEnabled( false );
+
+ QIconViewItem *i = 0;
+ for ( i = iconview->firstItem(); i; i = i->nextItem() ) {
+ (void)new QIconViewItem( preview, i->text(), *i->pixmap() );
+ }
+
+ if ( preview->firstItem() )
+ preview->setCurrentItem( preview->firstItem() );
+}
+
+void IconViewEditor::insertNewItem()
+{
+ QIconViewItem *i = new QIconViewItem( preview, i18n("New Item" ) );
+ preview->setCurrentItem( i );
+ preview->setSelected( i, true );
+}
+
+void IconViewEditor::deleteCurrentItem()
+{
+ delete preview->currentItem();
+ if ( preview->currentItem() )
+ preview->setSelected( preview->currentItem(), true );
+}
+
+void IconViewEditor::currentItemChanged( QIconViewItem *i )
+{
+ itemText->blockSignals( true );
+ itemText->setText( "" );
+ itemPixmap->setText( "" );
+ itemText->blockSignals( false );
+
+ if ( !i ) {
+ itemText->setEnabled( false );
+ itemChoosePixmap->setEnabled( false );
+ return;
+ }
+
+ itemText->blockSignals( true );
+ itemText->setEnabled( true );
+ itemChoosePixmap->setEnabled( true );
+ itemDeletePixmap->setEnabled( i->pixmap() && !i->pixmap()->isNull() );
+
+ itemText->setText( i->text() );
+ if ( i->pixmap() )
+ itemPixmap->setPixmap( *i->pixmap() );
+ itemText->blockSignals( false );
+}
+
+void IconViewEditor::currentTextChanged( const QString &txt )
+{
+ if ( !preview->currentItem() )
+ return;
+
+ preview->currentItem()->setText( txt );
+}
+
+void IconViewEditor::okClicked()
+{
+ applyClicked();
+ accept();
+}
+
+void IconViewEditor::cancelClicked()
+{
+ reject();
+}
+
+void IconViewEditor::applyClicked()
+{
+ QIconViewItem *i = 0;
+ QValueList<PopulateIconViewCommand::Item> items;
+ for ( i = preview->firstItem(); i; i = i->nextItem() ) {
+ PopulateIconViewCommand::Item item;
+ if ( i->pixmap() )
+ item.pix = *i->pixmap();
+ item.text = i->text();
+ items.append( item );
+ }
+
+ PopulateIconViewCommand *cmd = new PopulateIconViewCommand( i18n("Edit Items of '%1'" ).arg( iconview->name() ),
+ formwindow, iconview, items );
+ cmd->execute();
+ formwindow->commandHistory()->addCommand( cmd );
+}
+
+void IconViewEditor::choosePixmap()
+{
+ if ( !preview->currentItem() )
+ return;
+
+ QPixmap pix;
+ if ( preview->currentItem()->pixmap() )
+ pix = qChoosePixmap( this, formwindow, *preview->currentItem()->pixmap() );
+ else
+ pix = qChoosePixmap( this, formwindow, QPixmap() );
+
+ if ( pix.isNull() )
+ return;
+
+ preview->currentItem()->setPixmap( pix );
+ itemPixmap->setPixmap( pix );
+ itemDeletePixmap->setEnabled( true );
+}
+
+void IconViewEditor::deletePixmap()
+{
+ if ( !preview->currentItem() )
+ return;
+
+ preview->currentItem()->setPixmap( QPixmap() );
+ itemPixmap->setText( "" );
+ itemDeletePixmap->setEnabled( false );
+}
+#include "iconvieweditorimpl.moc"
diff --git a/kommander/editor/iconvieweditorimpl.h b/kommander/editor/iconvieweditorimpl.h
new file mode 100644
index 00000000..120f0bb6
--- /dev/null
+++ b/kommander/editor/iconvieweditorimpl.h
@@ -0,0 +1,52 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Designer.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef ICONVIEWEDITOR_H
+#define ICONVIEWEDITOR_H
+
+#include "iconvieweditor.h"
+
+class FormWindow;
+
+class IconViewEditor : public IconViewEditorBase
+{
+ Q_OBJECT
+
+public:
+ IconViewEditor( QWidget *parent, QWidget *editWidget, FormWindow *fw );
+
+protected slots:
+ void insertNewItem();
+ void deleteCurrentItem();
+ void currentItemChanged( QIconViewItem * );
+ void currentTextChanged( const QString & );
+ void okClicked();
+ void cancelClicked();
+ void applyClicked();
+ void choosePixmap();
+ void deletePixmap();
+
+private:
+ QIconView *iconview;
+ FormWindow *formwindow;
+
+};
+
+#endif
diff --git a/kommander/editor/kmdr-editor.desktop b/kommander/editor/kmdr-editor.desktop
new file mode 100644
index 00000000..cdef1c5c
--- /dev/null
+++ b/kommander/editor/kmdr-editor.desktop
@@ -0,0 +1,129 @@
+[Desktop Entry]
+GenericName=Dynamic Dialog Editor
+GenericName[bg]=Редактор за диалогови прозорци
+GenericName[ca]=Editor de diàlegs dinàmics
+GenericName[cs]=Editor dynamických dialogů
+GenericName[da]=Dynamisk dialog-editor
+GenericName[de]=Editor für dynamische Dialoge
+GenericName[el]=Επεξεργαστής δυναμικών διαλόγων
+GenericName[en_GB]=Dynamic Dialogue Editor
+GenericName[es]=Editor de cuadros de diálogo dinámicos
+GenericName[et]=Dünaamiliste dialoogide redaktor
+GenericName[eu]=Elkarrizketa editore dinamikoa
+GenericName[fa]=ویرایشگر محاورۀ پویا
+GenericName[fi]=Dynaamisten dialogien editori
+GenericName[fr]=Éditeur dynamique de boîtes de dialogue
+GenericName[gl]=Editor de diálogos dinámicos
+GenericName[hi]=गतिशील संवाद संपादक
+GenericName[hu]=Párbeszédablak-szerkesztő
+GenericName[is]=Dynamic Dialog ritillinn
+GenericName[it]=Editor per le maschere dinamiche
+GenericName[ja]=動的ダイアログエディタ
+GenericName[ka]=დინამიურ დიალოგთა რედაქტორი
+GenericName[lt]=Dinaminė dialogų rengyklė
+GenericName[ms]=Penyunting Dialog Dinamik
+GenericName[nds]=Editor för dünaamsch Dialogen
+GenericName[ne]=गतिशील संवाद सम्पादक
+GenericName[nl]=Dynamische dialoog-editor
+GenericName[pl]=Edytor do dynamicznych okien dialogowych
+GenericName[pt]=Editor de Diálogos Dinâmicos
+GenericName[pt_BR]=Editor de Diálogo Dinâmico
+GenericName[ru]=Редактор диалогов
+GenericName[sk]=Dynamický editor dialógov
+GenericName[sl]=Urejevalnik dinamičnih pogovornih oken
+GenericName[sr]=Уређивач динамичких дијалога
+GenericName[sr@Latn]=Uređivač dinamičkih dijaloga
+GenericName[sv]=Editor för dynamiska dialogrutor
+GenericName[ta]=நிகழும் உரையாடல் திருத்தி
+GenericName[tg]=Муҳаррири диалоги динамика
+GenericName[tr]=Dinamik Diyalog Düzenleyicisi
+GenericName[uk]=Динамічний редактор вікон
+GenericName[zh_CN]=动态对话框编辑器
+GenericName[zh_HK]=動態對話盒編輯器
+GenericName[zh_TW]=動態對話盒編輯器
+Name=Kommander Editor
+Name[br]=Aozer Kommander
+Name[ca]=Editor Kommander
+Name[cs]=Editor Kommanderu
+Name[da]=Kommander-editor
+Name[de]=Kommander-Editor
+Name[el]=Επεξεργαστής Kommander
+Name[et]=Redaktor Kommander
+Name[eu]=Kommander editorea
+Name[fa]=ویرایشگر Kommander
+Name[fi]=Komentoeditori
+Name[fr]=Éditeur Kommander
+Name[ga]=Eagarthóir Kommander
+Name[hi]=कमांडर संपादक
+Name[hu]=Kommander
+Name[is]=Kommander ritillinn
+Name[it]=Editor Kommander
+Name[ja]=Kommander エディタ
+Name[lt]=Kommander rengyklė
+Name[ms]=Penyunting Kommander
+Name[nds]=Kommander-Editor
+Name[ne]=आदेश सम्पादक
+Name[pa]=Kommander ਸੰਪਾਦਕ
+Name[pl]=Edytor Kommander
+Name[pt]=Editor do Kommander
+Name[pt_BR]=Editor Kommander
+Name[ru]=Редактор Kommander
+Name[sl]=Urejevalnik Kommander
+Name[sr]=Kommander уређивач
+Name[sr@Latn]=Kommander uređivač
+Name[sv]=Kommander editor
+Name[ta]=Kகட்டளைத் திருத்தி
+Name[tg]=Муҳаррири Kommander
+Name[tr]=Kommander Düzenleyici
+Name[uk]=Редактор Kommander
+Name[zh_CN]=Kommander 编辑器
+Name[zh_HK]=Kommander 編輯器
+Name[zh_TW]=Kommander 編輯器
+Exec=kmdr-editor %F
+Icon=kommander
+Type=Application
+Comment=Dynamic Dialog Editor
+Comment[bg]=Редактор за диалогови прозорци
+Comment[ca]=Editor de diàlegs dinàmics
+Comment[cs]=Editor dynamických dialogů
+Comment[da]=Dynamisk dialog-editor
+Comment[de]=Editor für dynamische Dialoge
+Comment[el]=Επεξεργαστής δυναμικών διαλόγων
+Comment[en_GB]=Dynamic Dialogue Editor
+Comment[es]=Editor de cuadros de diálogo dinámicos
+Comment[et]=Dünaamiliste dialoogide redaktor
+Comment[eu]=Elkarrizketa editore dinamikoa
+Comment[fa]=ویرایشگر محاورۀ پویا
+Comment[fi]=Dynaamisten dialogien editori
+Comment[fr]=Éditeur dynamique de boîtes de dialogue
+Comment[gl]=Editor de diálogos dinámicos
+Comment[hi]=गतिशील संवाद संपादक
+Comment[hu]=Párbeszédablak-szerkesztő
+Comment[is]=Dynamic Dialog ritillinn
+Comment[it]=Editor per le maschere dinamiche
+Comment[ja]=動的ダイアログエディタ
+Comment[ka]=დინამიურ დიალოგთა რედაქტორი
+Comment[lt]=Dinaminė dialogų rengyklė
+Comment[ms]=Penyunting Dialog Dinamik
+Comment[nds]=Editor för dünaamsch Dialogen
+Comment[ne]=गतिशील संवाद सम्पादक
+Comment[nl]=Dynamische dialoog-editor
+Comment[pl]=Edytor do dynamicznych okien dialogowych
+Comment[pt]=Editor de diálogos dinâmicos
+Comment[pt_BR]=Editor de Diálogo Dinâmico
+Comment[ru]=Динамический редактор диалогов
+Comment[sk]=Dynamický editor dialógov
+Comment[sl]=Urejevalnik dinamičnih pogovornih oken
+Comment[sr]=Уређивач динамичких дијалога
+Comment[sr@Latn]=Uređivač dinamičkih dijaloga
+Comment[sv]=Editor för dynamiska dialogrutor
+Comment[ta]=நிகழும் உரையாடல் திருத்தி
+Comment[tg]=Муҳаррири диалоги динамика
+Comment[tr]=Dinamik Diyalog Düzenleyicisi
+Comment[uk]=Динамічний редактор вікон
+Comment[zh_CN]=动态对话框编辑器
+Comment[zh_HK]=動態對話盒編輯器
+Comment[zh_TW]=動態對話盒編輯器
+MimeType=application/x-kommander;
+DocPath=kommander/index.html
+Categories=Qt;KDE;Development;
diff --git a/kommander/editor/kommander-new.xml b/kommander/editor/kommander-new.xml
new file mode 100644
index 00000000..deb3d88a
--- /dev/null
+++ b/kommander/editor/kommander-new.xml
@@ -0,0 +1,587 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE language SYSTEM "language.dtd"
+[
+ <!ENTITY funcname "[A-Za-z_:][A-Za-z0-9_:#&#37;@-]*">
+ <!ENTITY varname "[A-Za-z_][A-Za-z0-9_]*">
+ <!ENTITY word "[^|&amp;;()&lt;&gt;\s]+"> <!-- see man bash -->
+ <!ENTITY eos "(?=($|\s))"> <!-- eol or space following -->
+ <!ENTITY noword "(?![\w$+-])"> <!-- no word, $, + or - following -->
+]>
+<language name="Kommander (new parser)" version="1.0" kateversion="2.4" section="Scripts" extensions="*.kmdr" mimetype="application/x-shellscript" casesensitive="1" author="Wilbert Berendsen (wilbert@kde.nl), Andras Mantia (amantia@kde.org)" license="LGPL">
+
+<!-- (c) 2004 by Wilbert Berendsen, wilbert@kde.nl
+ Released under the LGPL, part of kdelibs/kate
+
+ Added Kommander specific highlighting.
+ (c) 2006 Andras Mantia, amantia@kde.org
+-->
+
+ <highlighting>
+
+ <list name="kmdrdcopfunctions">
+ <item>addUniqueItem</item>
+ <item>associatedText</item>
+ <item>cancel</item>
+ <item>cellText</item>
+ <item>clear</item>
+ <item>checked</item>
+ <item>children</item>
+ <item>columnCount</item>
+ <item>count</item>
+ <item>currentColumn</item>
+ <item>currentItem</item>
+ <item>currentRow</item>
+ <item>execute</item>
+ <item>findItem</item>
+ <item>geometry</item>
+ <item>global</item>
+ <item>hasFocus</item>
+ <item>insertColumn</item>
+ <item>insertItem</item>
+ <item>insertItems</item>
+ <item>insertRow</item>
+ <item>item</item>
+ <item>itemDepth</item>
+ <item>itemPath</item>
+ <item>removeColumn</item>
+ <item>removeItem</item>
+ <item>removeRow</item>
+ <item>rowCount</item>
+ <item>selection</item>
+ <item>setAssociatedText</item>
+ <item>setChecked</item>
+ <item>setCellText</item>
+ <item>setCurrentItem</item>
+ <item>setColumnCaption</item>
+ <item>setEnabled</item>
+ <item>setGlobal</item>
+ <item>setMaximum</item>
+ <item>setPixmap</item>
+ <item>setRowCaption</item>
+ <item>setSelection</item>
+ <item>setText</item>
+ <item>setVisible</item>
+ <item>text</item>
+ <item>type</item>
+ <item>setCellWidget</item>
+ <item>cellWidget</item>
+ <item>setEditable</item>
+ <item>type</item>
+ <item>insertTab</item>
+ </list>
+
+ <list name="kmdrfunctions">
+ <item>widgetText</item>
+ <item>selectedWidgetText</item>
+ <item>null</item>
+ <item>pid</item>
+ <item>dcopid</item>
+ <item>parentPid</item>
+ <item>debug</item>
+ <item>echo</item>
+ <item>env</item>
+ <item>exec</item>
+ <item>execBackground</item>
+ <item>global</item>
+ <item>i18n</item>
+ <item>dialog</item>
+ <item>readSetting</item>
+ <item>setGlobal</item>
+ <item>writeSetting</item>
+ <item>dcop</item>
+ <item>forBlock</item>
+ <item>forEachBlock</item>
+ <item>ifBlock</item>
+ <item>comment</item>
+ <item>createWidget</item>
+ <item>connect</item>
+ <item>disconnect</item>
+ <item>return</item>
+ <item>internalDcop</item>
+ <item>executeSlot</item>
+ <item>widgetExists</item>
+ </list>
+
+ <list name="kmdrarray">
+ <item>array_values</item>
+ <item>array_keys</item>
+ <item>array_clear</item>
+ <item>array_count</item>
+ <item>array_value</item>
+ <item>array_remove</item>
+ <item>array_setValue</item>
+ <item>array_fromString</item>
+ <item>array_toString</item>
+ <item>array_indexedFromString</item>
+ <item>array_indexedRemoveElements</item>
+ <item>array_indexedInsertElements</item>
+ <item>array_indexedToString</item>
+ <item>array_flipCopy</item>
+ </list>
+
+ <list name="kmdrmatrix">
+ <item>matrix_fromString</item>
+ <item>matrix_toString</item>
+ <item>matrix_clear</item>
+ <item>matrix_rows</item>
+ <item>matrix_columnToArray</item>
+ <item>matrix_columnToIndexedArray</item>
+ <item>matrix_rowToArray</item>
+ <item>matrix_columns</item>
+ <item>matrix_rowKeys</item>
+ <item>matrix_columnKeys</item>
+ <item>matrix_removeRow</item>
+ <item>matrix_removeColumn</item>
+ <item>matrix_addRow</item>
+ <item>matrix_findRow</item>
+ <!--<item>matrix_addColumn</item>
+ <item>matrix_indexedCopy</item>-->
+ </list>
+
+ <list name="kmdrstring">
+ <item>str_length</item>
+ <item>str_contains</item>
+ <item>str_find</item>
+ <item>str_findRev</item>
+ <item>str_left</item>
+ <item>str_right</item>
+ <item>str_mid</item>
+ <item>str_remove</item>
+ <item>str_replace</item>
+ <item>str_upper</item>
+ <item>str_lower</item>
+ <item>str_compare</item>
+ <item>str_isEmpty</item>
+ <item>str_isNumber</item>
+ <item>str_section</item>
+ <item>str_args</item>
+ <item>str_toint</item>
+ <item>str_todouble</item>
+ <item>str_round</item>
+ <item>str_sort</item>
+ <item>str_trim</item>
+ <item>str_padLeft</item>
+ <item>str_padRight</item>
+ <item>str_count</item>
+ </list>
+
+ <list name="kmdrfile">
+ <item>file_read</item>
+ <item>file_write</item>
+ <item>file_append</item>
+ <item>file_exists</item>
+ </list>
+
+ <list name="kmdrinput">
+ <item>input_color</item>
+ <item>input_text</item>
+ <item>input_password</item>
+ <item>input_value</item>
+ <item>input_double</item>
+ <item>input_valueDouble</item>
+ <item>input_openfile</item>
+ <item>input_openfiles</item>
+ <item>input_savefile</item>
+ <item>input_directory</item>
+ </list>
+
+ <list name="kmdrmessage">
+ <item>message_info</item>
+ <item>message_error</item>
+ <item>message_question</item>
+ <item>message_warning</item>
+ </list>
+
+
+ <list name="keywords">
+ <item> else </item>
+ <item> for </item>
+ <item> to </item>
+ <item> function </item>
+ <item> in </item>
+ <item> select </item>
+ <item> while </item>
+ <item> . </item>
+ <item> elseif </item>
+ <item> then </item>
+ <item> set </item>
+ <item> foreach </item>
+ <item> end </item>
+ <item> endif </item>
+ <item> do </item>
+ <item> break </item>
+ <item> continue </item>
+ <item> exit </item>
+ <item> switch </item>
+ <item> and </item>
+ <item> or </item>
+ <item> not </item>
+ <item> step </item>
+ <item> with </item>
+ </list>
+
+ <list name="booleans">
+ <item>true</item>
+ <item>false</item>
+ </list>
+
+ <contexts>
+ <context attribute="Normal Text" lineEndContext="#stay" name="Start">
+ <IncludeRules context="FindAll" />
+ </context>
+
+<!-- ====== The following rulessets are meant to be included ======== -->
+ <!-- FindAll tries to interpret everything -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="FindAll">
+ <IncludeRules context="FindComments" />
+ <IncludeRules context="FindBlockComments" />
+ <IncludeRules context="FindCommands" />
+ <IncludeRules context="FindStrings" />
+ <IncludeRules context="FindSubstitutions" />
+ <IncludeRules context="FindOthers" />
+ </context>
+
+ <!-- FindComments consumes shell comments till EOL -->
+ <context attribute="Normal Text" lineEndContext="#pop" name="FindComments">
+ <Detect2Chars attribute="Comment" context="Comment" char="/" char1="/" firstNonSpace="true"/>
+ <RegExpr attribute="Normal Text" context="Comment" String="[\s;](?=/)" />
+ </context>
+ <!-- FindBlockComments consumes comments to end of block -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="FindBlockComments">
+ <Detect2Chars attribute="Comment" context="twolinecomment" char="/" char1="&#42;" beginRegion="Comment" />
+ </context>
+ <context name="twolinecomment" attribute="Comment" lineEndContext="#stay">
+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment" />
+ </context>
+
+ <context attribute="Comment" lineEndContext="#pop" name="Comment">
+ <IncludeRules context="##Alerts" />
+ </context>
+
+ <!-- FindCommands matches many items that can be expected outside strings, substitutions etc. -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="FindCommands">
+ <!-- start expression in double parentheses -->
+ <Detect2Chars attribute="Keyword" context="ExprDblParen" char="(" char1="(" beginRegion="expression" />
+ <!-- start expression in double brackets -->
+ <RegExpr attribute="Keyword" context="ExprDblBracket" String="\[\[&eos;" beginRegion="expression" column="0"/>
+ <RegExpr attribute="Keyword" context="ExprDblBracket" String="\s\[\[&eos;" beginRegion="expression" />
+ <!-- start expression in single brackets -->
+ <RegExpr attribute="Builtin" context="ExprBracket" String="\[&eos;" beginRegion="expression" column="0"/>
+ <RegExpr attribute="Builtin" context="ExprBracket" String="\s\[&eos;" beginRegion="expression" />
+ <!-- start a group command with { -->
+ <RegExpr attribute="Keyword" context="Group" String="\{&eos;" beginRegion="group" />
+ <!-- match do and if blocks -->
+ <RegExpr attribute="Keyword" context="#stay" String="\bfor&noword;" beginRegion="for" />
+ <RegExpr attribute="Keyword" context="#stay" String="\bforeach&noword;" beginRegion="for" />
+ <RegExpr attribute="Keyword" context="#stay" String="\bwhile&noword;" beginRegion="for" />
+ <RegExpr attribute="Keyword" context="#stay" String="\bend&noword;" endRegion="for" />
+ <RegExpr attribute="Keyword" context="#stay" String="\bif&noword;" beginRegion="if" />
+ <RegExpr attribute="Keyword" context="#stay" String="\belseif&noword;" beginRegion="if" endRegion="if"/>
+ <RegExpr attribute="Keyword" context="#stay" String="\belse&noword;" beginRegion="if" endRegion="if"/>
+ <RegExpr attribute="Keyword" context="#stay" String="\bendif&noword;" endRegion="if"/>
+ <RegExpr attribute="Keyword" context="#stay" String="\}&eos;" endRegion="group"/>
+ <!-- handle case as a special case -->
+ <RegExpr attribute="Keyword" context="Case" String="\bcase&noword;" beginRegion="case" />
+ <!-- handle command line options -->
+ <RegExpr attribute="Option" context="#stay" String="-[A-Za-z0-9]+" />
+ <RegExpr attribute="Option" context="#stay" String="--[a-z][A-Za-z0-9_-]*" />
+ <!-- handle keywords -->
+ <keyword attribute="Keyword" context="#stay" String="keywords" />
+ <keyword attribute="Builtin" context="#stay" String="booleans" />
+ <!-- handle here-string -->
+ <StringDetect attribute="Redirection" context="#stay" String="&lt;&lt;&lt;" />
+ <!-- handle &, &&, | and || -->
+ <RegExpr attribute="Control" context="#stay" String="([|&amp;])\1?" />
+ <!-- Kommander rules -->
+ <RegExpr attribute="KmdrMethod" context="DetectKmdr" String="\b&varname;[\.|\[]" lookAhead="true"/>
+ <RegExpr attribute="KmdrMethod" context="DetectKmdrMethod" String="kmdrfunctions\(" />
+ <keyword attribute="DCOPMethod" context="#stay" String="kmdrfunctions" />
+ <keyword attribute="KmdrArray" context="#stay" String="kmdrarray" />
+ <keyword attribute="KmdrMatrix" context="#stay" String="kmdrmatrix" />
+ <keyword attribute="KmdrString" context="#stay" String="kmdrstring" />
+ <keyword attribute="KmdrFile" context="#stay" String="kmdrfile" />
+ <keyword attribute="KmdrInput" context="#stay" String="kmdrinput" />
+ <keyword attribute="KmdrMessage" context="#stay" String="kmdrmessage" />
+ <!-- handle variable assignments -->
+ <RegExpr attribute="GlobalVariable" context="#stay" String="\b_&varname;" />
+ <RegExpr attribute="Variable" context="#stay" String="\b&varname;" />
+ </context>
+
+ <!-- Kommander rules -->
+
+ <context attribute="KmdrVariable" lineEndContext="FindAll" name="DetectKmdr">
+ <RegExpr attribute="KmdrMethod" context="#stay" String="&varname;" />
+ <DetectChar attribute="Normal Text" context="#pop" char="(" lookAhead="true"/>
+ <DetectChar attribute="Normal Text" context="#pop" char=")" lookAhead="true"/>
+ <DetectChar attribute="Normal Text" context="#pop" char="[" lookAhead="true"/>
+ <DetectChar attribute="Normal Text" context="#pop" char="]" lookAhead="true"/>
+ <DetectChar attribute="Normal Text" context="#pop" char="{" lookAhead="true"/>
+ <DetectChar attribute="Normal Text" context="#pop" char="}" lookAhead="true"/>
+ <DetectChar attribute="KmdrMethod" context="DetectKmdrMethod" char="." lookAhead="true"/>
+ <RegExpr attribute="Normal Text" context="#pop" String="[\s\=\;\+\-\*\/\%]+" />
+
+ </context>
+ <context attribute="DCOPMethod" lineEndContext="FindAll" name="DetectKmdrMethod">
+ <DetectChar attribute="Normal Text" context="FindAll" char="(" lookAhead="true"/>
+ <DetectChar attribute="Normal Text" context="FindAll" char=")" lookAhead="true"/>
+ <RegExpr attribute="Normal Text" context="FindAll" String="[\s\=\;\+\-\*\/\%]+" />
+ </context>
+
+ <!-- FindOthers contains various rules to mark different shell input -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="FindOthers">
+ <RegExpr attribute="Escape" context="#stay" String="\\[][;&quot;\\'$`{}()|&amp;&lt;&gt;* ]" />
+ <RegExpr attribute="Keyword" context="#stay" String="\\$" />
+ <RegExpr attribute="Escape" context="#stay" String="\{(?!(\s|$))\S*\}" />
+ <RegExpr attribute="Path" context="#stay" String="\.?/[\w_@.+-]+(?=([\s/):]|$))" />
+ <!-- TODO: shell globs -->
+ </context>
+
+ <!-- FindStrings looks for single and double quoted strings, also with $-prefix -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="FindStrings">
+ <DetectChar attribute="String SingleQ" context="StringSQ" char="'" />
+ <DetectChar attribute="String DoubleQ" context="StringDQ" char="&quot;" />
+ <!-- <Detect2Chars attribute="String SingleQ" context="StringEsc" char="$" char1="'" /> -->
+ <!-- <Detect2Chars attribute="String Transl." context="StringDQ" char="$" char1="&quot;" /> -->
+ </context>
+
+ <!-- FindSubstitutions goes after anything starting with $ and ` and their escapes -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="FindSubstitutions">
+ <!-- <RegExpr attribute="Variable" context="#stay" String="\$[*@#?$!_0-9-]" />
+ <RegExpr attribute="Variable" context="Subscript" String="\$&varname;\[" />
+ <RegExpr attribute="Variable" context="#stay" String="\$&varname;" />
+ <RegExpr attribute="Variable" context="#stay" String="\$\{[*@#?$!_0-9-]\}" />
+ <RegExpr attribute="Variable" context="#stay" String="\$\{#&varname;\}" />
+ <RegExpr attribute="Variable" context="#stay" String="\$\{!&varname;\*?\}" />-->
+ <RegExpr attribute="Variable" context="VarBrace" String="\$\{&varname;" />
+ <RegExpr attribute="Variable" context="VarBrace" String="\$\{[*@#?$!_0-9-](?=[:#%/])" />
+ <StringDetect attribute="Variable" context="ExprDblParenSubst" String="$((" beginRegion="expression" />
+ <StringDetect attribute="Redirection" context="SubstFile" String="$(&lt;" />
+ <StringDetect attribute="Variable" context="SubstCommand" String="$(" />
+ <DetectChar attribute="Backquote" context="SubstBackq" char="`" />
+ <RegExpr attribute="Escape" context="#stay" String="\\[`$\\]" />
+ </context>
+
+
+
+
+
+<!-- ====== These are the contexts that can be branched to ======= -->
+
+ <!-- ExprDblParen consumes an expression started in command mode till )) -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblParen">
+ <Detect2Chars attribute="Keyword" context="#pop" char=")" char1=")" endRegion="expression" />
+ <DetectChar attribute="Normal Text" context="ExprSubParen" char="(" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+ <!-- ExprDblParenSubst like ExprDblParen but matches )) as Variable -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblParenSubst">
+ <Detect2Chars attribute="Variable" context="#pop" char=")" char1=")" endRegion="expression" />
+ <DetectChar attribute="Normal Text" context="ExprSubParen" char="(" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+ <!-- ExprSubParen consumes an expression till ) -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="ExprSubParen">
+ <DetectChar attribute="Normal Text" context="#pop" char=")" />
+ <DetectChar attribute="Normal Text" context="ExprSubParen" char="(" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+ <!-- ExprBracket consumes an expression till ] -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="ExprBracket">
+ <RegExpr attribute="Builtin" context="#pop" String="\s\](?=($|[\s;|&amp;]))" endRegion="expression" />
+ <RegExpr attribute="Builtin" context="#pop" String="\](?=($|[\s;|&amp;]))" endRegion="expression" column="0"/>
+ <DetectChar attribute="Normal Text" context="ExprSubParen" char="(" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+ <!-- ExprDblBracket consumes an expression till ]] -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracket">
+ <RegExpr attribute="Keyword" context="#pop" String="\s\]\](?=($|[\s;|&amp;]))" endRegion="expression" />
+ <RegExpr attribute="Keyword" context="#pop" String="\]\](?=($|[\s;|&amp;]))" endRegion="expression" column="0"/>
+ <DetectChar attribute="Normal Text" context="ExprSubParen" char="(" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+ <!-- Group consumes shell input till } -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="Group">
+ <DetectChar attribute="Keyword" context="#pop" char="}" endRegion="group" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+ <!-- SubShell consumes shell input till ) -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="SubShell">
+ <DetectChar attribute="Keyword" context="#pop" char=")" endRegion="subshell" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+ <!-- Assign consumes an expression till EOL or whitespace -->
+ <context attribute="Normal Text" lineEndContext="#pop" name="Assign" fallthrough="true" fallthroughContext="#pop">
+ <DetectChar attribute="Variable" context="AssignArray" char="(" />
+ <IncludeRules context="FindStrings" />
+ <IncludeRules context="FindSubstitutions" />
+ <IncludeRules context="FindOthers" />
+ <RegExpr attribute="Normal Text" context="#stay" String="[\w:,+_./-]+" />
+ </context>
+
+ <!-- AssignArray consumes everything till ), marking assignments -->
+ <context attribute="Normal Text" lineEndContext="#pop" name="AssignArray">
+ <DetectChar attribute="Variable" context="#pop" char=")" />
+ <DetectChar attribute="Variable" context="Subscript" char="[" />
+ <DetectChar attribute="Variable" context="Assign" char="=" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+ <!-- AssignSubscr first expects a [ then parses subscript and continues with '=value' -->
+ <context attribute="Normal Text" lineEndContext="#pop" name="AssignSubscr" fallthrough="true" fallthroughContext="#pop">
+ <DetectChar attribute="Variable" context="Subscript" char="[" />
+ <DetectChar attribute="Variable" context="Assign" char="=" />
+ <IncludeRules context="FindStrings" />
+ <IncludeRules context="FindSubstitutions" />
+ <IncludeRules context="FindOthers" />
+ </context>
+
+ <!-- Subscript consumes anything till ], marks as Variable -->
+ <context attribute="Variable" lineEndContext="#stay" name="Subscript">
+ <DetectChar attribute="Variable" context="#pop" char="]" />
+ <IncludeRules context="FindStrings" />
+ <IncludeRules context="FindSubstitutions" />
+ <IncludeRules context="FindOthers" />
+ </context>
+
+ <!-- FunctionDef consumes a name, possibly with (), marks as Function -->
+ <context attribute="Function" lineEndContext="#pop" name="FunctionDef" fallthrough="true" fallthroughContext="#pop">
+ <RegExpr attribute="Function" context="#pop" String="\s+&funcname;(\s*\(\))?" />
+ </context>
+
+ <!-- VarName consumes spare variable names and assignments -->
+ <context attribute="Normal Text" lineEndContext="#pop" name="VarName" fallthrough="true" fallthroughContext="#pop">
+ <!-- handle command line options -->
+ <RegExpr attribute="Option" context="#stay" String="-[A-Za-z0-9]+" />
+ <RegExpr attribute="Option" context="#stay" String="--[a-z][A-Za-z0-9_-]*" />
+ <RegExpr attribute="Variable" context="#stay" String="\b&varname;" />
+ <DetectChar attribute="Variable" context="Subscript" char="[" />
+ <DetectChar attribute="Variable" context="Assign" char="=" />
+ <IncludeRules context="FindAll" />
+ <!-- stay here in spaces and other safe characters -->
+ <RegExpr attribute="Normal Text" context="#stay" String="[^]})|;`&amp;&gt;&lt;]" />
+ </context>
+
+ <!-- StringSQ consumes anything till ' -->
+ <context attribute="String SingleQ" lineEndContext="#stay" name="StringSQ">
+
+ <DetectChar attribute="String SingleQ" context="#pop" char="'" />
+ </context>
+
+ <!-- StringDQ consumes anything till ", substitutes vars and expressions -->
+ <context attribute="String DoubleQ" lineEndContext="#stay" name="StringDQ">
+ <DetectChar attribute="String DoubleQ" context="#pop" char="&quot;" />
+ <RegExpr attribute="String Escape" context="#stay" String="\\[`&quot;\\$\n]" />
+ <IncludeRules context="FindSubstitutions" />
+ </context>
+
+ <!-- StringEsc eats till ', but escaping many characters -->
+ <context attribute="String SingleQ" lineEndContext="#stay" name="StringEsc">
+ <DetectChar attribute="String SingleQ" context="#pop" char="'" />
+ <RegExpr attribute="String Escape" context="#stay" String="\\[abefnrtv\\']" />
+ <RegExpr attribute="String Escape" context="#stay" String="\\([0-7]{1,3}|x[A-Fa-f0-9]{1,2}|c.)" />
+ </context>
+
+ <!-- VarBrace is called as soon as ${xxx is encoutered -->
+ <context attribute="Variable" lineEndContext="#stay" name="VarBrace">
+ <DetectChar attribute="Variable" context="#pop" char="}" />
+ <DetectChar attribute="Variable" context="Subscript" char="[" />
+ <IncludeRules context="FindStrings" />
+ <IncludeRules context="FindSubstitutions" />
+ <!-- TODO: highlight various special parameter expansions } -->
+ </context>
+
+ <!-- SubstFile is called after a <( or >( is encoutered -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="SubstFile">
+ <DetectChar attribute="Redirection" context="#pop" char=")" />
+ <IncludeRules context="FindStrings" />
+ <IncludeRules context="FindSubstitutions" />
+ <IncludeRules context="FindOthers" />
+ </context>
+
+ <!-- SubstCommand is called after a $( is encountered -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="SubstCommand">
+ <DetectChar attribute="Variable" context="#pop" char=")" />
+ <IncludeRules context="FindCommands" />
+ <IncludeRules context="FindStrings" />
+ <IncludeRules context="FindSubstitutions" />
+ <IncludeRules context="FindOthers" />
+ </context>
+
+ <!-- SubstBackq is called when a backquote is encountered -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="SubstBackq">
+ <DetectChar attribute="Keyword" context="#pop" char="`" />
+ <IncludeRules context="FindCommands" />
+ <IncludeRules context="FindStrings" />
+ <IncludeRules context="FindSubstitutions" />
+ <IncludeRules context="FindOthers" />
+ </context>
+
+ <!-- Case is called after the case keyword is encoutered. We handle this because of
+ the lonely closing parentheses that would otherwise disturb the expr matching -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="Case">
+ <RegExpr attribute="Keyword" context="CaseIn" String="\sin\b" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+ <!-- CaseIn is called when the construct 'case ... in' has been found. -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="CaseIn">
+ <RegExpr attribute="Keyword" context="#pop#pop" String="\besac(?=$|[\s;)])" endRegion="case" />
+ <DetectChar attribute="Keyword" context="CaseExpr" char=")" beginRegion="caseexpr" />
+ <AnyChar attribute="Keyword" context="#stay" String="(|" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+ <!-- CaseExpr eats shell input till ;; -->
+ <context attribute="Normal Text" lineEndContext="#stay" name="CaseExpr">
+ <Detect2Chars attribute="Keyword" context="#pop" char=";" char1=";" endRegion="caseexpr" />
+ <IncludeRules context="FindAll" />
+ </context>
+
+
+ </contexts>
+
+ <itemDatas>
+ <itemData name="Normal Text" defStyleNum="dsNormal" />
+ <itemData name="Comment" defStyleNum="dsComment" />
+ <itemData name="Keyword" defStyleNum="dsKeyword" />
+ <itemData name="Control" defStyleNum="dsKeyword" />
+ <itemData name="Builtin" defStyleNum="dsKeyword" color="#808" />
+ <itemData name="Command" defStyleNum="dsKeyword" color="#c0c" />
+ <itemData name="Redirection" defStyleNum="dsKeyword" color="#238" />
+ <itemData name="Escape" defStyleNum="dsDataType" />
+ <itemData name="String SingleQ" defStyleNum="dsString" />
+ <itemData name="String DoubleQ" defStyleNum="dsString" />
+ <itemData name="Backquote" defStyleNum="dsKeyword" />
+ <itemData name="String Transl." defStyleNum="dsString" />
+ <itemData name="String Escape" defStyleNum="dsDataType" />
+ <itemData name="Variable" defStyleNum="dsOthers" />
+ <itemData name="Expression" defStyleNum="dsOthers" />
+ <itemData name="Function" defStyleNum="dsChar" bold="1" />
+ <itemData name="Path" defStyleNum="dsNormal" />
+ <itemData name="Option" defStyleNum="dsNormal" />
+ <itemData name="GlobalVariable" defStyleNum="dsOthers" bold="1" />
+ <itemData name="KmdrMethod" defStyleNum="dsKeyword" italic="1" color="#008000" />
+ <itemData name="DCOPMethod" defStyleNum="dsKeyword" italic="1" color="#21E52B" />
+ <itemData name="KmdrString" defStyleNum="dsKeyword" italic="1" color="#D0D000" />
+ <itemData name="KmdrArray" defStyleNum="dsKeyword" italic="1" color="#C0C0FF" />
+ <itemData name="KmdrMatrix" defStyleNum="dsKeyword" italic="1" color="#5050AA" />
+ <itemData name="KmdrFile" defStyleNum="dsKeyword" italic="1" color="#FF0000" />
+ <itemData name="KmdrInput" defStyleNum="dsKeyword" italic="1" color="#FF8000" />
+ <itemData name="KmdrMessage" defStyleNum="dsKeyword" italic="1" color="#800000" />
+ </itemDatas>
+ </highlighting>
+ <general>
+ <comments>
+ <comment name="singleLine" start="//"/>
+ <comment name="multiLine" start="/*" end="*/" />
+ </comments>
+ <keywords casesensitive="1" weakDeliminator="^%#[]$._{}:-" additionalDeliminator="`."/>
+ </general>
+</language>
diff --git a/kommander/editor/kommander.xml b/kommander/editor/kommander.xml
new file mode 100644
index 00000000..f5880b2f
--- /dev/null
+++ b/kommander/editor/kommander.xml
@@ -0,0 +1,998 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE language SYSTEM "language.dtd"
+[
+ <!ENTITY funcname "[A-Za-z_:][A-Za-z0-9_:#&#37;@-]*">
+ <!ENTITY varname "[A-Za-z_][A-Za-z0-9_]*">
+ <!ENTITY word "[^|&amp;;()&lt;&gt;\s]+"> <!-- see man bash -->
+ <!ENTITY eos "(?=($|\s))"> <!-- eol or space following -->
+ <!ENTITY noword "(?![\w$+-])"> <!-- no word, $, + or - following -->
+]>
+<language name="Kommander (old parser)" version="2.07" kateversion="2.4" section="Scripts" extensions="*.kmdr" mimetype="application/x-shellscript" casesensitive="1" author="Wilbert Berendsen (wilbert@kde.nl), Andras Mantia (amantia@kde.org)" license="LGPL">
+
+<!-- (c) 2004 by Wilbert Berendsen, wilbert@kde.nl
+ Released under the LGPL, part of kdelibs/kate
+
+ Added Kommander specific highlighting.
+ (c) 2006 Andras Mantia, amantia@kde.org
+-->
+
+ <highlighting>
+
+ <list name="kmdrdcopfunctions">
+ <item>addUniqueItem</item>
+ <item>associatedText</item>
+ <item>cancel</item>
+ <item>cellText</item>
+ <item>clear</item>
+ <item>checked</item>
+ <item>children</item>
+ <item>count</item>
+ <item>currentColumn</item>
+ <item>currentItem</item>
+ <item>currentRow</item>
+ <item>execute</item>
+ <item>findItem</item>
+ <item>geometry</item>
+ <item>global</item>
+ <item>hasFocus</item>
+ <item>insertColumn</item>
+ <item>insertItem</item>
+ <item>insertItems</item>
+ <item>insertRow</item>
+ <item>item</item>
+ <item>itemDepth</item>
+ <item>itemPath</item>
+ <item>removeColumn</item>
+ <item>removeItem</item>
+ <item>removeRow</item>
+ <item>selection</item>
+ <item>setAssociatedText</item>
+ <item>setChecked</item>
+ <item>setCellText</item>
+ <item>setCurrentItem</item>
+ <item>setColumnCaption</item>
+ <item>setEnabled</item>
+ <item>setGlobal</item>
+ <item>setMaximum</item>
+ <item>setPixmap</item>
+ <item>setRowCaption</item>
+ <item>setSelection</item>
+ <item>setText</item>
+ <item>setVisible</item>
+ <item>text</item>
+ <item>type</item>
+ </list>
+
+ <list name="kmdrfunctions">
+ <item>widgetText</item>
+ <item>selectedWidgetText</item>
+ <item>null</item>
+ <item>pid</item>
+ <item>dcopid</item>
+ <item>parentPid</item>
+ <item>debug</item>
+ <item>echo</item>
+ <item>env</item>
+ <item>exec</item>
+ <item>expr</item>
+ <item>global</item>
+ <item>i18n</item>
+ <item>dialog</item>
+ <item>readSetting</item>
+ <item>setGlobal</item>
+ <item>writeSetting</item>
+ <item>dcop</item>
+ <item>switchBlock</item>
+ <item>execBegin</item>
+ <item>forBlock</item>
+ <item>forEachBlock</item>
+ <item>ifBlock</item>
+ <item>comment</item>
+ </list>
+
+ <list name="kmdrarray">
+ <item>values</item>
+ <item>keys</item>
+ <item>clear</item>
+ <item>count</item>
+ <item>value</item>
+ <item>remove</item>
+ <item>setValue</item>
+ <item>fromString</item>
+ <item>toString</item>
+ </list>
+
+ <list name="kmdrstring">
+ <item>length</item>
+ <item>contains</item>
+ <item>find</item>
+ <item>findRev</item>
+ <item>left</item>
+ <item>right</item>
+ <item>mid</item>
+ <item>remove</item>
+ <item>replace</item>
+ <item>upper</item>
+ <item>lower</item>
+ <item>compare</item>
+ <item>isEmpty</item>
+ <item>isNumber</item>
+ <item>section</item>
+ <item>args</item>
+ <item>round</item>
+ </list>
+
+ <list name="kmdrfile">
+ <item>read</item>
+ <item>write</item>
+ <item>append</item>
+ <item>exists</item>
+ </list>
+
+ <list name="kmdrinput">
+ <item>color</item>
+ <item>text</item>
+ <item>password</item>
+ <item>value</item>
+ <item>double</item>
+ <item>valueDouble</item>
+ <item>openfile</item>
+ <item>openfiles</item>
+ <item>savefile</item>
+ <item>directory</item>
+ </list>
+
+ <list name="kmdrmessage">
+ <item>info</item>
+ <item>error</item>
+ <item>question</item>
+ <item>warning</item>
+ </list>
+
+
+ <list name="keywords">
+ <item> else </item>
+ <item> for </item>
+ <item> function </item>
+ <item> in </item>
+ <item> select </item>
+ <item> until </item>
+ <item> while </item>
+ <item> . </item>
+ <item> elif </item>
+ <item> then </item>
+ <item> set </item>
+ <item> foreach </item>
+ <item> end </item>
+ </list>
+
+
+ <list name="builtins">
+ <item> : </item>
+ <item> . </item>
+ <item> source </item>
+ <item> alias </item>
+ <item> bg </item>
+ <item> bind </item>
+ <item> break </item>
+ <item> builtin </item>
+ <item> cd </item>
+ <item> command </item>
+ <item> compgen </item>
+ <item> complete </item>
+ <item> continue </item>
+ <item> dirs </item>
+ <item> disown </item>
+ <item> echo </item>
+ <item> enable </item>
+ <item> eval </item>
+ <item> exec </item>
+ <item> exit </item>
+ <item> fc </item>
+ <item> fg </item>
+ <item> getopts </item>
+ <item> hash </item>
+ <item> help </item>
+ <item> history </item>
+ <item> jobs </item>
+ <item> kill </item>
+ <item> let </item>
+ <item> logout </item>
+ <item> popd </item>
+ <item> printf </item>
+ <item> pushd </item>
+ <item> pwd </item>
+ <item> return </item>
+ <item> set </item>
+ <item> shift </item>
+ <item> shopt </item>
+ <item> suspend </item>
+ <item> test </item>
+ <item> times </item>
+ <item> trap </item>
+ <item> type </item>
+ <item> ulimit </item>
+ <item> umask </item>
+ <item> unalias </item>
+ <item> wait </item>
+ </list>
+
+ <list name="builtins_var">
+ <item> export </item>
+ <item> unset </item>
+ <item> declare </item>
+ <item> typeset </item>
+ <item> local </item>
+ <item> read </item>
+ <item> readonly </item>
+ </list>
+
+ <list name="unixcommands">
+ <!-- /bin -->
+ <item> arch </item>
+ <item> awk </item>
+ <item> bash </item>
+ <item> bunzip2 </item>
+ <item> bzcat </item>
+ <item> bzcmp </item>
+ <item> bzdiff </item>
+ <item> bzegrep </item>
+ <item> bzfgrep </item>
+ <item> bzgrep </item>
+ <item> bzip2 </item>
+ <item> bzip2recover </item>
+ <item> bzless </item>
+ <item> bzmore </item>
+ <item> cat </item>
+ <item> chattr </item>
+ <item> chgrp </item>
+ <item> chmod </item>
+ <item> chown </item>
+ <item> chvt </item>
+ <item> cp </item>
+ <item> date </item>
+ <item> dd </item>
+ <item> deallocvt </item>
+ <item> df </item>
+ <item> dir </item>
+ <item> dircolors </item>
+ <item> dmesg </item>
+ <item> dnsdomainname </item>
+ <item> domainname </item>
+ <item> du </item>
+ <item> dumpkeys </item>
+ <item> echo </item>
+ <item> ed </item>
+ <item> egrep </item>
+ <item> false </item>
+ <item> fgconsole </item>
+ <item> fgrep </item>
+ <item> fuser </item>
+ <item> gawk </item>
+ <item> getkeycodes </item>
+ <item> gocr </item>
+ <item> grep </item>
+ <item> groups </item>
+ <item> gunzip </item>
+ <item> gzexe </item>
+ <item> gzip </item>
+ <item> hostname </item>
+ <item> igawk </item>
+ <item> install </item>
+ <item> kbd_mode </item>
+ <item> kbdrate </item>
+ <item> killall </item>
+ <item> last </item>
+ <item> lastb </item>
+ <item> link </item>
+ <item> ln </item>
+ <item> loadkeys </item>
+ <item> loadunimap </item>
+ <item> login </item>
+ <item> ls </item>
+ <item> lsattr </item>
+ <item> lsmod </item>
+ <item> lsmod.old </item>
+ <item> mapscrn </item>
+ <item> mesg </item>
+ <item> mkdir </item>
+ <item> mkfifo </item>
+ <item> mknod </item>
+ <item> mktemp </item>
+ <item> more </item>
+ <item> mount </item>
+ <item> mv </item>
+ <item> nano </item>
+ <item> netstat </item>
+ <item> nisdomainname </item>
+ <item> openvt </item>
+ <item> pgawk </item>
+ <item> pidof </item>
+ <item> ping </item>
+ <item> ps </item>
+ <item> pstree </item>
+ <item> pwd </item>
+ <item> rbash </item>
+ <item> readlink </item>
+ <item> red </item>
+ <item> resizecons </item>
+ <item> rm </item>
+ <item> rmdir </item>
+ <item> run-parts </item>
+ <item> sash </item>
+ <item> sed </item>
+ <item> setfont </item>
+ <item> setkeycodes </item>
+ <item> setleds </item>
+ <item> setmetamode </item>
+ <item> setserial </item>
+ <item> sh </item>
+ <item> showkey </item>
+ <item> shred </item>
+ <item> sleep </item>
+ <item> ssed </item>
+ <item> stat </item>
+ <item> stty </item>
+ <item> su </item>
+ <item> sync </item>
+ <item> tar </item>
+ <item> tempfile </item>
+ <item> touch </item>
+ <item> true </item>
+ <item> umount </item>
+ <item> uname </item>
+ <item> unicode_start </item>
+ <item> unicode_stop </item>
+ <item> unlink </item>
+ <item> utmpdump </item>
+ <item> uuidgen </item>
+ <item> vdir </item>
+ <item> wall </item>
+ <item> wc </item>
+ <item> ypdomainname </item>
+ <item> zcat </item>
+ <item> zcmp </item>
+ <item> zdiff </item>
+ <item> zegrep </item>
+ <item> zfgrep </item>
+ <item> zforce </item>
+ <item> zgrep </item>
+ <item> zless </item>
+ <item> zmore </item>
+ <item> znew </item>
+ <item> zsh </item>
+
+ <!-- some from /usr/bin -->
+ <item> aclocal </item>
+ <item> aconnect </item>
+ <item> aplay </item>
+ <item> apm </item>
+ <item> apmsleep </item>
+ <item> apropos </item>
+ <item> ar </item>
+ <item> arecord </item>
+ <item> as </item>
+ <item> as86 </item>
+ <item> autoconf </item>
+ <item> autoheader </item>
+ <item> automake </item>
+ <item> awk </item>
+ <item> basename </item>
+ <item> bc </item>
+ <item> bison </item>
+ <item> c++ </item>
+ <item> cal </item>
+ <item> cat </item>
+ <item> cc </item>
+ <item> cdda2wav </item>
+ <item> cdparanoia </item>
+ <item> cdrdao </item>
+ <item> cd-read </item>
+ <item> cdrecord </item>
+ <item> chfn </item>
+ <item> chgrp </item>
+ <item> chmod </item>
+ <item> chown </item>
+ <item> chroot </item>
+ <item> chsh </item>
+ <item> clear </item>
+ <item> cmp </item>
+ <item> co </item>
+ <item> col </item>
+ <item> comm </item>
+ <item> cp </item>
+ <item> cpio </item>
+ <item> cpp </item>
+ <item> cut </item>
+ <item> dc </item>
+ <item> dd </item>
+ <item> df </item>
+ <item> diff </item>
+ <item> diff3 </item>
+ <item> dir </item>
+ <item> dircolors </item>
+ <item> directomatic </item>
+ <item> dirname </item>
+ <item> du </item>
+ <item> env </item>
+ <item> expr </item>
+ <item> fbset </item>
+ <item> file </item>
+ <item> find </item>
+ <item> flex </item>
+ <item> flex++ </item>
+ <item> fmt </item>
+ <item> free </item>
+ <item> ftp </item>
+ <item> funzip </item>
+ <item> fuser </item>
+ <item> g++ </item>
+ <item> gawk </item>
+ <item> gc </item>
+ <item> gcc </item>
+ <item> gdb </item>
+ <item> getent </item>
+ <item> getopt </item>
+ <item> gettext </item>
+ <item> gettextize </item>
+ <item> gimp </item>
+ <item> gimp-remote </item>
+ <item> gimptool </item>
+ <item> gmake </item>
+ <item> gs </item>
+ <item> head </item>
+ <item> hexdump </item>
+ <item> id </item>
+ <item> install </item>
+ <item> join </item>
+ <item> kill </item>
+ <item> killall </item>
+ <item> ld </item>
+ <item> ld86 </item>
+ <item> ldd </item>
+ <item> less </item>
+ <item> lex </item>
+ <item> ln </item>
+ <item> locate </item>
+ <item> lockfile </item>
+ <item> logname </item>
+ <item> lp </item>
+ <item> lpr </item>
+ <item> ls </item>
+ <item> lynx </item>
+ <item> m4 </item>
+ <item> make </item>
+ <item> man </item>
+ <item> mkdir </item>
+ <item> mknod </item>
+ <item> msgfmt </item>
+ <item> mv </item>
+ <item> namei </item>
+ <item> nasm </item>
+ <item> nawk </item>
+ <item> nice </item>
+ <item> nl </item>
+ <item> nm </item>
+ <item> nm86 </item>
+ <item> nmap </item>
+ <item> nohup </item>
+ <item> nop </item>
+ <item> od </item>
+ <item> passwd </item>
+ <item> patch </item>
+ <item> pcregrep </item>
+ <item> pcretest </item>
+ <item> perl </item>
+ <item> perror </item>
+ <item> pidof </item>
+ <item> pr </item>
+ <item> printf </item>
+ <item> procmail </item>
+ <item> prune </item>
+ <item> ps2ascii </item>
+ <item> ps2epsi </item>
+ <item> ps2frag </item>
+ <item> ps2pdf </item>
+ <item> ps2ps </item>
+ <item> psbook </item>
+ <item> psmerge </item>
+ <item> psnup </item>
+ <item> psresize </item>
+ <item> psselect </item>
+ <item> pstops </item>
+ <item> rcs </item>
+ <item> rev </item>
+ <item> rm </item>
+ <item> scp </item>
+ <item> sed </item>
+ <item> seq </item>
+ <item> setterm </item>
+ <item> shred </item>
+ <item> size </item>
+ <item> size86 </item>
+ <item> skill </item>
+ <item> slogin </item>
+ <item> snice </item>
+ <item> sort </item>
+ <item> sox </item>
+ <item> split </item>
+ <item> ssh </item>
+ <item> ssh-add </item>
+ <item> ssh-agent </item>
+ <item> ssh-keygen </item>
+ <item> ssh-keyscan </item>
+ <item> stat </item>
+ <item> strings </item>
+ <item> strip </item>
+ <item> sudo </item>
+ <item> suidperl </item>
+ <item> sum </item>
+ <item> tac </item>
+ <item> tail </item>
+ <item> tee </item>
+ <item> test </item>
+ <item> tr </item>
+ <item> uniq </item>
+ <item> unlink </item>
+ <item> unzip </item>
+ <item> updatedb </item>
+ <item> updmap </item>
+ <i