summaryrefslogtreecommitdiffstats
path: root/kommander
diff options
context:
space:
mode:
Diffstat (limited to 'kommander')
-rw-r--r--kommander/AUTHORS5
-rw-r--r--kommander/COPYING339
-rw-r--r--kommander/ChangeLog611
-rw-r--r--kommander/INSTALL186
-rw-r--r--kommander/Kommander-TODO.kno313
-rw-r--r--kommander/Makefile.am15
-rw-r--r--kommander/NEWS1
-rw-r--r--kommander/README70
-rw-r--r--kommander/VERSION1
-rw-r--r--kommander/configure.in.in14
-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
-rw-r--r--kommander/examples/Makefile.am1
-rw-r--r--kommander/examples/current/Makefile.am3
-rwxr-xr-xkommander/examples/current/a1.kmdr258
-rwxr-xr-xkommander/examples/current/b1.kmdr135
-rwxr-xr-xkommander/examples/current/editor-poc.kmdr1068
-rw-r--r--kommander/examples/current/keyvaluecombo.kmdr388
-rwxr-xr-xkommander/examples/current/kpartmwframe.kmdr618
-rwxr-xr-xkommander/examples/current/kpartpart.kmdr171
-rw-r--r--kommander/examples/current/passvariables.kmdr416
-rwxr-xr-xkommander/examples/current/tableselect.kmdr502
-rw-r--r--kommander/examples/old/Makefile.am7
-rw-r--r--kommander/examples/old/checkmail.kmdr44
-rw-r--r--kommander/examples/old/ex1.kmdr105
-rw-r--r--kommander/examples/old/execprogram.kmdr104
-rw-r--r--kommander/examples/old/firstform.kmdr.kmdr88
-rw-r--r--kommander/examples/old/form1.kmdr96
-rw-r--r--kommander/examples/old/form2.kmdr118
-rw-r--r--kommander/examples/old/form3.kmdr62
-rw-r--r--kommander/examples/old/form4.kmdr88
-rw-r--r--kommander/examples/old/form5.kmdr346
-rw-r--r--kommander/examples/old/newfile.kmdr934
-rw-r--r--kommander/examples/old/populate.kmdr111
-rw-r--r--kommander/examples/old/resize.kmdr217
-rw-r--r--kommander/examples/old/selectedwidgettext.kmdr105
-rw-r--r--kommander/examples/old/settings.kmdr264
-rw-r--r--kommander/examples/old/simplelist.kmdr214
-rw-r--r--kommander/examples/old/tar.kmdr479
-rw-r--r--kommander/examples/old/tidy.kmdr1159
-rw-r--r--kommander/examples/old/widgetgenerator.kmdr438
-rwxr-xr-xkommander/examples/old/wizard.kmdr301
-rw-r--r--kommander/examples/tutorial/Makefile.am10
-rw-r--r--kommander/examples/tutorial/README123
-rw-r--r--kommander/examples/tutorial/append.kmdr115
-rw-r--r--kommander/examples/tutorial/arrays.kmdr204
-rw-r--r--kommander/examples/tutorial/calc.kmdr271
-rw-r--r--kommander/examples/tutorial/cmdline.kmdr108
-rw-r--r--kommander/examples/tutorial/dcop.kmdr139
-rw-r--r--kommander/examples/tutorial/dialogs.kmdr198
-rw-r--r--kommander/examples/tutorial/globals.kmdr96
-rw-r--r--kommander/examples/tutorial/initialize.kmdr120
-rw-r--r--kommander/examples/tutorial/loop.kmdr114
-rw-r--r--kommander/examples/tutorial/picview.kmdr148
-rw-r--r--kommander/examples/tutorial/progressbar.kmdr192
-rw-r--r--kommander/examples/tutorial/settings.kmdr177
-rw-r--r--kommander/examples/tutorial/slots.kmdr200
-rw-r--r--kommander/examples/tutorial/statusbar.kmdr99
-rw-r--r--kommander/examples/tutorial/strings.kmdr206
-rw-r--r--kommander/examples/tutorial/table.kmdr258
-rw-r--r--kommander/examples/tutorial/tree.kmdr170
-rw-r--r--kommander/examples/tutorial/widgets.kmdr133
-rw-r--r--kommander/executor/Makefile.am25
-rw-r--r--kommander/executor/dcopkommanderif.h82
-rw-r--r--kommander/executor/instance.cpp683
-rw-r--r--kommander/executor/instance.h137
-rw-r--r--kommander/executor/kmdr-executor.desktop82
-rw-r--r--kommander/executor/main.cpp102
-rw-r--r--kommander/executor/register.cpp104
-rw-r--r--kommander/executor/templates/cpp_template16
-rw-r--r--kommander/executor/templates/header_template16
-rw-r--r--kommander/factory/Makefile.am16
-rw-r--r--kommander/factory/domtool.cpp412
-rw-r--r--kommander/factory/domtool.h45
-rw-r--r--kommander/factory/kommanderfactory.cpp1486
-rw-r--r--kommander/factory/kommanderfactory.h160
-rw-r--r--kommander/factory/kommanderversion.h7
-rw-r--r--kommander/icons/Makefile.am4
-rw-r--r--kommander/icons/cr128-app-kommander.pngbin0 -> 21090 bytes
-rw-r--r--kommander/icons/cr16-app-kommander.pngbin0 -> 934 bytes
-rw-r--r--kommander/icons/cr22-app-kommander.pngbin0 -> 1480 bytes
-rw-r--r--kommander/icons/cr32-app-kommander.pngbin0 -> 2605 bytes
-rw-r--r--kommander/icons/cr64-app-kommander.pngbin0 -> 7232 bytes
-rw-r--r--kommander/icons/hi22-action-arrow.pngbin0 -> 583 bytes
-rw-r--r--kommander/kmdrtools/Makefile.am3
-rwxr-xr-xkommander/kmdrtools/dcoptool-oldparser.kmdr2125
-rwxr-xr-xkommander/kmdrtools/examples.kmdr154
-rw-r--r--kommander/kommander-editor.kdevelop285
-rw-r--r--kommander/kommander.kdevelop279
-rw-r--r--kommander/part/Makefile.am8
-rw-r--r--kommander/part/kommander_part.cpp86
-rw-r--r--kommander/part/kommander_part.desktop15
-rw-r--r--kommander/part/kommander_part.h48
-rw-r--r--kommander/plugin/Makefile.am17
-rw-r--r--kommander/plugin/kommanderplugin.cpp82
-rw-r--r--kommander/plugin/kommanderplugin.h103
-rw-r--r--kommander/plugin/specialinformation.cpp623
-rw-r--r--kommander/plugin/specialinformation.h119
-rw-r--r--kommander/plugin/specials.h77
-rw-r--r--kommander/pluginmanager/Makefile.am18
-rw-r--r--kommander/pluginmanager/main.cpp101
-rw-r--r--kommander/pluginmanager/mainwindow.cpp106
-rw-r--r--kommander/pluginmanager/mainwindow.h56
-rw-r--r--kommander/pluginmanager/pluginmanager.cpp89
-rw-r--r--kommander/pluginmanager/pluginmanager.h53
-rw-r--r--kommander/widget/Makefile.am20
-rw-r--r--kommander/widget/expression.cpp332
-rw-r--r--kommander/widget/expression.h80
-rw-r--r--kommander/widget/function.cpp135
-rw-r--r--kommander/widget/function.h73
-rw-r--r--kommander/widget/functionlib.cpp1476
-rw-r--r--kommander/widget/invokeclass.cpp61
-rw-r--r--kommander/widget/invokeclass.h56
-rw-r--r--kommander/widget/kmdrmainwindow.cpp36
-rw-r--r--kommander/widget/kmdrmainwindow.h37
-rw-r--r--kommander/widget/kommander_export.h35
-rw-r--r--kommander/widget/kommanderfunctions.cpp349
-rw-r--r--kommander/widget/kommanderwidget.cpp745
-rw-r--r--kommander/widget/kommanderwidget.h162
-rw-r--r--kommander/widget/kommanderwindow.cpp35
-rw-r--r--kommander/widget/kommanderwindow.h37
-rw-r--r--kommander/widget/myprocess.cpp137
-rw-r--r--kommander/widget/myprocess.h58
-rw-r--r--kommander/widget/parsenode.cpp262
-rw-r--r--kommander/widget/parsenode.h129
-rw-r--r--kommander/widget/parser.cpp1243
-rw-r--r--kommander/widget/parser.h197
-rw-r--r--kommander/widget/parserdata.cpp134
-rw-r--r--kommander/widget/parserdata.h50
-rw-r--r--kommander/widgets/Makefile.am35
-rw-r--r--kommander/widgets/aboutdialog.cpp295
-rw-r--r--kommander/widgets/aboutdialog.h72
-rw-r--r--kommander/widgets/buttongroup.cpp159
-rw-r--r--kommander/widgets/buttongroup.h67
-rw-r--r--kommander/widgets/checkbox.cpp151
-rw-r--r--kommander/widgets/checkbox.h67
-rw-r--r--kommander/widgets/closebutton.cpp183
-rw-r--r--kommander/widgets/closebutton.h72
-rw-r--r--kommander/widgets/combobox.cpp210
-rw-r--r--kommander/widgets/combobox.h70
-rw-r--r--kommander/widgets/datepicker.cpp130
-rw-r--r--kommander/widgets/datepicker.h70
-rw-r--r--kommander/widgets/dialog.cpp226
-rw-r--r--kommander/widgets/dialog.h87
-rw-r--r--kommander/widgets/execbutton.cpp241
-rw-r--r--kommander/widgets/execbutton.h94
-rw-r--r--kommander/widgets/fileselector.cpp240
-rw-r--r--kommander/widgets/fileselector.h102
-rw-r--r--kommander/widgets/fontdialog.cpp158
-rw-r--r--kommander/widgets/fontdialog.h50
-rw-r--r--kommander/widgets/groupbox.cpp152
-rw-r--r--kommander/widgets/groupbox.h70
-rw-r--r--kommander/widgets/konsole.cpp153
-rw-r--r--kommander/widgets/konsole.h74
-rw-r--r--kommander/widgets/label.cpp127
-rw-r--r--kommander/widgets/label.h64
-rw-r--r--kommander/widgets/lineedit.cpp182
-rw-r--r--kommander/widgets/lineedit.h72
-rw-r--r--kommander/widgets/listbox.cpp225
-rw-r--r--kommander/widgets/listbox.h67
-rw-r--r--kommander/widgets/pixmaplabel.cpp132
-rw-r--r--kommander/widgets/pixmaplabel.h66
-rw-r--r--kommander/widgets/pixmaps/textbold.xpm27
-rw-r--r--kommander/widgets/pixmaps/textcenter.xpm27
-rw-r--r--kommander/widgets/pixmaps/textitalic.xpm27
-rw-r--r--kommander/widgets/pixmaps/textleft.xpm27
-rw-r--r--kommander/widgets/pixmaps/textright.xpm27
-rw-r--r--kommander/widgets/pixmaps/textunder.xpm27
-rw-r--r--kommander/widgets/plugin.cpp138
-rw-r--r--kommander/widgets/popupmenu.cpp246
-rw-r--r--kommander/widgets/popupmenu.h61
-rw-r--r--kommander/widgets/progressbar.cpp144
-rw-r--r--kommander/widgets/progressbar.h63
-rw-r--r--kommander/widgets/radiobutton.cpp144
-rw-r--r--kommander/widgets/radiobutton.h66
-rw-r--r--kommander/widgets/richtexteditor.cpp249
-rw-r--r--kommander/widgets/richtexteditor.h85
-rw-r--r--kommander/widgets/scriptobject.cpp191
-rw-r--r--kommander/widgets/scriptobject.h68
-rw-r--r--kommander/widgets/slider.cpp121
-rw-r--r--kommander/widgets/slider.h60
-rw-r--r--kommander/widgets/spinboxint.cpp140
-rw-r--r--kommander/widgets/spinboxint.h68
-rw-r--r--kommander/widgets/statusbar.cpp131
-rw-r--r--kommander/widgets/statusbar.h65
-rw-r--r--kommander/widgets/subdialog.cpp146
-rw-r--r--kommander/widgets/subdialog.h70
-rw-r--r--kommander/widgets/table.cpp373
-rw-r--r--kommander/widgets/table.h73
-rw-r--r--kommander/widgets/tabwidget.cpp194
-rw-r--r--kommander/widgets/tabwidget.h60
-rw-r--r--kommander/widgets/textbrowser.cpp139
-rw-r--r--kommander/widgets/textbrowser.h63
-rw-r--r--kommander/widgets/textedit.cpp229
-rw-r--r--kommander/widgets/textedit.h70
-rw-r--r--kommander/widgets/timer.cpp189
-rw-r--r--kommander/widgets/timer.h71
-rw-r--r--kommander/widgets/toolbox.cpp190
-rw-r--r--kommander/widgets/toolbox.h54
-rw-r--r--kommander/widgets/treewidget.cpp512
-rw-r--r--kommander/widgets/treewidget.h87
-rw-r--r--kommander/widgets/widgets.desktop36
-rw-r--r--kommander/widgets/wizard.cpp194
-rw-r--r--kommander/widgets/wizard.h82
-rw-r--r--kommander/working/Makefile.am4
-rwxr-xr-xkommander/working/extractkmdr112
-rwxr-xr-xkommander/working/kmdr2po11
-rw-r--r--kommander/working/plugintemplate/Makefile.am17
-rw-r--r--kommander/working/plugintemplate/README.dox55
-rw-r--r--kommander/working/plugintemplate/app.kdevelop116
-rw-r--r--kommander/working/plugintemplate/kommanderplugin.kdevtemplate66
-rw-r--r--kommander/working/plugintemplate/kommanderplugin.pngbin0 -> 7232 bytes
-rw-r--r--kommander/working/plugintemplate/plugin.cpp29
-rw-r--r--kommander/working/plugintemplate/src-Makefile.am19
-rw-r--r--kommander/working/plugintemplate/widget.cpp116
-rw-r--r--kommander/working/plugintemplate/widget.h46
-rw-r--r--kommander/x-kommander.desktop55
534 files changed, 105643 insertions, 0 deletions
diff --git a/kommander/AUTHORS b/kommander/AUTHORS
new file mode 100644
index 00000000..058f0f78
--- /dev/null
+++ b/kommander/AUTHORS
@@ -0,0 +1,5 @@
+Derived from Qt Designer by Trolltech
+Original author: Marc Britton <consume@optusnet.com.au>
+Design team leader: Eric Laffoon <sequitur@kde.org>
+Current maintainer: Michal Rudolf <mrudolf@kdewebdev.org>
+Contributor: Andras Mantia <amantia@kde.org> \ No newline at end of file
diff --git a/kommander/COPYING b/kommander/COPYING
new file mode 100644
index 00000000..0b84a43f
--- /dev/null
+++ b/kommander/COPYING
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/kommander/ChangeLog b/kommander/ChangeLog
new file mode 100644
index 00000000..dde3cebf
--- /dev/null
+++ b/kommander/ChangeLog
@@ -0,0 +1,611 @@
+2008-04-23 - Eric Laffoon <sequitur@kde.org>
+ o add a little color to tab widgets with icons
+2008-04-21 - Eric Laffoon <sequitur@kde.org>
+ o added the ability to set alignment in columns in Tree/list widget
+ o enhanced find to now use column and set additional parameters in TreeWidget
+ o renamed some new functions only released in special release recently as cleanup
+2008-04-17 - Eric Laffoon <sequitur@kde.org>
+ o added round function in strings to round number to x digits
+2008-04-14 - Eric Laffoon <sequitur@kde.org>
+ o added cut, copy and paste to editor popup menu
+ o added file exists function
+ 0 added geometry and hasFocus to primary data widgets
+2008-03-28 - Eric Laffoon <sequitur@kde.org>
+ o added test geometry function to buttons for popup use
+2008-03-23 - Eric Laffoon <sequitur@kde.org>
+ o it's about time scripts had a boolean execute slot!
+2008-03-23 - Eric Laffoon <sequitur@kde.org>
+ o Table - added keepCellVisible for my application - I will need to clean up the code if I want to release it as I want to rename some things and do other cleanup
+ o ComboBox - added popupList to bring up the list without using the mouse - faster data entry
+2008-03-22 - Eric Laffoon <sequitur@kde.org>
+ o LineEdit - added gotfocus event
+2008-03-20 - Eric Laffoon <sequitur@kde.org>
+ o made actions sort along with widgets in the connection dialog
+ o Tree/Detail (ListView) widget - enabled adding columns
+ o Tree/Detail (ListView) widget - enabled removing columns (copied from table widget)
+ o Tree/Detail (ListView) widget - return column count
+ o Tree/Detail (ListView) widget - return column caption for given index
+ o Tree/Detail (ListView) widget - set sort column and where ASC or DESC
+ o Tree/Detail (ListView) widget - set column width - serves as hide colum at 0 width
+ o Table widget - add column sort that does by whole rows - doesn't do well with float as strings :(
+ o TextEdit - added lostFocus event
+ o LineEdit - added gotFocus event
+ o fixed about dialog license to take text and files correctly
+2008-03-19 - Andras Mantia <amantia@kde.org>
+ o regression: add back the missing str_compare function.
+2008-03-18 - Eric Laffoon <sequitur@kde.org>
+ o raised the number of allowed paramaters for scripts
+2008-03-10 - Eric Laffoon <sequitur@kde.org>
+ o enable additional slots in dialog and restore slots for actions - you can now directly manipulate actions on a MainWindow via signals and slots from the dialog
+2008-01-20 - Eric Laffoon <sequitur@kde.org>
+ o set new functions only available to new parser such as createWidget to not be shown in the function browser if the old parser is run.
+
+January 2008 - Andras Mantia <amantia@kde.org>
+ o support executing of slots
+ o add "execute" method for PushButton
+ o possibility to pass parameters for ScriptObject added
+ o add "return" command to get back the result of a ScriptObject
+ o add createWidget function for on-the-fly widget creation
+ o add connect/disconnect function for on-the-fly signal/slot connection
+ o add widgetExists
+ o add execBackground
+ o add indexed array functions: array_indexedFromString, array_indexedToString, array_indexedRemoveElements, array_indexedInsertElements
+ o input_color and @Input.color accepts a default color argument
+ o fix "exit" command
+ o make a="Label1"; a.setText("foo") work
+ o make dcopid, pid, parentPid work in the new parser
+ o make TreeWidget.selection work in multi selection mode
+ o add TreeWidget.selectedIndexes
+ o make TreeWidget.setSelection show the selected item
+ o add setCellWidget/cellWidget for Table
+ o add setEditable(bool) for widgets that are editable
+ o add PopupMenu widget
+ o add ToolBox widget
+ o add AboutDialog widget
+ o optionally quote the strings inserted via function browser
+ o use combobox for booleans in the function browser
+ o use multiline insert box in function browser
+ o add highlighting for the new parser
+ o use the new parser by default for new dialogs
+ o make possible to open more associated editors at once
+ o fix problem with losing the parser type status in the editor when working with multiple dialogs
+ o @Array.fromString should append the new elements to the array, just like
+ it did before and how array_fromString does.
+ o fix @eval for addition/substraction and handle division by zero
+ o process code written in external script using the old parser
+ o make it possible to run external script in a ScriptObject
+ o "execute" DCOP call returns a string
+ o support shebang (#!/path_to/kmdr-executor) in the beginning of the .kmdr files.
+ Running .kmdr files is possible directly if you make them executable.
+ o store Kommander version in the VERSION/_VERSION global variable
+ o the editor does not save the dialog on running
+ o warn if a dialog file is not executable
+ o create backup files every 5 minutes
+ o add initialize/destroy signals to MainWindow
+ o add experimental Kommander KPart
+ o rework the plugin system
+ o bump version to 1.3
+
+Wed Jan 9 21:35:38 2008 - Andras Mantia <amantia@kde.org>
+ o add Table.selection to get back the selection coordinates
+
+Sun Dec 30 00:02:34 2007 - Andras Mantia <amantia@kde.org>
+ o don't do math operations in check only mode
+
+Thu Dec 22 00:38:31 2007 - Andras Mantia <amantia@kde.org>
+ o fix the for loop parsing if end < start
+
+Thu Dec 20 00:38:31 2007 - Andras Mantia <amantia@kde.org>
+ o insert the functions using the syntax of the new parser if #!kommander
+ is specified in the associated text
+ o add DatePicker widget
+
+Wed Dec 19 08:39:00 2007 - Eric Laffoon <eric@kdewebdev.org>
+ o fixed the bug in the input text dialog where entering a default value returned the caption.
+
+Sat Dec 15 23:58:45 2007 - Andras Mantia <amantia@kde.org>
+ o return the result of a division in floating form if the result is not an integer.
+ Changed the behavior in both the old and new parser.
+
+Wed Nov 28 13:21:34 2007 - Andras Mantia <amantia@kde.org>
+ o do not set array values when the assignment is in a code path which shouldn't be executed
+
+Tue Nov 20 20:03:34 2007 - Andras Mantia <amantia@kde.org>
+ o show the checked function for RadioButton widgets in the function browser
+
+Fri Oct 19 16:08:32 2007 - Andras Mantia <amantia@kde.org>
+ o make CheckBox.setChecked accept as argument false, "false", true, "true",
+ 0 (meaning false), everything else (meaning true)
+
+Sat Oct 6 17:53:47 2007 - Andras Mantia <amantia@kde.org>
+ o make multiplying work correctly for floating point values
+ o do not remove the whole text after undoing the changes in the editor [#147817]
+ o don't crash if opening a file the second time when the first try failed [#141110]
+ o don't close the dialogs with ESC (just like in real applications)
+ o fix ExecButton.setEnabled() [#113624]
+ o use icon instead of "..." in the file selector [#109985]
+ o make @echo really work [#138705]
+ o add DCOP method to get the winID [#111161]
+ o add DCOP method to change the cursor to the wait cursor and back [#109630]
+
+Thu Sep 14 20:01:18 2006 - Michal Rudolf <mrudolf@kdewebdev.org>
+(actually imported from a work branch on Sep 29, 2007 by Andras Mantia <amantia@kde.org>)
+ o function str_findrev works now
+ o fix crash when diving by zero
+ o make function names case insensitive
+ o fix dcop() function (external DCOP) in new parser
+ o add missing EOLs to array_values()
+ o don't open files with no filename given
+ o fix crash on incorrect syntax in new parser
+ o fix input_file() function
+ o add switch/case to new parser
+ o fix importing tables with empty cells
+ o Kommander 1.3.0 (development branch) released
+
+Thu Sep 7 20:01:18 2006 - Andras Mantia <amantia@kde.org>
+ o fix crash on exit in the editor
+
+Tue Sep 5 16:19:40 2006 - Andras Mantia <amantia@kde.org>
+ o use KTextEditor for the associated text editing
+
+Sun 16 sty 2005 00:44:39 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o add MessageLog to view output of dialogs run from Editor
+ o add @debug command
+
+Tue 11 sty 2005 23:00:00 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o update and unify version number
+ o Kommander 1.1dev3 released
+
+Sun 09 Jan 2005 15:22:05 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added support for Kommander dialog templates in Editor
+
+Tue 04 Jan 2004 14:30:00 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o implemented "Save All" files menu command
+ o implemented SingleShot option of Timer widget
+
+Thu 30 Dec 2004 14:00:32 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added setColumnCaption for TreeWidget
+
+Wed 29 Dec 2004 09:58:00 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added some new function for Table widget: removeRow,
+ removeColumn, setColumnCaption, setRowCaption
+ o fixed a bug with insertRow/insertColumn (incorrect number
+ of rows/columns inserted)
+ o added example of using Table widget to examples/tutorial
+
+Mon 20 Dec 2004 22:02:00 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added basic Table widget
+ o more Editor cleanup - remove obsolete code
+
+Sat 18 Dec 2004 22:17:00 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o remove obsolete include files and switch Editor to use
+ KMessageBox instead of QMessageBox
+
+Mon 13 Dec 2004 13:58:00 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o more flexible error handling: now you can continue, continue
+ ignoring next error, or stop application
+
+Fri 10 Dec 2004 19:00:00 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o compilation fix (solved problems with missing kmdrpligins link)
+
+Thu 09 Dec 2004 22:59:00 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fixed problems with hiding ActionEditor
+
+Thu 02 Dec 2004 21:54:00 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o bug fixed: accept 0 as false value.
+ o significant speedup of TreeWidget.setText/insertItem for large trees
+
+Sun 28 Nov 2004 19:48:00 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o remove obsolete CustomWidget code
+ o fixed a nasty bug in && evaluation
+
+Sun 21 Nov 2004 18:19:49 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o bug fixed: opening files from command-line
+ o granted addUniqueItem for Combos
+ o use KDE-based tools layout (KDockWidget) in Editor
+
+Fri 19 Nov 2004 13:48:45 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added signal finished(), emitted when Konsole process finishes
+ o remove obsolete signal from ScriptObject
+
+Tue 16 Nov 2004 23:28:16 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o Editor shortcuts can be configured and remembered
+ o Editor Recent files submenu is now KDE based
+ o Editor configuration file is a standard KDE config file
+ o Editor has now Settings menu
+ o some obsolete Editor options were removed
+
+Sun 14 Nov 2004 22:39:38 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o massive cleanup and KDE-ification of Editor
+ o most actions converted to KActions, some were standarized
+ o some obsolete dialogs removed
+ o About dialog changed to use KAboutDialog
+
+Wed 03 Nov 2004 14:28:39 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fix some problems detected by kdetestsscripts
+ o 1.1dev2 released
+
+Tue 02 Nov 2004 07:53:20 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o Signals and slots: disallow unmatched (signal, slot) connections.
+ Avoid duplicates in senders combo.
+
+Mon 01 Nov 2004 23:29:19 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o Signals and slots improved: slots that don't have any acceptable
+ signal in current sender are hidden now. For MainWindow dialogs,
+ actions are displayed together with widgets. Some rare crashes
+ were fixed. Connect/disconnect button should be properly
+ enabled/disabled now.
+ o Some tooltips for Function browser added.
+ o In Function Browser, don't add alone comma when optional
+ parameter is empty.
+ o Added missing %n in i18n() string in Function Browser.
+
+Sun 31 Oct 2004 22:14:13 CET - Michal Rudolf <mrudolf@kdewebdev.org>
+ o Complete rewrite of Signals & slots editor. All connections
+ are now displayed, it is possible to change both sender and
+ receiver without closing window. Both slots and signals
+ are sorted, more slots are filtered.
+
+Thu 28 Oct 2004 15:14:26 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added count() function for getting number of items in widget
+
+Wed 27 Oct 2004 23:58:56 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added <> and != for 'not equal to' condition in expressions
+
+Sun 24 Oct 2004 19:04:03 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added missing setMaximum for Slider
+
+Fri 22 Oct 2004 22:27:05 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added 'no-editor' FileSelector (only a button with configurable
+ caption)
+ o added warning for unmatched @if and @switch
+
+Tue 19 Oct 2004 23:23:28 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o Konsole now uses TextEdit widget
+ o improved EOL handling in Konsole
+ o compilation fixes
+
+Sat 16 Oct 2004 09:39:48 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fix: recognize floating-point numbers in @String.isNumber
+
+Thu 14 Oct 2004 12:06:05 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added Timer widget
+
+Wed 13 Oct 2004 12:29:13 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added missing 'checked' function for RadioButton
+ o added @String.findRev function for searching string backwards
+
+Tue 12 Oct 2004 14:00:03 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fix: don't add brackets to functions with no parameters
+
+Mon 11 Oct 2004 14:00:03 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o improved 'cancel'
+
+Sat 09 Oct 2004 16:54 PDT - Eric Laffoon <sequitur@kde.org>
+ o Edited specials text and added comment @# to function browser
+ o fixed function browser to support a fourth parameter
+
+Sat 09 Oct 2004 14:00:03 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fix: bug in @File.append
+ o In Function Browser show common widget functions for each widget
+ o scroll content when process output is longer; show hourglass
+ in Konsole widget when process is running
+ o added new command 'cancel' to cancel script running in Konsole
+
+Tue 05 Oct 2004 11:19:41 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fix: use "\n" as separator in multiselection mode of FileSelector
+ o preliminary version of Konsole widget
+
+Sat 02 Oct 2004 20:38:40 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added 'execute' command to ScriptObject widget
+ o fix: properly report failure when saving file and ask to
+ provide another file name
+
+Fri 01 Oct 2004 22:26:06 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fix: output was not sent to stdout by ExecButton
+
+Sat 28 Aug 2004 19:20:06 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fixed a crash in TreeWidget setText function
+ o added support for multiselection in ListBox (via selection
+ function)
+
+Tue 24 Aug 2004 11:00:16 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o Function Browser: don't show unnecessary 'widget' parameter
+ o Function Browser: make widget functions default
+ o Kommander Text Editor: focus on script text
+ o re-add new i18n descriptions for some new functions
+ o added new 'checked' function for checkboxes and buttonboxes
+ o bool values returned from DCOP calls are now supported
+
+Wed 18 Jul 2004 18:19:21 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o Kommander 1.0 released together with KDE 3.3
+
+Wed 04 Jul 2004 23:59:21 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added @switch..@case..@end statement
+ o added @if()...@endif statement
+
+Wed 04 Jul 2004 18:20:21 CEST - Eric Laffoon <eric@kdewebdev.org>
+ o fixed missing @ for Kommander functions in function browser
+
+Tue 03 Jul 2004 11:06:26 CEST - Eric Laffoon <eric@kdewebdev.org>
+ o added new background
+
+Mon 02 Aug 2004 23:58:01 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added DCOP-enabled Label and PixmapLabel widgets
+
+Sun 01 Aug 2004 17:32:11 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added support for string comparisons in @expr
+ o added support for floats in @expr
+
+Fri 30 Jul 2004 14:59:12 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added support for math expressions
+ o added @expr(string) function that parses and evaluates string
+
+Wed 28 Jul 2004 00:14:28 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fixed about.ui which caused problems due to some Designer
+ incompatibility
+ o fixed i18n: tab pages and wizard pages titles were not
+ translated
+ o added some missing i18n strings
+ o added option to specify i18n catalogue from command-line
+ (useful for application-related dialogs)
+
+Sat 24 Jul 2004 10:15:10 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o bug fixed: crash with non-existing item in ListBox
+ o bug fixed: blocking button with no script was not unblocked
+ o automatically set tree mode for Tree Widget when adding nestes items
+ o release 1.0beta1
+
+Fri 23 Jul 2004 19:54:26 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added hourclass cursor when invoking ExecButton script with blocked GUI
+ o added missing i18n strings for *.ui files
+ o changed editor to use included background
+
+Fri 23 Jul 2004 18:34:26 CEST - Eric Laffoon <eric@kdewebdev.org>
+ o added new background and splash
+
+Thu 22 Jul 2004 22:17:49 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o ExecButton now has three modes: no blocking, block only ExecButton,
+ block whole GUI
+
+Wed 22 Jul 2004 24:10:59 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o optimized Tree Widget
+ o bug fixed: some missing i18n strings
+
+Tue 20 Jul 2004 19:51:32 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o bug fixed: @dcop with more than 4 arguments
+ o bug fixed: in @forEach, @var_count has incorrect value
+ o in @forEach, @var_index has now 1-based index, not 0-based
+ o setMaximum for ProgressBar
+
+Mon 19 Jul 2004 11:47:58 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added ScriptObject - hidden script container
+
+Fri 16 Jul 2004 15:37:41 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added Slider widget
+ o removed some obsolete code from editor
+
+Thu 15 Jul 2004 23:22:33 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added TextBrowser widget for rich text viewing, with clickable
+ links
+ o in @forEach, not only @var, but @var_index and @var_count are
+ expanded (first to index of current item, second to item count)
+ o bug fixed: incorrect version number in Editor
+
+Wed 14 Jul 2004 12:22:33 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added @String.args (based on Qt QString("%1").arg()
+ o support parameters in function browser
+
+Tue 13 Jul 2004 22:33:19 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added support for internationalization of Kommander dialogs
+ o added @i18n special for marking strings for translation
+
+Tue 13 Jul 2004 13:33:00 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o function browser: support for nested functions
+ o function browser: properly prefix function groups with @
+ o function browser: add information about obligatory and optional
+ parameters.
+ o function browser: add clear button
+ o Kommander Text Editor: change buttons order
+
+Tue 13 Jul 2004 01:10:34 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added function browser for editor
+
+Sat 10 Jul 2004 15:51:07 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o forEach(variable, list) function for internal loops
+ o for(variable, start, end, [step]) function for internal loops
+ o Kommander 1.0alpha7 released
+
+Fri 09 Jul 2004 17:39:43 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o TreeWidget optimized - it should be much faster for big trees now
+ o bug fixed: TreeWidget findItem function
+
+Thu 09 Jul 2004 13:27:47 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o StatusBar widget added
+ o ProgressBar widget added
+ o widgets icons updated
+ o removed obsolete ListView widget
+
+Tue 06 Jul 2004 10:12:44 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o bug fixed: calling @dcop with parameterless functions
+ o bug fixed: ListBox.setCurrentItem didn't work
+ o added setCurrentItem for ComboBox
+ o added setCurrentItem/currentItem for TabWidget, remove obsolete
+ text and setText
+ o bug fixed: itemDepth and itemPath
+ o bug fixed: adding items to TreeWidget failed sometimes
+ o added @String.section(string, substring, index) function, returning
+ section of a string
+ o added third (optional) index parameter to @String.find
+
+Fri 02 Jul 2004 23:33:46 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o more TreeView methods: itemDepth(index) and itemPath(index)
+ o setText, text and populate work for TreeView
+ o parser cleanup and fixes
+ o setPixmap(iconName, index) method for ListBoxes and TreeViews;
+ use index = -1 to set pixmaps for all items
+ o Kommander 1.0alpha6 released
+
+Thu 01 Jul 2004 16:03:20 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o add children(QString widget) DCOP call, returning list of
+ widgets that are direct children of the widget (or all widgets
+ if widget is null)
+ o added type(QString widget) DCOP call returning class of widget
+ o bug fixed: main dialog wasn't supported in @Widget.method syntax
+ o QStringList is now supported as DCOP return value
+
+Wed 30 Jun 2004 15:01:23 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o TreeView DCOP methods: insertItem(), insertItems(), clear(),
+ item(), setCurrentItem(), selection(), setSelection(),
+ removeItem()
+ o TreeView tree support: use / to separate nodes (f. e.
+ insertItem("Root/Node/Subnode")
+ o TreeView multiple column support: use \t to separate columns
+ (f. e. insertItem("document.txt\t45kb\t2004-06-30")
+
+Tue 29 Jun 2004 00:44:39 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o all DCOP functions are handled in appropriate widgets
+ o DCOP and specials are now registered together in single class
+ o it is now possible to create new methods for new (plugin) widgets
+ o setVisible() DCOP method added (show/hide widgets)
+ o setText() alias for changeWidgetText
+ o insertItem() alias for addListItem
+ o insertItems() alias for addListItems
+ o setEnabled() alias for enableWidget
+ o setCurrentItem() for setting current item on index base
+ o selection() for getting selected text/text of selected item
+ o setSelection() for setting selected text/text of selected item
+ (alias for setCurrentListItem() for ListBoxes)
+ o text() DCOP method to get content of widget
+ (@SomeWidget.text is equivalent to @SomeWidget with default script
+ set to @widgetText)
+ o clear() DCOP method handles LineEdit, TextEdit and FileSelector now
+ o text()/setText() work for spinbox
+
+Mon 21 Jun 2004 13:36:52 CEST - Eric Laffoon <eric@kdewebdev.org>
+ o added documentation
+
+Sat 19 Jun 2004 00:47:42 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added changeWidgetText support for listboxes and combos
+ o security fix: warning when running from /tmp directory
+ o added @null special
+ o Kommander 1.0alpha5 released
+
+Thu 17 Jun 2004 23:13:18 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added @String.find
+ o added specials descriptions
+ o fix: crash when opening main-window dialog (created in Designer)
+ in executor
+
+Wed 16 Jun 2004 13:04:30 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added @Array.count
+ o added @Array.read/write
+
+Tue 15 Jun 2004 23:24:52 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added file functions (@File: read, write, append)
+ o added warning for empty @Widget text
+
+Mon 15 Jun 2004 18:32:01 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added string-handling functions (@String: left, right,
+ contains, left, right, mid, compare, isEmpty, isNumber,
+ remove, replace, lower, upper)
+
+Mon 14 Jun 2004 10:23:12 CEST - Eric Laffoon <eric@kdewebdev.org>
+ o fix: parentPid bug
+ o fix: execBegin bug
+
+Sat 12 Jun 2004 01:49:07 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added more array functions: @Array.values(), @Array.clear()
+ and @Array.remove()
+ o rebuild parser to made it more flexible
+ o fix: FileSelector now opens file dialog in current directory
+ o added two new DCOP functions for ListBoxes: findItem()
+ and addUniqueItem()
+ o ButtonGroup now has 'checked' and 'unchecked' states, it
+ also supports setChecked()
+ o Kommander 1.0alpha4 released
+
+Thu 10 Jun 2004 00:49:07 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added DCOP information database that translates function
+ name to function prototype
+ o enhanced parser to handle @<widget>.<DCOP function> syntax
+
+Mon 07 Jun 2004 14:45:53 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added assotiative arrays: @Array.value(), @Array.keys() and
+ @Array.setValue() specials
+
+Sun 06 Jun 2004 23:13:34 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fix compilation problems on Debian and Slackware
+ o @@ is now interpreted as @
+
+Sat 05 Jun 2004 10:12:05 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added @env(variable) special to get environment variable value
+ o added @dialog(dialog, params) that would call child dialog, setting
+ _PARENTPID and _PARENTDCOPID variables for it
+ o check for global variable _PARENTPID when getting @parentPid
+ o added _KMDIR and _NAME global variables that return
+ path/filename of current dialog
+ o @dialog now searches for a dialog in both dialog path
+ and current path
+ o parser fixes (improved handling of nested specials)
+ o Kommander 1.0alpha3 released
+
+Fri 04 Jun 2004 00:40:59 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o fixed: don't execute Initialization/Executor in Editor
+ o changed DCOP id of Editor to kmdr-editor
+ o version numbers unified
+
+Thu 02 Jun 2004 15:08:32 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o KDE widgets are now used for lists, buttons and combos
+ o added file completion to FileSelector
+
+Fri 28 May 2004 22:40:10 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o support for Kommander comments (in @# <comment> format)
+ o added two new specials: global(var) and setGlobal(var, value)
+ o removed obsolete Preview menu commands
+ o Kommander 1.0alpha2 released
+
+Wed 26 May 2004 23:22:46 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o changeWidgetText for FileSelector class is now handled
+ o added currentItem(QString) DCOP call for lists and combos
+ o added item(QString,int) DCOP call for lists and combos
+
+Wed 26 May 2004 01:10:01 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o parser of specials() rewritten
+ o added optional shebang argument for execBegin()
+ o handling of non-string @dcop() arguments fixed
+ o handling of multiple @dcop() arguments fixed
+ o Makefile.am dependencies for executor cleaned
+ o Kommander 1.0alpha1 released
+
+Thu Apr 27 2004 16:38:36 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added @parentPid evaluated to parent process pid
+ o install Kommander Editor and Executor desktop files
+
+Thu Apr 20 2004 16:38:36 CEST - Michal Rudolf <mrudolf@kdewebdev.org>
+ o added @pid evaluated to current process pid
+ o added @dcopid evaluated to current process DCOP id
+ o rebuilt Kommander Text editor
+ o added support for shebang (#!/bin/sh) for both ExecButton
+ script and @execBegin scripts
+ o added ChooseWidget dialog
+
+Thu Jan 29 13:48:49 2004 - Andras Mantia <amantia@kde.org>
+ o DCOP methods for modifying the widgets
+
+Sat Nov 1 17:00:03 AEST 2003
+ o New widget plugin system KommanderPlugin and KommanderFactory
+
+Sun 04 May 2003 07:38:42 PM EEST - Andras Mantia <amantia@kde.org>
+ o do not add the .kmdr extension to files ending with .kmdr
+ o remove some warning/error messages polluting the output
+ o flush the stdout buffer after writing to it
+
+Sat Sep 28 23:18:08 EST 2002 - Marc Britton <consume@optushome.com.au>
+ o Cleaned up and reworked file overview window
+ o Removed 'Source File' tab from hierarchy view
+ o Removed more disabled source files
+ o Now searches for templates in custom directory (default $KDEDIR/templates)
+
+Sun Sep 15 15:31:48 EST 2002 - Marc Britton <consume@optushome.com.au>
+ o Initial Creation
diff --git a/kommander/INSTALL b/kommander/INSTALL
new file mode 100644
index 00000000..e7c19dfc
--- /dev/null
+++ b/kommander/INSTALL
@@ -0,0 +1,186 @@
+2002-10-12 - Preview building instructions
+To build Kommander you need to created a link to the admin directory
+in the kommander directory. Then treat Kommander as a base direactory
+and run make -f Makefile.cvs and do your configure and amake.
+
+Basic Installation
+==================
+
+ These are generic installation instructions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+ The file `configure.in' is used to create `configure' by a program
+called `autoconf'. You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system. If you're
+ using `csh' on an old version of System V, you might need to type
+ `sh ./configure' instead to prevent `csh' from trying to execute
+ `configure' itself.
+
+ Running `configure' takes awhile. While running, it prints some
+ messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. You can give `configure'
+initial values for variables by setting them in the environment. Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+ CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+ env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory. After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+ By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc. You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on. Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+ CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+ If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+ Use and save the results of the tests in FILE instead of
+ `./config.cache'. Set FILE to `/dev/null' to disable caching, for
+ debugging `configure'.
+
+`--help'
+ Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made.
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--version'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
+
diff --git a/kommander/Kommander-TODO.kno b/kommander/Kommander-TODO.kno
new file mode 100644
index 00000000..ebbe5651
--- /dev/null
+++ b/kommander/Kommander-TODO.kno
@@ -0,0 +1,313 @@
+\NewEntry 0 GUI
+
+\NewEntry 1 Widgets
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Widgets available in Kommander</span></p>
+<ul type="disc"><div></div>
+<li>KJanusWidget</li>
+<li>Switch from using Qt widget to their KDE equivalents? - mostly done</li>
+<li>Menu</li>
+<li>KHistoryCombo<br /></li>
+<div></div></ul>
+<p></p>
+<ul type="disc"><div></div></ul>
+</body></html>
+
+\NewEntry 1 Editor
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Layout of Edit Kommander Text dialog<br /><br />Old ideas:</span></p>
+<ul type="disc"><li>better layout</li>
+<li>replace list of widgets with tree of widgets</li>
+<li>replace widget class with widget pixmap in combos</li>
+<li>redesign layout</li>
+<li>cleanup Connections, not it is unusable, may be obsolete</li>
+<li>find in scripts</li>
+<li>list of non-empty scripts for current dialog</li>
+<li>allow using custom Kommander dialog to generate code</li>
+<li>add DCOP per widget display</li>
+<li>DCOP editor (similar to Tag editor in Quanta)<br /></li></ul>
+<p></p>
+</body></html>
+
+\NewEntry 1 Usability
+\Link knowit://Source code
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Various GUI-related features (outdated, KDE3 version will not be changed)</span></p>
+<ul type="disc"><li>clean up popup menus, remove disabled items</li>
+<li>use KDE dialogs, not Qt ones if possible</li>
+<li>some widget information on mouseover</li>
+<li>review of event model</li>
+<li>add more layout-handling commands (center selected widgets horizontally/vertically, fit to window width/height)</li>
+<li>handle middle click</li>
+<li>carefully check defaults, choose most useful ones</li>
+<li>add wizards? (replace current New dialogs with Kommander-based ones?)</li>
+<li>better undo</li>
+<li>add WhatsThis for most items</li>
+<li>detect function name/widget name clash</li>
+<li>improve order of widget icons</li>
+<li>switch to KMDI (arghhhh!)</li></ul>
+</body></html>
+
+\NewEntry 1 Run/debug
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Running/testing inside Editor</span></p>
+<ul type="disc"><li>allow debugging</li>
+<div></div></ul>
+</body></html>
+
+\NewEntry 1 DCOP browser
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Georgia">
+<p><span style="font-weight:600">DCOP browser (preliminary ideas)</span></p>
+<ul type="disc"><li>DCOP browser for both local and external DCOP calls</li>
+<li>easy-to-use application DCOP browser</li>
+<li>use XML describing given application DCOP's</li>
+<li>two flags for a call: hiden and important</li>
+<li>three mode: important (only important calls), default (all except hidden), advanced (all calls)</li>
+<li>use some pattern matching to allow marking whole subtrees or function sets</li>
+<li>add purpose (for example all editor-related functions, all file-management-related functions)</li>
+<li>merge trees for given window (f. e. Editor#2, File#2, Structure#2 etc.)</li>
+<li>standalone application mode</li></ul>
+</body></html>
+
+\NewEntry 1 Other
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Other GUI-related issues</span></p>
+<ul type="disc"><li>cleanup slots/signals/connections interface</li>
+<li>find out why slots are shown only for current tab<br /></li></ul>
+<p><span style="font-weight:600">KDE4 ideas:<br /></span></p>
+<ul type="disc"><li>create a KDevelop plugin for the editor</li>
+<li>use KFormDesigner or the new Qt Designer</li></ul>
+</body></html>
+
+\NewEntry 0 Bugs
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Various bugs to be fixed</span></p>
+<ul type="disc"><li>Charset is sometimes incorrectly converted from/to local charset</li>
+<li>SubDialog crashes now</li>
+<li>Labels do not show up unless you edit their text</li>
+<li>toolbox editing is ugly after group layout is applied. Goes back to normal if the dialog is reloaded.</li>
+<div></div></ul>
+</body></html>
+
+\NewEntry 0 Help
+
+\NewEntry 1 Documentation
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Kommander tutorials, documentation etc.</span></p>
+<ul type="disc"><li>Update new parser docs</li>
+<li>Update docs, at least on website ?</li></ul>
+</body></html>
+
+\NewEntry 1 Examples
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Georgia">
+<p><span style="font-weight:600">Examples to be used with tutorial</span></p>
+<ul type="disc"><li>add a way to comment *.kmdr file</li>
+<li>create examples for tutorial</li>
+<li>clean up examples: reomve obsolete or unclear ones, add some more instructive ones</li></ul>
+</body></html>
+
+\NewEntry 1 Scripts
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Georgia">
+<p><span style="font-weight:600">Kommander scripts that can be useful</span></p>
+<ul type="disc"><li>improve script for Quick Start (Quanta): handle indentation with, quotation character and tag case</li>
+<li>create script for Quick List (Quanta)</li>
+<li>create scripts for common command-line programs to demonstrate power of Kommander (it would be nice if those could be documented somehow)</li>
+<li>create scripts for HTML templates</li></ul>
+<p></p>
+<p></p>
+</body></html>
+
+\NewEntry 0 Language
+
+\NewEntry 1 Syntax
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Georgia">
+<li type="disc"><span style="font-weight:600">Syntax-related problems</span></li>
+<ul type="disc"><li>better handling of lists</li>
+<li>better handling of other structures (trees, arrays etc.)</li>
+<li>add some way to define and use macros/aliases</li></ul>
+<p></p>
+<p></p>
+</body></html>
+
+\NewEntry 1 New functions
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">New functions that could be useful</span></p>
+<ul type="disc"><li>capitalize, substring string handling functions?</li>
+<li>@if (a, b, c)? - or is BASH enough?<br /><span style="font-style:italic">This will be solved by new parser.</span></li>
+<li>add @include and @includelocal commands - to include external script or local (project script); that should make code more readable</li>
+<li>add @call to call local script (no need for external @call, as it is equivalent to @exec<br /><span style="font-style:italic">Naming: use @execlocal for consistency?</span></li>
+<li>add @requireVersion(command, version) that would detect version of program (presumably script language, like perl), compare it to given minimum and fail if it is not matched</li>
+<li>add function for string conversion (@String.cvs2tab, @Stringcvs2eol ...)</li>
+<li>add @ldcop for calling local DCOP functions</li></ul>
+</body></html>
+
+\NewEntry 1 Script languages
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Using script languages other than Bash</span></p>
+<ul type="disc"><li>detect incorrect path at shebang, allow user to choose correct one and remeber that pair</li>
+<div></div>
+<div></div></ul>
+<p><span style="font-weight:600">If we keep the old parser.<br /><br /></span><br />Make it possible to use any language with Kommander. The idea is to replace Kommander specials with language specific code in a way that it will not break conditions and loops, like now. example:<br />#!/bin/bash<br />array=&quot;1 2 3 4 5&quot;<br />for i in $array do<br /> @Label.setText($i)<br />done<br /><br />This does not work now. The idea is to replace @Widget.method() with a language specific DCOP call.<br />If the language has DCOP bindings, use those bindings to execute the dcop call. If not, use the command line<br />DCOP application. This is slower, but always works. In the above case, Kommander would replace <br />@Label.setText($i) <br />with<br />dcop kmdr-executor-PID KommanderIf setText Label $i<br /><br />Kommander will have description files for each supported language about how to execute DCOP calls.<br />If the language has DCOP bindings, this description tells the syntax of the bindings. If it doesn't have, the description gives a way how to execute external applications. This should always exists, as all languages can execute external applications.<br /><br />In KDE4, of course use DBUS instead of DCOP.<br /><br /></p>
+</body></html>
+
+\NewEntry 1 Aliases
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Georgia">
+<p><span style="font-weight:600">Aliases - easier access to Kommander features</span></p>
+<ul type="disc"><li>add @String.&lt;function&gt;(&lt;args&gt;) as alias to string-handling function</li>
+<li>add @&lt;widgetName&gt;.&lt;function&gt;(&lt;args&gt;) as alias to dcop @dcopid KommanderIf &lt;widgetName&gt; &lt;args&gt;</li>
+<li>add aliases to various widgets properties, f. e. text, selectedText, state, items etc.; syntax: @&lt;widgetName&gt;.&lt;attribute&gt;</li></ul>
+</body></html>
+
+\NewEntry 1 Signals
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Georgia">
+<p><span style="font-weight:600">New signals for existing widgets</span></p>
+<ul type="disc"><li>add signals for D&amp;D<br /><span style="font-style:italic">Requires dragContent and dragType, perhaps dragSource to be set.</span></li>
+<li></li></ul>
+</body></html>
+
+\NewEntry 1 Parser
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Features of new parser</span></p>
+<ul type="disc"><li>add syntax checking</li>
+<li>add debugger</li>
+<li>add step-by-step running</li>
+<li>add code-completion</li>
+<li>add syntax hints</li>
+<li>share code betwen the two parsers (new methods are needed to be added only once)</li></ul>
+</body></html>
+
+\NewEntry 0 1.3 release prep 2008
+
+\NewEntry 1 To Do
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Kommander Release Do list</span></p>
+<ul type="disc"><li><span style="color:#00ff00">Add missing functions in FB</span></li>
+<li>KPart create to go with KPart load</li>
+<li><span style="color:#ff0000">executor version required field/command - enable someone sharing dialogs to have an executing window check if the executor is capable of fully supporting it - Not the self checking Michal suggested, but better than nothing by far</span></li>
+<li><span style="color:#ff0000">ability to identify calling table widget from signal in a script slot - ideally by row and column in table grid </span></li></ul>
+</body></html>
+
+\NewEntry 1 Eric's To Do
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<ul type="disc"><li>Look into project tools, currently ready for 0.7 update</li></ul>
+</body></html>
+
+\NewEntry 1 Supplemental
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<ul type="disc"><li>We need to look at how to emulate KStfuff using HTTP and a Kommander dialog... will require KStuff back end and some PHP scripts</li>
+<li>Samples go into the install for use</li>
+<li>Web site needs docs and tutorials updated</li></ul>
+</body></html>
+
+\NewEntry 1 investigate
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Things to look into</span></p>
+<ul type="disc"><li>Qt database connection?</li>
+<li><span style="color:#ffff00">Code completion? If easy to do, otherwise we recommend users try the Kate completion plugin</span></li>
+<li><span style="color:#ffff00">D&amp;D of text/selection data</span></li>
+<li>simple DCOP functions in editor to enable Kommander based tools to call the editor and open a dialog to edit - otherwise any interfaces can at least make use of D&amp;D from file manager (KPart) views</li>
+<li><span style="color:#ff0000">Additional XML fields in dialog for author name, version of Kommander required, etc... - not required as KAbout would be better</span></li></ul>
+</body></html>
+
+\NewEntry 1 Bugs to squish
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Version 1.3 FIXME list</span></p>
+<ul type="disc"><li>link handling in TextBrowser opens file manager in execute directory even if calling another Kommander dialog. First it opens the file, then konqeror.</li></ul>
+</body></html>
+
+
+\NewEntry 1 Done
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p>New widgets include the DatePicker, Popup Menu and Toolbox. New functions inlcude widget creation, hooking and unhooking signals and slots and full slot access as well as passing and returning parameters in scripts. WooHoo! Take that do list!<br /></p>
+<ul type="disc"><li>fixed dcop functions</li>
+<li>added indexed array functions</li>
+<li>made color slot work in TextEdit</li>
+<li>Enhnaced function browser for easier widget creation</li>
+<li>quote handling in function browser - made user selectable</li></ul>
+<p>See changlog for more complete list</p>
+</body></html>
+
+\NewEntry 1 Won't Do
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p>The Kommander editor is effectively dead for KDE3. Porting is senseless as it is an old Qt Designer hack. Since Designer for Qt 4x is actually designed this time to be easy to extend and modify the first generation of the editor will be scrapped.<br /><br />Other parts of Kommander like the parser should be much more portable.<br /><br /> - creating table widgets means if you need to know the calling widget you need create scripts on the fly for this.</p>
+</body></html>
+
+\CurrentEntry 0 KDE4 prep
+
+\NewEntry 0 Executor
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Executing Kommander scripts</span></p>
+<ul type="disc"><li>detect and handle missing plugin widgets</li>
+<li>cache @pid, @dcopid, @parentPid, perhaps calculate and cache @parentdcopid</li>
+<li>handle multiple dialogs: they could be packaged in single *.tgz file, unpacked and executed internally</li>
+<div></div>
+<div><br /></div></ul>
+</body></html>
+
+\NewEntry 0 Refactoring, other ideas
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
+<p><span style="font-weight:600">Kommander source code</span></p>
+<ul type="disc"><li>move all widgets into a library (mostly done)</li>
+<li>widgets should contain the code how they are displayed in the editor</li>
+<li>widgets should contain the functions they support. Share only very common functions, like show, execute, etc, otherwise soon it becomes confusing if insertItem expect and int, a string, or and int and a string. </li>
+<li>widgets and plugin should query the plugin manager for available method IDs (and register how many they need) OR on registering do not pass the ID, but get back. This makes sure you don't have plugins/widgets using the same function IDs. </li>
+<li>check if we can live without making specials.h public</li>
+<li>the icons used in the editor should be returned by the widgets itself (partly done)</li>
+<li>check if it is enough to have a public KommanderWidget instead of making KWidgetPlugin as well public</li>
+<li>get back a version number from plugins and from Kommander. This way both the plugins and the executor can decide if they are compatible or not.</li></ul>
+</body></html>
+
+\NewEntry 0 Last changes
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Georgia">
+<p><span style="font-weight:600">Last changes in TODO file</span></p>
+<ul type="disc"><li>remove done items</li></ul>
+<p><span style="color:#0000ff">2004-05-28, 17:35</span></p>
+<ul type="disc"><li>GUI/Widgets: Tree, History Combo, Picture Viewer, Table</li>
+<li>GUI/Other added</li>
+<li>Executor: handle multiple dialogs package</li>
+<li>Language/New functions: string conversion</li>
+<li>Language/Signals added</li></ul>
+<p><span style="color:#0000ff">2004-05-14, 12:44</span></p>
+<ul type="disc"><li>Bugs: added</li>
+<li>Language/New functions, Executor: added i18n</li></ul>
+<p><span style="color:#0000ff">2004-05-08, 23:00</span></p>
+<ul type="disc"><li>Widgets: Menu and popup menu</li>
+<li>added Language:Aliases</li>
+<li>Syntax: remove @dcop, moved aliases to new note, macros</li>
+<li>Editor: Connections</li>
+<li>New functions: @requireVersion</li>
+<li>Executor: detect loop, handle startup parameters, cache</li></ul>
+<p></p>
+</body></html>
+
+\NewEntry 0 Done
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Georgia">
+<li type="disc"><span style="font-weight:600">ChangeLog of Kommander</span></li>
+<li type="disc"><span style="font-style:italic">See ChangeLog file for details and dates</span></li>
+<ul type="disc"><li>added @parentPid evaluated to parent process pid</li>
+<li>added @pid evaluated to current process pid</li>
+<li>added @dcopid evaluated to current process DCOP id</li>
+<li>significantly improved Kommander Text editor usability</li>
+<li>added <span style="font-style:italic">initialization</span> and <span style="font-style:italic">destroy</span> scripts for main dialog</li>
+<li>global variables added (setGlobal and global DCOP calls)</li>
+<li>added support for shebang (#!/bin/sh) for both ExecButton script and @execBegin scripts</li>
+<li>added command-line parameters (<span style="font-style:italic">kmdr-executor dialog.kmdr VAR=VALUE ARG1 ARG2...)</span></li>
+<li>dialog setting are now stored with full path</li>
+<li>completely rebuilt @dcop() parser: check number of arguments, handle various types etc.</li>
+<li>support for @execBegin(&lt;program-name&gt;)</li>
+<li>avoid infinite loop when trying to run @&lt;widget&gt; inside &lt;widget&gt;:&lt;state&gt;</li>
+<li>handle other values for DCOP (not only <span style="font-style:italic">string</span> and <span style="font-style:italic">int</span>)</li>
+<li>add option to pass shebang as argument of @execBegin, f. e. @execBegin(/usr/bin/perl)</li>
+<li>add Run command to editor</li>
+<li>added global and setGlobal specials</li>
+<li>added warnings for missing specials</li>
+<div></div></ul>
+</body></html>
+
+\NewEntry 0 About this file
+<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:11pt;font-family:helvetica">
+<p>This file should document both what should be done in Kommander and what was done.</p>
+<p>All entries marked with a date without an author were made by Michal Rudolf</p>
+<p>When adding something important, please enter it in ChangeLog or Done and mark it with current date (in yyyy-MM-dd, hh:mm format) and your name.</p>
+</body></html>
+
diff --git a/kommander/Makefile.am b/kommander/Makefile.am
new file mode 100644
index 00000000..936bca9b
--- /dev/null
+++ b/kommander/Makefile.am
@@ -0,0 +1,15 @@
+SUBDIRS = icons plugin \
+ factory widget widgets \
+ pluginmanager editor executor part working examples kmdrtools
+
+mimetypedata_DATA = x-kommander.desktop
+mimetypedatadir = $(kde_mimedir)/application
+
+messages: rc.cpp
+ $(EXTRACTRC) `find . -name \*.ui` >> rc.cpp ; \
+ LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \
+ if test -n "$$LIST"; then \
+ $(XGETTEXT) $$LIST -o $(podir)/kommander.pot; \
+ fi;
+
+
diff --git a/kommander/NEWS b/kommander/NEWS
new file mode 100644
index 00000000..6c2f9bb5
--- /dev/null
+++ b/kommander/NEWS
@@ -0,0 +1 @@
+No news is good news.
diff --git a/kommander/README b/kommander/README
new file mode 100644
index 00000000..7de24937
--- /dev/null
+++ b/kommander/README
@@ -0,0 +1,70 @@
+Kommander v1.0Alpha series
+Eric Laffoon <sequitur@kde.org>
+----------------------------------------------------------------------
+Kommander is a visual dialog building tool which may be expanded to create
+full mainwindow applications. The primary objective is to create as much
+functionality as possible without using any scripting language. This is
+provided by the following features:
+* Specials - these are prefaced with an "@" like @widgetText. The offer
+special features like the value of a widget, functions, aliases, global
+variables and such.
+* DCOP integration - this allows Kommander dialogs to control and be
+controled in interactions with other KDE applicatins. It is a very powerful
+feature!
+* Signals and Slots - this is a little less intuitive to a new user. It is
+under review for how we process things in the first major release. These
+offer a limited event model for when a button is pushed or a widget is
+changed. Combined with "Population Text" it is rather powerful.
+
+The central key feature of Kommander dialogs is that you can bind text
+(Kommander Text) to a widget. So if you have @widget1 and @widget2 and
+they are line edits you can set Kommander to show their contents by
+entering @widgetText in their Kommander Text area. Then enter hello in
+@widget1 and world in @widget2. A button can have the string
+My first @widget1 @widget2 program in Kommander
+If you run this dialog from a console it will output
+My first hello world program in Kommander
+
+Hopefully you begin to see a small glimmering of the potential. Kommander
+enables a much faster design model for simple applications because if allows
+you to stop thinking so much about language and revert to the more basic and
+natural conceptual model. In computers language is a means to define concepts
+and as such it is a layer between concept and implementation that can impede
+progress with minutia. Kommander seeks to minimize that layer.
+
+Kommander also seeks to build on standards. It is built on the Qt Designer
+framework and creates *.ui files which it renames to *.kmdr. It can easily
+import any KDE widget and this can be done without having to rebuild
+Kommander, by using plugins.
+
+Kommander's other significant factor is how it addresses the requirements of
+language. Computer languages can be wonderful things but they tend to have
+their own dogmas and zealots often seeking to provide an advance to GUI
+design in an integrated development environment. Ironically the accpetance
+of such IDEs is limited by the number of people willing to adopt a new new
+language to gain access to a desired feature. It is really not reasonable to
+expect people to need to change over to a dozen languages to access various
+feature sets. By being language neutral and allowing a Kommander dialog to be
+extended by using any scripting language Kommander positions it's self in a
+unique position for wide spread adoption. Multiple script languages can be
+used in a single dialog and applications can be taken over by people using
+a different language than the original developer and gradually converting
+and extending it. New widgets and featurs can be instantly leveraged by all
+available languages.
+
+We hope that Kommander begins to get the developer support and recognition
+required to achieve the potential it offers. Our end goal is to make Kommander
+useful for novice users to extend and merge their applications. At the same
+time it should become a good prototyping tool. Also it opens the door to the
+promise of open source in a new way. We know that people can extend our GPL'd
+prgrams, but the fact remains very few have the skills. With Kommander those
+numbers see a huge multiplier! Some applications may be most logical as a
+Kommander application. We already use it in areas we want to allow
+extensibility in Quanta Plus.
+
+We hope you enjoy Kommander. Please help us with bug reports and example
+dialogs, as well as any requests you may have. You can join our user list
+for help developing Kommander applications at
+http://mail.kdewebdev.org/mailman/listinfo/kommander
+
+Best Regards from the Kommander development team!
diff --git a/kommander/VERSION b/kommander/VERSION
new file mode 100644
index 00000000..fc89135a
--- /dev/null
+++ b/kommander/VERSION
@@ -0,0 +1 @@
+Kommander 1.2.2
diff --git a/kommander/configure.in.in b/kommander/configure.in.in
new file mode 100644
index 00000000..6d8c8d93
--- /dev/null
+++ b/kommander/configure.in.in
@@ -0,0 +1,14 @@
+CPPFLAGS="$CPPFLAGS -DKOMMANDER -DDESIGNER -DQT_NO_SQL -DHAVE_KDE"
+
+# Process user input to configure
+build_kommander="yes"
+AC_ARG_WITH(kommander,
+[ --without-kommander don't build Kommander],
+[if test "$withval" = "no" ; then
+ build_kommander="no"
+fi])
+
+if test "$build_kommander" = "no"; then
+ DO_NOT_COMPILE="$DO_NOT_COMPILE kommander"
+fi
+
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>
<