From 086012dcad8a976a0dabbb7cbc20c9cb612cdfa9 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 28 Aug 2025 22:44:34 +0900 Subject: Restructure source folders Signed-off-by: Michele Calgaro --- src/Makefile.am | 10 + src/app/ActionMan/Makefile.am | 14 + src/app/ActionMan/actionman.cpp | 60 + src/app/ActionMan/actionman.h | 37 + src/app/ActionMan/actionproperty.cpp | 470 +++++ src/app/ActionMan/actionproperty.h | 147 ++ src/app/ActionMan/actionpropertybase.cpp | 463 +++++ src/app/ActionMan/actionpropertybase.ui | 1116 +++++++++++ src/app/ActionMan/addplaceholderpopup.cpp | 582 ++++++ src/app/ActionMan/addplaceholderpopup.h | 322 ++++ src/app/ActionMan/useractionlistview.cpp | 232 +++ src/app/ActionMan/useractionlistview.h | 81 + src/app/ActionMan/useractionpage.cpp | 317 ++++ src/app/ActionMan/useractionpage.h | 74 + src/app/BookMan/Makefile.am | 11 + src/app/BookMan/kraddbookmarkdlg.cpp | 117 ++ src/app/BookMan/kraddbookmarkdlg.h | 40 + src/app/BookMan/krbookmark.cpp | 92 + src/app/BookMan/krbookmark.h | 46 + src/app/BookMan/krbookmarkbutton.cpp | 38 + src/app/BookMan/krbookmarkbutton.h | 24 + src/app/BookMan/krbookmarkhandler.cpp | 576 ++++++ src/app/BookMan/krbookmarkhandler.h | 64 + src/app/CMakeL10n.txt | 3 + src/app/Dialogs/Makefile.am | 22 + src/app/Dialogs/checksumdlg.cpp | 603 ++++++ src/app/Dialogs/checksumdlg.h | 54 + src/app/Dialogs/krdialogs.cpp | 255 +++ src/app/Dialogs/krdialogs.h | 116 ++ src/app/Dialogs/krkeydialog.cpp | 157 ++ src/app/Dialogs/krkeydialog.h | 38 + src/app/Dialogs/krmaskchoice.cpp | 179 ++ src/app/Dialogs/krmaskchoice.h | 77 + src/app/Dialogs/krpleasewait.cpp | 153 ++ src/app/Dialogs/krpleasewait.h | 84 + src/app/Dialogs/krprogress.cpp | 270 +++ src/app/Dialogs/krprogress.h | 87 + src/app/Dialogs/krspecialwidgets.cpp | 239 +++ src/app/Dialogs/krspecialwidgets.h | 129 ++ src/app/Dialogs/krspwidgets.cpp | 316 ++++ src/app/Dialogs/krspwidgets.h | 110 ++ src/app/Dialogs/krsqueezedtextlabel.cpp | 80 + src/app/Dialogs/krsqueezedtextlabel.h | 45 + src/app/Dialogs/kurllistrequester.cpp | 202 ++ src/app/Dialogs/kurllistrequester.h | 77 + src/app/Dialogs/newftpgui.cpp | 182 ++ src/app/Dialogs/newftpgui.h | 55 + src/app/Dialogs/packgui.cpp | 122 ++ src/app/Dialogs/packgui.h | 54 + src/app/Dialogs/packguibase.cpp | 468 +++++ src/app/Dialogs/packguibase.h | 110 ++ src/app/Dialogs/percentalsplitter.cpp | 193 ++ src/app/Dialogs/percentalsplitter.h | 59 + src/app/Dialogs/popularurls.cpp | 307 +++ src/app/Dialogs/popularurls.h | 86 + src/app/DiskUsage/Makefile.am | 17 + src/app/DiskUsage/diskusage.cpp | 1147 ++++++++++++ src/app/DiskUsage/diskusage.h | 206 ++ src/app/DiskUsage/diskusagegui.cpp | 227 +++ src/app/DiskUsage/diskusagegui.h | 90 + src/app/DiskUsage/dufilelight.cpp | 236 +++ src/app/DiskUsage/dufilelight.h | 81 + src/app/DiskUsage/dulines.cpp | 522 ++++++ src/app/DiskUsage/dulines.h | 79 + src/app/DiskUsage/dulistview.cpp | 293 +++ src/app/DiskUsage/dulistview.h | 145 ++ src/app/DiskUsage/filelightParts/Config.cpp | 50 + src/app/DiskUsage/filelightParts/Config.h | 37 + src/app/DiskUsage/filelightParts/Makefile.am | 9 + src/app/DiskUsage/filelightParts/debug.h | 14 + src/app/DiskUsage/filelightParts/fileTree.cpp | 78 + src/app/DiskUsage/filelightParts/fileTree.h | 299 +++ src/app/DiskUsage/radialMap/Makefile.am | 13 + src/app/DiskUsage/radialMap/builder.cpp | 139 ++ src/app/DiskUsage/radialMap/builder.h | 37 + src/app/DiskUsage/radialMap/labels.cpp | 342 ++++ src/app/DiskUsage/radialMap/map.cpp | 432 +++++ src/app/DiskUsage/radialMap/radialMap.h | 71 + src/app/DiskUsage/radialMap/segmentTip.cpp | 163 ++ src/app/DiskUsage/radialMap/segmentTip.h | 33 + src/app/DiskUsage/radialMap/sincos.h | 17 + src/app/DiskUsage/radialMap/widget.cpp | 199 ++ src/app/DiskUsage/radialMap/widget.h | 111 ++ src/app/DiskUsage/radialMap/widgetEvents.cpp | 241 +++ src/app/Filter/Makefile.am | 11 + src/app/Filter/advancedfilter.cpp | 711 +++++++ src/app/Filter/advancedfilter.h | 116 ++ src/app/Filter/filterbase.h | 51 + src/app/Filter/filterdialog.cpp | 87 + src/app/Filter/filterdialog.h | 61 + src/app/Filter/filtertabs.cpp | 133 ++ src/app/Filter/filtertabs.h | 81 + src/app/Filter/generalfilter.cpp | 536 ++++++ src/app/Filter/generalfilter.h | 107 ++ src/app/GUI/Makefile.am | 18 + src/app/GUI/dirhistorybutton.cpp | 82 + src/app/GUI/dirhistorybutton.h | 57 + src/app/GUI/dirhistoryqueue.cpp | 87 + src/app/GUI/dirhistoryqueue.h | 48 + src/app/GUI/kcmdline.cpp | 253 +++ src/app/GUI/kcmdline.h | 101 + src/app/GUI/kcmdmodebutton.cpp | 74 + src/app/GUI/kcmdmodebutton.h | 53 + src/app/GUI/kfnkeys.cpp | 133 ++ src/app/GUI/kfnkeys.h | 55 + src/app/GUI/krremoteencodingmenu.cpp | 207 +++ src/app/GUI/krremoteencodingmenu.h | 68 + src/app/GUI/krusaderstatus.cpp | 46 + src/app/GUI/krusaderstatus.h | 57 + src/app/GUI/mediabutton.cpp | 692 +++++++ src/app/GUI/mediabutton.h | 107 ++ src/app/GUI/profilemanager.cpp | 198 ++ src/app/GUI/profilemanager.h | 70 + src/app/GUI/syncbrowsebutton.cpp | 72 + src/app/GUI/syncbrowsebutton.h | 67 + src/app/KViewer/Makefile.am | 11 + src/app/KViewer/diskusageviewer.cpp | 129 ++ src/app/KViewer/diskusageviewer.h | 69 + src/app/KViewer/kimagefilepreview.cpp | 136 ++ src/app/KViewer/kimagefilepreview.h | 71 + src/app/KViewer/krviewer.cpp | 702 +++++++ src/app/KViewer/krviewer.h | 130 ++ src/app/KViewer/panelviewer.cpp | 307 +++ src/app/KViewer/panelviewer.h | 91 + src/app/Konfigurator/Makefile.am | 23 + src/app/Konfigurator/kgadvanced.cpp | 133 ++ src/app/Konfigurator/kgadvanced.h | 45 + src/app/Konfigurator/kgarchives.cpp | 157 ++ src/app/Konfigurator/kgarchives.h | 55 + src/app/Konfigurator/kgcolors.cpp | 633 +++++++ src/app/Konfigurator/kgcolors.h | 140 ++ src/app/Konfigurator/kgdependencies.cpp | 170 ++ src/app/Konfigurator/kgdependencies.h | 59 + src/app/Konfigurator/kggeneral.cpp | 214 +++ src/app/Konfigurator/kggeneral.h | 55 + src/app/Konfigurator/kglookfeel.cpp | 373 ++++ src/app/Konfigurator/kglookfeel.h | 70 + src/app/Konfigurator/kgprotocols.cpp | 419 +++++ src/app/Konfigurator/kgprotocols.h | 87 + src/app/Konfigurator/kgstartup.cpp | 117 ++ src/app/Konfigurator/kgstartup.h | 53 + src/app/Konfigurator/kguseractions.cpp | 106 ++ src/app/Konfigurator/kguseractions.h | 52 + src/app/Konfigurator/kgwelcome.cpp | 50 + src/app/Konfigurator/kgwelcome.h | 45 + src/app/Konfigurator/konfigurator.cpp | 220 +++ src/app/Konfigurator/konfigurator.h | 82 + src/app/Konfigurator/konfiguratoritems.cpp | 815 ++++++++ src/app/Konfigurator/konfiguratoritems.h | 428 +++++ src/app/Konfigurator/konfiguratorpage.cpp | 334 ++++ src/app/Konfigurator/konfiguratorpage.h | 523 ++++++ src/app/Konfigurator/krresulttable.cpp | 380 ++++ src/app/Konfigurator/krresulttable.h | 142 ++ src/app/Konfigurator/krresulttabledialog.cpp | 97 + src/app/Konfigurator/krresulttabledialog.h | 84 + src/app/Konfigurator/searchobject.cpp | 106 ++ src/app/Konfigurator/searchobject.h | 131 ++ src/app/KrJS/Makefile.am | 13 + src/app/KrJS/krjs.cpp | 89 + src/app/KrJS/krjs.h | 32 + src/app/Locate/Makefile.am | 7 + src/app/Locate/locate.cpp | 613 ++++++ src/app/Locate/locate.h | 101 + src/app/Makefile.am | 195 ++ src/app/MountMan/Makefile.am | 10 + src/app/MountMan/kdiskfreesp.cpp | 168 ++ src/app/MountMan/kdiskfreesp.h | 89 + src/app/MountMan/kmountman.cpp | 327 ++++ src/app/MountMan/kmountman.h | 103 + src/app/MountMan/kmountmangui.cpp | 396 ++++ src/app/MountMan/kmountmangui.h | 199 ++ src/app/Panel/Makefile.am | 29 + src/app/Panel/krbriefview.cpp | 1462 +++++++++++++++ src/app/Panel/krbriefview.h | 173 ++ src/app/Panel/krbriefviewitem.cpp | 225 +++ src/app/Panel/krbriefviewitem.h | 79 + src/app/Panel/krcalcspacedialog.cpp | 187 ++ src/app/Panel/krcalcspacedialog.h | 107 ++ src/app/Panel/krcolorcache.cpp | 761 ++++++++ src/app/Panel/krcolorcache.h | 102 + src/app/Panel/krdetailedview.cpp | 1588 ++++++++++++++++ src/app/Panel/krdetailedview.h | 181 ++ src/app/Panel/krdetailedviewitem.cpp | 313 ++++ src/app/Panel/krdetailedviewitem.h | 73 + src/app/Panel/krdrag.cpp | 103 + src/app/Panel/krdrag.h | 63 + src/app/Panel/krpopupmenu.cpp | 354 ++++ src/app/Panel/krpopupmenu.h | 78 + src/app/Panel/krpreviewpopup.cpp | 68 + src/app/Panel/krpreviewpopup.h | 49 + src/app/Panel/krselectionmode.cpp | 61 + src/app/Panel/krselectionmode.h | 97 + src/app/Panel/krview.cpp | 332 ++++ src/app/Panel/krview.h | 248 +++ src/app/Panel/krviewitem.cpp | 106 ++ src/app/Panel/krviewitem.h | 76 + src/app/Panel/listpanel.cpp | 1115 +++++++++++ src/app/Panel/listpanel.h | 212 +++ src/app/Panel/panelfunc.cpp | 1200 ++++++++++++ src/app/Panel/panelfunc.h | 106 ++ src/app/Panel/panelpopup.cpp | 400 ++++ src/app/Panel/panelpopup.h | 74 + src/app/Queue/Makefile.am | 10 + src/app/Queue/queue.cpp | 22 + src/app/Queue/queue.h | 33 + src/app/Queue/queue_mgr.cpp | 31 + src/app/Queue/queue_mgr.h | 26 + src/app/Queue/queuewidget.cpp | 10 + src/app/Queue/queuewidget.h | 15 + src/app/RemoteMan/Makefile.am | 9 + src/app/RemoteMan/remoteman.cpp | 385 ++++ src/app/RemoteMan/remoteman.h | 71 + src/app/RemoteMan/remotemanbase.cpp | 331 ++++ src/app/RemoteMan/remotemanbase.h | 83 + src/app/Search/Makefile.am | 9 + src/app/Search/krsearchdialog.cpp | 628 +++++++ src/app/Search/krsearchdialog.h | 184 ++ src/app/Search/krsearchmod.cpp | 253 +++ src/app/Search/krsearchmod.h | 86 + src/app/Splitter/Makefile.am | 11 + src/app/Splitter/combiner.cpp | 328 ++++ src/app/Splitter/combiner.h | 93 + src/app/Splitter/crc32.cpp | 69 + src/app/Splitter/crc32.h | 48 + src/app/Splitter/splitter.cpp | 252 +++ src/app/Splitter/splitter.h | 84 + src/app/Splitter/splittergui.cpp | 213 +++ src/app/Splitter/splittergui.h | 180 ++ src/app/Synchronizer/Makefile.am | 13 + src/app/Synchronizer/feedtolistboxdialog.cpp | 200 ++ src/app/Synchronizer/feedtolistboxdialog.h | 66 + src/app/Synchronizer/synchronizedialog.cpp | 199 ++ src/app/Synchronizer/synchronizedialog.h | 92 + src/app/Synchronizer/synchronizer.cpp | 1493 +++++++++++++++ src/app/Synchronizer/synchronizer.h | 205 ++ src/app/Synchronizer/synchronizerdirlist.cpp | 216 +++ src/app/Synchronizer/synchronizerdirlist.h | 73 + src/app/Synchronizer/synchronizerfileitem.h | 170 ++ src/app/Synchronizer/synchronizergui.cpp | 2478 +++++++++++++++++++++++++ src/app/Synchronizer/synchronizergui.h | 225 +++ src/app/Synchronizer/synchronizertask.cpp | 343 ++++ src/app/Synchronizer/synchronizertask.h | 170 ++ src/app/UserAction/Makefile.am | 17 + src/app/UserAction/expander.cpp | 1242 +++++++++++++ src/app/UserAction/expander.h | 245 +++ src/app/UserAction/kraction.cpp | 586 ++++++ src/app/UserAction/kraction.h | 170 ++ src/app/UserAction/kractionbase.cpp | 77 + src/app/UserAction/kractionbase.h | 97 + src/app/UserAction/tstring.h | 116 ++ src/app/UserAction/useraction.cpp | 212 +++ src/app/UserAction/useraction.h | 145 ++ src/app/UserAction/useractionpopupmenu.cpp | 26 + src/app/UserAction/useractionpopupmenu.h | 25 + src/app/UserMenu/Makefile.am | 7 + src/app/UserMenu/usermenu.cpp | 85 + src/app/UserMenu/usermenu.h | 46 + src/app/VFS/Makefile.am | 19 + src/app/VFS/arc_vfs.cpp | 866 +++++++++ src/app/VFS/arc_vfs.h | 131 ++ src/app/VFS/ftp_vfs.cpp | 297 +++ src/app/VFS/ftp_vfs.h | 80 + src/app/VFS/krarchandler.cpp | 785 ++++++++ src/app/VFS/krarchandler.h | 151 ++ src/app/VFS/krdirwatch.cpp | 124 ++ src/app/VFS/krdirwatch.h | 80 + src/app/VFS/krpermhandler.cpp | 355 ++++ src/app/VFS/krpermhandler.h | 89 + src/app/VFS/krquery.cpp | 653 +++++++ src/app/VFS/krquery.h | 209 +++ src/app/VFS/krvfshandler.cpp | 71 + src/app/VFS/krvfshandler.h | 40 + src/app/VFS/normal_vfs.cpp | 437 +++++ src/app/VFS/normal_vfs.h | 93 + src/app/VFS/preservingcopyjob.cpp | 319 ++++ src/app/VFS/preservingcopyjob.h | 85 + src/app/VFS/temp_vfs.cpp | 136 ++ src/app/VFS/temp_vfs.h | 60 + src/app/VFS/vfile.cpp | 311 ++++ src/app/VFS/vfile.h | 167 ++ src/app/VFS/vfs.cpp | 393 ++++ src/app/VFS/vfs.h | 187 ++ src/app/VFS/virt_vfs.cpp | 341 ++++ src/app/VFS/virt_vfs.h | 77 + src/app/VFS/virtualcopyjob.cpp | 316 ++++ src/app/VFS/virtualcopyjob.h | 126 ++ src/app/alpa-yellow.color | Bin 0 -> 2468 bytes src/app/bash.color | Bin 0 -> 2650 bytes src/app/calc.js | 64 + src/app/calc.ui | 267 +++ src/app/cr16-app-krusader_blue.png | Bin 0 -> 827 bytes src/app/cr16-app-krusader_red.png | Bin 0 -> 891 bytes src/app/cr16-app-krusader_root.png | Bin 0 -> 168 bytes src/app/cr16-app-krusader_user.png | Bin 0 -> 155 bytes src/app/cr22-app-krusader_blue.png | Bin 0 -> 1264 bytes src/app/cr22-app-krusader_red.png | Bin 0 -> 1395 bytes src/app/cr22-app-krusader_root.png | Bin 0 -> 460 bytes src/app/cr22-app-krusader_shield.png | Bin 0 -> 1254 bytes src/app/cr22-app-krusader_user.png | Bin 0 -> 439 bytes src/app/cr32-app-krusader_blue.png | Bin 0 -> 2248 bytes src/app/cr32-app-krusader_red.png | Bin 0 -> 2509 bytes src/app/cr32-app-krusader_root.png | Bin 0 -> 601 bytes src/app/cr32-app-krusader_shield.png | Bin 0 -> 2090 bytes src/app/cr32-app-krusader_user.png | Bin 0 -> 643 bytes src/app/cr48-app-krusader_blue.png | Bin 0 -> 4124 bytes src/app/cr48-app-krusader_red.png | Bin 0 -> 4375 bytes src/app/cr48-app-krusader_root.png | Bin 0 -> 1657 bytes src/app/cr48-app-krusader_shield.png | Bin 0 -> 3383 bytes src/app/cr48-app-krusader_user.png | Bin 0 -> 1641 bytes src/app/cr64-app-krusader_blue.png | Bin 0 -> 5908 bytes src/app/cr64-app-krusader_red.png | Bin 0 -> 6299 bytes src/app/cr64-app-krusader_root.png | Bin 0 -> 2130 bytes src/app/cr64-app-krusader_shield.png | Bin 0 -> 4818 bytes src/app/cr64-app-krusader_user.png | Bin 0 -> 2114 bytes src/app/defaults.h | 308 +++ src/app/dos_navigator.color | Bin 0 -> 2674 bytes src/app/kicons.cpp | 377 ++++ src/app/kicons.h | 29 + src/app/krservices.cpp | 216 +++ src/app/krservices.h | 79 + src/app/krslots.cpp | 944 ++++++++++ src/app/krslots.h | 188 ++ src/app/krusader.cpp | 1263 +++++++++++++ src/app/krusader.desktop | 86 + src/app/krusader.h | 275 +++ src/app/krusader_root-mode.desktop | 90 + src/app/krusaderapp.h | 32 + src/app/krusaderui.rc | 193 ++ src/app/krusaderview.cpp | 415 +++++ src/app/krusaderview.h | 111 ++ src/app/lo16-app-krusader.png | Bin 0 -> 815 bytes src/app/lo32-app-krusader.png | Bin 0 -> 3532 bytes src/app/lo32-app-krusader2.png | Bin 0 -> 529 bytes src/app/main.cpp | 248 +++ src/app/midnight_cmd_AHamann.color | Bin 0 -> 2732 bytes src/app/midnight_commander.color | Bin 0 -> 1776 bytes src/app/midnight_commander.keymap | Bin 0 -> 1375 bytes src/app/midnight_commander.keymap.info | 42 + src/app/mount.js | 37 + src/app/mount.ui | 195 ++ src/app/panelmanager.cpp | 352 ++++ src/app/panelmanager.h | 79 + src/app/paneltabbar.cpp | 262 +++ src/app/paneltabbar.h | 100 + src/app/recode.js | 202 ++ src/app/recode.ui | 286 +++ src/app/resources.h | 42 + src/app/select_from_file.js | 13 + src/app/splash.png | Bin 0 -> 74631 bytes src/app/total_cmd_pleasent.color | Bin 0 -> 2652 bytes src/app/total_commander.color | Bin 0 -> 1760 bytes src/app/total_commander.keymap | 112 ++ src/app/total_commander.keymap.info | 10 + src/app/useraction_examples.xml | 406 ++++ src/app/x-ace.desktop | 7 + src/iso/Makefile.am | 64 + src/iso/iso.cpp | 525 ++++++ src/iso/iso.h | 51 + src/iso/iso.protocol | 12 + src/iso/isoservice.desktop | 14 + src/iso/kiso.cpp | 469 +++++ src/iso/kiso.h | 112 ++ src/iso/kisodirectory.cpp | 31 + src/iso/kisodirectory.h | 40 + src/iso/kisofile.cpp | 53 + src/iso/kisofile.h | 49 + src/iso/libisofs/COPYING | 280 +++ src/iso/libisofs/ChangeLog | 6 + src/iso/libisofs/Makefile.am | 18 + src/iso/libisofs/README | 24 + src/iso/libisofs/bswap.h | 94 + src/iso/libisofs/configure.in.in | 1 + src/iso/libisofs/el_torito.h | 63 + src/iso/libisofs/iso_fs.h | 219 +++ src/iso/libisofs/isofs.c | 876 +++++++++ src/iso/libisofs/isofs.h | 161 ++ src/iso/libisofs/rock.h | 127 ++ src/iso/qfilehack.cpp | 40 + src/iso/qfilehack.h | 38 + src/iso/tdeio_isorc | 2 + src/krArc/CMakeL10n.txt | 3 + src/krArc/Makefile.am | 59 + src/krArc/krarc.cpp | 1692 +++++++++++++++++ src/krArc/krarc.h | 144 ++ src/krArc/krarc.protocol | 18 + src/tar/Makefile.am | 22 + src/tar/ar.protocol | 12 + src/tar/ktartest.cpp | 201 ++ src/tar/tar.cpp | 482 +++++ src/tar/tar.h | 48 + src/tar/tar.protocol | 12 + src/tar/zip.protocol | 12 + src/tdeconf_update/Makefile.am | 3 + src/tdeconf_update/krusader_tqt_selection.upd | 4 + src/virt/CMakeL10n.txt | 3 + src/virt/Makefile.am | 17 + src/virt/virt.cpp | 305 +++ src/virt/virt.h | 55 + src/virt/virt.protocol | 19 + 399 files changed, 73351 insertions(+) create mode 100644 src/Makefile.am create mode 100644 src/app/ActionMan/Makefile.am create mode 100644 src/app/ActionMan/actionman.cpp create mode 100644 src/app/ActionMan/actionman.h create mode 100644 src/app/ActionMan/actionproperty.cpp create mode 100644 src/app/ActionMan/actionproperty.h create mode 100644 src/app/ActionMan/actionpropertybase.cpp create mode 100644 src/app/ActionMan/actionpropertybase.ui create mode 100644 src/app/ActionMan/addplaceholderpopup.cpp create mode 100644 src/app/ActionMan/addplaceholderpopup.h create mode 100644 src/app/ActionMan/useractionlistview.cpp create mode 100644 src/app/ActionMan/useractionlistview.h create mode 100644 src/app/ActionMan/useractionpage.cpp create mode 100644 src/app/ActionMan/useractionpage.h create mode 100644 src/app/BookMan/Makefile.am create mode 100644 src/app/BookMan/kraddbookmarkdlg.cpp create mode 100644 src/app/BookMan/kraddbookmarkdlg.h create mode 100644 src/app/BookMan/krbookmark.cpp create mode 100644 src/app/BookMan/krbookmark.h create mode 100644 src/app/BookMan/krbookmarkbutton.cpp create mode 100644 src/app/BookMan/krbookmarkbutton.h create mode 100644 src/app/BookMan/krbookmarkhandler.cpp create mode 100644 src/app/BookMan/krbookmarkhandler.h create mode 100644 src/app/CMakeL10n.txt create mode 100644 src/app/Dialogs/Makefile.am create mode 100644 src/app/Dialogs/checksumdlg.cpp create mode 100644 src/app/Dialogs/checksumdlg.h create mode 100644 src/app/Dialogs/krdialogs.cpp create mode 100644 src/app/Dialogs/krdialogs.h create mode 100644 src/app/Dialogs/krkeydialog.cpp create mode 100644 src/app/Dialogs/krkeydialog.h create mode 100644 src/app/Dialogs/krmaskchoice.cpp create mode 100644 src/app/Dialogs/krmaskchoice.h create mode 100644 src/app/Dialogs/krpleasewait.cpp create mode 100644 src/app/Dialogs/krpleasewait.h create mode 100644 src/app/Dialogs/krprogress.cpp create mode 100644 src/app/Dialogs/krprogress.h create mode 100644 src/app/Dialogs/krspecialwidgets.cpp create mode 100644 src/app/Dialogs/krspecialwidgets.h create mode 100644 src/app/Dialogs/krspwidgets.cpp create mode 100644 src/app/Dialogs/krspwidgets.h create mode 100644 src/app/Dialogs/krsqueezedtextlabel.cpp create mode 100644 src/app/Dialogs/krsqueezedtextlabel.h create mode 100644 src/app/Dialogs/kurllistrequester.cpp create mode 100644 src/app/Dialogs/kurllistrequester.h create mode 100644 src/app/Dialogs/newftpgui.cpp create mode 100644 src/app/Dialogs/newftpgui.h create mode 100644 src/app/Dialogs/packgui.cpp create mode 100644 src/app/Dialogs/packgui.h create mode 100644 src/app/Dialogs/packguibase.cpp create mode 100644 src/app/Dialogs/packguibase.h create mode 100644 src/app/Dialogs/percentalsplitter.cpp create mode 100644 src/app/Dialogs/percentalsplitter.h create mode 100644 src/app/Dialogs/popularurls.cpp create mode 100644 src/app/Dialogs/popularurls.h create mode 100644 src/app/DiskUsage/Makefile.am create mode 100644 src/app/DiskUsage/diskusage.cpp create mode 100644 src/app/DiskUsage/diskusage.h create mode 100644 src/app/DiskUsage/diskusagegui.cpp create mode 100644 src/app/DiskUsage/diskusagegui.h create mode 100644 src/app/DiskUsage/dufilelight.cpp create mode 100644 src/app/DiskUsage/dufilelight.h create mode 100644 src/app/DiskUsage/dulines.cpp create mode 100644 src/app/DiskUsage/dulines.h create mode 100644 src/app/DiskUsage/dulistview.cpp create mode 100644 src/app/DiskUsage/dulistview.h create mode 100644 src/app/DiskUsage/filelightParts/Config.cpp create mode 100644 src/app/DiskUsage/filelightParts/Config.h create mode 100644 src/app/DiskUsage/filelightParts/Makefile.am create mode 100644 src/app/DiskUsage/filelightParts/debug.h create mode 100644 src/app/DiskUsage/filelightParts/fileTree.cpp create mode 100644 src/app/DiskUsage/filelightParts/fileTree.h create mode 100644 src/app/DiskUsage/radialMap/Makefile.am create mode 100644 src/app/DiskUsage/radialMap/builder.cpp create mode 100644 src/app/DiskUsage/radialMap/builder.h create mode 100644 src/app/DiskUsage/radialMap/labels.cpp create mode 100644 src/app/DiskUsage/radialMap/map.cpp create mode 100644 src/app/DiskUsage/radialMap/radialMap.h create mode 100644 src/app/DiskUsage/radialMap/segmentTip.cpp create mode 100644 src/app/DiskUsage/radialMap/segmentTip.h create mode 100644 src/app/DiskUsage/radialMap/sincos.h create mode 100644 src/app/DiskUsage/radialMap/widget.cpp create mode 100644 src/app/DiskUsage/radialMap/widget.h create mode 100644 src/app/DiskUsage/radialMap/widgetEvents.cpp create mode 100644 src/app/Filter/Makefile.am create mode 100644 src/app/Filter/advancedfilter.cpp create mode 100644 src/app/Filter/advancedfilter.h create mode 100644 src/app/Filter/filterbase.h create mode 100644 src/app/Filter/filterdialog.cpp create mode 100644 src/app/Filter/filterdialog.h create mode 100644 src/app/Filter/filtertabs.cpp create mode 100644 src/app/Filter/filtertabs.h create mode 100644 src/app/Filter/generalfilter.cpp create mode 100644 src/app/Filter/generalfilter.h create mode 100644 src/app/GUI/Makefile.am create mode 100644 src/app/GUI/dirhistorybutton.cpp create mode 100644 src/app/GUI/dirhistorybutton.h create mode 100644 src/app/GUI/dirhistoryqueue.cpp create mode 100644 src/app/GUI/dirhistoryqueue.h create mode 100644 src/app/GUI/kcmdline.cpp create mode 100644 src/app/GUI/kcmdline.h create mode 100644 src/app/GUI/kcmdmodebutton.cpp create mode 100644 src/app/GUI/kcmdmodebutton.h create mode 100644 src/app/GUI/kfnkeys.cpp create mode 100644 src/app/GUI/kfnkeys.h create mode 100644 src/app/GUI/krremoteencodingmenu.cpp create mode 100644 src/app/GUI/krremoteencodingmenu.h create mode 100644 src/app/GUI/krusaderstatus.cpp create mode 100644 src/app/GUI/krusaderstatus.h create mode 100644 src/app/GUI/mediabutton.cpp create mode 100644 src/app/GUI/mediabutton.h create mode 100644 src/app/GUI/profilemanager.cpp create mode 100644 src/app/GUI/profilemanager.h create mode 100644 src/app/GUI/syncbrowsebutton.cpp create mode 100644 src/app/GUI/syncbrowsebutton.h create mode 100644 src/app/KViewer/Makefile.am create mode 100644 src/app/KViewer/diskusageviewer.cpp create mode 100644 src/app/KViewer/diskusageviewer.h create mode 100644 src/app/KViewer/kimagefilepreview.cpp create mode 100644 src/app/KViewer/kimagefilepreview.h create mode 100644 src/app/KViewer/krviewer.cpp create mode 100644 src/app/KViewer/krviewer.h create mode 100644 src/app/KViewer/panelviewer.cpp create mode 100644 src/app/KViewer/panelviewer.h create mode 100644 src/app/Konfigurator/Makefile.am create mode 100644 src/app/Konfigurator/kgadvanced.cpp create mode 100644 src/app/Konfigurator/kgadvanced.h create mode 100644 src/app/Konfigurator/kgarchives.cpp create mode 100644 src/app/Konfigurator/kgarchives.h create mode 100644 src/app/Konfigurator/kgcolors.cpp create mode 100644 src/app/Konfigurator/kgcolors.h create mode 100644 src/app/Konfigurator/kgdependencies.cpp create mode 100644 src/app/Konfigurator/kgdependencies.h create mode 100644 src/app/Konfigurator/kggeneral.cpp create mode 100644 src/app/Konfigurator/kggeneral.h create mode 100644 src/app/Konfigurator/kglookfeel.cpp create mode 100644 src/app/Konfigurator/kglookfeel.h create mode 100644 src/app/Konfigurator/kgprotocols.cpp create mode 100644 src/app/Konfigurator/kgprotocols.h create mode 100644 src/app/Konfigurator/kgstartup.cpp create mode 100644 src/app/Konfigurator/kgstartup.h create mode 100644 src/app/Konfigurator/kguseractions.cpp create mode 100644 src/app/Konfigurator/kguseractions.h create mode 100644 src/app/Konfigurator/kgwelcome.cpp create mode 100644 src/app/Konfigurator/kgwelcome.h create mode 100644 src/app/Konfigurator/konfigurator.cpp create mode 100644 src/app/Konfigurator/konfigurator.h create mode 100644 src/app/Konfigurator/konfiguratoritems.cpp create mode 100644 src/app/Konfigurator/konfiguratoritems.h create mode 100644 src/app/Konfigurator/konfiguratorpage.cpp create mode 100644 src/app/Konfigurator/konfiguratorpage.h create mode 100644 src/app/Konfigurator/krresulttable.cpp create mode 100644 src/app/Konfigurator/krresulttable.h create mode 100644 src/app/Konfigurator/krresulttabledialog.cpp create mode 100644 src/app/Konfigurator/krresulttabledialog.h create mode 100644 src/app/Konfigurator/searchobject.cpp create mode 100644 src/app/Konfigurator/searchobject.h create mode 100644 src/app/KrJS/Makefile.am create mode 100644 src/app/KrJS/krjs.cpp create mode 100644 src/app/KrJS/krjs.h create mode 100644 src/app/Locate/Makefile.am create mode 100644 src/app/Locate/locate.cpp create mode 100644 src/app/Locate/locate.h create mode 100644 src/app/Makefile.am create mode 100644 src/app/MountMan/Makefile.am create mode 100644 src/app/MountMan/kdiskfreesp.cpp create mode 100644 src/app/MountMan/kdiskfreesp.h create mode 100644 src/app/MountMan/kmountman.cpp create mode 100644 src/app/MountMan/kmountman.h create mode 100644 src/app/MountMan/kmountmangui.cpp create mode 100644 src/app/MountMan/kmountmangui.h create mode 100644 src/app/Panel/Makefile.am create mode 100644 src/app/Panel/krbriefview.cpp create mode 100644 src/app/Panel/krbriefview.h create mode 100644 src/app/Panel/krbriefviewitem.cpp create mode 100644 src/app/Panel/krbriefviewitem.h create mode 100644 src/app/Panel/krcalcspacedialog.cpp create mode 100644 src/app/Panel/krcalcspacedialog.h create mode 100644 src/app/Panel/krcolorcache.cpp create mode 100644 src/app/Panel/krcolorcache.h create mode 100644 src/app/Panel/krdetailedview.cpp create mode 100644 src/app/Panel/krdetailedview.h create mode 100644 src/app/Panel/krdetailedviewitem.cpp create mode 100644 src/app/Panel/krdetailedviewitem.h create mode 100644 src/app/Panel/krdrag.cpp create mode 100644 src/app/Panel/krdrag.h create mode 100644 src/app/Panel/krpopupmenu.cpp create mode 100644 src/app/Panel/krpopupmenu.h create mode 100644 src/app/Panel/krpreviewpopup.cpp create mode 100644 src/app/Panel/krpreviewpopup.h create mode 100644 src/app/Panel/krselectionmode.cpp create mode 100644 src/app/Panel/krselectionmode.h create mode 100644 src/app/Panel/krview.cpp create mode 100644 src/app/Panel/krview.h create mode 100644 src/app/Panel/krviewitem.cpp create mode 100644 src/app/Panel/krviewitem.h create mode 100644 src/app/Panel/listpanel.cpp create mode 100644 src/app/Panel/listpanel.h create mode 100644 src/app/Panel/panelfunc.cpp create mode 100644 src/app/Panel/panelfunc.h create mode 100644 src/app/Panel/panelpopup.cpp create mode 100644 src/app/Panel/panelpopup.h create mode 100644 src/app/Queue/Makefile.am create mode 100644 src/app/Queue/queue.cpp create mode 100644 src/app/Queue/queue.h create mode 100644 src/app/Queue/queue_mgr.cpp create mode 100644 src/app/Queue/queue_mgr.h create mode 100644 src/app/Queue/queuewidget.cpp create mode 100644 src/app/Queue/queuewidget.h create mode 100644 src/app/RemoteMan/Makefile.am create mode 100644 src/app/RemoteMan/remoteman.cpp create mode 100644 src/app/RemoteMan/remoteman.h create mode 100644 src/app/RemoteMan/remotemanbase.cpp create mode 100644 src/app/RemoteMan/remotemanbase.h create mode 100644 src/app/Search/Makefile.am create mode 100644 src/app/Search/krsearchdialog.cpp create mode 100644 src/app/Search/krsearchdialog.h create mode 100644 src/app/Search/krsearchmod.cpp create mode 100644 src/app/Search/krsearchmod.h create mode 100644 src/app/Splitter/Makefile.am create mode 100644 src/app/Splitter/combiner.cpp create mode 100644 src/app/Splitter/combiner.h create mode 100644 src/app/Splitter/crc32.cpp create mode 100644 src/app/Splitter/crc32.h create mode 100644 src/app/Splitter/splitter.cpp create mode 100644 src/app/Splitter/splitter.h create mode 100644 src/app/Splitter/splittergui.cpp create mode 100644 src/app/Splitter/splittergui.h create mode 100755 src/app/Synchronizer/Makefile.am create mode 100644 src/app/Synchronizer/feedtolistboxdialog.cpp create mode 100644 src/app/Synchronizer/feedtolistboxdialog.h create mode 100644 src/app/Synchronizer/synchronizedialog.cpp create mode 100644 src/app/Synchronizer/synchronizedialog.h create mode 100644 src/app/Synchronizer/synchronizer.cpp create mode 100644 src/app/Synchronizer/synchronizer.h create mode 100644 src/app/Synchronizer/synchronizerdirlist.cpp create mode 100644 src/app/Synchronizer/synchronizerdirlist.h create mode 100644 src/app/Synchronizer/synchronizerfileitem.h create mode 100644 src/app/Synchronizer/synchronizergui.cpp create mode 100644 src/app/Synchronizer/synchronizergui.h create mode 100644 src/app/Synchronizer/synchronizertask.cpp create mode 100644 src/app/Synchronizer/synchronizertask.h create mode 100644 src/app/UserAction/Makefile.am create mode 100644 src/app/UserAction/expander.cpp create mode 100644 src/app/UserAction/expander.h create mode 100644 src/app/UserAction/kraction.cpp create mode 100644 src/app/UserAction/kraction.h create mode 100644 src/app/UserAction/kractionbase.cpp create mode 100644 src/app/UserAction/kractionbase.h create mode 100644 src/app/UserAction/tstring.h create mode 100644 src/app/UserAction/useraction.cpp create mode 100644 src/app/UserAction/useraction.h create mode 100644 src/app/UserAction/useractionpopupmenu.cpp create mode 100644 src/app/UserAction/useractionpopupmenu.h create mode 100644 src/app/UserMenu/Makefile.am create mode 100644 src/app/UserMenu/usermenu.cpp create mode 100644 src/app/UserMenu/usermenu.h create mode 100644 src/app/VFS/Makefile.am create mode 100644 src/app/VFS/arc_vfs.cpp create mode 100644 src/app/VFS/arc_vfs.h create mode 100644 src/app/VFS/ftp_vfs.cpp create mode 100644 src/app/VFS/ftp_vfs.h create mode 100644 src/app/VFS/krarchandler.cpp create mode 100644 src/app/VFS/krarchandler.h create mode 100644 src/app/VFS/krdirwatch.cpp create mode 100644 src/app/VFS/krdirwatch.h create mode 100644 src/app/VFS/krpermhandler.cpp create mode 100644 src/app/VFS/krpermhandler.h create mode 100644 src/app/VFS/krquery.cpp create mode 100644 src/app/VFS/krquery.h create mode 100644 src/app/VFS/krvfshandler.cpp create mode 100644 src/app/VFS/krvfshandler.h create mode 100644 src/app/VFS/normal_vfs.cpp create mode 100644 src/app/VFS/normal_vfs.h create mode 100644 src/app/VFS/preservingcopyjob.cpp create mode 100644 src/app/VFS/preservingcopyjob.h create mode 100644 src/app/VFS/temp_vfs.cpp create mode 100644 src/app/VFS/temp_vfs.h create mode 100644 src/app/VFS/vfile.cpp create mode 100644 src/app/VFS/vfile.h create mode 100644 src/app/VFS/vfs.cpp create mode 100644 src/app/VFS/vfs.h create mode 100644 src/app/VFS/virt_vfs.cpp create mode 100644 src/app/VFS/virt_vfs.h create mode 100644 src/app/VFS/virtualcopyjob.cpp create mode 100644 src/app/VFS/virtualcopyjob.h create mode 100644 src/app/alpa-yellow.color create mode 100644 src/app/bash.color create mode 100644 src/app/calc.js create mode 100644 src/app/calc.ui create mode 100644 src/app/cr16-app-krusader_blue.png create mode 100644 src/app/cr16-app-krusader_red.png create mode 100644 src/app/cr16-app-krusader_root.png create mode 100644 src/app/cr16-app-krusader_user.png create mode 100644 src/app/cr22-app-krusader_blue.png create mode 100644 src/app/cr22-app-krusader_red.png create mode 100644 src/app/cr22-app-krusader_root.png create mode 100644 src/app/cr22-app-krusader_shield.png create mode 100644 src/app/cr22-app-krusader_user.png create mode 100644 src/app/cr32-app-krusader_blue.png create mode 100644 src/app/cr32-app-krusader_red.png create mode 100644 src/app/cr32-app-krusader_root.png create mode 100644 src/app/cr32-app-krusader_shield.png create mode 100644 src/app/cr32-app-krusader_user.png create mode 100644 src/app/cr48-app-krusader_blue.png create mode 100644 src/app/cr48-app-krusader_red.png create mode 100644 src/app/cr48-app-krusader_root.png create mode 100644 src/app/cr48-app-krusader_shield.png create mode 100644 src/app/cr48-app-krusader_user.png create mode 100644 src/app/cr64-app-krusader_blue.png create mode 100644 src/app/cr64-app-krusader_red.png create mode 100644 src/app/cr64-app-krusader_root.png create mode 100644 src/app/cr64-app-krusader_shield.png create mode 100644 src/app/cr64-app-krusader_user.png create mode 100644 src/app/defaults.h create mode 100644 src/app/dos_navigator.color create mode 100644 src/app/kicons.cpp create mode 100644 src/app/kicons.h create mode 100644 src/app/krservices.cpp create mode 100644 src/app/krservices.h create mode 100644 src/app/krslots.cpp create mode 100644 src/app/krslots.h create mode 100644 src/app/krusader.cpp create mode 100644 src/app/krusader.desktop create mode 100644 src/app/krusader.h create mode 100644 src/app/krusader_root-mode.desktop create mode 100644 src/app/krusaderapp.h create mode 100644 src/app/krusaderui.rc create mode 100644 src/app/krusaderview.cpp create mode 100644 src/app/krusaderview.h create mode 100644 src/app/lo16-app-krusader.png create mode 100644 src/app/lo32-app-krusader.png create mode 100644 src/app/lo32-app-krusader2.png create mode 100644 src/app/main.cpp create mode 100644 src/app/midnight_cmd_AHamann.color create mode 100644 src/app/midnight_commander.color create mode 100644 src/app/midnight_commander.keymap create mode 100644 src/app/midnight_commander.keymap.info create mode 100644 src/app/mount.js create mode 100644 src/app/mount.ui create mode 100644 src/app/panelmanager.cpp create mode 100644 src/app/panelmanager.h create mode 100644 src/app/paneltabbar.cpp create mode 100644 src/app/paneltabbar.h create mode 100644 src/app/recode.js create mode 100644 src/app/recode.ui create mode 100644 src/app/resources.h create mode 100644 src/app/select_from_file.js create mode 100644 src/app/splash.png create mode 100644 src/app/total_cmd_pleasent.color create mode 100644 src/app/total_commander.color create mode 100644 src/app/total_commander.keymap create mode 100644 src/app/total_commander.keymap.info create mode 100644 src/app/useraction_examples.xml create mode 100644 src/app/x-ace.desktop create mode 100644 src/iso/Makefile.am create mode 100644 src/iso/iso.cpp create mode 100644 src/iso/iso.h create mode 100644 src/iso/iso.protocol create mode 100644 src/iso/isoservice.desktop create mode 100644 src/iso/kiso.cpp create mode 100644 src/iso/kiso.h create mode 100644 src/iso/kisodirectory.cpp create mode 100644 src/iso/kisodirectory.h create mode 100644 src/iso/kisofile.cpp create mode 100644 src/iso/kisofile.h create mode 100644 src/iso/libisofs/COPYING create mode 100644 src/iso/libisofs/ChangeLog create mode 100644 src/iso/libisofs/Makefile.am create mode 100644 src/iso/libisofs/README create mode 100644 src/iso/libisofs/bswap.h create mode 100644 src/iso/libisofs/configure.in.in create mode 100644 src/iso/libisofs/el_torito.h create mode 100644 src/iso/libisofs/iso_fs.h create mode 100644 src/iso/libisofs/isofs.c create mode 100644 src/iso/libisofs/isofs.h create mode 100644 src/iso/libisofs/rock.h create mode 100644 src/iso/qfilehack.cpp create mode 100644 src/iso/qfilehack.h create mode 100644 src/iso/tdeio_isorc create mode 100644 src/krArc/CMakeL10n.txt create mode 100644 src/krArc/Makefile.am create mode 100644 src/krArc/krarc.cpp create mode 100644 src/krArc/krarc.h create mode 100644 src/krArc/krarc.protocol create mode 100644 src/tar/Makefile.am create mode 100644 src/tar/ar.protocol create mode 100644 src/tar/ktartest.cpp create mode 100644 src/tar/tar.cpp create mode 100644 src/tar/tar.h create mode 100644 src/tar/tar.protocol create mode 100644 src/tar/zip.protocol create mode 100644 src/tdeconf_update/Makefile.am create mode 100644 src/tdeconf_update/krusader_tqt_selection.upd create mode 100644 src/virt/CMakeL10n.txt create mode 100644 src/virt/Makefile.am create mode 100644 src/virt/virt.cpp create mode 100644 src/virt/virt.h create mode 100644 src/virt/virt.protocol (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..b87c8d0 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,10 @@ +# the condition for this is found in configure.in.in +if with_tar +TARDIR = tar +endif + +if with_iso +ISODIR = iso +endif + +SUBDIRS = app krArc $(ISODIR) tdeconf_update virt $(TARDIR) diff --git a/src/app/ActionMan/Makefile.am b/src/app/ActionMan/Makefile.am new file mode 100644 index 0000000..e71563a --- /dev/null +++ b/src/app/ActionMan/Makefile.am @@ -0,0 +1,14 @@ +noinst_LIBRARIES = libActionMan.a + +INCLUDES = $(all_includes) + +libActionMan_a_METASOURCES = AUTO + +libActionMan_a_SOURCES = \ + actionman.cpp \ + actionpropertybase.ui \ + actionproperty.cpp \ + addplaceholderpopup.cpp \ + useractionlistview.cpp \ + useractionpage.cpp +noinst_HEADERS = useractionpage.h diff --git a/src/app/ActionMan/actionman.cpp b/src/app/ActionMan/actionman.cpp new file mode 100644 index 0000000..080ece3 --- /dev/null +++ b/src/app/ActionMan/actionman.cpp @@ -0,0 +1,60 @@ +// +// C++ Implementation: actionman +// +// Description: This manages all useractions +// +// +// Author: Jonas Bähr (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "actionman.h" + +#include +#include + +#include "useractionpage.h" +#include "../krusader.h" +#include "../UserAction/useraction.h" + + +ActionMan::ActionMan( TQWidget * parent ) + : KDialogBase( parent, "ActionMan", true /*modal*/, "ActionMan - Manage your useractions", KDialogBase::Apply | KDialogBase::Close ) +{ + setPlainCaption(i18n("ActionMan - Manage Your Useractions")); + + userActionPage = new UserActionPage( this ); + setMainWidget( userActionPage ); + + connect( userActionPage, TQ_SIGNAL( changed() ), TQ_SLOT( slotEnableApplyButton() ) ); + connect( userActionPage, TQ_SIGNAL( applied() ), TQ_SLOT( slotDisableApplyButton() ) ); + enableButtonApply( false ); + + exec(); +} + +ActionMan::~ActionMan() { +} + +void ActionMan::slotClose() { + if ( userActionPage->readyToQuit() ) + reject(); +} + +void ActionMan::slotApply() { + userActionPage->applyChanges(); +} + +void ActionMan::slotEnableApplyButton() { + enableButtonApply( true ); +} + +void ActionMan::slotDisableApplyButton() { + enableButtonApply( false ); +} + + + +#include "actionman.moc" diff --git a/src/app/ActionMan/actionman.h b/src/app/ActionMan/actionman.h new file mode 100644 index 0000000..29ab30b --- /dev/null +++ b/src/app/ActionMan/actionman.h @@ -0,0 +1,37 @@ +// +// C++ Interface: actionman +// +// Description: This manages all useractions +// +// +// Author: Jonas B�r (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef ACTIONMAN_H +#define ACTIONMAN_H + +#include + +class UserActionPage; + +class ActionMan : public KDialogBase { +TQ_OBJECT + +public: + ActionMan( TQWidget* parent=0 ); + ~ActionMan(); + +protected slots: + void slotClose(); + void slotApply(); + void slotEnableApplyButton(); + void slotDisableApplyButton(); + +private: + UserActionPage* userActionPage; +}; + +#endif // ifndef ACTIONMAN_H diff --git a/src/app/ActionMan/actionproperty.cpp b/src/app/ActionMan/actionproperty.cpp new file mode 100644 index 0000000..361f0a9 --- /dev/null +++ b/src/app/ActionMan/actionproperty.cpp @@ -0,0 +1,470 @@ +// +// C++ Implementation: actionproperty +// +// Description: +// +// +// Author: Jonas B�r (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "actionproperty.h" +#include "addplaceholderpopup.h" + +#include "../UserAction/useraction.h" +#include "../UserAction/kraction.h" +#include "../krusader.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ICON(N) TDEGlobal::iconLoader()->loadIcon(N, TDEIcon::Small) + +ActionProperty::ActionProperty( TQWidget *parent, const char *name, KrAction *action ) + : ActionPropertyBase( parent, name ), _modified(false) + { + if ( action ) { + _action = action; + updateGUI( _action ); + } + + ButtonAddPlaceholder->setPixmap( ICON("add") ); + ButtonAddStartpath->setPixmap( ICON("document-open") ); + + // fill with all existing categories + cbCategory->insertStringList( krUserAction->allCategories() ); + + connect( ButtonAddPlaceholder, TQ_SIGNAL( clicked() ), this, TQ_SLOT( addPlaceholder() ) ); + connect( ButtonAddStartpath, TQ_SIGNAL( clicked() ), this, TQ_SLOT( addStartpath() ) ); + connect( ButtonNewProtocol, TQ_SIGNAL( clicked() ), this, TQ_SLOT( newProtocol() ) ); + connect( ButtonEditProtocol, TQ_SIGNAL( clicked() ), this, TQ_SLOT( editProtocol() ) ); + connect( ButtonRemoveProtocol, TQ_SIGNAL( clicked() ), this, TQ_SLOT( removeProtocol() ) ); + connect( ButtonAddPath, TQ_SIGNAL( clicked() ), this, TQ_SLOT( addPath() ) ); + connect( ButtonEditPath, TQ_SIGNAL( clicked() ), this, TQ_SLOT( editPath() ) ); + connect( ButtonRemovePath, TQ_SIGNAL( clicked() ), this, TQ_SLOT( removePath() ) ); + connect( ButtonAddMime, TQ_SIGNAL( clicked() ), this, TQ_SLOT( addMime() ) ); + connect( ButtonEditMime, TQ_SIGNAL( clicked() ), this, TQ_SLOT( editMime() ) ); + connect( ButtonRemoveMime, TQ_SIGNAL( clicked() ), this, TQ_SLOT( removeMime() ) ); + connect( ButtonNewFile, TQ_SIGNAL( clicked() ), this, TQ_SLOT( newFile() ) ); + connect( ButtonEditFile, TQ_SIGNAL( clicked() ), this, TQ_SLOT( editFile() ) ); + connect( ButtonRemoveFile, TQ_SIGNAL( clicked() ), this, TQ_SLOT( removeFile() ) ); + connect( KeyButtonShortcut, TQ_SIGNAL( capturedShortcut(const TDEShortcut&) ), this, TQ_SLOT( changedShortcut(const TDEShortcut&) ) ); + // track modifications: + connect( leDistinctName, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( leTitle, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( ButtonIcon, TQ_SIGNAL( iconChanged(TQString) ), TQ_SLOT( setModified() ) ); + connect( cbCategory, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( leTooltip, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( textDescription, TQ_SIGNAL( textChanged() ), TQ_SLOT( setModified() ) ); + connect( leDistinctName, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( leCommandline, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( leStartpath, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( bgExecType, TQ_SIGNAL( clicked(int) ), TQ_SLOT( setModified() ) ); + connect( bgAccept, TQ_SIGNAL( clicked(int) ), TQ_SLOT( setModified() ) ); + connect( KeyButtonShortcut, TQ_SIGNAL( capturedShortcut(const TDEShortcut&) ), TQ_SLOT( setModified() ) ); + connect( leDifferentUser, TQ_SIGNAL( textChanged(const TQString&) ), TQ_SLOT( setModified() ) ); + connect( chkDifferentUser, TQ_SIGNAL( clicked() ), TQ_SLOT( setModified() ) ); + connect( chkConfirmExecution, TQ_SIGNAL( clicked() ), TQ_SLOT( setModified() ) ); + // The modified-state of the ShowOnly-lists is tracked in the access-functions below +} + +ActionProperty::~ActionProperty() { +} + +void ActionProperty::changedShortcut( const TDEShortcut& shortcut ) { + KeyButtonShortcut->setShortcut( shortcut, false ); +} + + +void ActionProperty::clear() { + _action = 0; + + // This prevents the changed-signal from being emited during the GUI-update + _modified = true; // The real state is set at the end of this function. + + leDistinctName->clear(); + cbCategory->clearEdit(); + leTitle->clear(); + leTooltip->clear(); + textDescription->clear(); + leCommandline->clear(); + leStartpath->clear(); + KeyButtonShortcut->setShortcut( TDEShortcut(), false ); + + lbShowonlyProtocol->clear(); + lbShowonlyPath->clear(); + lbShowonlyMime->clear(); + lbShowonlyFile->clear(); + + chkSeparateStdError->setChecked( false ); + radioNormal->setChecked( true ); + + radioLocal->setChecked( true ); + + chkConfirmExecution->setChecked( false ); + + ButtonIcon->resetIcon(); + + leDifferentUser->clear(); + chkDifferentUser->setChecked( false ); + + setModified( false ); +} + +void ActionProperty::updateGUI( KrAction *action ) { + if ( action ) + _action = action; + if ( ! _action ) + return; + + // This prevents the changed-signal from being emited during the GUI-update. + _modified = true; // The real state is set at the end of this function. + + leDistinctName->setText( _action->name() ); + cbCategory->setCurrentText( _action->category() ); + leTitle->setText( _action->text() ); + leTooltip->setText( _action->toolTip() ); + textDescription->setText( _action->whatsThis() ); + leCommandline->setText( _action->command() ); + leCommandline->home(false); + leStartpath->setText( _action->startpath() ); + KeyButtonShortcut->setShortcut( _action->shortcut(), false ); + + lbShowonlyProtocol->clear(); + lbShowonlyProtocol->insertStringList( _action->showonlyProtocol() ); + lbShowonlyPath->clear(); + lbShowonlyPath->insertStringList( _action->showonlyPath() ); + lbShowonlyMime->clear(); + lbShowonlyMime->insertStringList( _action->showonlyMime() ); + lbShowonlyFile->clear(); + lbShowonlyFile->insertStringList( _action->showonlyFile() ); + + chkSeparateStdError->setChecked( false ); + switch ( _action->execType() ) { + case KrAction::CollectOutputSeparateStderr: + chkSeparateStdError->setChecked( true ); + radioCollectOutput->setChecked( true ); + break; + case KrAction::CollectOutput: + radioCollectOutput->setChecked( true ); + break; + case KrAction::Terminal: + radioTerminal->setChecked( true ); + break; + default: // case KrAction::Normal: + radioNormal->setChecked( true ); + break; + } + + if ( _action->acceptURLs() ) + radioUrl->setChecked( true ); + else + radioLocal->setChecked( true ); + + chkConfirmExecution->setChecked( _action->confirmExecution() ); + + if ( ! _action->icon().isEmpty() ) + ButtonIcon->setIcon( _action->icon() ); + else + ButtonIcon->resetIcon(); + + leDifferentUser->setText( _action->user() ); + if ( _action->user().isEmpty() ) + chkDifferentUser->setChecked( false ); + else + chkDifferentUser->setChecked( true ); + + setModified( false ); +} + +void ActionProperty::updateAction( KrAction *action ) { + if ( action ) + _action = action; + if ( ! _action ) + return; + + if ( _action->category() != cbCategory->currentText() ) { + _action->setCategory( cbCategory->currentText() ); + // Update the category-list + cbCategory->clear(); + cbCategory->insertStringList( krUserAction->allCategories() ); + cbCategory->setCurrentText( _action->category() ); + } + + _action->setName( leDistinctName->text().latin1() ); + _action->setText( leTitle->text() ); + _action->setToolTip( leTooltip->text() ); + _action->setWhatsThis( textDescription->text() ); + _action->setCommand( leCommandline->text() ); + _action->setStartpath( leStartpath->text() ); + _action->setShortcut( KeyButtonShortcut->shortcut() ); + + TQListBoxItem* lbi = lbShowonlyProtocol->firstItem(); + TQStringList list; + while ( lbi ) { + list << lbi->text(); + lbi = lbi->next(); + } + _action->setShowonlyProtocol( list ); + + lbi = lbShowonlyPath->firstItem(); + list = TQStringList(); + while ( lbi ) { + list << lbi->text(); + lbi = lbi->next(); + } + _action->setShowonlyPath( list ); + + lbi = lbShowonlyMime->firstItem(); + list = TQStringList(); + while ( lbi ) { + list << lbi->text(); + lbi = lbi->next(); + } + _action->setShowonlyMime( list ); + + lbi = lbShowonlyFile->firstItem(); + list = TQStringList(); + while ( lbi ) { + list << lbi->text(); + lbi = lbi->next(); + } + _action->setShowonlyFile( list ); + + if ( radioCollectOutput->isChecked() && chkSeparateStdError->isChecked() ) + _action->setExecType( KrAction::CollectOutputSeparateStderr ); + else if ( radioCollectOutput->isChecked() && ! chkSeparateStdError->isChecked() ) + _action->setExecType( KrAction::CollectOutput ); + else if ( radioTerminal->isChecked() ) + _action->setExecType( KrAction::Terminal ); + else + _action->setExecType( KrAction::Normal ); + + if ( radioUrl->isChecked() ) + _action->setAcceptURLs( true ); + else + _action->setAcceptURLs( false ); + + _action->setConfirmExecution( chkConfirmExecution->isChecked() ); + + _action->setIcon( ButtonIcon->icon() ); + + _action->setUser( leDifferentUser->text() ); + + setModified( false ); +} + +void ActionProperty::addPlaceholder() { + AddPlaceholderPopup popup( this ); + TQString exp = popup.getPlaceholder( mapToGlobal( + TQPoint( + ButtonAddPlaceholder->pos().x() + ButtonAddPlaceholder->width()+6, // 6 is the default margin + ButtonAddPlaceholder->pos().y() + ) + ) ); + leCommandline->insert( exp ); +} + + +void ActionProperty::addStartpath() { + TQString folder = KFileDialog::getExistingDirectory(TQString(), this); + if (folder != TQString()) { + leStartpath->setText( folder ); + } +} + + +void ActionProperty::newProtocol() { + bool ok; + TQString text = KInputDialog::getText( + i18n( "New protocol" ), + i18n( "Set a protocol:" ), + lbShowonlyProtocol->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyProtocol->insertStringList( TQStringList::split( ";", text ) ); + setModified(); + } +} + +void ActionProperty::editProtocol() { + if (lbShowonlyProtocol->currentItem() == -1) + return; + + bool ok; + TQString text = KInputDialog::getText( + i18n( "Edit protocol" ), + i18n( "Set another protocol:" ), + lbShowonlyProtocol->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyProtocol->changeItem( text, lbShowonlyProtocol->currentItem() ); + setModified(); + } +} + +void ActionProperty::removeProtocol() { + if (lbShowonlyProtocol->currentItem() != -1) { + lbShowonlyProtocol->removeItem( lbShowonlyProtocol->currentItem() ); + setModified(); + } +} + +void ActionProperty::addPath() { + TQString folder = KFileDialog::getExistingDirectory(TQString(), this); + if (folder != TQString()) { + lbShowonlyPath->insertItem( folder ); + setModified(); + } +} + +void ActionProperty::editPath() { + if (lbShowonlyPath->currentItem() == -1) + return; + + bool ok; + TQString text = KInputDialog::getText( + i18n( "Edit path" ), + i18n( "Set another path:" ), + lbShowonlyPath->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyPath->changeItem( text, lbShowonlyPath->currentItem() ); + setModified(); + } +} + +void ActionProperty::removePath() { + if (lbShowonlyPath->currentItem() != -1) { + lbShowonlyPath->removeItem( lbShowonlyPath->currentItem() ); + setModified(); + } +} + +void ActionProperty::addMime() { + bool ok; + TQString text = KInputDialog::getText( + i18n( "New mime-type" ), + i18n( "Set a mime-type:" ), + lbShowonlyMime->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyMime->insertStringList( TQStringList::split( ";", text ) ); + setModified(); + } +} + +void ActionProperty::editMime() { + if (lbShowonlyMime->currentItem() == -1) + return; + + bool ok; + TQString text = KInputDialog::getText( + i18n( "Edit mime-type" ), + i18n( "Set another mime-type:" ), + lbShowonlyMime->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyMime->changeItem( text, lbShowonlyMime->currentItem() ); + setModified(); + } +} + +void ActionProperty::removeMime() { + if (lbShowonlyMime->currentItem() != -1) { + lbShowonlyMime->removeItem( lbShowonlyMime->currentItem() ); + setModified(); + } +} + +void ActionProperty::newFile() { + bool ok; + TQString text = KInputDialog::getText( + i18n( "New filename" ), + i18n( "Set a filename:" ), + lbShowonlyFile->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyFile->insertStringList( TQStringList::split( ";", text ) ); + setModified(); + } +} + +void ActionProperty::editFile() { + if (lbShowonlyFile->currentItem() == -1) + return; + + bool ok; + TQString text = KInputDialog::getText( + i18n( "Edit filename" ), + i18n( "Set another filename:" ), + lbShowonlyFile->currentText(), + &ok, this ); + if ( ok && !text.isEmpty() ) { + lbShowonlyFile->changeItem( text, lbShowonlyFile->currentItem() ); + setModified(); + } +} + +void ActionProperty::removeFile() { + if (lbShowonlyFile->currentItem() != -1) { + lbShowonlyFile->removeItem( lbShowonlyFile->currentItem() ); + setModified(); + } +} + + +bool ActionProperty::validProperties() { + if ( leDistinctName->text().simplifyWhiteSpace().isEmpty() ) { + KMessageBox::error( this, i18n("Please set a unique name for the useraction") ); + leDistinctName->setFocus(); + return false; + } + if ( leTitle->text().simplifyWhiteSpace().isEmpty() ) { + KMessageBox::error( this, i18n("Please set a title for the menu entry") ); + leTitle->setFocus(); + return false; + } + if ( leCommandline->text().simplifyWhiteSpace().isEmpty() ) { + KMessageBox::error( this, i18n("Command line is empty") ); + leCommandline->setFocus(); + return false; + } + if ( leDistinctName->isEnabled() ) + if ( krApp->actionCollection()->action( leDistinctName->text().latin1() ) ) { + KMessageBox::error( this, + i18n("There already is an action with this name\n" + "If you don't have such an useraction the name is used by Krusader for an internal action") + ); + leDistinctName->setFocus(); + return false; + } + + return true; +} + +void ActionProperty::setModified( bool m ) +{ + if ( m && !_modified ) { // emit only when the state _changes_to_true_, + emit changed(); + } + _modified = m; +} + + +#include "actionproperty.moc" diff --git a/src/app/ActionMan/actionproperty.h b/src/app/ActionMan/actionproperty.h new file mode 100644 index 0000000..dfdc5a1 --- /dev/null +++ b/src/app/ActionMan/actionproperty.h @@ -0,0 +1,147 @@ +// +// C++ Interface: actionproperty +// +// Description: +// +// +// Author: Jonas Bähr (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef ACTIONPROPERTY_H +#define ACTIONPROPERTY_H + +#include "actionpropertybase.h" + +class KrAction; +class TDEShortcut; + +/** + * Use this widget where ever you need to manipulate a UserAction + * @author Jonas Bähr (http://www.jonas-baehr.de) + */ +class ActionProperty : public ActionPropertyBase { + TQ_OBJECT + +public: + ActionProperty( TQWidget *parent=0, const char *name=0, KrAction *action=0 ); + ~ActionProperty(); + + /** + * @return the currently displayed action + */ + KrAction* action() { return _action; }; + + /** + * This inits the widget with the actions properties. + * If no action is provided, the last used will be taken! + * It also resets the changed() state. + * @param action the action which should be displayd + */ + void updateGUI( KrAction *action = 0 ); + + /** + * This writes the displayed properties back into the action. + * If no action is provided, the last used will be taken! + * It also resets the changed() state. + * @param action the action which should be manipulated + */ + void updateAction( KrAction *action = 0 ); + + /** + * clears everything + */ + void clear(); + + /** + * @return true if all properties got valid values + */ + bool validProperties(); + + /** + * @return true if any property got changed + */ + bool isModified() { return _modified; }; + +signals: + /** + * emited when any actionproperty changed. This signal is only emited when + * the _modified attribute changes to true. If there are changes made and + * _modified is already true, no signal is emited! + */ + void changed(); + +protected slots: + void setModified( bool m = true ); + /** + * executes the AddPlaceholderPopup + */ + void addPlaceholder(); + /** + * asks for an existing path + */ + void addStartpath(); + /** + * (availability) asks for a new protocol + */ + void newProtocol(); + /** + * (availability) changes a protocol of the list + */ + void editProtocol(); + /** + * (availability) removes a protocol from the list + */ + void removeProtocol(); + /** + * (availability) asks for a new path + */ + void addPath(); + /** + * (availability) edits a path of the list + */ + void editPath(); + /** + * (availability) removes a path from the list + */ + void removePath(); + /** + * (availability) asks for a new mime-type + */ + void addMime(); + /** + * (availability) changes a mime-type of the list + */ + void editMime(); + /** + * (availability) removes a mime-type from the list + */ + void removeMime(); + /** + * (availability) asks for a new file-filter + */ + void newFile(); + /** + * (availability) edits a file-filter of the list + */ + void editFile(); + /** + * (availability) removes a file-filter from the lsit + */ + void removeFile(); + +private: + KrAction *_action; + bool _modified; + +private slots: + /** + * This updates the ShortcutButton + * @internal + */ + void changedShortcut(const TDEShortcut& shortcut); +}; + +#endif diff --git a/src/app/ActionMan/actionpropertybase.cpp b/src/app/ActionMan/actionpropertybase.cpp new file mode 100644 index 0000000..7facfa5 --- /dev/null +++ b/src/app/ActionMan/actionpropertybase.cpp @@ -0,0 +1,463 @@ +#include +#include +/**************************************************************************** +** Form implementation generated from reading ui file './actionpropertybase.ui' +** +** Created: Sat Mar 15 11:41:43 2008 +** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.8 edited Jan 11 14:47 $) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + +#include "actionpropertybase.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "klineedit.h" +#include "kcombobox.h" +#include "kicondialog.h" +#include "ktextedit.h" +#include "kkeybutton.h" +#include "tdelistbox.h" + +/* + * Constructs a ActionPropertyBase as a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +ActionPropertyBase::ActionPropertyBase( TQWidget* parent, const char* name, WFlags fl ) + : TQWidget( parent, name, fl ) +{ + if ( !name ) + setName( "ActionPropertyBase" ); + ActionPropertyBaseLayout = new TQGridLayout( this, 1, 1, 0, 0, "ActionPropertyBaseLayout"); + + tabWidget3 = new TQTabWidget( this, "tabWidget3" ); + + tab = new TQWidget( tabWidget3, "tab" ); + tabLayout = new TQGridLayout( tab, 1, 1, 11, 6, "tabLayout"); + + ButtonAddStartpath = new TQToolButton( tab, "ButtonAddStartpath" ); + + tabLayout->addWidget( ButtonAddStartpath, 8, 3 ); + + LabelDescription = new TQLabel( tab, "LabelDescription" ); + LabelDescription->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)1, 0, 0, LabelDescription->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelDescription, 4, 0 ); + + bgAccept = new TQButtonGroup( tab, "bgAccept" ); + bgAccept->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)5, (TQSizePolicy::SizeType)1, 0, 0, bgAccept->sizePolicy().hasHeightForWidth() ) ); + bgAccept->setColumnLayout(0, TQt::Vertical ); + bgAccept->layout()->setSpacing( 6 ); + bgAccept->layout()->setMargin( 11 ); + bgAcceptLayout = new TQGridLayout( bgAccept->layout() ); + bgAcceptLayout->setAlignment( TQt::AlignTop ); + + radioLocal = new TQRadioButton( bgAccept, "radioLocal" ); + radioLocal->setChecked( true ); + + bgAcceptLayout->addWidget( radioLocal, 0, 0 ); + + radioUrl = new TQRadioButton( bgAccept, "radioUrl" ); + + bgAcceptLayout->addWidget( radioUrl, 1, 0 ); + + tabLayout->addMultiCellWidget( bgAccept, 9, 9, 2, 3 ); + + leTitle = new KLineEdit( tab, "leTitle" ); + + tabLayout->addMultiCellWidget( leTitle, 2, 2, 1, 3 ); + + LabelTitle = new TQLabel( tab, "LabelTitle" ); + LabelTitle->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, LabelTitle->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelTitle, 2, 0 ); + + layout3 = new TQHBoxLayout( 0, 0, 6, "layout3"); + + layout2 = new TQVBoxLayout( 0, 0, 6, "layout2"); + + leDistinctName = new KLineEdit( tab, "leDistinctName" ); + layout2->addWidget( leDistinctName ); + + cbCategory = new KComboBox( false, tab, "cbCategory" ); + cbCategory->setEditable( true ); + layout2->addWidget( cbCategory ); + layout3->addLayout( layout2 ); + + ButtonIcon = new TDEIconButton( tab, "ButtonIcon" ); + ButtonIcon->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0, 0, 0, ButtonIcon->sizePolicy().hasHeightForWidth() ) ); + ButtonIcon->setMinimumSize( TQSize( 50, 50 ) ); + ButtonIcon->setMaximumSize( TQSize( 50, 50 ) ); + layout3->addWidget( ButtonIcon ); + + tabLayout->addMultiCellLayout( layout3, 0, 1, 1, 3 ); + + LabelDistinctName = new TQLabel( tab, "LabelDistinctName" ); + LabelDistinctName->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, LabelDistinctName->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelDistinctName, 0, 0 ); + + LabelCommandline = new TQLabel( tab, "LabelCommandline" ); + LabelCommandline->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0, 0, 0, LabelCommandline->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelCommandline, 7, 0 ); + + leTooltip = new KLineEdit( tab, "leTooltip" ); + + tabLayout->addMultiCellWidget( leTooltip, 3, 3, 1, 3 ); + + leStartpath = new KLineEdit( tab, "leStartpath" ); + + tabLayout->addMultiCellWidget( leStartpath, 8, 8, 1, 2 ); + + LabelTooltip = new TQLabel( tab, "LabelTooltip" ); + LabelTooltip->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, LabelTooltip->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelTooltip, 3, 0 ); + + leCommandline = new KLineEdit( tab, "leCommandline" ); + + tabLayout->addMultiCellWidget( leCommandline, 7, 7, 1, 2 ); + + LabelCategory = new TQLabel( tab, "LabelCategory" ); + LabelCategory->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, LabelCategory->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelCategory, 1, 0 ); + + ButtonAddPlaceholder = new TQToolButton( tab, "ButtonAddPlaceholder" ); + ButtonAddPlaceholder->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0, 0, 0, ButtonAddPlaceholder->sizePolicy().hasHeightForWidth() ) ); + ButtonAddPlaceholder->setMinimumSize( TQSize( 0, 0 ) ); + + tabLayout->addWidget( ButtonAddPlaceholder, 7, 3 ); + + textDescription = new KTextEdit( tab, "textDescription" ); + textDescription->setWordWrap( KTextEdit::WidgetWidth ); + + tabLayout->addMultiCellWidget( textDescription, 4, 6, 1, 3 ); + + LabelStartpath = new TQLabel( tab, "LabelStartpath" ); + LabelStartpath->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0, 0, 0, LabelStartpath->sizePolicy().hasHeightForWidth() ) ); + + tabLayout->addWidget( LabelStartpath, 8, 0 ); + spacer = new TQSpacerItem( 80, 19, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + tabLayout->addItem( spacer, 6, 0 ); + + layout4 = new TQHBoxLayout( 0, 0, 6, "layout4"); + + LabelShortcut = new TQLabel( tab, "LabelShortcut" ); + layout4->addWidget( LabelShortcut ); + spacer6_2 = new TQSpacerItem( 161, 21, TQSizePolicy::Expanding, TQSizePolicy::Minimum ); + layout4->addItem( spacer6_2 ); + + KeyButtonShortcut = new KKeyButton( tab, "KeyButtonShortcut" ); + layout4->addWidget( KeyButtonShortcut ); + + tabLayout->addMultiCellLayout( layout4, 10, 10, 2, 3 ); + + bgExecType = new TQButtonGroup( tab, "bgExecType" ); + bgExecType->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)5, (TQSizePolicy::SizeType)1, 0, 0, bgExecType->sizePolicy().hasHeightForWidth() ) ); + bgExecType->setColumnLayout(0, TQt::Vertical ); + bgExecType->layout()->setSpacing( 6 ); + bgExecType->layout()->setMargin( 11 ); + bgExecTypeLayout = new TQGridLayout( bgExecType->layout() ); + bgExecTypeLayout->setAlignment( TQt::AlignTop ); + + radioCollectOutput = new TQRadioButton( bgExecType, "radioCollectOutput" ); + + bgExecTypeLayout->addWidget( radioCollectOutput, 2, 0 ); + + chkSeparateStdError = new TQCheckBox( bgExecType, "chkSeparateStdError" ); + chkSeparateStdError->setEnabled( false ); + + bgExecTypeLayout->addWidget( chkSeparateStdError, 3, 0 ); + + radioNormal = new TQRadioButton( bgExecType, "radioNormal" ); + radioNormal->setChecked( true ); + + bgExecTypeLayout->addWidget( radioNormal, 0, 0 ); + + radioTerminal = new TQRadioButton( bgExecType, "radioTerminal" ); + + bgExecTypeLayout->addWidget( radioTerminal, 1, 0 ); + + tabLayout->addMultiCellWidget( bgExecType, 9, 10, 0, 1 ); + tabWidget3->insertTab( tab, TQString::fromLatin1("") ); + + tab_2 = new TQWidget( tabWidget3, "tab_2" ); + tabLayout_2 = new TQGridLayout( tab_2, 1, 1, 11, 6, "tabLayout_2"); + + gbShowonly = new TQGroupBox( tab_2, "gbShowonly" ); + gbShowonly->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)7, (TQSizePolicy::SizeType)7, 0, 0, gbShowonly->sizePolicy().hasHeightForWidth() ) ); + gbShowonly->setColumnLayout(0, TQt::Vertical ); + gbShowonly->layout()->setSpacing( 6 ); + gbShowonly->layout()->setMargin( 11 ); + gbShowonlyLayout = new TQGridLayout( gbShowonly->layout() ); + gbShowonlyLayout->setAlignment( TQt::AlignTop ); + + tabShowonly = new TQTabWidget( gbShowonly, "tabShowonly" ); + tabShowonly->setTabPosition( TQTabWidget::Top ); + tabShowonly->setTabShape( TQTabWidget::Triangular ); + + TabPage = new TQWidget( tabShowonly, "TabPage" ); + TabPageLayout = new TQGridLayout( TabPage, 1, 1, 11, 6, "TabPageLayout"); + + ButtonNewProtocol = new TQToolButton( TabPage, "ButtonNewProtocol" ); + ButtonNewProtocol->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonNewProtocol->sizePolicy().hasHeightForWidth() ) ); + ButtonNewProtocol->setMinimumSize( TQSize( 0, 0 ) ); + ButtonNewProtocol->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout->addWidget( ButtonNewProtocol, 0, 1 ); + + ButtonEditProtocol = new TQToolButton( TabPage, "ButtonEditProtocol" ); + ButtonEditProtocol->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonEditProtocol->sizePolicy().hasHeightForWidth() ) ); + ButtonEditProtocol->setMinimumSize( TQSize( 0, 0 ) ); + ButtonEditProtocol->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout->addWidget( ButtonEditProtocol, 1, 1 ); + spacer6_3 = new TQSpacerItem( 21, 58, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + TabPageLayout->addItem( spacer6_3, 3, 1 ); + + ButtonRemoveProtocol = new TQToolButton( TabPage, "ButtonRemoveProtocol" ); + ButtonRemoveProtocol->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonRemoveProtocol->sizePolicy().hasHeightForWidth() ) ); + ButtonRemoveProtocol->setMinimumSize( TQSize( 0, 0 ) ); + ButtonRemoveProtocol->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout->addWidget( ButtonRemoveProtocol, 2, 1 ); + + lbShowonlyProtocol = new TDEListBox( TabPage, "lbShowonlyProtocol" ); + + TabPageLayout->addMultiCellWidget( lbShowonlyProtocol, 0, 3, 0, 0 ); + tabShowonly->insertTab( TabPage, TQString::fromLatin1("") ); + + tab_3 = new TQWidget( tabShowonly, "tab_3" ); + tabLayout_3 = new TQGridLayout( tab_3, 1, 1, 11, 6, "tabLayout_3"); + + lbShowonlyPath = new TDEListBox( tab_3, "lbShowonlyPath" ); + + tabLayout_3->addMultiCellWidget( lbShowonlyPath, 0, 3, 0, 0 ); + + ButtonAddPath = new TQToolButton( tab_3, "ButtonAddPath" ); + ButtonAddPath->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonAddPath->sizePolicy().hasHeightForWidth() ) ); + ButtonAddPath->setMinimumSize( TQSize( 0, 0 ) ); + ButtonAddPath->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_3->addWidget( ButtonAddPath, 0, 1 ); + + ButtonEditPath = new TQToolButton( tab_3, "ButtonEditPath" ); + ButtonEditPath->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonEditPath->sizePolicy().hasHeightForWidth() ) ); + ButtonEditPath->setMinimumSize( TQSize( 0, 0 ) ); + ButtonEditPath->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_3->addWidget( ButtonEditPath, 1, 1 ); + + ButtonRemovePath = new TQToolButton( tab_3, "ButtonRemovePath" ); + ButtonRemovePath->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonRemovePath->sizePolicy().hasHeightForWidth() ) ); + ButtonRemovePath->setMinimumSize( TQSize( 0, 0 ) ); + ButtonRemovePath->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_3->addWidget( ButtonRemovePath, 2, 1 ); + spacer4 = new TQSpacerItem( 21, 61, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + tabLayout_3->addItem( spacer4, 3, 1 ); + tabShowonly->insertTab( tab_3, TQString::fromLatin1("") ); + + tab_4 = new TQWidget( tabShowonly, "tab_4" ); + tabLayout_4 = new TQGridLayout( tab_4, 1, 1, 11, 6, "tabLayout_4"); + + lbShowonlyMime = new TDEListBox( tab_4, "lbShowonlyMime" ); + + tabLayout_4->addMultiCellWidget( lbShowonlyMime, 0, 3, 0, 0 ); + + ButtonAddMime = new TQToolButton( tab_4, "ButtonAddMime" ); + ButtonAddMime->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonAddMime->sizePolicy().hasHeightForWidth() ) ); + ButtonAddMime->setMinimumSize( TQSize( 0, 0 ) ); + ButtonAddMime->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_4->addWidget( ButtonAddMime, 0, 1 ); + + ButtonEditMime = new TQToolButton( tab_4, "ButtonEditMime" ); + ButtonEditMime->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonEditMime->sizePolicy().hasHeightForWidth() ) ); + ButtonEditMime->setMinimumSize( TQSize( 0, 0 ) ); + ButtonEditMime->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_4->addWidget( ButtonEditMime, 1, 1 ); + + ButtonRemoveMime = new TQToolButton( tab_4, "ButtonRemoveMime" ); + ButtonRemoveMime->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonRemoveMime->sizePolicy().hasHeightForWidth() ) ); + ButtonRemoveMime->setMinimumSize( TQSize( 0, 0 ) ); + ButtonRemoveMime->setMaximumSize( TQSize( 32767, 32767 ) ); + + tabLayout_4->addWidget( ButtonRemoveMime, 2, 1 ); + spacer5 = new TQSpacerItem( 21, 41, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + tabLayout_4->addItem( spacer5, 3, 1 ); + tabShowonly->insertTab( tab_4, TQString::fromLatin1("") ); + + TabPage_2 = new TQWidget( tabShowonly, "TabPage_2" ); + TabPageLayout_2 = new TQGridLayout( TabPage_2, 1, 1, 11, 6, "TabPageLayout_2"); + + lbShowonlyFile = new TDEListBox( TabPage_2, "lbShowonlyFile" ); + + TabPageLayout_2->addMultiCellWidget( lbShowonlyFile, 0, 3, 0, 0 ); + + ButtonNewFile = new TQToolButton( TabPage_2, "ButtonNewFile" ); + ButtonNewFile->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonNewFile->sizePolicy().hasHeightForWidth() ) ); + ButtonNewFile->setMinimumSize( TQSize( 0, 0 ) ); + ButtonNewFile->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout_2->addWidget( ButtonNewFile, 0, 1 ); + + ButtonEditFile = new TQToolButton( TabPage_2, "ButtonEditFile" ); + ButtonEditFile->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonEditFile->sizePolicy().hasHeightForWidth() ) ); + ButtonEditFile->setMinimumSize( TQSize( 0, 0 ) ); + ButtonEditFile->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout_2->addWidget( ButtonEditFile, 1, 1 ); + + ButtonRemoveFile = new TQToolButton( TabPage_2, "ButtonRemoveFile" ); + ButtonRemoveFile->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0, 0, 0, ButtonRemoveFile->sizePolicy().hasHeightForWidth() ) ); + ButtonRemoveFile->setMinimumSize( TQSize( 0, 0 ) ); + ButtonRemoveFile->setMaximumSize( TQSize( 32767, 32767 ) ); + + TabPageLayout_2->addWidget( ButtonRemoveFile, 2, 1 ); + spacer6 = new TQSpacerItem( 21, 41, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + TabPageLayout_2->addItem( spacer6, 3, 1 ); + tabShowonly->insertTab( TabPage_2, TQString::fromLatin1("") ); + + gbShowonlyLayout->addWidget( tabShowonly, 0, 0 ); + + tabLayout_2->addMultiCellWidget( gbShowonly, 0, 0, 0, 1 ); + + chkConfirmExecution = new TQCheckBox( tab_2, "chkConfirmExecution" ); + + tabLayout_2->addMultiCellWidget( chkConfirmExecution, 1, 1, 0, 1 ); + + chkDifferentUser = new TQCheckBox( tab_2, "chkDifferentUser" ); + + tabLayout_2->addWidget( chkDifferentUser, 2, 0 ); + + leDifferentUser = new KLineEdit( tab_2, "leDifferentUser" ); + leDifferentUser->setEnabled( false ); + + tabLayout_2->addWidget( leDifferentUser, 2, 1 ); + spacer3 = new TQSpacerItem( 161, 102, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + tabLayout_2->addMultiCell( spacer3, 3, 3, 0, 1 ); + tabWidget3->insertTab( tab_2, TQString::fromLatin1("") ); + + ActionPropertyBaseLayout->addWidget( tabWidget3, 0, 0 ); + languageChange(); + resize( TQSize(485, 470).expandedTo(minimumSizeHint()) ); + clearWState( WState_Polished ); + + // signals and slots connections + connect( radioCollectOutput, TQ_SIGNAL( toggled(bool) ), chkSeparateStdError, TQ_SLOT( setEnabled(bool) ) ); + connect( chkDifferentUser, TQ_SIGNAL( toggled(bool) ), leDifferentUser, TQ_SLOT( setEnabled(bool) ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +ActionPropertyBase::~ActionPropertyBase() +{ + // no need to delete child widgets, TQt does it all for us +} + +/* + * Sets the strings of the subwidgets using the current + * language. + */ +void ActionPropertyBase::languageChange() +{ + setCaption( tr2i18n( "Action Property" ) ); + ButtonAddStartpath->setText( tr2i18n( "..." ) ); + LabelDescription->setText( tr2i18n( "Description:" ) ); + TQWhatsThis::add( LabelDescription, tr2i18n( "A detailed description of the Useraction. It is only displayed in the Konfigurator and via Shift-F1." ) ); + bgAccept->setTitle( tr2i18n( "Command accepts" ) ); + radioLocal->setText( tr2i18n( "Local files only (no URL's)" ) ); + TQWhatsThis::add( radioLocal, tr2i18n( "Substitute the Placeholders with local filenames." ) ); + radioUrl->setText( tr2i18n( "URL's (remote and local)" ) ); + TQWhatsThis::add( radioUrl, tr2i18n( "Substitute the Placeholders with valid URL's." ) ); + TQWhatsThis::add( leTitle, tr2i18n( "The title displayed in the Usermenu." ) ); + LabelTitle->setText( tr2i18n( "Title:" ) ); + TQWhatsThis::add( LabelTitle, tr2i18n( "The title displayed in the Usermenu." ) ); + TQWhatsThis::add( leDistinctName, tr2i18n( "Unique name of the Useraction. It is only used in the Konfigurator and doesn't appear in any other menu.

Note: The Title shown in the Usermenu can be set below." ) ); + TQWhatsThis::add( cbCategory, tr2i18n( "Useractions can be grouped in categories for better distinction. Choose a existing Category or create a new one by entering a name." ) ); + ButtonIcon->setText( tr2i18n( "Icon" ) ); + TQWhatsThis::add( ButtonIcon, tr2i18n( "Each Useraction can have its own icon. It will appear in front of the title in the Usermenu." ) ); + LabelDistinctName->setText( tr2i18n( "Identifier:" ) ); + TQWhatsThis::add( LabelDistinctName, tr2i18n( "

Unique name of the Useraction. It is only used in the Konfigurator and doesn't appear in any other menu.

Note: The Title shown in the Usermenu can be set below.

" ) ); + LabelCommandline->setText( tr2i18n( "Command:" ) ); + TQWhatsThis::add( LabelCommandline, tr2i18n( "

The Command defines the command that will be executed when the Useraction is used. It can be a simple shell command or a complex sequence of multiple commands with Placeholders.

Examples:

  • eject /mnt/cdrom
  • amarok --append %aList(\"Selected\")%
\n" +"Please consult the handbook to learn more about the syntax.

" ) ); + TQWhatsThis::add( leTooltip, tr2i18n( "The Tooltip is shown when the mouse cursor is hold over an entry of the Useraction Toolbar." ) ); + TQWhatsThis::add( leStartpath, tr2i18n( "The Workdir defines in which directory the Command will be executed." ) ); + LabelTooltip->setText( tr2i18n( "Tooltip:" ) ); + TQWhatsThis::add( LabelTooltip, tr2i18n( "The Tooltip is shown when the mouse cursor is hold over an entry of the Useraction Toolbar." ) ); + leCommandline->setText( TQString() ); + TQWhatsThis::add( leCommandline, tr2i18n( "The Command defines the command that will be executed when the Useraction is used. It can be a simple shell command or a complex sequence of multiple commands with Placeholders.

\n" +"Examples:

  • eject /mnt/cdrom
  • amarok --append %aList(\"Selected\")%
\n" +"Please consult the handbook to learn more about the syntax." ) ); + LabelCategory->setText( tr2i18n( "Category:" ) ); + TQWhatsThis::add( LabelCategory, tr2i18n( "Useractions can be grouped in categories for better distinction. Choose a existing Category or create a new one by entering a name." ) ); + ButtonAddPlaceholder->setText( tr2i18n( "&Add" ) ); + TQWhatsThis::add( ButtonAddPlaceholder, tr2i18n( "Add Placeholders for the selected files in the panel." ) ); + TQWhatsThis::add( textDescription, tr2i18n( "A detailed description of the Useraction. It is only displayed in the Konfigurator and via Shift-F1." ) ); + LabelStartpath->setText( tr2i18n( "Workdir:" ) ); + TQWhatsThis::add( LabelStartpath, tr2i18n( "The Workdir defines in which directory the Command will be executed." ) ); + LabelShortcut->setText( tr2i18n( "Default shortcut:" ) ); + KeyButtonShortcut->setText( tr2i18n( "None" ) ); + TQWhatsThis::add( KeyButtonShortcut, tr2i18n( "Set a default keyboard shortcut." ) ); + bgExecType->setTitle( tr2i18n( "Execution mode" ) ); + radioCollectOutput->setText( tr2i18n( "Collect output" ) ); + TQWhatsThis::add( radioCollectOutput, tr2i18n( "Collect the output of the executed program." ) ); + chkSeparateStdError->setText( tr2i18n( "Separate standard error" ) ); + TQWhatsThis::add( chkSeparateStdError, tr2i18n( "Separate standard out and standard error in the output collection." ) ); + radioNormal->setText( tr2i18n( "Normal" ) ); + radioTerminal->setText( tr2i18n( "Run in terminal" ) ); + TQWhatsThis::add( radioTerminal, tr2i18n( "Run the command in a terminal." ) ); + tabWidget3->changeTab( tab, tr2i18n( "Basic Properties" ) ); + gbShowonly->setTitle( tr2i18n( "The Useraction is only available for" ) ); + ButtonNewProtocol->setText( tr2i18n( "&New..." ) ); + ButtonEditProtocol->setText( tr2i18n( "Chan&ge..." ) ); + ButtonRemoveProtocol->setText( tr2i18n( "De&lete" ) ); + TQWhatsThis::add( lbShowonlyProtocol, tr2i18n( "Show the Useraction only for the values defined here." ) ); + tabShowonly->changeTab( TabPage, tr2i18n( "Protocol" ) ); + TQWhatsThis::add( lbShowonlyPath, tr2i18n( "Show the Useraction only for the values defined here." ) ); + ButtonAddPath->setText( tr2i18n( "&New..." ) ); + ButtonEditPath->setText( tr2i18n( "Chan&ge..." ) ); + ButtonRemovePath->setText( tr2i18n( "De&lete" ) ); + tabShowonly->changeTab( tab_3, tr2i18n( "Path" ) ); + TQWhatsThis::add( lbShowonlyMime, tr2i18n( "Show the Useraction only for the values defined here." ) ); + ButtonAddMime->setText( tr2i18n( "&New..." ) ); + ButtonEditMime->setText( tr2i18n( "Chan&ge..." ) ); + ButtonRemoveMime->setText( tr2i18n( "De&lete" ) ); + tabShowonly->changeTab( tab_4, tr2i18n( "Mime-type" ) ); + TQWhatsThis::add( lbShowonlyFile, tr2i18n( "Show the Useraction only for the filenames defined here. The wildcards '?' and '*' can be used." ) ); + ButtonNewFile->setText( tr2i18n( "&New..." ) ); + ButtonEditFile->setText( tr2i18n( "Chan&ge..." ) ); + ButtonRemoveFile->setText( tr2i18n( "De&lete" ) ); + tabShowonly->changeTab( TabPage_2, tr2i18n( "Filename" ) ); + chkConfirmExecution->setText( tr2i18n( "Confirm each program call separately" ) ); + TQWhatsThis::add( chkConfirmExecution, tr2i18n( "Allows to tweak the Command before it is executed." ) ); + chkDifferentUser->setText( tr2i18n( "Run as different user:" ) ); + TQWhatsThis::add( chkDifferentUser, tr2i18n( "Execute the Command under a different user-id." ) ); + TQWhatsThis::add( leDifferentUser, tr2i18n( "Execute the Command under a different user-id." ) ); + tabWidget3->changeTab( tab_2, tr2i18n( "Advanced Properties" ) ); +} + +#include "actionpropertybase.moc" diff --git a/src/app/ActionMan/actionpropertybase.ui b/src/app/ActionMan/actionpropertybase.ui new file mode 100644 index 0000000..42cd052 --- /dev/null +++ b/src/app/ActionMan/actionpropertybase.ui @@ -0,0 +1,1116 @@ + +ActionPropertyBase + + + ActionPropertyBase + + + + 0 + 0 + 485 + 470 + + + + Action Property + + + + unnamed + + + 0 + + + 0 + + + + tabWidget3 + + + + tab + + + Basic Properties + + + + unnamed + + + + ButtonAddStartpath + + + ... + + + + + LabelDescription + + + + 1 + 1 + 0 + 0 + + + + Description: + + + A detailed description of the <b>Useraction</b>. It is only displayed in the <i>Konfigurator</i> and via <code>Shift-F1</code>. + + + + + bgAccept + + + + 5 + 1 + 0 + 0 + + + + Command accepts + + + + unnamed + + + + radioLocal + + + Local files only (no URL's) + + + true + + + Substitute the <b>Placeholders</b> with local filenames. + + + + + radioUrl + + + URL's (remote and local) + + + Substitute the <b>Placeholders</b> with valid URL's. + + + + + + + leTitle + + + The title displayed in the <b>Usermenu</b>. + + + + + LabelTitle + + + + 1 + 0 + 0 + 0 + + + + Title: + + + The title displayed in the <b>Usermenu</b>. + + + + + layout3 + + + + unnamed + + + + layout2 + + + + unnamed + + + + leDistinctName + + + Unique name of the <b>Useraction</b>. It is only used in the <i>Konfigurator</i> and doesn't appear in any other menu.<p><b>Note</b>: The <i>Title</i> shown in the <b>Usermenu</b> can be set below. + + + + + cbCategory + + + true + + + <b>Useractions</b> can be grouped in categories for better distinction. Choose a existing <i>Category</i> or create a new one by entering a name. + + + + + + + ButtonIcon + + + + 0 + 0 + 0 + 0 + + + + + 50 + 50 + + + + + 50 + 50 + + + + Icon + + + Each <b>Useraction</b> can have its own icon. It will appear in front of the title in the <b>Usermenu</b>. + + + + + + + LabelDistinctName + + + + 1 + 0 + 0 + 0 + + + + Identifier: + + + <p>Unique name of the <b>Useraction</b>. It is only used in the <i>Konfigurator</i> and doesn't appear in any other menu.</p><p><b>Note</b>: The <i>Title</i> shown in the <b>Usermenu</b> can be set below.</p> + + + + + LabelCommandline + + + + 0 + 0 + 0 + 0 + + + + Command: + + + <p>The <i>Command</i> defines the command that will be executed when the <b>Useraction</b> is used. It can be a simple shell command or a complex sequence of multiple commands with <b>Placeholders</b>.</p><p>Examples:<ul><code><li>eject /mnt/cdrom</li><li>amarok --append %aList("Selected")%</li></code></ul> +Please consult the handbook to learn more about the syntax.</p> + + + + + leTooltip + + + The <i>Tooltip</i> is shown when the mouse cursor is hold over an entry of the <b>Useraction Toolbar</b>. + + + + + leStartpath + + + The <i>Workdir</i> defines in which directory the <i>Command</i> will be executed. + + + + + LabelTooltip + + + + 1 + 0 + 0 + 0 + + + + Tooltip: + + + The <i>Tooltip</i> is shown when the mouse cursor is hold over an entry of the <b>Useraction Toolbar</b>. + + + + + leCommandline + + + + + + The <i>Command</i> defines the command that will be executed when the <b>Useraction</b> is used. It can be a simple shell command or a complex sequence of multiple commands with <b>Placeholders</b>.<p> +Examples:<ul><code><li>eject /mnt/cdrom</li><li>amarok --append %aList("Selected")%</li></code></ul> +Please consult the handbook to learn more about the syntax. + + + + + LabelCategory + + + + 1 + 0 + 0 + 0 + + + + Category: + + + <b>Useractions</b> can be grouped in categories for better distinction. Choose a existing <i>Category</i> or create a new one by entering a name. + + + + + ButtonAddPlaceholder + + + + 0 + 0 + 0 + 0 + + + + + 0 + 0 + + + + &Add + + + Add <b>Placeholders</b> for the selected files in the panel. + + + + + textDescription + + + WidgetWidth + + + A detailed description of the <b>Useraction</b>. It is only displayed in the <i>Konfigurator</i> and via <code>Shift-F1</code>. + + + + + LabelStartpath + + + + 0 + 0 + 0 + 0 + + + + Workdir: + + + The <i>Workdir</i> defines in which directory the <i>Command</i> will be executed. + + + + + spacer + + + Vertical + + + Expanding + + + + 80 + 19 + + + + + + layout4 + + + + unnamed + + + + LabelShortcut + + + Default shortcut: + + + + + spacer6_2 + + + Horizontal + + + Expanding + + + + 161 + 21 + + + + + + KeyButtonShortcut + + + None + + + Set a default keyboard shortcut. + + + + + + + bgExecType + + + + 5 + 1 + 0 + 0 + + + + Execution mode + + + + unnamed + + + + radioCollectOutput + + + Collect output + + + Collect the output of the executed program. + + + + + chkSeparateStdError + + + false + + + Separate standard error + + + Separate standard out and standard error in the output collection. + + + + + radioNormal + + + Normal + + + true + + + + + radioTerminal + + + Run in terminal + + + Run the command in a terminal. + + + + + + + + + tab + + + Advanced Properties + + + + unnamed + + + + gbShowonly + + + + 7 + 7 + 0 + 0 + + + + The Useraction is only available for + + + + unnamed + + + + tabShowonly + + + Top + + + Triangular + + + + TabPage + + + Protocol + + + + unnamed + + + + ButtonNewProtocol + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + &New... + + + + + ButtonEditProtocol + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + Chan&ge... + + + + + spacer6_3 + + + Vertical + + + Expanding + + + + 21 + 58 + + + + + + ButtonRemoveProtocol + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + De&lete + + + + + lbShowonlyProtocol + + + Show the <b>Useraction</b> only for the values defined here. + + + + + + + tab + + + Path + + + + unnamed + + + + lbShowonlyPath + + + Show the <b>Useraction</b> only for the values defined here. + + + + + ButtonAddPath + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + &New... + + + + + ButtonEditPath + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + Chan&ge... + + + + + ButtonRemovePath + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + De&lete + + + + + spacer4 + + + Vertical + + + Expanding + + + + 21 + 61 + + + + + + + + tab + + + Mime-type + + + + unnamed + + + + lbShowonlyMime + + + Show the <b>Useraction</b> only for the values defined here. + + + + + ButtonAddMime + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + &New... + + + + + ButtonEditMime + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + Chan&ge... + + + + + ButtonRemoveMime + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + De&lete + + + + + spacer5 + + + Vertical + + + Expanding + + + + 21 + 41 + + + + + + + + TabPage + + + Filename + + + + unnamed + + + + lbShowonlyFile + + + Show the <b>Useraction</b> only for the filenames defined here. The wildcards '<code>?</code>' and '<code>*</code>' can be used. + + + + + ButtonNewFile + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + &New... + + + + + ButtonEditFile + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + Chan&ge... + + + + + ButtonRemoveFile + + + + 1 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + 32767 + 32767 + + + + De&lete + + + + + spacer6 + + + Vertical + + + Expanding + + + + 21 + 41 + + + + + + + + + + + chkConfirmExecution + + + Confirm each program call separately + + + Allows to tweak the <i>Command</i> before it is executed. + + + + + chkDifferentUser + + + Run as different user: + + + Execute the <i>Command</i> under a different user-id. + + + + + leDifferentUser + + + false + + + Execute the <i>Command</i> under a different user-id. + + + + + spacer3 + + + Vertical + + + Expanding + + + + 161 + 102 + + + + + + + + + + + radioCollectOutput + toggled(bool) + chkSeparateStdError + setEnabled(bool) + + + chkDifferentUser + toggled(bool) + leDifferentUser + setEnabled(bool) + + + + + kcombobox.h + kicondialog.h + kkeybutton.h + klineedit.h + ktextedit.h + tdelistbox.h + + diff --git a/src/app/ActionMan/addplaceholderpopup.cpp b/src/app/ActionMan/addplaceholderpopup.cpp new file mode 100644 index 0000000..3fe7c29 --- /dev/null +++ b/src/app/ActionMan/addplaceholderpopup.cpp @@ -0,0 +1,582 @@ +// +// C++ Implementation: addplaceholderpopup +// +// Description: +// +// +// Author: Shie Erlich and Rafi Yanai <>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "addplaceholderpopup.h" + +#include "../UserAction/expander.h" + +#include +#include +#include + +// for ParameterDialog +#include "../krusader.h" // for konfig-access +#include "../BookMan/krbookmarkbutton.h" +#include "../GUI/profilemanager.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define ACTIVE_MASK 0x0100 +#define OTHER_MASK 0x0200 +#define LEFT_MASK 0x0400 +#define RIGHT_MASK 0x0800 +#define INDEPENDENT_MASK 0x1000 +#define EXECUTABLE_ID 0xFFFF + + +AddPlaceholderPopup::AddPlaceholderPopup( TQWidget *parent ) : TDEPopupMenu( parent ) { + + _activeSub = new TDEPopupMenu( this ); + _otherSub = new TDEPopupMenu( this ); + _leftSub = new TDEPopupMenu( this ); + _rightSub = new TDEPopupMenu( this ); + _independentSub = new TDEPopupMenu( this ); + + insertItem( i18n( "Active panel" ), _activeSub ); + insertItem( i18n( "Other panel" ), _otherSub ); + insertItem( i18n( "Left panel" ), _leftSub ); + insertItem( i18n( "Right panel" ), _rightSub ); + insertItem( i18n( "Panel independent" ), _independentSub ); + _independentSub->insertItem( i18n( "Choose executable..." ), EXECUTABLE_ID ); + _independentSub->insertSeparator(); + + // read the expressions array from the user menu and populate menus + Expander expander; + for ( int i = 0; i < expander.placeholderCount(); ++i ) { + if ( expander.placeholder( i )->expression().isEmpty() ) { + if ( expander.placeholder( i )->needPanel() ) { + _activeSub->insertSeparator(); + _otherSub->insertSeparator(); + _leftSub->insertSeparator(); + _rightSub->insertSeparator(); + } + else + _independentSub->insertSeparator(); + } + else { + if ( expander.placeholder( i )->needPanel() ) { + _activeSub->insertItem( i18n( expander.placeholder( i )->description().utf8() ), ( i | ACTIVE_MASK ) ); + _otherSub->insertItem( i18n( expander.placeholder( i )->description().utf8() ), ( i | OTHER_MASK ) ); + _leftSub->insertItem( i18n( expander.placeholder( i )->description().utf8() ), ( i | LEFT_MASK ) ); + _rightSub->insertItem( i18n( expander.placeholder( i )->description().utf8() ), ( i | RIGHT_MASK ) ); + } + else + _independentSub->insertItem( i18n( expander.placeholder( i )->description().utf8() ), ( i | INDEPENDENT_MASK ) ); + } + } + +} + + +TQString AddPlaceholderPopup::getPlaceholder( const TQPoint& pos ) { + int res = exec( pos ); + if ( res == -1 ) + return TQString(); + + // add the selected flag to the command line + if ( res == EXECUTABLE_ID ) { // did the user need an executable ? + // select an executable + TQString filename = KFileDialog::getOpenFileName(TQString(), TQString(), this); + if (filename != TQString()) + return filename + " "; // with extra space + //return filename; // without extra space + } else { // user selected something from the menus + Expander expander; + const exp_placeholder* currentPlaceholder = expander.placeholder( res & ~( ACTIVE_MASK | OTHER_MASK | LEFT_MASK | RIGHT_MASK | INDEPENDENT_MASK ) ); +// if ( ¤tPlaceholder->expFunc == 0 ) { +// KMessageBox::sorry( this, "BOFH Excuse #93:\nFeature not yet implemented" ); +// return TQString(); +// } + ParameterDialog* parameterDialog = new ParameterDialog( currentPlaceholder, this ); + TQString panel, parameter = parameterDialog->getParameter(); + delete parameterDialog; + // indicate the panel with 'a' 'o', 'l', 'r' or '_'. + if ( res & ACTIVE_MASK ) + panel = "a"; + else if ( res & OTHER_MASK ) + panel = "o"; + else if ( res & LEFT_MASK ) + panel = "l"; + else if ( res & RIGHT_MASK ) + panel = "r"; + else if ( res & INDEPENDENT_MASK ) + panel = "_"; + //return "%" + panel + currentPlaceholder->expression() + parameter + "% "; // with extra space + return "%" + panel + currentPlaceholder->expression() + parameter + "%"; // without extra space + } + return TQString(); +} + + +//////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////// ParameterDialog //////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////// + +ParameterDialog::ParameterDialog( const exp_placeholder* currentPlaceholder, TQWidget *parent ) : KDialogBase( Plain, i18n("User Action Parameter Dialog"), Default | Ok, Ok, parent ) { + _parameter.clear(); + _parameterCount = currentPlaceholder->parameterCount(); + + TQVBoxLayout* layout = new TQVBoxLayout( plainPage() ); + layout->setAutoAdd( true ); + layout->setSpacing( 11 ); + + new TQLabel( i18n("This placeholder allows some parameter:"), plainPage(), "intro" ); + + for (int i = 0; i < _parameterCount; ++i ) { + if ( currentPlaceholder->parameter( i ).preset() == "__placeholder" ) + _parameter.append( new ParameterPlaceholder( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__yes" ) + _parameter.append( new ParameterYes( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__no" ) + _parameter.append( new ParameterNo( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__file" ) + _parameter.append( new ParameterFile( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset().find( "__choose" ) != -1 ) + _parameter.append( new ParameterChoose( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__select" ) + _parameter.append( new ParameterSelect( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__goto" ) + _parameter.append( new ParameterGoto( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__syncprofile" ) + _parameter.append( new ParameterSyncprofile( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__searchprofile" ) + _parameter.append( new ParameterSearch( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset() == "__panelprofile" ) + _parameter.append( new ParameterPanelprofile( currentPlaceholder->parameter( i ), plainPage() ) ); + else if ( currentPlaceholder->parameter( i ).preset().find( "__int" ) != -1 ) + _parameter.append( new ParameterInt( currentPlaceholder->parameter( i ), plainPage() ) ); + else + _parameter.append( new ParameterText( currentPlaceholder->parameter( i ), plainPage() ) ); + } + + TQFrame * line = new TQFrame( plainPage() ); + line->setFrameShape( TQFrame::HLine ); + line->setFrameShadow( TQFrame::Sunken ); + + connect( this, TQ_SIGNAL(defaultClicked()), this, TQ_SLOT(reset()) ); +} + +TQString ParameterDialog::getParameter() { + if ( _parameterCount == 0 ) // meaning no parameters + return TQString(); + + if ( exec() == -1 ) + return TQString(); + + int lastParameter = _parameterCount; + while ( --lastParameter > -1 ) { + if ( _parameter[ lastParameter ]->text() != _parameter[ lastParameter ]->preset() || _parameter[ lastParameter ]->nessesary() ) + break; + } + + if ( lastParameter < 0) // all parameters have default-values + return TQString(); + + TQString parameter = "("; + for ( int i = 0; i <= lastParameter; ++i ) { + if ( i > 0 ) + parameter += ", "; + parameter += "\"" + _parameter[ i ]->text().replace( "\"", "\\\"" ) + "\""; + } + parameter += ")"; + return parameter; +} + +void ParameterDialog::reset() { + for ( int i = 0; i < _parameterCount; ++i ) + _parameter[ i ]->reset(); +} + +void ParameterDialog::slotOk() { + bool valid = true; + for (int i = 0; i < _parameterCount; ++i ) { + if ( _parameter[ i ]->nessesary() && ! _parameter[ i ]->valid() ) + valid = false; + } + + if ( valid ) + accept(); +} + +///////////// ParameterText +ParameterText::ParameterText( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _lineEdit = new KLineEdit( parameter.preset(), this ); + _preset = parameter.preset(); +} + +TQString ParameterText::text() { + return _lineEdit->text(); +} +TQString ParameterText::preset() { + return _preset; +} +void ParameterText::reset() { + _lineEdit->setText( _preset ); +} +bool ParameterText::valid() { + if ( _lineEdit->text().isEmpty() ) + return false; + else + return true; +} + +///////////// ParameterPlaceholder +ParameterPlaceholder::ParameterPlaceholder( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + TQHBox * hbox = new TQHBox( this ); + hbox->setSpacing( 6 ); + _lineEdit = new KLineEdit( hbox ); + _button = new TQToolButton( hbox); + _button->setText( i18n("add") ); + connect( _button, TQ_SIGNAL(clicked()), this, TQ_SLOT(addPlaceholder()) ); +} + +TQString ParameterPlaceholder::text() { + return _lineEdit->text(); +} +TQString ParameterPlaceholder::preset() { + return TQString(); +} +void ParameterPlaceholder::reset() { + _lineEdit->setText( TQString() ); +} +bool ParameterPlaceholder::valid() { + if ( _lineEdit->text().isEmpty() ) + return false; + else + return true; +} +void ParameterPlaceholder::addPlaceholder() { + AddPlaceholderPopup* popup = new AddPlaceholderPopup( this ); + TQString exp = popup->getPlaceholder( mapToGlobal( TQPoint( _button->pos().x() + _button->width() + 6, _button->pos().y() + _button->height() / 2 ) ) ); + _lineEdit->insert( exp ); + delete popup; +} + +///////////// ParameterYes +ParameterYes::ParameterYes( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + _checkBox = new TQCheckBox( i18n( parameter.description().utf8() ), this ); + _checkBox->setChecked( true ); +} + +TQString ParameterYes::text() { + if ( _checkBox->isChecked() ) + return TQString(); + else + return "No"; +} +TQString ParameterYes::preset() { + return TQString(); +} +void ParameterYes::reset() { + _checkBox->setChecked( true ); +} +bool ParameterYes::valid() { + return true; +} + +///////////// ParameterNo +ParameterNo::ParameterNo( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + _checkBox = new TQCheckBox( i18n( parameter.description().utf8() ), this ); + _checkBox->setChecked( false ); +} + +TQString ParameterNo::text() { + if ( _checkBox->isChecked() ) + return "Yes"; + else + return TQString(); +} +TQString ParameterNo::preset() { + return TQString(); +} +void ParameterNo::reset() { + _checkBox->setChecked( false ); +} +bool ParameterNo::valid() { + return true; +} + +///////////// ParameterFile +ParameterFile::ParameterFile( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + TQHBox * hbox = new TQHBox( this ); + hbox->setSpacing( 6 ); + _lineEdit = new KLineEdit( hbox ); + _button = new TQToolButton( hbox); + TDEIconLoader *iconLoader = new TDEIconLoader(); + _button->setPixmap( iconLoader->loadIcon( "document-open", TDEIcon::Toolbar, 16 ) ); + connect( _button, TQ_SIGNAL(clicked()), this, TQ_SLOT(addFile()) ); +} + +TQString ParameterFile::text() { + return _lineEdit->text(); +} +TQString ParameterFile::preset() { + return TQString(); +} +void ParameterFile::reset() { + _lineEdit->setText( TQString() ); +} +bool ParameterFile::valid() { + if ( _lineEdit->text().isEmpty() ) + return false; + else + return true; +} +void ParameterFile::addFile() { + TQString filename = KFileDialog::getOpenFileName(TQString(), TQString(), this); + _lineEdit->insert( filename ); +} + +///////////// ParameterChoose +ParameterChoose::ParameterChoose( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _combobox = new KComboBox( this ); + _combobox->insertStringList( TQStringList::split( ";", parameter.preset().section(":", 1) ) ); +} + +TQString ParameterChoose::text() { + return _combobox->currentText(); +} +TQString ParameterChoose::preset() { + return _combobox->text( 0 ); +} +void ParameterChoose::reset() { + _combobox->setCurrentItem( 0 ); +} +bool ParameterChoose::valid() { + return true; +} + +///////////// ParameterSelect +ParameterSelect::ParameterSelect( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _combobox = new KComboBox( this ); + _combobox->setEditable( true ); + + krConfig->setGroup( "Private" ); + TQStrList lst; + int i = krConfig->readListEntry( "Predefined Selections", lst ); + if ( i > 0 ) + _combobox->insertStrList( lst ); + + _combobox->setCurrentText( "*" ); +} + +TQString ParameterSelect::text() { + return _combobox->currentText(); +} +TQString ParameterSelect::preset() { + return "*"; +} +void ParameterSelect::reset() { + _combobox->setCurrentText( "*" ); +} +bool ParameterSelect::valid() { + return true; +} + +///////////// ParameterGoto +ParameterGoto::ParameterGoto( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + TQHBox * hbox = new TQHBox( this ); + hbox->setSpacing( 6 ); + _lineEdit = new KLineEdit( hbox ); + _lineEdit->setCompletionObject( new KURLCompletion( KURLCompletion::DirCompletion ) ); + _dirButton = new TQToolButton( hbox ); + TDEIconLoader *iconLoader = new TDEIconLoader(); + _dirButton->setPixmap( iconLoader->loadIcon( "document-open", TDEIcon::Toolbar, 16 ) ); + connect( _dirButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(setDir()) ); + _placeholderButton = new TQToolButton( hbox); + _placeholderButton->setText( i18n("add") ); + connect( _placeholderButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(addPlaceholder()) ); +} + +TQString ParameterGoto::text() { + return _lineEdit->text(); +} +TQString ParameterGoto::preset() { + return TQString(); +} +void ParameterGoto::reset() { + _lineEdit->setText( TQString() ); +} +bool ParameterGoto::valid() { + if ( _lineEdit->text().isEmpty() ) + return false; + else + return true; +} +void ParameterGoto::setDir() { + TQString folder = KFileDialog::getExistingDirectory(TQString(), this); + _lineEdit->setText( folder ); +} +void ParameterGoto::addPlaceholder() { + AddPlaceholderPopup* popup = new AddPlaceholderPopup( this ); + TQString exp = popup->getPlaceholder( mapToGlobal( TQPoint( _placeholderButton->pos().x() + _placeholderButton->width() + 6, _placeholderButton->pos().y() + _placeholderButton->height() / 2 ) ) ); + _lineEdit->insert( exp ); + delete popup; +} + +///////////// ParameterSyncprofile +ParameterSyncprofile::ParameterSyncprofile( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _combobox = new KComboBox( this ); + + _combobox->insertStringList( ProfileManager::availableProfiles("SynchronizerProfile") ); +} + +TQString ParameterSyncprofile::text() { + return _combobox->currentText(); +} +TQString ParameterSyncprofile::preset() { + return _combobox->text( 0 ); +} +void ParameterSyncprofile::reset() { + _combobox->setCurrentItem( 0 ); +} +bool ParameterSyncprofile::valid() { + return true; +} + +///////////// ParameterSearch +ParameterSearch::ParameterSearch( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _combobox = new KComboBox( this ); + + _combobox->insertStringList( ProfileManager::availableProfiles("SearcherProfile") ); +} + +TQString ParameterSearch::text() { + return _combobox->currentText(); +} +TQString ParameterSearch::preset() { + return _combobox->text( 0 ); +} +void ParameterSearch::reset() { + _combobox->setCurrentItem( 0 ); +} +bool ParameterSearch::valid() { + return true; +} + +///////////// ParameterPanelprofile +ParameterPanelprofile::ParameterPanelprofile( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _combobox = new KComboBox( this ); + + _combobox->insertStringList( ProfileManager::availableProfiles("Panel") ); +} + +TQString ParameterPanelprofile::text() { + return _combobox->currentText(); +} +TQString ParameterPanelprofile::preset() { + return _combobox->text( 0 ); +} +void ParameterPanelprofile::reset() { + _combobox->setCurrentItem( 0 ); +} +bool ParameterPanelprofile::valid() { + return true; +} + +///////////// ParameterInt +ParameterInt::ParameterInt( const exp_parameter& parameter, TQWidget* parent ) : ParameterBase( parameter, parent ) { + TQHBoxLayout* layout = new TQHBoxLayout( this ); + layout->setAutoAdd( true ); + layout->setSpacing( 6 ); + + new TQLabel( i18n( parameter.description().utf8() ), this ); + _spinbox = new KIntSpinBox( this ); + TQStringList para = TQStringList::split( ";", parameter.preset().section(":", 1) ); + + _spinbox->setMinValue( para[0].toInt() ); + _spinbox->setMaxValue( para[1].toInt() ); + _spinbox->setLineStep( para[2].toInt() ); + _spinbox->setValue( para[3].toInt() ); + + _default = _spinbox->value(); +} + +TQString ParameterInt::text() { + return _spinbox->text(); +} +TQString ParameterInt::preset() { + return TQString( "%1" ).arg( _default ); +} +void ParameterInt::reset() { + return _spinbox->setValue( _default ); +} +bool ParameterInt::valid() { + return true; +} + + +#include "addplaceholderpopup.moc" diff --git a/src/app/ActionMan/addplaceholderpopup.h b/src/app/ActionMan/addplaceholderpopup.h new file mode 100644 index 0000000..c463dae --- /dev/null +++ b/src/app/ActionMan/addplaceholderpopup.h @@ -0,0 +1,322 @@ +// +// C++ Interface: addplaceholderpopup +// +// Description: +// +// +// Author: Shie Erlich and Rafi Yanai <>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef ADDPLACEHOLDERPOPUP_H +#define ADDPLACEHOLDERPOPUP_H + +#include +#include +#include "../UserAction/expander.h" + +class TQString; +class KLineEdit; +class TQToolButton; +class TQCheckBox; +class KComboBox; +class KrBookmarkButton; +class KURL; +class KIntSpinBox; + + +/** + * This reads Expander::placeholder[] and fills a popup for easy access to the UserAction Placeholder + * @author Jonas Bhr (http://www.jonas-baehr.de), Shie Erlich + */ +class AddPlaceholderPopup : public TDEPopupMenu { + +public: + AddPlaceholderPopup( TQWidget *parent ); + + /** + * Use this to exec the popup. + * @param pos Position where the popup should appear + * @return the expression which can be placed in the UserAction commandline + */ + TQString getPlaceholder( const TQPoint& pos ); + +protected: + /** + * This is calles when a Placeholder got parameter. + * @param currentPlaceholder A pointer to the Placeholder the user has choosen + * @return a parameter-string + */ + TQString getParameter( exp_placeholder* currentPlaceholder ); + +private: + TDEPopupMenu *_activeSub, *_otherSub, *_leftSub, *_rightSub, *_independentSub; +}; + + +//////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Parameter Widgets /////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////// + +/** + * abstract baseclass for all Parameter widgets + * @author Jonas Bhr (http://www.jonas-baehr.de) + */ +class ParameterBase : public TQWidget { +public: + inline ParameterBase( const exp_parameter& parameter, TQWidget* parent ) : TQWidget( parent ) { _nessesary = parameter.nessesary(); } + /** + * @return the text for the parameter + */ + virtual TQString text() = 0; + /** + * @return the default of the parameter + */ + virtual TQString preset() = 0; + /** + * re-init the parameter with the default + */ + virtual void reset() = 0; + /** + * @return true if the Parameter as a valid value + */ + virtual bool valid() = 0; + /** + * @return true if the Placeholder realy needs this parameter + */ + inline bool nessesary() { return _nessesary; } +private: + bool _nessesary; +}; + +/** + * The simple Parameter widgets: a line-edit with the description above + * used by default + */ +class ParameterText : public ParameterBase { +public: + ParameterText( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KLineEdit * _lineEdit; + TQString _preset; +}; + +/** + * A line-edit with the "addPlaceholder"-button + * used with default = "__placeholder" + */ +class ParameterPlaceholder : public ParameterBase { +TQ_OBJECT + +public: + ParameterPlaceholder( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KLineEdit * _lineEdit; + TQToolButton* _button; +private slots: + void addPlaceholder(); +}; + +/** + * A Checkbox, default: checked; retuns "No" if unchecked + * used with default = "__yes" + */ +class ParameterYes : public ParameterBase { +public: + ParameterYes( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + TQCheckBox* _checkBox; +}; + +/** + * A Checkbox, default: unchecked; retuns "Yes" if checked + * used with default = "__no" + */ +class ParameterNo : public ParameterBase { +public: + ParameterNo( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + TQCheckBox* _checkBox; +}; + +/** + * A line-edit with the "file open"-button + * used with default = "__file" + */ +class ParameterFile : public ParameterBase { +TQ_OBJECT + +public: + ParameterFile( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KLineEdit * _lineEdit; + TQToolButton* _button; +private slots: + void addFile(); +}; + +/** + * A ComboBox with the description above + * used with default = "__choose:item1;item2;..." + */ +class ParameterChoose : public ParameterBase { +public: + ParameterChoose( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KComboBox * _combobox; +}; + +/** + * An editable ComboBox with the predifined selections + * used with default = "__select" + */ +class ParameterSelect : public ParameterBase { +public: + ParameterSelect( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KComboBox * _combobox; +}; + +/** + * A line-edit with a "choose dir"- and a bookmark-button + * used with default = "__goto" + */ +class ParameterGoto : public ParameterBase { +TQ_OBJECT + +public: + ParameterGoto( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KLineEdit * _lineEdit; + TQToolButton* _dirButton, *_placeholderButton; +private slots: + void setDir(); + void addPlaceholder(); +}; + +/** + * A ComboBox with all profiles available for the Synchronizer + * used with default = "__syncprofile" + */ +class ParameterSyncprofile : public ParameterBase { +public: + ParameterSyncprofile( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KComboBox * _combobox; +}; + +/** + * A ComboBox with all profiles available for the panels + * used with default = "__panelprofile" + */ +class ParameterPanelprofile : public ParameterBase { +public: + ParameterPanelprofile( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KComboBox * _combobox; +}; + +/** + * A ComboBox with all profiles available for the Searchmodule + * used with default = "__searchprofile" + */ +class ParameterSearch : public ParameterBase { +public: + ParameterSearch( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KComboBox * _combobox; +}; + +/** + * A SpinBox for integer + * used with default = "__int:min;max;step;value" + */ +class ParameterInt : public ParameterBase { +public: + ParameterInt( const exp_parameter& parameter, TQWidget* parent ); + TQString text(); + TQString preset(); + void reset(); + bool valid(); +private: + KIntSpinBox * _spinbox; + int _default; +}; + +//////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////// ParameterDialog //////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Opens a dialog for the parameter. Depending on the default (preset) a differend widget is used. + * See Parameter-Classes for details + */ +class ParameterDialog : public KDialogBase { +TQ_OBJECT + +public: + ParameterDialog( const exp_placeholder* currentPlaceholder, TQWidget *parent ); + + /** + * Use this to execute the dialog. + * @return a TQString with all paremeters; ommiting the optional ones if they have the default-value. + */ + TQString getParameter(); + +private: + typedef TQValueList ParameterList; + ParameterList _parameter; + int _parameterCount; +private slots: + void reset(); + void slotOk(); +}; + + +#endif // ADDPLACEHOLDERPOPUP_H diff --git a/src/app/ActionMan/useractionlistview.cpp b/src/app/ActionMan/useractionlistview.cpp new file mode 100644 index 0000000..fe078e5 --- /dev/null +++ b/src/app/ActionMan/useractionlistview.cpp @@ -0,0 +1,232 @@ +// +// C++ Implementation: useractionlistview +// +// Description: +// +// +// Author: Jonas Bähr, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "useractionlistview.h" + +#include +#include +#include +#include + +#include "../krusader.h" +#include "../UserAction/kraction.h" +#include "../UserAction/useraction.h" + +#define COL_TITLE 0 +#define COL_NAME 1 + + +////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// UserActionListView ///////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////// + +UserActionListView::UserActionListView( TQWidget * parent, const char * name ) + : TDEListView( parent, name ) +{ + addColumn( i18n("Title") ); + //addColumn( i18n("Identifier") ); + setResizeMode( TQListView::AllColumns ); + + setRootIsDecorated( true ); + setSelectionMode( TQListView::Extended ); // normaly select single items but one may use Ctrl or Shift to select multiple + setSorting( COL_TITLE ); + + update(); +} + +UserActionListView::~UserActionListView() +{ +} + +TQSize UserActionListView::sizeHint() const { + return TQSize(200, 400); +} + + +void UserActionListView::update() { + clear(); + UserAction::KrActionList list = krUserAction->actionList(); + for ( KrAction* action = list.first(); action; action = list.next() ) + insertAction( action ); + //sort(); // this is done automaticly +} + +void UserActionListView::update( KrAction* action ) { + UserActionListViewItem* item = findActionItem( action ); + if ( item ) { + // deleting & re-inserting is _much_easyer then tracking all possible cases of category changes! + bool current = ( item == currentItem() ); + bool selected = item->isSelected(); + delete item; + item = insertAction( action ); + if ( current ) + setCurrentItem( item ); + if ( selected ) + setSelected( item, true ); + } +} + +UserActionListViewItem* UserActionListView::insertAction( KrAction* action ) { + if ( ! action ) + return 0; + + UserActionListViewItem* item; + + if ( action->category().isEmpty() ) + item = new UserActionListViewItem( this, action ); + else { + TQListViewItem* categoryItem = findCategoryItem( action->category() ); + if ( ! categoryItem ) { + categoryItem = new TDEListViewItem( this, action->category() ); // create the new category item it not already present + categoryItem->setSelectable( false ); + } + item = new UserActionListViewItem( categoryItem, action ); + } + + item->setAction( action ); + return item; +} + +TQListViewItem* UserActionListView::findCategoryItem( const TQString& category ) { + for ( TQListViewItem* item = firstChild(); item; item = item->nextSibling() ) + if ( item->text( COL_TITLE ) == category && item->text( COL_NAME ).isEmpty() ) // because actions must have a name, items without name haveto be categories + return item; + + return 0; +} + +UserActionListViewItem* UserActionListView::findActionItem( const KrAction* action ) { + for ( TQListViewItemIterator it( this ); it.current(); ++it ) { + if ( UserActionListViewItem* item = dynamic_cast( it.current() ) ) { + if ( item->action() == action ) + return item; + } + } //for + return 0; +} + +KrAction * UserActionListView::currentAction() const { + if ( UserActionListViewItem* item = dynamic_cast( currentItem() ) ) + return item->action(); + else + return 0; +} + +void UserActionListView::setCurrentAction( const KrAction* action) { + UserActionListViewItem* item = findActionItem( action ); + if ( item ) { + setCurrentItem( item ); +// setSelected( item, true ); +// repaintItem( item ); + } +} + +void UserActionListView::setFirstActionCurrent() { + for ( TQListViewItemIterator it( this ); it.current(); ++it ) { + if ( UserActionListViewItem* item = dynamic_cast( it.current() ) ) { + setCurrentItem( item ); + break; + } + } //for +} + +void UserActionListView::setCurrentItem( TQListViewItem* item ) { + if ( ! item ) + return; + ensureItemVisible( item ); + TQListView::setCurrentItem( item ); +} + +TQDomDocument UserActionListView::dumpSelectedActions( TQDomDocument* mergeDoc ) const { + TQPtrList list = selectedItems(); + TQDomDocument doc; + if ( mergeDoc ) + doc = *mergeDoc; + else + doc = UserAction::createEmptyDoc(); + TQDomElement root = doc.documentElement(); + + for ( TQListViewItem* item = list.first(); item; item = list.next() ) + if ( UserActionListViewItem* actionItem = dynamic_cast( item ) ) + root.appendChild( actionItem->action()->xmlDump( doc ) ); + + return doc; +} + +void UserActionListView::removeSelectedActions() { + TQPtrList list = selectedItems(); + + for ( TQListViewItem* item = list.first(); item; item = list.next() ) + if ( UserActionListViewItem* actionItem = dynamic_cast( item ) ) { + delete actionItem->action(); // remove the action itself + delete actionItem; // remove the action from the list + } // if + +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// UserActionListViewItem //////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////// + +UserActionListViewItem::UserActionListViewItem( TQListView* view, KrAction* action ) + : TDEListViewItem( view ) +{ + setAction( action ); +} + +UserActionListViewItem::UserActionListViewItem( TQListViewItem* item, KrAction * action ) + : TDEListViewItem( item ) +{ + setAction( action ); +} + +UserActionListViewItem::~UserActionListViewItem() { +/* // remove category-item if the last member ofthiscategory disappears + if ( TQListViewItem* item = dynamic_cast( parent() ) ) { + if ( item->childCount() <= 1 ) + item->deleteLater(); // not possible since not inherited from TQObject + }*/ +} + + +void UserActionListViewItem::setAction( KrAction * action ) { + if ( ! action ) + return; + + _action = action; + update(); +} + +KrAction * UserActionListViewItem::action() const { + return _action; +} + +void UserActionListViewItem::update() { + if ( ! _action ) + return; + + if ( ! _action->icon().isEmpty() ) + setPixmap( COL_TITLE, TDEGlobal::iconLoader()->loadIcon( _action->icon(), TDEIcon::Small ) ); + setText( COL_TITLE, _action->text() ); + setText( COL_NAME, _action->name() ); +} + +int UserActionListViewItem::compare( TQListViewItem* i, int col, bool ascending ) const { +// FIXME some how this only produces bullshit :-/ +// if ( i->text( COL_NAME ).isEmpty() ) { // categories only have titles +// //kdDebug() << "this->title: " << text(COL_TITLE) << " |=| i->title: " << i->text(COL_TITLE) << endl; +// return ( ascending ? -1 : 1 ); // <0 means this is smaller then i +// } +// else + return TQListViewItem::compare( i, col, ascending ); +} + + diff --git a/src/app/ActionMan/useractionlistview.h b/src/app/ActionMan/useractionlistview.h new file mode 100644 index 0000000..b423637 --- /dev/null +++ b/src/app/ActionMan/useractionlistview.h @@ -0,0 +1,81 @@ +// +// C++ Interface: useractionlistview +// +// Description: +// +// +// Author: Jonas Bähr, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef USERACTIONLISTVIEW_H +#define USERACTIONLISTVIEW_H + +#include + +class KrAction; +class TQString; +class UserActionListViewItem; +class TQDomDocument; + +/** + * @author Jonas Bähr + */ +class UserActionListView : public TDEListView { +public: + UserActionListView( TQWidget* parent = 0, const char* name = 0 ); + ~UserActionListView(); + virtual TQSize sizeHint() const; + + void update(); + void update( KrAction* action ); + UserActionListViewItem* insertAction( KrAction* action ); + + KrAction* currentAction() const; + void setCurrentAction( const KrAction* ); + + TQDomDocument dumpSelectedActions( TQDomDocument* mergeDoc = 0 ) const; + + void removeSelectedActions(); + + /** + * makes the first action in the list current + */ + void setFirstActionCurrent(); + + /** + * makes @e item current and ensures its visibility + */ + virtual void setCurrentItem( TQListViewItem* item ); + +protected: + TQListViewItem* findCategoryItem( const TQString& category ); + UserActionListViewItem* findActionItem( const KrAction* action ); +}; + + +/** + * @author Jonas Bähr + */ +class UserActionListViewItem : public TDEListViewItem { +public: + UserActionListViewItem( TQListView* view, KrAction* action ); + UserActionListViewItem( TQListViewItem* item, KrAction* action ); + ~UserActionListViewItem(); + + void setAction( KrAction* action ); + KrAction* action() const; + void update(); + + /** + * This reimplements TQt's compare-function in order to have categories on the top of the list + */ + int compare ( TQListViewItem * i, int col, bool ascending ) const; + +private: + KrAction* _action; +}; + + +#endif //USERACTIONLISTVIEW_H diff --git a/src/app/ActionMan/useractionpage.cpp b/src/app/ActionMan/useractionpage.cpp new file mode 100644 index 0000000..065b087 --- /dev/null +++ b/src/app/ActionMan/useractionpage.cpp @@ -0,0 +1,317 @@ +// +// C++ Implementation: useractionpage +// +// Description: +// +// +// Author: Shie Erlich and Rafi Yanai <>, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "useractionpage.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "actionproperty.h" +#include "useractionlistview.h" +#include "../UserMenu/usermenu.h" //FIXME this should not be needed here! +#include "../UserAction/useraction.h" +#include "../UserAction/kraction.h" +#include "../krusader.h" + +#define ICON(N) TDEGlobal::iconLoader()->loadIcon(N, TDEIcon::Toolbar) +//This is the filter in the KFileDialog of Import/Export: +static const char* FILE_FILTER = I18N_NOOP("*.xml|xml-files\n*|all files"); + + +UserActionPage::UserActionPage( TQWidget* parent ) + : TQWidget( parent, "UserActionPage" ) +{ + TQVBoxLayout* layout = new TQVBoxLayout( this, 0, 6, "UserActionPageLayout" ); // 0px margin, 6px item-spacing + + // ======== pseudo-toolbar start ======== + TQHBoxLayout* toolbarLayout = new TQHBoxLayout( layout, 0, 0 ); // neither margin nor spacing for the toolbar with autoRaise + + newButton = new TQToolButton( this, "newButton" ); + newButton->setPixmap( ICON("document-new") ); + newButton->setAutoRaise(true); + TQToolTip::add( newButton, i18n("Create new useraction") ); + + importButton = new TQToolButton( this, "importButton" ); + importButton->setPixmap( ICON("fileimport") ); + importButton->setAutoRaise(true); + TQToolTip::add( importButton, i18n("Import useractions") ); + + exportButton = new TQToolButton( this, "exportButton" ); + exportButton->setPixmap( ICON("fileexport") ); + exportButton->setAutoRaise(true); + TQToolTip::add( exportButton, i18n("Export useractions") ); + + copyButton = new TQToolButton( this, "copyButton" ); + copyButton->setPixmap( ICON("edit-copy") ); + copyButton->setAutoRaise(true); + TQToolTip::add( copyButton, i18n("Copy useractions to clipboard") ); + + pasteButton = new TQToolButton( this, "pasteButton" ); + pasteButton->setPixmap( ICON("edit-paste") ); + pasteButton->setAutoRaise(true); + TQToolTip::add( pasteButton, i18n("Paste useractions from clipboard") ); + + removeButton = new TQToolButton( this, "removeButton" ); + removeButton->setPixmap( ICON("edit-delete") ); + removeButton->setAutoRaise(true); + TQToolTip::add( removeButton, i18n("Delete selected useractions") ); + + toolbarLayout->addWidget( newButton ); + toolbarLayout->addWidget( importButton ); + toolbarLayout->addWidget( exportButton ); + toolbarLayout->addWidget( copyButton ); + toolbarLayout->addWidget( pasteButton ); + toolbarLayout->addSpacing( 6 ); // 6 pixel nothing + toolbarLayout->addWidget( removeButton ); + toolbarLayout->addStretch( 1000 ); // some very large stretch-factor + // ======== pseudo-toolbar end ======== +/* This seems obsolete now! + // Display some help + KMessageBox::information( this, // parent + i18n( "When you apply changes to an action, the modifications " + "become available in the current session immediately.\n" + "When closing ActionMan, you will be asked to save the changes permanently." + ), + TQString(), // caption + "show UserAction help" //dontShowAgainName for the config + ); +*/ + TQSplitter *split = new TQSplitter( this, "useractionpage splitter"); + layout->addWidget( split, 1000 ); // again a very large stretch-factor to fix the height of the toolbar + + actionTree = new UserActionListView( split, "actionTree" ); + actionProperties = new ActionProperty( split, "actionProperties" ); + actionProperties->setEnabled( false ); // if there are any actions in the list, the first is displayed and this widget is enabled + + connect( actionTree, TQ_SIGNAL( currentChanged(TQListViewItem*) ), TQ_SLOT( slotChangeCurrent() ) ); + connect( newButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotNewAction() ) ); + connect( removeButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotRemoveAction() ) ); + connect( importButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotImport() ) ); + connect( exportButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotExport() ) ); + connect( copyButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotToClip() ) ); + connect( pasteButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotFromClip() ) ); + + // forwards the changed signal of the properties + connect ( actionProperties, TQ_SIGNAL( changed() ), TQ_SIGNAL( changed() ) ); + + actionTree->setFirstActionCurrent(); + actionTree->setFocus(); +} + +UserActionPage::~UserActionPage() +{ +} + +bool UserActionPage::continueInSpiteOfChanges() { + if ( ! actionProperties->isModified() ) + return true; + + int answer = KMessageBox::questionYesNoCancel( this, + i18n("The current action has been modified. Do you want to apply these changes?") + ); + if ( answer == KMessageBox::Cancel ) { + disconnect( actionTree, TQ_SIGNAL( currentChanged(TQListViewItem*) ), this, TQ_SLOT( slotChangeCurrent() ) ); + actionTree->setCurrentAction( actionProperties->action() ); + connect( actionTree, TQ_SIGNAL( currentChanged(TQListViewItem*) ), TQ_SLOT( slotChangeCurrent() ) ); + return false; + } + if ( answer == KMessageBox::Yes ) { + if ( ! actionProperties->validProperties() ) { + disconnect( actionTree, TQ_SIGNAL( currentChanged(TQListViewItem*) ), this, TQ_SLOT( slotChangeCurrent() ) ); + actionTree->setCurrentAction( actionProperties->action() ); + connect( actionTree, TQ_SIGNAL( currentChanged(TQListViewItem*) ), TQ_SLOT( slotChangeCurrent() ) ); + return false; + } + slotUpdateAction(); + } // if Yes + return true; +} + +void UserActionPage::slotChangeCurrent() { + if ( ! continueInSpiteOfChanges() ) + return; + + KrAction* action = actionTree->currentAction(); + if ( action ) { + actionProperties->setEnabled( true ); + // the discinct name is used as ID it is not allowd to change it afterwards because it is may referenced anywhere else + actionProperties->leDistinctName->setEnabled( false ); + actionProperties->updateGUI( action ); + } + else { + // If the current item in the tree is no action (i.e. a cathegory), disable the properties + actionProperties->clear(); + actionProperties->setEnabled( false ); + } + emit applied(); // to disable the apply-button +} + + +void UserActionPage::slotUpdateAction() { + // check that we have a command line, title and a name + if ( ! actionProperties->validProperties() ) + return; + + if ( actionProperties->leDistinctName->isEnabled() ) { + // := new entry + KrAction* action = new KrAction( krApp->actionCollection(), actionProperties->leDistinctName->text().latin1() ); + krUserAction->addKrAction( action ); + actionProperties->updateAction( action ); + UserActionListViewItem* item = actionTree->insertAction( action ); + actionTree->setCurrentItem( item ); + krApp->userMenu->update(); + } + else { // := edit an existing + actionProperties->updateAction(); + actionTree->update( actionProperties->action() ); // update the listviewitem as well... + } + apply(); +} + + +void UserActionPage::slotNewAction() { + if ( continueInSpiteOfChanges() ) { + actionTree->clearSelection(); // else the user may think that he is overwriting the selected action + actionProperties->clear(); + actionProperties->setEnabled( true ); // it may be disabled because the tree has the focus on a category + actionProperties->leDistinctName->setEnabled( true ); + actionProperties->leDistinctName->setFocus(); + } +} + +void UserActionPage::slotRemoveAction() { + if ( ! dynamic_cast( actionTree->currentItem() ) ) + return; + + int messageDelete = KMessageBox::warningContinueCancel ( this, //parent + i18n("Are you sure that you want to remove all selected actions?"), //text + i18n("Remove selected actions?"), //caption + i18n("Remove"), //Label for the continue-button + "Confirm Remove UserAction", //dontAskAgainName (for the config-file) + KMessageBox::Dangerous) ; + + if ( messageDelete != KMessageBox::Continue ) + return; + + actionTree->removeSelectedActions(); + + apply(); +} + +void UserActionPage::slotImport() { + TQString filename = KFileDialog::getOpenFileName(TQString(), i18n(FILE_FILTER), this); + if ( filename.isEmpty() ) + return; + + UserAction::KrActionList newActions; + krUserAction->readFromFile( filename, UserAction::renameDoublicated, &newActions ); + for ( KrAction* action = newActions.first(); action; action = newActions.next() ) + actionTree->insertAction( action ); + + if ( newActions.count() > 0 ) { + apply(); + } +} + +void UserActionPage::slotExport() { + if ( ! dynamic_cast( actionTree->currentItem() ) ) + return; + + TQString filename = KFileDialog::getSaveFileName(TQString(), i18n(FILE_FILTER), this); + if ( filename.isEmpty() ) + return; + + TQDomDocument doc = TQDomDocument( ACTION_DOCTYPE ); + TQFile file( filename ); + int answer = 0; + if( file.open( IO_ReadOnly ) ) { // getting here, means the file already exists an can be read + if( doc.setContent( &file ) ) // getting here means the file exists and already contains an UserAction-XML-tree + answer = KMessageBox::warningYesNoCancel( this, //parent + i18n("This file already contains some useractions.\nDo you want to overwrite it or should it be merged with the selected actions?"), //text + i18n("Overwrite or merge?"), //caption + i18n("Overwrite"), //label for Yes-Button + i18n("Merge") //label for No-Button + ); + file.close(); + } + if ( answer == 0 && file.exists() ) + answer = KMessageBox::warningContinueCancel( this, //parent + i18n("This file already exists. Do you want to overwrite it?"), //text + i18n("Overwrite existing file?"), //caption + i18n("Overwrite") //label for Continue-Button + ); + + if ( answer == KMessageBox::Cancel ) + return; + + if ( answer == KMessageBox::No ) // that means the merge-button + doc = actionTree->dumpSelectedActions( &doc ); // merge + else // Yes or Continue means overwrite + doc = actionTree->dumpSelectedActions(); + + bool success = UserAction::writeToFile( doc, filename ); + if ( ! success ) + KMessageBox::error( this, + i18n("Can't open %1 for writing!\nNothing exported.").arg(filename), + i18n("Export failed!") + ); +} + +void UserActionPage::slotToClip() { + if ( ! dynamic_cast( actionTree->currentItem() ) ) + return; + + TQDomDocument doc = actionTree->dumpSelectedActions(); + TDEApplication::clipboard()->setText( doc.toString() ); +} + +void UserActionPage::slotFromClip() { + TQDomDocument doc( ACTION_DOCTYPE ); + if ( doc.setContent( TDEApplication::clipboard()->text() ) ) { + TQDomElement root = doc.documentElement(); + UserAction::KrActionList newActions; + krUserAction->readFromElement( root, UserAction::renameDoublicated, &newActions ); + for ( KrAction* action = newActions.first(); action; action = newActions.next() ) + actionTree->insertAction( action ); + if ( newActions.count() > 0 ) { + apply(); + } + } // if ( doc.setContent ) +} + +bool UserActionPage::readyToQuit() { + // Check if the current UserAction has changed + if ( ! continueInSpiteOfChanges() ) + return false; + + krUserAction->writeActionFile(); + return true; +} + +void UserActionPage::apply() { + krUserAction->writeActionFile(); + emit applied(); +} + +void UserActionPage::applyChanges() { + slotUpdateAction(); +} + + +#include "useractionpage.moc" diff --git a/src/app/ActionMan/useractionpage.h b/src/app/ActionMan/useractionpage.h new file mode 100644 index 0000000..2a117f6 --- /dev/null +++ b/src/app/ActionMan/useractionpage.h @@ -0,0 +1,74 @@ +// +// C++ Interface: useractionpage +// +// Description: +// +// +// Author: Shie Erlich and Rafi Yanai <>, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef USERACTIONPAGE_H +#define USERACTIONPAGE_H + +#include + +class UserActionListView; +class ActionProperty; +class TQToolButton; + +/** + * @author Jonas Bähr +*/ +class UserActionPage : public TQWidget { +TQ_OBJECT + +public: + UserActionPage( TQWidget* parent ); + ~UserActionPage(); + + /** + * Be sure to call this function before you delete this page!! + * @return true if this page can be closed + */ + bool readyToQuit(); + + void applyChanges(); + +signals: + void changed(); ///< emited on changes to an action (used to enable the apply-button) + void applied(); ///< emited when changes are applied to an action (used to disable the apply-button) + +private: + /** + * If there are modifications in the property-widget, the user is asked + * what to do. Apply, discard or continue editing. In the first case, + * saving is done in this function. + * @return true if a new action can be loaded in the property-widget. + */ + bool continueInSpiteOfChanges(); + /** + * applyes all changes by writing the actionfile and emits "applied" + */ + void apply(); + + //bool _modified; ///< true if the action-tree was changed (= changes were applied to an action) + UserActionListView *actionTree; + ActionProperty *actionProperties; + TQToolButton *importButton, *exportButton; + TQToolButton *copyButton, *pasteButton; + TQToolButton *removeButton, *newButton; + +private slots: + void slotChangeCurrent(); //loads a new action into the detail-view + void slotUpdateAction(); //updates the action to the xml-file + void slotNewAction(); + void slotRemoveAction(); + void slotImport(); + void slotExport(); + void slotToClip(); + void slotFromClip(); +}; + +#endif //USERACTIONPAGE_H diff --git a/src/app/BookMan/Makefile.am b/src/app/BookMan/Makefile.am new file mode 100644 index 0000000..3f602d3 --- /dev/null +++ b/src/app/BookMan/Makefile.am @@ -0,0 +1,11 @@ +noinst_LIBRARIES = libBookMan.a + +INCLUDES = $(all_includes) + +libBookMan_a_METASOURCES = AUTO + +libBookMan_a_SOURCES = \ + krbookmark.cpp \ + krbookmarkbutton.cpp \ + krbookmarkhandler.cpp \ + kraddbookmarkdlg.cpp diff --git a/src/app/BookMan/kraddbookmarkdlg.cpp b/src/app/BookMan/kraddbookmarkdlg.cpp new file mode 100644 index 0000000..1af3736 --- /dev/null +++ b/src/app/BookMan/kraddbookmarkdlg.cpp @@ -0,0 +1,117 @@ +#include "kraddbookmarkdlg.h" +#include "../krusader.h" +#include "krbookmarkhandler.h" +#include +#include +#include +#include +#include +#include +#include + +KrAddBookmarkDlg::KrAddBookmarkDlg(TQWidget *parent, KURL url): + KDialogBase(KDialogBase::Swallow, i18n("Add Bookmark"), + KDialogBase::User1 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent) { + // create the 'new folder' button + setButtonText(KDialogBase::User1, i18n("New Folder")); + showButton(KDialogBase::User1, false); // hide it until _createIn is shown + connect(this, TQ_SIGNAL(user1Clicked()), this, TQ_SLOT(newFolder())); + + // create the main widget + TQWidget *page = new TQWidget(this); + setMainWidget(page); + + TQGridLayout *layout = new TQGridLayout(page, 1, 1, 0, spacingHint()); // expanding + // name and url + TQLabel *lb1 = new TQLabel(i18n("Name:"), page); + _name = new KLineEdit(page); + _name->setText(url.prettyURL()); // default name is the url + _name->selectAll(); // make the text selected + layout->addWidget(lb1, 0, 0); + layout->addWidget(_name, 0, 1); + + TQLabel *lb2 = new TQLabel(i18n("URL:"), page); + _url = new KLineEdit(page); + layout->addWidget(lb2, 1, 0); + layout->addWidget(_url, 1, 1); + _url->setText(url.prettyURL()); // set the url in the field + + // create in linedit and button + TQLabel *lb3 = new TQLabel(i18n("Create in:"), page); + _folder = new KLineEdit(page); + layout->addWidget(lb3, 2, 0); + layout->addWidget(_folder, 2, 1); + _folder->setReadOnly(true); + + _createInBtn = new TQToolButton(page); + _createInBtn->setPixmap(krLoader->loadIcon("go-down", TDEIcon::Small)); + _createInBtn->setToggleButton(true); + connect(_createInBtn, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(toggleCreateIn(bool ))); + layout->addWidget(_createInBtn, 2, 2); + + setDetailsWidget(createInWidget()); + + _name->setFocus(); +} + +void KrAddBookmarkDlg::toggleCreateIn(bool show) { + _createInBtn->setPixmap(krLoader->loadIcon(show ? "go-up" :"go-down", TDEIcon::Small)); + showButton(KDialogBase::User1, show); + setDetails(show); +} + +// creates the widget that lets you decide where to put the new bookmark +TQWidget *KrAddBookmarkDlg::createInWidget() { + _createIn = new TDEListView(this); + _createIn->addColumn("Folders"); + _createIn->header()->hide(); + _createIn->setRootIsDecorated(true); + _createIn->setAlternateBackground(TQColor()); // disable alternate coloring + + TDEListViewItem *item = new TDEListViewItem(_createIn, i18n("Bookmarks")); + item->setOpen(true); + item->setSelected(true); + _xr[item] = krBookMan->_root; + + populateCreateInWidget(krBookMan->_root, item); + _createIn->setCurrentItem(item); + createInSelection(item); + connect(_createIn, TQ_SIGNAL(selectionChanged(TQListViewItem*)), this, TQ_SLOT(createInSelection(TQListViewItem*))); + + return _createIn; +} + +void KrAddBookmarkDlg::createInSelection(TQListViewItem *item) { + if (item) { + _folder->setText(_xr[static_cast(item)]->text()); + } +} + +void KrAddBookmarkDlg::populateCreateInWidget(KrBookmark *root, TDEListViewItem *parent) { + for (KrBookmark *bm = root->children().first(); bm; bm = root->children().next()) { + if (bm->isFolder()) { + TDEListViewItem *item = new TDEListViewItem(parent, bm->text()); + item->setOpen(true); + _xr[item] = bm; + populateCreateInWidget(bm, item); + } + } +} + +void KrAddBookmarkDlg::newFolder() { + // get the name + TQString newFolder = KInputDialog::getText(i18n("New Folder"), i18n("Folder name:"), TQString(), 0, this); + if (newFolder == TQString()) + return; + // add to the list in bookman + KrBookmark *bm = new KrBookmark(newFolder); + krBookMan->addBookmark(bm, _xr[static_cast(_createIn->selectedItem())]); + // fix the gui + TDEListViewItem *item = new TDEListViewItem(_createIn->selectedItem(), bm->text()); + _xr[item] = bm; + + _createIn->setCurrentItem(item); + item->setSelected(true); +} + +#include "kraddbookmarkdlg.moc" diff --git a/src/app/BookMan/kraddbookmarkdlg.h b/src/app/BookMan/kraddbookmarkdlg.h new file mode 100644 index 0000000..b270781 --- /dev/null +++ b/src/app/BookMan/kraddbookmarkdlg.h @@ -0,0 +1,40 @@ +#ifndef KRADDBOOKMARKDLG_H +#define KRADDBOOKMARKDLG_H + +#include "krbookmark.h" +#include "../VFS/vfs.h" +#include +#include +#include +#include +#include +#include + +class KrAddBookmarkDlg: public KDialogBase { + TQ_OBJECT + +public: + KrAddBookmarkDlg(TQWidget *parent, KURL url = 0); + KURL url() const { return vfs::fromPathOrURL(_url->text()); } + TQString name() const { return _name->text(); } + KrBookmark *folder() const { return _xr[static_cast(_createIn->selectedItem())]; } + +protected: + TQWidget *createInWidget(); + void populateCreateInWidget(KrBookmark *root, TDEListViewItem *parent); + +protected slots: + void toggleCreateIn(bool show); + void createInSelection(TQListViewItem *item); + void newFolder(); + +private: + KLineEdit *_name; + KLineEdit *_url; + KLineEdit *_folder; + TDEListView *_createIn; + TQMap _xr; + TQToolButton *_createInBtn; +}; + +#endif // KRADDBOOKMARKDLG_H diff --git a/src/app/BookMan/krbookmark.cpp b/src/app/BookMan/krbookmark.cpp new file mode 100644 index 0000000..cc67228 --- /dev/null +++ b/src/app/BookMan/krbookmark.cpp @@ -0,0 +1,92 @@ +#include "krbookmark.h" +#include "../krusader.h" +#include "../VFS/krarchandler.h" +#include +#include +#include +#include + +#define BM_NAME(X) (TQString("Bookmark:")+X) + +#if KDE_IS_VERSION(3,4,0) +static const char* NAME_DEVICES = I18N_NOOP("Media"); +#else +static const char* NAME_DEVICES = I18N_NOOP("Devices"); +#endif +static const char* NAME_VIRTUAL = I18N_NOOP("Virtual Filesystem"); +static const char* NAME_LAN = I18N_NOOP("Local Network"); + +KrBookmark::KrBookmark(TQString name, KURL url, TDEActionCollection *parent, TQString icon, TQString actionName ): + TDEAction(name, 0, 0, 0, parent, actionName.isNull() ? BM_NAME(name).latin1() : BM_NAME(actionName).latin1()), + _url(url), _folder(false), _separator(false) { + connect(this, TQ_SIGNAL(activated()), this, TQ_SLOT(activatedProxy())); + // do we have an icon? + if (!icon.isEmpty()) + setIcon(icon); + else { + // what kind of a url is it? + if (_url.isLocalFile()) { + setIcon("folder"); + } else { // is it an archive? + if (KRarcHandler::isArchive(_url)) + setIcon("application-x-tar"); + else setIcon("folder_html"); + } + } + + _children.setAutoDelete(true); +} + +KrBookmark::KrBookmark(TQString name, TQString icon): + TDEAction(name, 0, 0, 0, 0), _folder(true), _separator(false) { + setIcon(icon=="" ? "folder" : icon); +} + +KrBookmark* KrBookmark::getExistingBookmark(TQString actionName, TDEActionCollection *collection) { + return static_cast(collection->action(BM_NAME(actionName).latin1())); +} + +KrBookmark* KrBookmark::devices(TDEActionCollection *collection) { + KrBookmark *bm = getExistingBookmark(i18n(NAME_DEVICES), collection); + if (!bm) { +#if KDE_IS_VERSION(3,4,0) + bm = new KrBookmark(i18n(NAME_DEVICES), "media:/", collection); +#else + bm = new KrBookmark(i18n(NAME_DEVICES), "devices:/", collection); +#endif + bm->setIconSet(krLoader->loadIcon("blockdevice", TDEIcon::Small)); + } + return bm; +} + +KrBookmark* KrBookmark::virt(TDEActionCollection *collection) { + KrBookmark *bm = getExistingBookmark(i18n(NAME_VIRTUAL), collection); + if (!bm) { + bm = new KrBookmark(i18n(NAME_VIRTUAL), "virt:/", collection); + bm->setIconSet(krLoader->loadIcon("pipe", TDEIcon::Small)); + } + return bm; +} + +KrBookmark* KrBookmark::lan(TDEActionCollection *collection) { + KrBookmark *bm = getExistingBookmark(i18n(NAME_LAN), collection); + if (!bm) { + bm = new KrBookmark(i18n(NAME_LAN), "lan:/", collection); + bm->setIconSet(krLoader->loadIcon("network", TDEIcon::Small)); + } + return bm; +} + +KrBookmark* KrBookmark::separator() { + KrBookmark *bm = new KrBookmark(""); + bm->_separator = true; + bm->_folder = false; + return bm; +} + + +void KrBookmark::activatedProxy() { + emit activated(url()); +} + +#include "krbookmark.moc" diff --git a/src/app/BookMan/krbookmark.h b/src/app/BookMan/krbookmark.h new file mode 100644 index 0000000..567b3c8 --- /dev/null +++ b/src/app/BookMan/krbookmark.h @@ -0,0 +1,46 @@ +#ifndef KRBOOKMARK_H +#define KRBOOKMARK_H + +#include +#include +#include + +class TDEActionCollection; + +class KrBookmark: public TDEAction { + TQ_OBJECT + +public: + KrBookmark(TQString name, KURL url, TDEActionCollection *parent, TQString icon = "", TQString actionName = TQString() ); + KrBookmark(TQString name, TQString icon = ""); // creates a folder + // text() and setText() to change the name of the bookmark + // icon() and setIcon() to change icons (by name) + inline const KURL& url() const { return _url; } + inline void setURL(const KURL& url) { _url = url; } + inline bool isFolder() const { return _folder; } + inline bool isSeparator() const { return _separator; } + TQPtrList& children() { return _children; } + + static KrBookmark* getExistingBookmark(TQString actionName, TDEActionCollection *collection); + // ----- special bookmarks + static KrBookmark* devices(TDEActionCollection *collection); + static KrBookmark* virt(TDEActionCollection *collection); + static KrBookmark* lan(TDEActionCollection *collection); + static KrBookmark* separator(); + +signals: + void activated(const KURL& url); + +protected slots: + void activatedProxy(); + + +private: + KURL _url; + TQString _icon; + bool _folder; + bool _separator; + TQPtrList _children; +}; + +#endif // KRBOOKMARK_H diff --git a/src/app/BookMan/krbookmarkbutton.cpp b/src/app/BookMan/krbookmarkbutton.cpp new file mode 100644 index 0000000..b7ac61c --- /dev/null +++ b/src/app/BookMan/krbookmarkbutton.cpp @@ -0,0 +1,38 @@ +#include "krbookmarkbutton.h" +#include "krbookmarkhandler.h" +#include "../krusader.h" +#include +#include +#include +#include +#include +#include + +KrBookmarkButton::KrBookmarkButton(TQWidget *parent): TQToolButton(parent) { + TQPixmap icon = krLoader->loadIcon("bookmark", TDEIcon::Toolbar, 16); + setFixedSize(icon.width() + 4, icon.height() + 4); + setPixmap(icon); + setTextLabel(i18n("BookMan II"), true); + setPopupDelay(10); // 0.01 seconds press + setAcceptDrops(false); + + acmBookmarks = new TDEActionMenu(i18n("Bookmarks"), "bookmark", 0, 0); + acmBookmarks->setDelayed(false); + acmBookmarks->popupMenu()->setKeyboardShortcutsEnabled(true); + acmBookmarks->popupMenu()->setKeyboardShortcutsExecute(true); + + setPopup(acmBookmarks->popupMenu()); + connect(this, TQ_SIGNAL(pressed()), this, TQ_SLOT(populate())); + populate(); +} + +void KrBookmarkButton::populate() { + krBookMan->populate(static_cast(popup())); +} + +void KrBookmarkButton::openPopup() { + populate(); + popup()->exec(mapToGlobal(TQPoint(0, height()))); +} + +#include "krbookmarkbutton.moc" diff --git a/src/app/BookMan/krbookmarkbutton.h b/src/app/BookMan/krbookmarkbutton.h new file mode 100644 index 0000000..54136f2 --- /dev/null +++ b/src/app/BookMan/krbookmarkbutton.h @@ -0,0 +1,24 @@ +#ifndef KRBOOKMARK_BUTTON_H +#define KRBOOKMARK_BUTTON_H + +#include +#include "krbookmarkhandler.h" + +class KrBookmarkButton: public TQToolButton { + TQ_OBJECT + +public: + KrBookmarkButton(TQWidget *parent); + void openPopup(); + +signals: + void openUrl(const KURL &url); + +protected slots: + void populate(); + +private: + TDEActionMenu *acmBookmarks; +}; + +#endif // KRBOOKMARK_BUTTON_H diff --git a/src/app/BookMan/krbookmarkhandler.cpp b/src/app/BookMan/krbookmarkhandler.cpp new file mode 100644 index 0000000..183122f --- /dev/null +++ b/src/app/BookMan/krbookmarkhandler.cpp @@ -0,0 +1,576 @@ +#include "krbookmarkhandler.h" +#include "kraddbookmarkdlg.h" +#include "../krusader.h" +#include "../krslots.h" +#include "../Dialogs/popularurls.h" +#include "../VFS/vfs.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPECIAL_BOOKMARKS true + +// ------------------------ for internal use +#define BOOKMARKS_FILE "krusader/krbookmarks.xml" +#define CONNECT_BM(X) { disconnect(X, TQ_SIGNAL(activated(const KURL&)), 0, 0); connect(X, TQ_SIGNAL(activated(const KURL&)), this, TQ_SLOT(slotActivated(const KURL&))); } + +KrBookmarkHandler::KrBookmarkHandler(): TQObject(0), _middleClick(false), _mainBookmarkPopup( 0 ), _specialBookmarkIDs(), _bookmarkIDTable() { + // create our own action collection and make the shortcuts apply only to parent + _privateCollection = new TDEActionCollection(krApp, "private collection"); + _collection = krApp->actionCollection(); + + // create _root: father of all bookmarks. it is a dummy bookmark and never shown + _root = new KrBookmark(i18n("Bookmarks")); + + _bookmarkIDTable.setAutoDelete( true ); + + // load bookmarks + importFromFile(); + + // hack + manager = KBookmarkManager::managerForFile(locateLocal( "data", BOOKMARKS_FILE ), false); + connect(manager, TQ_SIGNAL(changed(const TQString&, const TQString& )), this, TQ_SLOT(bookmarksChanged(const TQString&, const TQString& ))); +} + +KrBookmarkHandler::~KrBookmarkHandler() { + delete manager; + delete _privateCollection; +} + +void KrBookmarkHandler::menuOperation(int id) { + switch (id) { + case BookmarkCurrent: + bookmarkCurrent(ACTIVE_PANEL->virtualPath()); + break; + case ManageBookmarks: + manager->slotEditBookmarks(); + break; + } +} + +void KrBookmarkHandler::bookmarkCurrent(KURL url) { + KrAddBookmarkDlg dlg(krApp, url); + if (dlg.exec() == KDialog::Accepted) { + KrBookmark *bm = new KrBookmark(dlg.name(), dlg.url(), _collection); + addBookmark(bm, dlg.folder()); + } +} + +void KrBookmarkHandler::addBookmark(KrBookmark *bm, KrBookmark *folder) { + if (folder == 0) + folder = _root; + + // add to the list (bottom) + folder->children().append(bm); + + exportToFile(); +} + +void KrBookmarkHandler::deleteBookmark(KrBookmark *bm) { + if( bm->isFolder() ) + clearBookmarks( bm ); // remove the child bookmarks + removeReferences( _root, bm ); + bm->unplugAll(); + delete bm; + + exportToFile(); +} + +void KrBookmarkHandler::removeReferences( KrBookmark *root, KrBookmark *bmToRemove ) { + int index = root->children().find( bmToRemove ); + if( index >= 0 ) + root->children().take( index ); + + KrBookmark *bm = root->children().first(); + while (bm) { + if (bm->isFolder()) + removeReferences(bm, bmToRemove); + bm = root->children().next(); + } +} + +void KrBookmarkHandler::exportToFileBookmark(TQDomDocument &doc, TQDomElement &where, KrBookmark *bm) { + if( bm->isSeparator() ) { + TQDomElement bookmark = doc.createElement("separator"); + where.appendChild(bookmark); + } + else { + TQDomElement bookmark = doc.createElement("bookmark"); + // url + bookmark.setAttribute("href", bm->url().prettyURL()); + // icon + bookmark.setAttribute("icon", bm->icon()); + // title + TQDomElement title = doc.createElement("title"); + title.appendChild(doc.createTextNode(bm->text())); + bookmark.appendChild(title); + + where.appendChild(bookmark); + } +} + +void KrBookmarkHandler::exportToFileFolder(TQDomDocument &doc, TQDomElement &parent, KrBookmark *folder) { + for (KrBookmark *bm = folder->children().first(); bm; bm = folder->children().next()) { + if (bm->isFolder()) { + TQDomElement newFolder = doc.createElement("folder"); + newFolder.setAttribute("icon", bm->icon()); + parent.appendChild(newFolder); + TQDomElement title = doc.createElement("title"); + title.appendChild(doc.createTextNode(bm->text())); + newFolder.appendChild(title); + exportToFileFolder(doc, newFolder, bm); + } else { + exportToFileBookmark(doc, parent, bm); + } + } +} + +// export to file using the xbel standard +// +// +// Developer Web Site +// +// Title of this folder +// KDE Web Site +// +// My own bookmarks +// KOffice Web Site +// +// KDevelop Web Site +// +// +// +void KrBookmarkHandler::exportToFile() { + TQDomDocument doc( "xbel" ); + TQDomElement root = doc.createElement( "xbel" ); + doc.appendChild( root ); + + exportToFileFolder(doc, root, _root); + if (!doc.firstChild().isProcessingInstruction()) { + // adding: if not already present + TQDomProcessingInstruction instr = doc.createProcessingInstruction( "xml", + "version=\"1.0\" encoding=\"UTF-8\" "); + doc.insertBefore( instr, doc.firstChild() ); + } + + + TQString filename = locateLocal( "data", BOOKMARKS_FILE ); + TQFile file(filename); + if ( file.open( IO_WriteOnly ) ) { + TQTextStream stream( &file ); + stream.setEncoding(stream.UnicodeUTF8); + stream << doc.toString(); + file.close(); + } else { + KMessageBox::error(krApp, i18n("Unable to write to %1").arg(filename), i18n("Error")); + } +} + +bool KrBookmarkHandler::importFromFileBookmark(TQDomElement &e, KrBookmark *parent, TQString path, TQString *errorMsg) { + TQString url, name, icon; + // verify tag + if (e.tagName() != "bookmark") { + *errorMsg = e.tagName() + i18n(" instead of ")+"bookmark"; + return false; + } + // verify href + if (!e.hasAttribute("href")) { + *errorMsg = i18n("missing tag ")+ "href"; + return false; + } else url = e.attribute("href"); + // verify title + TQDomElement te = e.firstChild().toElement(); + if (te.tagName() != "title") { + *errorMsg = i18n("missing tag ")+"title"; + return false; + } else name = te.text(); + // do we have an icon? + if (e.hasAttribute("icon")) { + icon=e.attribute("icon"); + } + // ok: got name and url, let's add a bookmark + KrBookmark *bm = KrBookmark::getExistingBookmark(path+name, _collection); + if (!bm) { + bm = new KrBookmark(name, vfs::fromPathOrURL( url ), _collection, icon, path+name); + parent->children().append(bm); + } + + return true; +} + +bool KrBookmarkHandler::importFromFileFolder(TQDomNode &first, KrBookmark *parent, TQString path, TQString *errorMsg) { + TQString name; + TQDomNode n = first; + while (!n.isNull()) { + TQDomElement e = n.toElement(); + if (e.tagName() == "bookmark") { + if (!importFromFileBookmark(e, parent, path, errorMsg)) + return false; + } else if (e.tagName() == "folder") { + TQString iconName = ""; + if (e.hasAttribute("icon")) iconName=e.attribute("icon"); + // the title is the first child of the folder + TQDomElement tmp = e.firstChild().toElement(); + if (tmp.tagName() != "title") { + *errorMsg = i18n("missing tag ")+"title"; + return false; + } else name = tmp.text(); + KrBookmark *folder = new KrBookmark(name, iconName); + parent->children().append(folder); + + TQDomNode nextOne = tmp.nextSibling(); + if (!importFromFileFolder(nextOne, folder, path + name + "/", errorMsg)) + return false; + } else if (e.tagName() == "separator") { + parent->children().append(KrBookmark::separator()); + } + n = n.nextSibling(); + } + return true; +} + + +void KrBookmarkHandler::importFromFile() { + clearBookmarks(_root); + + TQString filename = locateLocal( "data", BOOKMARKS_FILE ); + TQFile file( filename ); + if ( !file.open(IO_ReadOnly)) + return; // no bookmarks file + + TQString errorMsg; + TQDomNode n; + TQDomElement e; + TQDomDocument doc( "xbel" ); + if ( !doc.setContent( &file, &errorMsg ) ) { + goto ERROR; + } + // iterate through the document: first child should be "xbel" (skip all until we find it) + n = doc.firstChild(); + while (!n.isNull() && n.toElement().tagName()!="xbel") + n = n.nextSibling(); + + if (n.isNull() || n.toElement().tagName()!="xbel") { + errorMsg = i18n("%1 doesn't seem to be a valid Bookmarks file").arg(filename); + goto ERROR; + } else n = n.firstChild(); // skip the xbel part + importFromFileFolder(n, _root, "", &errorMsg); + goto SUCCESS; + +ERROR: + KMessageBox::error(krApp, i18n("Error reading bookmarks file: %1").arg(errorMsg), i18n( "Error" )); + +SUCCESS: + file.close(); +} + +void KrBookmarkHandler::populate(TDEPopupMenu *menu) { + _mainBookmarkPopup = menu; + menu->clear(); + _bookmarkIDTable.clear(); + _specialBookmarkIDs.clear(); + buildMenu(_root, menu); +} + +void KrBookmarkHandler::buildMenu(KrBookmark *parent, TDEPopupMenu *menu) { + static int inSecondaryMenu = 0; // used to know if we're on the top menu + + // run the loop twice, in order to put the folders on top. stupid but easy :-) + // note: this code drops the separators put there by the user + for (KrBookmark *bm = parent->children().first(); bm; bm = parent->children().next()) { + if (!bm->isFolder()) continue; + TDEPopupMenu *newMenu = new TDEPopupMenu(menu); + int id = menu->insertItem(TQIconSet(krLoader->loadIcon(bm->icon(), TDEIcon::Small)), + bm->text(), newMenu, -1 /* dummy id */, -1 /* end of list */); + + if( !_bookmarkIDTable.find( menu ) ) + _bookmarkIDTable.insert( menu, new TQMap ); + (*_bookmarkIDTable[ menu ])[ id ] = bm; + + ++inSecondaryMenu; + buildMenu(bm, newMenu); + --inSecondaryMenu; + } + for (KrBookmark *bm = parent->children().first(); bm; bm = parent->children().next()) { + if (bm->isFolder()) continue; + if (bm->isSeparator() ) { + menu->insertSeparator(); + continue; + } + int itemIndex = bm->plug(menu, -1 /* end of list */); + CONNECT_BM(bm); + + int id = bm->itemId( itemIndex ); + if( !_bookmarkIDTable.find( menu ) ) + _bookmarkIDTable.insert( menu, new TQMap ); + (*_bookmarkIDTable[ menu ])[ id ] = bm; + } + + if (!inSecondaryMenu) { + krConfig->setGroup( "Private" ); + bool hasPopularURLs = krConfig->readBoolEntry( "BM Popular URLs", true ); + bool hasDevices = krConfig->readBoolEntry( "BM Devices", true ); + bool hasLan = krConfig->readBoolEntry( "BM Lan", true ); + bool hasVirtualFS = krConfig->readBoolEntry( "BM Virtual FS", true ); + bool hasJumpback = krConfig->readBoolEntry( "BM Jumpback", true ); + + int itemIndex; + + if( hasPopularURLs ) { + menu->insertSeparator(); + + // add the popular links submenu + TDEPopupMenu *newMenu = new TDEPopupMenu(menu); + itemIndex = menu->insertItem(TQIconSet(krLoader->loadIcon("bookmark_folder", TDEIcon::Small)), + i18n("Popular URLs"), newMenu, -1 /* dummy id */, -1 /* end of list */); + _specialBookmarkIDs.append( itemIndex ); + // add the top 15 urls + #define MAX 15 + KURL::List list = krApp->popularUrls->getMostPopularUrls(MAX); + KURL::List::Iterator it; + for (it = list.begin(); it != list.end(); ++it) { + TQString name; + if ((*it).isLocalFile()) name = (*it).path(); + else name = (*it).prettyURL(); + // note: these bookmark are put into the private collection + // as to not spam the general collection + KrBookmark *bm = KrBookmark::getExistingBookmark(name, _privateCollection); + if (!bm) + bm = new KrBookmark(name, *it, _privateCollection); + bm->plug(newMenu); + CONNECT_BM(bm); + } + + newMenu->insertSeparator(); + krPopularUrls->plug(newMenu); + newMenu->installEventFilter(this); + } + + // do we need to add special bookmarks? + if (SPECIAL_BOOKMARKS) { + if( hasDevices || hasLan || hasVirtualFS || hasJumpback ) + menu->insertSeparator(); + + KrBookmark *bm; + + // note: special bookmarks are not kept inside the _bookmarks list and added ad-hoc + if( hasDevices ) { + bm = KrBookmark::devices(_collection); + itemIndex = bm->plug(menu); + _specialBookmarkIDs.append( bm->itemId( itemIndex ) ); + CONNECT_BM(bm); + } + + if( hasLan ) { + bm = KrBookmark::lan(_collection); + itemIndex = bm->plug(menu); + _specialBookmarkIDs.append( bm->itemId( itemIndex ) ); + CONNECT_BM(bm); + } + + if( hasVirtualFS ) { + bm = KrBookmark::virt(_collection); + itemIndex = bm->plug(menu); + _specialBookmarkIDs.append( bm->itemId( itemIndex ) ); + CONNECT_BM(bm); + } + + if( hasJumpback ) { + // add the jump-back button + itemIndex = krJumpBack->plug(menu); + _specialBookmarkIDs.append( krJumpBack->itemId( itemIndex ) ); + menu->insertSeparator(); + itemIndex = krSetJumpBack->plug(menu); + _specialBookmarkIDs.append( krSetJumpBack->itemId( itemIndex ) ); + } + } + + if( !hasJumpback ) + menu->insertSeparator(); + + itemIndex = menu->insertItem(krLoader->loadIcon("bookmark_add", TDEIcon::Small), + i18n("Bookmark Current"), BookmarkCurrent); + _specialBookmarkIDs.append( itemIndex ); + itemIndex = menu->insertItem(krLoader->loadIcon("bookmark", TDEIcon::Small), + i18n("Manage Bookmarks"), ManageBookmarks); + _specialBookmarkIDs.append( itemIndex ); + + // make sure the menu is connected to us + disconnect(menu, TQ_SIGNAL(activated(int)), 0, 0); + connect(menu, TQ_SIGNAL(activated(int)), this, TQ_SLOT(menuOperation(int))); + } + + menu->installEventFilter(this); +} + +void KrBookmarkHandler::clearBookmarks(KrBookmark *root) { + KrBookmark *bm = root->children().first(); + while (bm) { + if (bm->isFolder()) + clearBookmarks(bm); + else { + bm->unplugAll(); + delete bm; + } + + bm = root->children().next(); + } + root->children().clear(); +} + +void KrBookmarkHandler::bookmarksChanged(const TQString&, const TQString&) { + importFromFile(); +} + +bool KrBookmarkHandler::eventFilter( TQObject *obj, TQEvent *ev ) { + if (ev->type() == TQEvent::MouseButtonRelease) { + switch (static_cast(ev)->button()) { + case TQt::RightButton: + _middleClick = false; + if( obj->inherits( "TQPopupMenu" ) ) { + int id = static_cast(obj)->idAt( static_cast(ev)->pos() ); + + if( obj == _mainBookmarkPopup && _specialBookmarkIDs.contains( id ) ) { + rightClickOnSpecialBookmark(); + return true; + } + + if( _bookmarkIDTable.find( obj ) ) { + TQMap * table = _bookmarkIDTable[ obj ]; + if( table && table->count( id ) ) { + KrBookmark *bm = (*table)[ id ]; + rightClicked( static_cast(obj), id, bm ); + return true; + } + } + } + case TQt::LeftButton: + _middleClick = false; + break; + case TQt::MidButton: + _middleClick = true; + break; + default: + break; + } + } + return TQObject::eventFilter(obj, ev); +} + +#define POPULAR_URLS_ID 100100 +#define DEVICES_ID 100101 +#define LAN_ID 100103 +#define VIRTUAL_FS_ID 100102 +#define JUMP_BACK_ID 100104 + +void KrBookmarkHandler::rightClickOnSpecialBookmark() { + krConfig->setGroup( "Private" ); + bool hasPopularURLs = krConfig->readBoolEntry( "BM Popular URLs", true ); + bool hasDevices = krConfig->readBoolEntry( "BM Devices", true ); + bool hasLan = krConfig->readBoolEntry( "BM Lan", true ); + bool hasVirtualFS = krConfig->readBoolEntry( "BM Virtual FS", true ); + bool hasJumpback = krConfig->readBoolEntry( "BM Jumpback", true ); + + TQPopupMenu menu( _mainBookmarkPopup ); + menu.setCaption( i18n( "Enable special bookmarks" ) ); + menu.setCheckable( true ); + + menu.insertItem( i18n( "Popular URLs" ), POPULAR_URLS_ID ); + menu.setItemChecked( POPULAR_URLS_ID, hasPopularURLs ); + menu.insertItem( i18n( "Devices" ), DEVICES_ID ); + menu.setItemChecked( DEVICES_ID, hasDevices ); + menu.insertItem( i18n( "Local Network" ), LAN_ID ); + menu.setItemChecked( LAN_ID, hasLan ); + menu.insertItem( i18n( "Virtual Filesystem" ), VIRTUAL_FS_ID ); + menu.setItemChecked( VIRTUAL_FS_ID, hasVirtualFS ); + menu.insertItem( i18n( "Jump back" ), JUMP_BACK_ID ); + menu.setItemChecked( JUMP_BACK_ID, hasJumpback ); + + connect( _mainBookmarkPopup, TQ_SIGNAL( highlighted( int ) ), &menu, TQ_SLOT( close() ) ); + connect( _mainBookmarkPopup, TQ_SIGNAL( activated( int ) ), &menu, TQ_SLOT( close() ) ); + + int result = menu.exec( TQCursor::pos() ); + bool doCloseMain = true; + + krConfig->setGroup( "Private" ); + + switch( result ) { + case POPULAR_URLS_ID: + krConfig->writeEntry( "BM Popular URLs", !hasPopularURLs ); + break; + case DEVICES_ID: + krConfig->writeEntry( "BM Devices", !hasDevices ); + break; + case LAN_ID: + krConfig->writeEntry( "BM Lan", !hasLan ); + break; + case VIRTUAL_FS_ID: + krConfig->writeEntry( "BM Virtual FS", !hasVirtualFS ); + break; + case JUMP_BACK_ID: + krConfig->writeEntry( "BM Jumpback", !hasJumpback ); + break; + default: + doCloseMain = false; + break; + } + + menu.close(); + + if( doCloseMain && _mainBookmarkPopup ) + _mainBookmarkPopup->close(); +} + +#define OPEN_ID 100200 +#define OPEN_NEW_TAB_ID 100201 +#define DELETE_ID 100202 + +void KrBookmarkHandler::rightClicked( TQPopupMenu *menu, int /*id*/, KrBookmark * bm ) { + TQPopupMenu popup( _mainBookmarkPopup ); + + popup.insertItem( krLoader->loadIcon( "document-open", TDEIcon::Panel ), i18n( "Open" ), OPEN_ID ); + popup.insertItem( krLoader->loadIcon( "tab_new", TDEIcon::Panel ), i18n( "Open in a new tab" ), OPEN_NEW_TAB_ID ); + popup.insertSeparator(); + popup.insertItem( krLoader->loadIcon( "edit-delete", TDEIcon::Panel ), i18n( "Delete" ), DELETE_ID ); + + connect( menu, TQ_SIGNAL( highlighted( int ) ), &popup, TQ_SLOT( close() ) ); + connect( menu, TQ_SIGNAL( activated( int ) ), &popup, TQ_SLOT( close() ) ); + + int result = popup.exec( TQCursor::pos() ); + + popup.close(); + if( _mainBookmarkPopup && result >= OPEN_ID && result <= DELETE_ID ) { + _mainBookmarkPopup->close(); + } + + switch( result ) { + case OPEN_ID: + SLOTS->refresh( bm->url() ); + break; + case OPEN_NEW_TAB_ID: + SLOTS->newTab( bm->url() ); + break; + case DELETE_ID: + deleteBookmark( bm ); + break; + } +} + +// used to monitor middle clicks. if mid is found, then the +// bookmark is opened in a new tab. ugly, but easier than overloading +// TDEAction and TDEActionCollection. +void KrBookmarkHandler::slotActivated(const KURL& url) { + if (_middleClick) + SLOTS->newTab(url); + else SLOTS->refresh(url); +} + + +#include "krbookmarkhandler.moc" diff --git a/src/app/BookMan/krbookmarkhandler.h b/src/app/BookMan/krbookmarkhandler.h new file mode 100644 index 0000000..818c3c9 --- /dev/null +++ b/src/app/BookMan/krbookmarkhandler.h @@ -0,0 +1,64 @@ +#ifndef KRBOOKMARK_HANDLER_H +#define KRBOOKMARK_HANDLER_H + +#include "krbookmark.h" +#include +#include +#include +#include +#include +#include +#include +#include + +class TDEActionCollection; +class KBookmarkManager; + +class KrBookmarkHandler: public TQObject { + TQ_OBJECT + + friend class KrAddBookmarkDlg; + enum Actions { BookmarkCurrent=0, ManageBookmarks }; +public: + KrBookmarkHandler(); + ~KrBookmarkHandler(); + void populate(TDEPopupMenu *menu); + void addBookmark(KrBookmark *bm, KrBookmark *parent = 0); + void bookmarkCurrent(KURL url); + +protected: + void deleteBookmark(KrBookmark *bm); + void importFromFile(); + bool importFromFileBookmark(TQDomElement &e, KrBookmark *parent, TQString path, TQString *errorMsg); + bool importFromFileFolder(TQDomNode &first, KrBookmark *parent, TQString path, TQString *errorMsg); + void exportToFile(); + void exportToFileFolder(TQDomDocument &doc, TQDomElement &parent, KrBookmark *folder); + void exportToFileBookmark(TQDomDocument &doc, TQDomElement &where, KrBookmark *bm); + void clearBookmarks(KrBookmark *root); + void buildMenu(KrBookmark *parent, TDEPopupMenu *menu); + + bool eventFilter( TQObject *obj, TQEvent *ev ); + + void rightClicked( TQPopupMenu *menu, int id, KrBookmark *bm ); + void rightClickOnSpecialBookmark(); + + void removeReferences( KrBookmark *root, KrBookmark *bmToRemove ); + +protected slots: + void menuOperation(int id); + void bookmarksChanged(const TQString&, const TQString&); + void slotActivated(const KURL& url); + +private: + TDEActionCollection *_collection, *_privateCollection; + KrBookmark *_root; + // the whole KBookmarkManager is an ugly hack. use it until we have our own + KBookmarkManager *manager; + bool _middleClick; // if true, the user clicked the middle button to open the bookmark + + TQGuardedPtr _mainBookmarkPopup; // main bookmark popup menu + TQValueList _specialBookmarkIDs; // the ID list of the special bookmarks + TQPtrDict > _bookmarkIDTable; // the IDs of the bookmarks +}; + +#endif // KRBOOKMARK_HANDLER_H diff --git a/src/app/CMakeL10n.txt b/src/app/CMakeL10n.txt new file mode 100644 index 0000000..086cbe6 --- /dev/null +++ b/src/app/CMakeL10n.txt @@ -0,0 +1,3 @@ +##### create translation templates ############## + +tde_l10n_create_template( "messages/krusader/" ) diff --git a/src/app/Dialogs/Makefile.am b/src/app/Dialogs/Makefile.am new file mode 100644 index 0000000..83cc13d --- /dev/null +++ b/src/app/Dialogs/Makefile.am @@ -0,0 +1,22 @@ +noinst_LIBRARIES = libDialogs.a + +INCLUDES = $(all_includes) + +libDialogs_a_METASOURCES = AUTO + +libDialogs_a_SOURCES = \ + krsqueezedtextlabel.cpp \ + krprogress.cpp \ + packgui.cpp \ + packguibase.cpp \ + newftpgui.cpp \ + krspwidgets.cpp \ + krspecialwidgets.cpp \ + krpleasewait.cpp \ + krmaskchoice.cpp \ + krdialogs.cpp \ + kurllistrequester.cpp \ + popularurls.cpp \ + checksumdlg.cpp \ + percentalsplitter.cpp \ + krkeydialog.cpp diff --git a/src/app/Dialogs/checksumdlg.cpp b/src/app/Dialogs/checksumdlg.cpp new file mode 100644 index 0000000..26e5c7b --- /dev/null +++ b/src/app/Dialogs/checksumdlg.cpp @@ -0,0 +1,603 @@ +#include "checksumdlg.h" +#include "../krusader.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../krservices.h" +#include +#include +#include +#include + +class CS_Tool; // forward +typedef void PREPARE_PROC_FUNC(TDEProcess& proc, CS_Tool *self, const TQStringList& files, + const TQString checksumFile, bool recursive, const TQString& stdoutFileName, + const TQString& stderrFileName, const TQString& type); +typedef TQStringList GET_FAILED_FUNC(const TQStringList& stdOut, const TQStringList& stdErr); + +class CS_Tool { +public: + enum Type { + MD5=0, SHA1, SHA256, TIGER, WHIRLPOOL, SFV, CRC, + SHA224, SHA384, SHA512, + NumOfTypes + }; + + Type type; + TQString binary; + bool recursive; + bool standardFormat; + PREPARE_PROC_FUNC *create, *verify; + GET_FAILED_FUNC *failed; +}; + +class CS_ToolByType { +public: + TQPtrList tools, r_tools; // normal and recursive tools +}; + +// handles md5sum and sha1sum +void sumCreateFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& files, + const TQString, bool recursive, const TQString& stdoutFileName, + const TQString& stderrFileName, const TQString&) { + proc.setUseShell(true, "/bin/bash"); + proc << KrServices::fullPathName( self->binary ); + Q_ASSERT(!recursive); + proc << files << "1>" << stdoutFileName << "2>" << stderrFileName; +} + +void sumVerifyFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& /* files */, + const TQString checksumFile, bool recursive, const TQString& stdoutFileName, + const TQString& stderrFileName, const TQString& /* type */) { + proc.setUseShell(true, "/bin/bash"); + proc << KrServices::fullPathName( self->binary ); + Q_ASSERT(!recursive); + proc << "-c" << checksumFile << "1>" << stdoutFileName << "2>" << stderrFileName; +} + +TQStringList sumFailedFunc(const TQStringList& stdOut, const TQStringList& stdErr) { + // md5sum and sha1sum print "...: FAILED" for failed files and display + // the number of failures to stderr. so if stderr is empty, we'll assume all is ok + TQStringList result; + if (stdErr.size()==0) return result; + result += stdErr; + // grep for the ":FAILED" substring + const TQString tmp = TQString(": FAILED").local8Bit(); + for (uint i=0; ibinary ); + if (recursive) proc << "-r"; + proc << "-l" << files << "1>" << stdoutFileName << "2>" << stderrFileName; +} + +void deepVerifyFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& files, + const TQString checksumFile, bool recursive, const TQString& stdoutFileName, + const TQString& stderrFileName, const TQString&) { + proc.setUseShell(true, "/bin/bash"); + proc << KrServices::fullPathName( self->binary ); + if (recursive) proc << "-r"; + proc << "-x" << checksumFile << files << "1>" << stdoutFileName << "2>" << stderrFileName; +} + +TQStringList deepFailedFunc(const TQStringList& stdOut, const TQStringList&/* stdErr */) { + // *deep dumps (via -x) all failed hashes to stdout + return stdOut; +} + +// handles cfv binary +void cfvCreateFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& files, + const TQString, bool recursive, const TQString& stdoutFileName, + const TQString& stderrFileName, const TQString& type) { + proc.setUseShell(true, "/bin/bash"); + proc << KrServices::fullPathName( self->binary ) << "-C" << "-VV"; + if (recursive) proc << "-rr"; + proc << "-t" << type << "-f-" << "-U" << files << "1>" << stdoutFileName << "2>" << stderrFileName; +} + +void cfvVerifyFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& /* files */, + const TQString checksumFile, bool recursive, const TQString& stdoutFileName, + const TQString& stderrFileName, const TQString&type) { + proc.setUseShell(true, "/bin/bash"); + proc << KrServices::fullPathName( self->binary ) << "-M"; + if (recursive) proc << "-rr"; + proc << "-U" << "-VV" << "-t" << type << "-f" << checksumFile << "1>" << stdoutFileName << "2>" << stderrFileName;// << files; +} + +TQStringList cfvFailedFunc(const TQStringList& /* stdOut */, const TQStringList& stdErr) { + // cfv dumps all failed hashes to stderr + return stdErr; +} + +// important: this table should be ordered like so that all md5 tools should be +// one after another, and then all sha1 and so on and so forth. they tools must be grouped, +// since the code in getTools() counts on it! +CS_Tool cs_tools[] = { + // type binary recursive stdFmt create_func verify_func failed_func + {CS_Tool::MD5, "md5sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc}, + {CS_Tool::MD5, "md5deep", true, true, deepCreateFunc, deepVerifyFunc, deepFailedFunc}, + {CS_Tool::MD5, "cfv", true, true, cfvCreateFunc, cfvVerifyFunc, cfvFailedFunc}, + {CS_Tool::SHA1, "sha1sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc}, + {CS_Tool::SHA1, "sha1deep", true, true, deepCreateFunc, deepVerifyFunc, deepFailedFunc}, + {CS_Tool::SHA1, "cfv", true, true, cfvCreateFunc, cfvVerifyFunc, cfvFailedFunc}, + {CS_Tool::SHA224, "sha224sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc}, + {CS_Tool::SHA256, "sha256sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc}, + {CS_Tool::SHA256, "sha256deep", true, true, deepCreateFunc, deepVerifyFunc, deepFailedFunc}, + {CS_Tool::SHA384, "sha384sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc}, + {CS_Tool::SHA512, "sha512sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc}, + {CS_Tool::TIGER, "tigerdeep", true, true, deepCreateFunc, deepVerifyFunc, deepFailedFunc}, + {CS_Tool::WHIRLPOOL, "whirlpooldeep", true, true, deepCreateFunc, deepVerifyFunc, deepFailedFunc}, + {CS_Tool::SFV, "cfv", true, false, cfvCreateFunc, cfvVerifyFunc, cfvFailedFunc}, + {CS_Tool::CRC, "cfv", true, false, cfvCreateFunc, cfvVerifyFunc, cfvFailedFunc}, +}; + +TQMap cs_textToType; +TQMap cs_typeToText; + +void initChecksumModule() { + // prepare the dictionaries - pity it has to be manually + cs_textToType["md5"]=CS_Tool::MD5; + cs_textToType["sha1"]=CS_Tool::SHA1; + cs_textToType["sha256"]=CS_Tool::SHA256; + cs_textToType["sha224"]=CS_Tool::SHA224; + cs_textToType["sha384"]=CS_Tool::SHA384; + cs_textToType["sha512"]=CS_Tool::SHA512; + cs_textToType["tiger"]=CS_Tool::TIGER; + cs_textToType["whirlpool"]=CS_Tool::WHIRLPOOL; + cs_textToType["sfv"]=CS_Tool::SFV; + cs_textToType["crc"]=CS_Tool::CRC; + + cs_typeToText[CS_Tool::MD5]="md5"; + cs_typeToText[CS_Tool::SHA1]="sha1"; + cs_typeToText[CS_Tool::SHA256]="sha256"; + cs_typeToText[CS_Tool::SHA224]="sha224"; + cs_typeToText[CS_Tool::SHA384]="sha384"; + cs_typeToText[CS_Tool::SHA512]="sha512"; + cs_typeToText[CS_Tool::TIGER]="tiger"; + cs_typeToText[CS_Tool::WHIRLPOOL]="whirlpool"; + cs_typeToText[CS_Tool::SFV]="sfv"; + cs_typeToText[CS_Tool::CRC]="crc"; + + // build the checksumFilter (for usage in KRQuery) + TQMap::Iterator it; + for (it=cs_textToType.begin(); it!=cs_textToType.end(); ++it) + MatchChecksumDlg::checksumTypesFilter += ("*."+it.key()+" "); +} + +// -------------------------------------------------- + +// returns a list of tools which can work with recursive or non-recursive mode and are installed +// note: only 1 tool from each type is suggested +static TQPtrList getTools(bool folders) { + TQPtrList result; + uint i; + for (i=0; i < sizeof(cs_tools)/sizeof(CS_Tool); ++i) { + if (result.last() && result.last()->type == cs_tools[i].type) continue; // 1 from each type please + if (folders && !cs_tools[i].recursive) continue; + if (KrServices::cmdExist(cs_tools[i].binary)) + result.append(&cs_tools[i]); + } + + return result; +} + +// ------------- CreateChecksumDlg + +CreateChecksumDlg::CreateChecksumDlg(const TQStringList& files, bool containFolders, const TQString& path): + KDialogBase(Plain, i18n("Create Checksum"), Ok | Cancel, Ok, krApp) { + + TQPtrList tools = getTools(containFolders); + + if (tools.count() == 0) { // nothing was suggested?! + TQString error = i18n("Can't calculate checksum since no supported tool was found. " + "Please check the Dependencies page in Krusader's settings."); + if (containFolders) + error += i18n("Note: you've selected directories, and probably have no recursive checksum tool installed." + " Krusader currently supports md5deep, sha1deep, sha256deep, tigerdeep and cfv"); + KMessageBox::error(0, error); + return; + } + + TQGridLayout *layout = new TQGridLayout( plainPage(), 1, 1, + KDialogBase::marginHint(), KDialogBase::spacingHint()); + + int row=0; + + // title (icon+text) + TQHBoxLayout *hlayout = new TQHBoxLayout(layout, KDialogBase::spacingHint()); + TQLabel *p = new TQLabel(plainPage()); + p->setPixmap(krLoader->loadIcon("application-octet-stream", TDEIcon::Desktop, 32)); + hlayout->addWidget(p); + TQLabel *l1 = new TQLabel(i18n("About to calculate checksum for the following files") + + (containFolders ? i18n(" and folders:") : ":"), plainPage()); + hlayout->addWidget(l1); + layout->addMultiCellLayout(hlayout, row, row, 0, 1, TQt::AlignLeft); + ++row; + + // file list + TDEListBox *lb = new TDEListBox(plainPage()); + lb->insertStringList(files); + layout->addMultiCellWidget(lb, row, row, 0, 1); + ++row; + + // checksum method + TQHBoxLayout *hlayout2 = new TQHBoxLayout(layout, KDialogBase::spacingHint()); + TQLabel *l2 = new TQLabel(i18n("Select the checksum method:"), plainPage()); + hlayout2->addWidget(l2); + KComboBox *method = new KComboBox(plainPage()); + // -- fill the combo with available methods + uint i; + for ( i=0; iinsertItem( cs_typeToText[tools.at(i)->type], i); + method->setFocus(); + hlayout2->addWidget(method); + layout->addMultiCellLayout(hlayout2, row, row, 0, 1, TQt::AlignLeft); + ++row; + + if (exec() != Accepted) return; + // else implied: run the process + tmpOut = new KTempFile(locateLocal("tmp", "krusader"), ".stdout" ); + tmpErr = new KTempFile(locateLocal("tmp", "krusader"), ".stderr" ); + TDEProcess proc; + CS_Tool *mytool = tools.at(method->currentItem()); + mytool->create(proc, mytool, KrServices::quote(files), TQString(), containFolders, + tmpOut->name(), tmpErr->name(), method->currentText()); + + krApp->startWaiting(i18n("Calculating checksums ..."), 0, true); + TQApplication::setOverrideCursor( KCursor::waitCursor() ); + bool r = proc.start(TDEProcess::NotifyOnExit, TDEProcess::AllOutput); + if (r) while ( proc.isRunning() ) { + usleep( 500 ); + tqApp->processEvents(); + if (krApp->wasWaitingCancelled()) { // user cancelled + proc.kill(); + TQApplication::restoreOverrideCursor(); + return; + } + }; + krApp->stopWait(); + TQApplication::restoreOverrideCursor(); + if (!r || !proc.normalExit()) { + KMessageBox::error(0, i18n("There was an error while running %1.").arg(mytool->binary)); + return; + } + + // suggest a filename + TQString suggestedFilename = path + '/'; + if (files.count() > 1) suggestedFilename += ("checksum." + cs_typeToText[mytool->type]); + else suggestedFilename += (files[0] + '.' + cs_typeToText[mytool->type]); + // send both stdout and stderr + TQStringList stdOut, stdErr; + if (!KrServices::fileToStringList(tmpOut->textStream(), stdOut) || + !KrServices::fileToStringList(tmpErr->textStream(), stdErr)) { + KMessageBox::error(krApp, i18n("Error reading stdout or stderr")); + return; + } + + ChecksumResultsDlg dlg( stdOut, stdErr, suggestedFilename, mytool->binary, cs_typeToText[mytool->type], mytool->standardFormat); + tmpOut->unlink(); delete tmpOut; + tmpErr->unlink(); delete tmpErr; +} + +// ------------- MatchChecksumDlg + +TQString MatchChecksumDlg::checksumTypesFilter; + +MatchChecksumDlg::MatchChecksumDlg(const TQStringList& files, bool containFolders, + const TQString& path, const TQString& checksumFile): + KDialogBase(Plain, i18n("Verify Checksum"), Ok | Cancel, Ok, krApp) { + + TQPtrList tools = getTools(containFolders); + + if (tools.count() == 0) { // nothing was suggested?! + TQString error = i18n("Can't verify checksum since no supported tool was found. " + "Please check the Dependencies page in Krusader's settings."); + if (containFolders) + error += i18n("Note: you've selected directories, and probably have no recursive checksum tool installed." + " Krusader currently supports md5deep, sha1deep, sha256deep, tigerdeep and cfv"); + KMessageBox::error(0, error); + return; + } + + TQGridLayout *layout = new TQGridLayout( plainPage(), 1, 1, + KDialogBase::marginHint(), KDialogBase::spacingHint()); + + int row=0; + + // title (icon+text) + TQHBoxLayout *hlayout = new TQHBoxLayout(layout, KDialogBase::spacingHint()); + TQLabel *p = new TQLabel(plainPage()); + p->setPixmap(krLoader->loadIcon("application-octet-stream", TDEIcon::Desktop, 32)); + hlayout->addWidget(p); + TQLabel *l1 = new TQLabel(i18n("About to verify checksum for the following files") + + (containFolders ? i18n(" and folders:") : ":"), plainPage()); + hlayout->addWidget(l1); + layout->addMultiCellLayout(hlayout, row, row, 0, 1, TQt::AlignLeft); + ++row; + + // file list + TDEListBox *lb = new TDEListBox(plainPage()); + lb->insertStringList(files); + layout->addMultiCellWidget(lb, row, row, 0, 1); + ++row; + + // checksum file + TQHBoxLayout *hlayout2 = new TQHBoxLayout(layout, KDialogBase::spacingHint()); + TQLabel *l2 = new TQLabel(i18n("Checksum file:"), plainPage()); + hlayout2->addWidget(l2); + KURLRequester *checksumFileReq = new KURLRequester( plainPage() ); + if (!checksumFile.isEmpty()) + checksumFileReq->setURL(checksumFile); + checksumFileReq->fileDialog()->setURL(path); + checksumFileReq->setFocus(); + hlayout2->addWidget(checksumFileReq); + layout->addMultiCellLayout(hlayout2, row, row, 0, 1, TQt::AlignLeft); + + if (exec() != Accepted) return; + TQString file = checksumFileReq->url(); + TQString extension; + if (!verifyChecksumFile(file, extension)) { + KMessageBox::error(0, i18n("Error reading checksum file %1.
Please specify a valid checksum file.
").arg(file)); + return; + } + + // do we have a tool for that extension? + uint i; + CS_Tool *mytool = 0; + for ( i=0; i < tools.count(); ++i ) + if (cs_typeToText[tools.at(i)->type] == extension.lower()) { + mytool = tools.at(i); + break; + } + if (!mytool) { + KMessageBox::error(0, i18n("Krusader can't find a checksum tool that handles %1 on your system. Please check the Dependencies page in Krusader's settings.").arg(extension)); + return; + } + + // else implied: run the process + tmpOut = new KTempFile(locateLocal("tmp", "krusader"), ".stdout" ); + tmpErr = new KTempFile(locateLocal("tmp", "krusader"), ".stderr" ); + TDEProcess proc; + mytool->verify(proc, mytool, KrServices::quote(files), KrServices::quote(file), containFolders, tmpOut->name(), tmpErr->name(), extension); + krApp->startWaiting(i18n("Verifying checksums ..."), 0, true); + TQApplication::setOverrideCursor( KCursor::waitCursor() ); + bool r = proc.start(TDEProcess::NotifyOnExit, TDEProcess::AllOutput); + if (r) while ( proc.isRunning() ) { + usleep( 500 ); + tqApp->processEvents(); + if (krApp->wasWaitingCancelled()) { // user cancelled + proc.kill(); + TQApplication::restoreOverrideCursor(); + return; + } + }; + if (!r || !proc.normalExit()) { + KMessageBox::error(0, i18n("There was an error while running %1.").arg(mytool->binary)); + return; + } + TQApplication::restoreOverrideCursor(); + krApp->stopWait(); + // send both stdout and stderr + TQStringList stdOut,stdErr; + if (!KrServices::fileToStringList(tmpOut->textStream(), stdOut) || + !KrServices::fileToStringList(tmpErr->textStream(), stdErr)) { + KMessageBox::error(krApp, i18n("Error reading stdout or stderr")); + return; + } + VerifyResultDlg dlg(mytool->failed(stdOut, stdErr)); + tmpOut->unlink(); delete tmpOut; + tmpErr->unlink(); delete tmpErr; +} + +bool MatchChecksumDlg::verifyChecksumFile(TQString path, TQString& extension) { + TQFileInfo f(path); + if (!f.exists() || f.isDir()) return false; + // find the extension + extension = path.mid(path.findRev(".")+1); + + // TODO: do we know the extension? if not, ask the user for one + + + return true; +} + +// ------------- VerifyResultDlg +VerifyResultDlg::VerifyResultDlg(const TQStringList& failed): + KDialogBase(Plain, i18n("Verify Checksum"), Close, Close, krApp) { + TQGridLayout *layout = new TQGridLayout( plainPage(), 1, 1, + KDialogBase::marginHint(), KDialogBase::spacingHint()); + + bool errors = failed.size()>0; + int row = 0; + + // create the icon and title + TQHBoxLayout *hlayout = new TQHBoxLayout(layout, KDialogBase::spacingHint()); + TQLabel p(plainPage()); + p.setPixmap(krLoader->loadIcon(errors ? "messagebox_critical" : "messagebox_info", TDEIcon::Desktop, 32)); + hlayout->addWidget(&p); + + TQLabel *l1 = new TQLabel((errors ? i18n("Errors were detected while verifying the checksums") : + i18n("Checksums were verified successfully")), plainPage()); + hlayout->addWidget(l1); + layout->addMultiCellLayout(hlayout,row,row,0,1, TQt::AlignLeft); + ++row; + + if (errors) { + TQLabel *l3 = new TQLabel(i18n("The following files have failed:"), plainPage()); + layout->addMultiCellWidget(l3, row, row, 0, 1); + ++row; + TDEListBox *lb2 = new TDEListBox(plainPage()); + lb2->insertStringList(failed); + layout->addMultiCellWidget(lb2, row, row, 0, 1); + ++row; + } + + exec(); +} + +// ------------- ChecksumResultsDlg + +ChecksumResultsDlg::ChecksumResultsDlg(const TQStringList& stdOut, const TQStringList& stdErr, + const TQString& suggestedFilename, const TQString& binary, const TQString& /* type */, bool standardFormat): + KDialogBase(Plain, i18n("Create Checksum"), Ok | Cancel, Ok, krApp), _binary(binary) { + TQGridLayout *layout = new TQGridLayout( plainPage(), 1, 1, + KDialogBase::marginHint(), KDialogBase::spacingHint()); + + // md5 tools display errors into stderr, so we'll use that to determine the result of the job + bool errors = stdErr.size()>0; + bool successes = stdOut.size()>0; + int row = 0; + + // create the icon and title + TQHBoxLayout *hlayout = new TQHBoxLayout(layout, KDialogBase::spacingHint()); + TQLabel p(plainPage()); + p.setPixmap(krLoader->loadIcon(errors ? "messagebox_critical" : "messagebox_info", TDEIcon::Desktop, 32)); + hlayout->addWidget(&p); + + TQLabel *l1 = new TQLabel((errors ? i18n("Errors were detected while creating the checksums") : + i18n("Checksums were created successfully")), plainPage()); + hlayout->addWidget(l1); + layout->addMultiCellLayout(hlayout,row,row,0,1, TQt::AlignLeft); + ++row; + + if (successes) { + if (errors) { + TQLabel *l2 = new TQLabel(i18n("Here are the calculated checksums:"), plainPage()); + layout->addMultiCellWidget(l2, row, row, 0, 1); + ++row; + } + TDEListView *lv = new TDEListView(plainPage()); + if(standardFormat){ + lv->addColumn(i18n("Hash")); + lv->addColumn(i18n("File")); + lv->setAllColumnsShowFocus(true); + } else { + lv->addColumn(i18n("File and hash")); + } + for ( TQStringList::ConstIterator it = stdOut.begin(); it != stdOut.end(); ++it ) { + TQString line = (*it); + if(standardFormat) { + int space = line.find(' '); + new TDEListViewItem(lv, line.left(space), line.mid(space+2)); + } else { + new TDEListViewItem(lv, line); + } + } + layout->addMultiCellWidget(lv, row, row, 0, 1); + ++row; + } + + if (errors) { + TQFrame *line1 = new TQFrame( plainPage() ); + line1->setGeometry( TQRect( 60, 210, 501, 20 ) ); + line1->setFrameShape( TQFrame::HLine ); + line1->setFrameShadow( TQFrame::Sunken ); + layout->addMultiCellWidget(line1, row, row, 0, 1); + ++row; + + TQLabel *l3 = new TQLabel(i18n("Here are the errors received:"), plainPage()); + layout->addMultiCellWidget(l3, row, row, 0, 1); + ++row; + TDEListBox *lb = new TDEListBox(plainPage()); + lb->insertStringList(stdErr); + layout->addMultiCellWidget(lb, row, row, 0, 1); + ++row; + } + + // save checksum to disk, if any hashes are found + KURLRequester *checksumFile=0; + TQCheckBox *saveFileCb=0; + if (successes) { + TQHBoxLayout *hlayout2 = new TQHBoxLayout(layout, KDialogBase::spacingHint()); + saveFileCb = new TQCheckBox(i18n("Save checksum to file:"), plainPage()); + saveFileCb->setChecked(true); + hlayout2->addWidget(saveFileCb); + + checksumFile = new KURLRequester( suggestedFilename, plainPage() ); + hlayout2->addWidget(checksumFile, TQt::AlignLeft); + layout->addMultiCellLayout(hlayout2, row, row,0,1, TQt::AlignLeft); + ++row; + connect(saveFileCb, TQ_SIGNAL(toggled(bool)), checksumFile, TQ_SLOT(setEnabled(bool))); + checksumFile->setFocus(); + } + + TQCheckBox *onePerFile=0; + if (stdOut.size() > 1 && standardFormat) { + onePerFile = new TQCheckBox(i18n("Checksum file for each source file"), plainPage()); + onePerFile->setChecked(false); + // clicking this, disables the 'save as' part + connect(onePerFile, TQ_SIGNAL(toggled(bool)), saveFileCb, TQ_SLOT(toggle())); + connect(onePerFile, TQ_SIGNAL(toggled(bool)), saveFileCb, TQ_SLOT(setDisabled(bool))); + connect(onePerFile, TQ_SIGNAL(toggled(bool)), checksumFile, TQ_SLOT(setDisabled(bool))); + layout->addMultiCellWidget(onePerFile, row, row,0,1, TQt::AlignLeft); + ++row; + } + + if (exec() == Accepted && successes) { + if (stdOut.size()>1 && standardFormat && onePerFile->isChecked()) { + savePerFile(stdOut, suggestedFilename.mid(suggestedFilename.findRev('.'))); + } else if (saveFileCb->isEnabled() && saveFileCb->isChecked() && !checksumFile->url().simplifyWhiteSpace().isEmpty()) { + saveChecksum(stdOut, checksumFile->url()); + } + } +} + +bool ChecksumResultsDlg::saveChecksum(const TQStringList& data, TQString filename) { + if (TQFile::exists(filename) && + KMessageBox::warningContinueCancel(this, + i18n("File %1 already exists.\nAre you sure you want to overwrite it?").arg(filename), + i18n("Warning"), i18n("Overwrite")) != KMessageBox::Continue) { + // find a better name to save to + filename = KFileDialog::getSaveFileName(TQString(), "*", 0, i18n("Select a file to save to")); + if (filename.simplifyWhiteSpace().isEmpty()) return false; + } + TQFile file(filename); + if (!file.open(IO_WriteOnly)) { + KMessageBox::detailedError(0, i18n("Error saving file %1").arg(filename), + file.errorString()); + return false; + } + TQTextStream stream(&file); + for ( TQStringList::ConstIterator it = data.constBegin(); it != data.constEnd(); ++it) + stream << *it << "\n"; + file.close(); + return true; +} + +void ChecksumResultsDlg::savePerFile(const TQStringList& data, const TQString& type) { + krApp->startWaiting(i18n("Saving checksum files..."), 0); + for ( TQStringList::ConstIterator it = data.begin(); it != data.end(); ++it ) { + TQString line = (*it); + TQString filename = line.mid(line.find(' ')+2)+type; + if (!saveChecksum(*it, filename)) { + KMessageBox::error(0, i18n("Errors occured while saving multiple checksums. Stopping")); + krApp->stopWait(); + return; + } + } + krApp->stopWait(); +} diff --git a/src/app/Dialogs/checksumdlg.h b/src/app/Dialogs/checksumdlg.h new file mode 100644 index 0000000..a145a35 --- /dev/null +++ b/src/app/Dialogs/checksumdlg.h @@ -0,0 +1,54 @@ +#ifndef CHECKSUMDLG_H +#define CHECKSUMDLG_H + +#include +#include + +class KTempFile; +extern void initChecksumModule(); + +class CreateChecksumDlg: public KDialogBase { +public: + CreateChecksumDlg(const TQStringList& files, bool containFolders, const TQString& path); + +private: + KTempFile *tmpOut, *tmpErr; +}; + + +class MatchChecksumDlg: public KDialogBase { +public: + MatchChecksumDlg(const TQStringList& files, bool containFolders, + const TQString& path, const TQString& checksumFile=TQString()); + + static TQString checksumTypesFilter; + +protected: + bool verifyChecksumFile(TQString path, TQString& extension); + +private: + KTempFile *tmpOut, *tmpErr; +}; + + +class ChecksumResultsDlg: public KDialogBase { +public: + ChecksumResultsDlg(const TQStringList& stdOut, const TQStringList& stdErr, + const TQString& suggestedFilename, const TQString& binary, const TQString& type, + bool standardFormat); + +protected: + bool saveChecksum(const TQStringList& data, TQString filename); + void savePerFile(const TQStringList& data, const TQString& type); + +private: + TQString _binary; +}; + + +class VerifyResultDlg: public KDialogBase { +public: + VerifyResultDlg(const TQStringList& failed); +}; + +#endif // CHECKSUMDLG_H diff --git a/src/app/Dialogs/krdialogs.cpp b/src/app/Dialogs/krdialogs.cpp new file mode 100644 index 0000000..feb4c85 --- /dev/null +++ b/src/app/Dialogs/krdialogs.cpp @@ -0,0 +1,255 @@ +/*************************************************************************** + krdialogs.cpp + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +// Krusader includes +#include "krdialogs.h" +// TQt includes +#include +#include +#include +#include +#include +// TDE includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// Krusader includes +#include "../krusader.h" +#include "../resources.h" +#include "../VFS/vfs.h" +#include "../defaults.h" +#include + +KURL KChooseDir::getDir(TQString text,const KURL& url, const KURL& cwd) { + KURLRequesterDlg *dlg = new KURLRequesterDlg( vfs::pathOrURL( url, 1 ),text,krApp,""); + dlg->urlRequester()->completionObject()->setDir(cwd.url()); + dlg->urlRequester()->setMode(KFile::LocalOnly | KFile::Directory); + KURL u; + if (dlg->exec() == TQDialog::Accepted) { + u = vfs::fromPathOrURL(dlg->urlRequester()->completionObject()->replacedPath( + dlg->urlRequester()->lineEdit()->text())); + if (u.isRelativeURL(u.url())) { + KURL temp = u; + u = cwd; + u.addPath(temp.url()); + u.cleanPath(); + if( u.protocol() == "zip" || u.protocol() == "krarc" || u.protocol() == "tar" || u.protocol() == "iso" ) { + if( TQDir( u.path() ).exists() ) + u.setProtocol( "file" ); + } + } + } + delete dlg; + return u; +} + +KURL KChooseDir::getDir(TQString text,const KURL& url, const KURL& cwd, bool &preserveAttrs ) { + KURLRequesterDlgForCopy *dlg = new KURLRequesterDlgForCopy( vfs::pathOrURL( url, 1 ),text, preserveAttrs, krApp,"" ); + dlg->urlRequester()->completionObject()->setDir(cwd.url()); + KURL u; + if (dlg->exec() == TQDialog::Accepted) { + u = vfs::fromPathOrURL(dlg->urlRequester()->completionObject()->replacedPath( + dlg->urlRequester()->lineEdit()->text())); + if (u.isRelativeURL(u.url())) { + KURL temp = u; + u = cwd; + u.addPath(temp.url()); + u.cleanPath(); + if( u.protocol() == "zip" || u.protocol() == "krarc" || u.protocol() == "tar" || u.protocol() == "iso" ) { + if( TQDir( u.path() ).exists() ) + u.setProtocol( "file" ); + } + } + } + preserveAttrs = dlg->preserveAttrs(); + delete dlg; + return u; +} + +KURL KChooseDir::getDir(TQString text,const KURL& url, const KURL& cwd, bool &preserveAttrs, KURL &baseURL ) { + KURLRequesterDlgForCopy *dlg = new KURLRequesterDlgForCopy( vfs::pathOrURL( url, 1 ),text, preserveAttrs, krApp,"", true, baseURL ); + dlg->urlRequester()->completionObject()->setDir(cwd.url()); + KURL u; + if (dlg->exec() == TQDialog::Accepted) { + u = vfs::fromPathOrURL(dlg->urlRequester()->completionObject()->replacedPath( + dlg->urlRequester()->lineEdit()->text())); + if (u.isRelativeURL(u.url())) { + KURL temp = u; + u = cwd; + u.addPath(temp.url()); + u.cleanPath(); + if( u.protocol() == "zip" || u.protocol() == "krarc" || u.protocol() == "tar" || u.protocol() == "iso" ) { + if( TQDir( u.path() ).exists() ) + u.setProtocol( "file" ); + } + } + + if( dlg->copyDirStructure() ) { + baseURL = dlg->baseURL(); + } else { + baseURL = KURL(); + } + } + preserveAttrs = dlg->preserveAttrs(); + delete dlg; + return u; +} + +KURLRequesterDlgForCopy::KURLRequesterDlgForCopy( const TQString& urlName, const TQString& _text, bool presAttrs, TQWidget *parent, + const char *name, bool modal, KURL baseURL ) + : KDialogBase( Plain, TQString(), Ok|Cancel|User1, Ok, parent, name, modal, true, KStdGuiItem::clear() ), + baseUrlCombo( 0 ), copyDirStructureCB( 0 ) { + + TQVBoxLayout * topLayout = new TQVBoxLayout( plainPage(), 0, spacingHint() ); + + TQLabel * label = new TQLabel( _text, plainPage() ); + topLayout->addWidget( label ); + + urlRequester_ = new KURLRequester( urlName, plainPage(), "urlRequester" ); + urlRequester_->setMinimumWidth( urlRequester_->sizeHint().width() * 3 ); + topLayout->addWidget( urlRequester_ ); + preserveAttrsCB = new TQCheckBox(i18n("Preserve attributes (only for local targets)"), plainPage()); + preserveAttrsCB->setChecked( presAttrs ); + topLayout->addWidget( preserveAttrsCB ); + if( !baseURL.isEmpty() ) { + TQFrame *line = new TQFrame( plainPage(), "sepLine" ); + line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken ); + topLayout->addWidget( line ); + copyDirStructureCB = new TQCheckBox(i18n("Keep virtual directory structure"), plainPage()); + connect( copyDirStructureCB, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotDirStructCBChanged() ) ); + copyDirStructureCB->setChecked( false ); + topLayout->addWidget( copyDirStructureCB ); + TQHBox * hbox = new TQHBox( plainPage(), "copyDirStructure" ); + new TQLabel( i18n("Base URL:"), hbox, "baseURLLabel" ); + + baseUrlCombo = new TQComboBox( hbox, "baseUrlRequester" ); + baseUrlCombo->setMinimumWidth( baseUrlCombo->sizeHint().width() * 3 ); + baseUrlCombo->setEnabled( copyDirStructureCB->isChecked() ); + KURL temp = baseURL, tempOld; + do { + TQString baseURLText = vfs::pathOrURL( temp ); + baseUrlCombo->insertItem( baseURLText ); + tempOld = temp; + temp = temp.upURL(); + }while( !tempOld.equals( temp, true ) ); + baseUrlCombo->setCurrentItem( 0 ); + + topLayout->addWidget( hbox ); + } + urlRequester_->setFocus(); + connect( urlRequester_->lineEdit(), TQ_SIGNAL(textChanged(const TQString&)), + TQ_SLOT(slotTextChanged(const TQString&)) ); + bool state = !urlName.isEmpty(); + enableButtonOK( state ); + enableButton( KDialogBase::User1, state ); + connect( this, TQ_SIGNAL( user1Clicked() ), TQ_SLOT( slotClear() ) ); +} + +KURLRequesterDlgForCopy::KURLRequesterDlgForCopy() { +} + +bool KURLRequesterDlgForCopy::preserveAttrs() { + return preserveAttrsCB->isChecked(); +} + +bool KURLRequesterDlgForCopy::copyDirStructure() { + if( copyDirStructureCB == 0 ) + return false; + return copyDirStructureCB->isChecked(); +} + +void KURLRequesterDlgForCopy::slotTextChanged(const TQString & text) { + bool state = !text.stripWhiteSpace().isEmpty(); + enableButtonOK( state ); + enableButton( KDialogBase::User1, state ); +} + +void KURLRequesterDlgForCopy::slotClear() { + urlRequester_->clear(); +} + +void KURLRequesterDlgForCopy::slotDirStructCBChanged() { + baseUrlCombo->setEnabled( copyDirStructureCB->isChecked() ); +} + +KURL KURLRequesterDlgForCopy::selectedURL() const { + if ( result() == TQDialog::Accepted ) { + KURL url = KURL::fromPathOrURL( urlRequester_->url() ); + if( url.isValid() ) + TDERecentDocument::add(url); + return url; + } + else + return KURL(); +} + +KURLRequester * KURLRequesterDlgForCopy::urlRequester() { + return urlRequester_; +} + +KURL KURLRequesterDlgForCopy::baseURL() const { + if( baseUrlCombo == 0 ) + return KURL(); + return vfs::fromPathOrURL( baseUrlCombo->currentText() ); +} + +KRGetDate::KRGetDate(TQDate date, TQWidget *parent, const char *name) : KDialog(parent, name,true,WStyle_DialogBorder) { + dateWidget = new KDatePicker(this, date); + dateWidget->resize(dateWidget->sizeHint()); + setMinimumSize(dateWidget->sizeHint()); + setMaximumSize(dateWidget->sizeHint()); + resize(minimumSize()); + connect(dateWidget, TQ_SIGNAL(dateSelected(TQDate)), this, TQ_SLOT(setDate(TQDate))); + connect(dateWidget, TQ_SIGNAL(dateEntered(TQDate)), this, TQ_SLOT(setDate(TQDate))); + + // keep the original date - incase ESC is pressed + originalDate = date; +} + +TQDate KRGetDate::getDate() { + if (exec() == TQDialog::Rejected) chosenDate.setYMD(0,0,0); + hide(); + return chosenDate; +} + +void KRGetDate::setDate(TQDate date) { + chosenDate = date; + accept(); +} + +#include "krdialogs.moc" diff --git a/src/app/Dialogs/krdialogs.h b/src/app/Dialogs/krdialogs.h new file mode 100644 index 0000000..ca447bf --- /dev/null +++ b/src/app/Dialogs/krdialogs.h @@ -0,0 +1,116 @@ +/*************************************************************************** + krdialogs.h + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + email : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 KCHOSEDIR_H +#define KCHOSEDIR_H + +// TDE includes +#include +#include +#include +#include +#include +// TQt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** \class KChooseDir + * Used for asking the user for a folder. + * example: + * \code + * KURL u = KChooseDir::getDir("target folder", "/suggested/path", ACTIVE_PANEL->virtualPath()); + * if (u.isEmpty()) { + * // user canceled (either by pressing cancel, or esc + * } else { + * // do you thing here: you've got a safe url to use + * } + * \endcode + */ +class KChooseDir { +public: + /** + * \param text - description of the info requested from the user + * \param url - a suggested url to appear in the box as a default choice + * \param cwd - a path which is the current working directory (usually ACTIVE_PANEL->virtualPath()). + * this is used for completion of partial urls + */ + static KURL getDir(TQString text,const KURL& url, const KURL& cwd); + static KURL getDir(TQString text,const KURL& url, const KURL& cwd, bool & preserveAttrs ); + static KURL getDir(TQString text,const KURL& url, const KURL& cwd, bool & preserveAttrs, KURL &baseURL ); +}; + +class KURLRequesterDlgForCopy : public KDialogBase { + TQ_OBJECT + +public: + KURLRequesterDlgForCopy( const TQString& url, const TQString& text, bool presAttrs, + TQWidget *parent, const char *name, bool modal=true, KURL baseURL = KURL() ); + KURLRequesterDlgForCopy(); + + KURL selectedURL() const; + KURL baseURL() const; + bool preserveAttrs(); + bool copyDirStructure(); + + KURLRequester *urlRequester(); +private slots: + void slotClear(); + void slotTextChanged(const TQString &); + void slotDirStructCBChanged(); +private: + KURLRequester *urlRequester_; + TQComboBox *baseUrlCombo; + TQCheckBox *preserveAttrsCB; + TQCheckBox *copyDirStructureCB; +}; + +class KRGetDate : public KDialog { + TQ_OBJECT + +public: + KRGetDate(TQDate date=TQDate::currentDate(), TQWidget *parent = 0, const char *name = 0); + TQDate getDate(); + +private slots: + void setDate(TQDate); + +private: + KDatePicker *dateWidget; + TQDate chosenDate, originalDate; +}; + +#endif diff --git a/src/app/Dialogs/krkeydialog.cpp b/src/app/Dialogs/krkeydialog.cpp new file mode 100644 index 0000000..30f5dda --- /dev/null +++ b/src/app/Dialogs/krkeydialog.cpp @@ -0,0 +1,157 @@ +// +// C++ Implementation: krkeydialog +// +// Description: +// +// +// Author: Jonas Bähr , (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "krkeydialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../krusader.h" + +//This is the filter in the KFileDialog of Import/Export: +static const char* FILE_FILTER = I18N_NOOP("*.keymap|Krusader keymaps\n*|all files"); + + +KrKeyDialog::KrKeyDialog( TQWidget * parent ) : KKeyDialog( false /* allow letter shortcuts */, parent ) { + insert( krApp->actionCollection() ); + + // HACK This fetches the layout of the buttonbox from KDialogBase, although it is not accessable with KDialogBase's API + // None the less it's quite save to use since this implementation hasn't changed since KDE-3.3 (I haven't looked at earlier + // versions since we don't support them) and now all work is done in KDE-4. + TQWidget* buttonBox = static_cast( actionButton(KDialogBase::Ok)->parent() ); + TQBoxLayout* buttonBoxLayout = static_cast( buttonBox->layout() ); + + KPushButton* importButton = new KPushButton( i18n("Import shortcuts"), buttonBox ); + TQWhatsThis::add( importButton, i18n( "Load a keybinding profile, e.g., total_commander.keymap" ) ); + buttonBoxLayout->insertWidget( 1, importButton ); // the defaults-button should stay on position 0 + connect( importButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotImportShortcuts() ) ); + + KPushButton* exportButton = new KPushButton( i18n("Export shortcuts"), buttonBox ); + TQWhatsThis::add( exportButton, i18n( "Save current keybindings in a keymap file." ) ); + buttonBoxLayout->insertWidget( 2, exportButton ); + connect( exportButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotExportShortcuts() ) ); + + // Also quite HACK 'isch but unfortunately KKeyDialog don't giveus access to this widget + _chooser = static_cast( mainWidget() ); + + configure( true /* SaveSettings */ ); // this runs the dialog +} + +KrKeyDialog::~KrKeyDialog() { +} + +void KrKeyDialog::slotImportShortcuts() { + // find $TDEDIR/share/apps/krusader + TQString basedir = TDEGlobal::dirs()->findResourceDir("appdata", "total_commander.keymap"); + // let the user select a file to load + TQString filename = KFileDialog::getOpenFileName(basedir, i18n(FILE_FILTER), 0, i18n("Select a keymap file")); + if ( filename.isEmpty() ) + return; + + TDEConfig conf( filename, true /*read only*/, false /*no KDEGlobal*/ ); + if ( ! conf.hasGroup("Shortcuts") ) { + int answer = KMessageBox::warningContinueCancel( this, //parent + i18n("This file does not seem to be a valid keymap.\n" + "It may be a keymap using a legacy format. The import can't be undone!"), //text + i18n("Try to import legacy format?"), //caption + i18n("Import anyway"), //Label for the continue-button + "Confirm Import Legacy Shortcuts" //dontAskAgainName (for the config-file) + ); + if ( answer == KMessageBox::Continue ) + importLegacyShortcuts( filename ); + else + return; + } + else + _chooser->syncToConfig( "Shortcuts", &conf, false /* don't delete shortcuts of actions not listed in conf */ ); +} + +void KrKeyDialog::importLegacyShortcuts( const TQString& file ) { +/* + * This is basicaly Shie's code. It's copied from Kronfigurator's loog&feel page and adapted to the dialog + */ + // check if there's an info file with the keymap + TQFile info(file+".info"); + if (info.open(IO_ReadOnly)) { + TQTextStream stream(&info); + TQStringList infoText = TQStringList::split("\n", stream.read()); + if (KMessageBox::questionYesNoList(krApp, i18n("The following information was attached to the keymap. Do you really want to import this keymap?"), infoText)!=KMessageBox::Yes) + return; + } + + // ok, import away + TQFile f(file); + if (!f.open(IO_ReadOnly)) { + krOut << "Error opening " << file << endl; + return; + } + char *actionName; + TQDataStream stream(&f); + int key; + TDEAction *action; + while (!stream.atEnd()) { + stream >> actionName >> key; + action = krApp->actionCollection()->action(actionName); + if (action) { + action->setShortcut(key); +// krOut << "set shortcut for " << actionName <File %1 already exists. Do you really want to overwrite it?").arg(filename), + i18n("Warning"), i18n("Overwrite") ) + != KMessageBox::Continue) + return; + if ( f.open( IO_WriteOnly ) ) + // This is the only way to detect if the file is writable since we don't get feetback from TDEConfig's sync + // Additionaly this prevents merging if the file already contains some shortcuts + f.close(); + else { + KMessageBox::error( this, i18n("Can't open %1 for writing!").arg(filename) ); + return; + } + + TDEConfig conf( filename, false /*read only*/, false /*no KDEGlobal*/ ); + + // unfortunately we can't use this function since it only writes the actions which are different from default. + //krApp->actionCollection()->writeShortcutSettings( "Shortcuts", &conf ); + TDEActionShortcutList list( krApp->actionCollection() ); + list.writeSettings( "Shortcuts", &conf, true /* write all actions */ ); + // That does TDEActionShortcutList::writeSettings for us + //conf.sync(); // write back all changes +} + +#include "krkeydialog.moc" diff --git a/src/app/Dialogs/krkeydialog.h b/src/app/Dialogs/krkeydialog.h new file mode 100644 index 0000000..082ac0a --- /dev/null +++ b/src/app/Dialogs/krkeydialog.h @@ -0,0 +1,38 @@ +// +// C++ Interface: krkeydialog +// +// Description: +// +// +// Author: Jonas Bähr , (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef KRKEYDIALOG_H +#define KRKEYDIALOG_H + +#include + +/** + * @short KDE's KKeyDialog extended by the ability to export/import shortcuts + * @author Jonas Bähr + */ +class KrKeyDialog : protected KKeyDialog +{ +TQ_OBJECT + +public: + KrKeyDialog( TQWidget* parent = 0 ); + ~KrKeyDialog(); + +private slots: + void slotImportShortcuts(); + void slotExportShortcuts(); + +private: + void importLegacyShortcuts( const TQString& file ); + KKeyChooser* _chooser; +}; + +#endif diff --git a/src/app/Dialogs/krmaskchoice.cpp b/src/app/Dialogs/krmaskchoice.cpp new file mode 100644 index 0000000..159cbf9 --- /dev/null +++ b/src/app/Dialogs/krmaskchoice.cpp @@ -0,0 +1,179 @@ +/*************************************************************************** + krmaskchoice.cpp + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ +#include "krmaskchoice.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a KRMaskChoice which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * true to construct a modal dialog. + */ +KRMaskChoice::KRMaskChoice( TQWidget* parent, const char* name, bool modal, WFlags fl ) + : TQDialog( parent, name, modal, fl ) +{ + if ( !name ) + setName( "KRMaskChoice" ); + resize( 401, 314 ); + setCaption( i18n( "Choose Files" ) ); + setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)5, (TQSizePolicy::SizeType)5 ) ); + + selection = new TQComboBox( false, this, "selection" ); + int height = TQFontMetrics( selection->font() ).height(); + height = height + 5*(height > 14) + 6; + selection->setGeometry( TQRect( 12, 48, 377, height) ); + selection->setEditable( true ); + selection->setInsertionPolicy( TQComboBox::AtTop ); + selection->setAutoCompletion( true ); + + TQWidget* Layout7 = new TQWidget( this, "Layout7" ); + Layout7->setGeometry( TQRect( 10, 10, 380, 30 ) ); + hbox = new TQHBoxLayout( Layout7 ); + hbox->setSpacing( 6 ); + hbox->setMargin( 0 ); + + PixmapLabel1 = new TQLabel( Layout7, "PixmapLabel1" ); + PixmapLabel1->setScaledContents( true ); + PixmapLabel1->setMaximumSize( TQSize( 31, 31 ) ); + // now, add space for the pixmap + hbox->addWidget( PixmapLabel1 ); + + label = new TQLabel( Layout7, "label" ); + label->setText( i18n( "Select the following files:" ) ); + hbox->addWidget( label ); + + GroupBox1 = new TQGroupBox( this, "GroupBox1" ); + GroupBox1->setGeometry( TQRect( 11, 77, 379, 190 ) ); + GroupBox1->setTitle( i18n( "Predefined Selections" ) ); + + TQWidget* Layout6 = new TQWidget( GroupBox1, "Layout6" ); + Layout6->setGeometry( TQRect( 10, 20, 360, 160 ) ); + hbox_2 = new TQHBoxLayout( Layout6 ); + hbox_2->setSpacing( 6 ); + hbox_2->setMargin( 0 ); + + preSelections = new TQListBox( Layout6, "preSelections" ); + preSelections->setVScrollBarMode( TQListBox::AlwaysOn ); + TQWhatsThis::add( preSelections, i18n( "A predefined selection is a file-mask which you use often.\nSome examples are: \"*.c, *.h\", \"*.c, *.o\", etc.\nYou can add these masks to the list by typing them and pressing the Add button.\nDelete removes a predefined selection and Clear removes all of them.\nNotice that the line in which you edit the mask has it's own history, you can scroll it, if needed." ) ); + hbox_2->addWidget( preSelections ); + + vbox = new TQVBoxLayout; + vbox->setSpacing( 6 ); + vbox->setMargin( 0 ); + + PushButton7 = new TQPushButton( Layout6, "PushButton7" ); + PushButton7->setText( i18n( "Add" ) ); + TQToolTip::add( PushButton7, i18n( "Adds the selection in the line-edit to the list" ) ); + vbox->addWidget( PushButton7 ); + + PushButton7_2 = new TQPushButton( Layout6, "PushButton7_2" ); + PushButton7_2->setText( i18n( "Delete" ) ); + TQToolTip::add( PushButton7_2, i18n( "Delete the marked selection from the list" ) ); + vbox->addWidget( PushButton7_2 ); + + PushButton7_3 = new TQPushButton( Layout6, "PushButton7_3" ); + PushButton7_3->setText( i18n( "Clear" ) ); + TQToolTip::add( PushButton7_3, i18n( "Clears the entire list of selections" ) ); + vbox->addWidget( PushButton7_3 ); + TQSpacerItem* spacer = new TQSpacerItem( 20, 54, TQSizePolicy::Fixed, TQSizePolicy::Expanding ); + vbox->addItem( spacer ); + hbox_2->addLayout( vbox ); + + TQWidget* Layout18 = new TQWidget( this, "Layout18" ); + Layout18->setGeometry( TQRect( 10, 280, 379, 30 ) ); + hbox_3 = new TQHBoxLayout( Layout18 ); + hbox_3->setSpacing( 6 ); + hbox_3->setMargin( 0 ); + TQSpacerItem* spacer_2 = new TQSpacerItem( 205, 20, TQSizePolicy::Expanding, TQSizePolicy::Fixed ); + hbox_3->addItem( spacer_2 ); + + PushButton3 = new TQPushButton( Layout18, "PushButton3" ); + PushButton3->setText( i18n( "OK" ) ); + hbox_3->addWidget( PushButton3 ); + + PushButton3_2 = new TQPushButton( Layout18, "PushButton3_2" ); + PushButton3_2->setText( i18n( "Cancel" ) ); + hbox_3->addWidget( PushButton3_2 ); + + // signals and slots connections + connect( PushButton3_2, TQ_SIGNAL( clicked() ), this, TQ_SLOT( reject() ) ); + connect( PushButton3, TQ_SIGNAL( clicked() ), this, TQ_SLOT( accept() ) ); + connect( PushButton7, TQ_SIGNAL( clicked() ), this, TQ_SLOT( addSelection() ) ); + connect( PushButton7_2, TQ_SIGNAL( clicked() ), this, TQ_SLOT( deleteSelection() ) ); + connect( PushButton7_3, TQ_SIGNAL( clicked() ), this, TQ_SLOT( clearSelections() ) ); + connect( selection, TQ_SIGNAL( activated(const TQString&) ), selection, TQ_SLOT( setEditText(const TQString &) ) ); + connect( selection->lineEdit(), TQ_SIGNAL( returnPressed() ), this, TQ_SLOT( accept() )); + connect( preSelections, TQ_SIGNAL( doubleClicked(TQListBoxItem*) ), this, TQ_SLOT( acceptFromList(TQListBoxItem *) ) ); + connect( preSelections, TQ_SIGNAL( highlighted(const TQString&) ), selection, TQ_SLOT( setEditText(const TQString &) ) ); + connect( preSelections, TQ_SIGNAL( returnPressed(TQListBoxItem*) ), this, TQ_SLOT( acceptFromList(TQListBoxItem *) ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +KRMaskChoice::~KRMaskChoice() +{ + // no need to delete child widgets, TQt does it all for us +} + +void KRMaskChoice::addSelection() +{ + tqWarning( "KRMaskChoice::addSelection(): Not implemented yet!" ); +} + +void KRMaskChoice::clearSelections() +{ + tqWarning( "KRMaskChoice::clearSelections(): Not implemented yet!" ); +} + +void KRMaskChoice::deleteSelection() +{ + tqWarning( "KRMaskChoice::deleteSelection(): Not implemented yet!" ); +} + +void KRMaskChoice::acceptFromList(TQListBoxItem *) +{ + tqWarning( "KRMaskChoice::acceptFromList(TQListBoxItem *): Not implemented yet!" ); +} + +#include "krmaskchoice.moc" diff --git a/src/app/Dialogs/krmaskchoice.h b/src/app/Dialogs/krmaskchoice.h new file mode 100644 index 0000000..a4324da --- /dev/null +++ b/src/app/Dialogs/krmaskchoice.h @@ -0,0 +1,77 @@ +/*************************************************************************** + krmaskchoice.h + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + email : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 KRMASKCHOICE_H +#define KRMASKCHOICE_H + +#include +class TQVBoxLayout; +class TQHBoxLayout; +class TQGridLayout; +class TQComboBox; +class TQGroupBox; +class TQLabel; +class TQListBox; +class TQListBoxItem; +class TQPushButton; + +class KRMaskChoice : public TQDialog +{ + TQ_OBJECT + + +public: + KRMaskChoice( TQWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); + ~KRMaskChoice(); + + TQComboBox* selection; + TQLabel* PixmapLabel1; + TQLabel* label; + TQGroupBox* GroupBox1; + TQListBox* preSelections; + TQPushButton* PushButton7; + TQPushButton* PushButton7_2; + TQPushButton* PushButton7_3; + TQPushButton* PushButton3; + TQPushButton* PushButton3_2; + +public slots: + virtual void addSelection(); + virtual void clearSelections(); + virtual void deleteSelection(); + virtual void acceptFromList(TQListBoxItem *); + +protected: + TQHBoxLayout* hbox; + TQHBoxLayout* hbox_2; + TQHBoxLayout* hbox_3; + TQVBoxLayout* vbox; +}; + +#endif // KRMASKCHOICE_H diff --git a/src/app/Dialogs/krpleasewait.cpp b/src/app/Dialogs/krpleasewait.cpp new file mode 100644 index 0000000..55521f7 --- /dev/null +++ b/src/app/Dialogs/krpleasewait.cpp @@ -0,0 +1,153 @@ +/*************************************************************************** + krpleasewait.cpp + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "krpleasewait.h" +#include +#include +#include +#include +#include +#include "../krusader.h" +#include "tdelocale.h" +#include + +KRPleaseWait::KRPleaseWait( TQString msg, int count, bool cancel ): + TQProgressDialog( cancel ? 0 : krApp,0, !cancel) , inc(true) { + + timer = new TQTimer(this); + setCaption( i18n( "Krusader::Wait" ) ); + + setMinimumDuration(500); + setAutoClose(false); + setAutoReset(false); + + connect( timer,TQ_SIGNAL(timeout()), this, TQ_SLOT(cycleProgress())); + + TQProgressBar* progress = new TQProgressBar(count,this); + progress->setCenterIndicator(true); + setBar(progress); + + TQLabel* label = new TQLabel(this); + setLabel(label); + + TQPushButton* btn = new TQPushButton(i18n("&Cancel"),this); + setCancelButton(btn); + + btn->setEnabled(canClose = cancel); + setLabelText(msg); + + show(); +} + +void KRPleaseWait::closeEvent ( TQCloseEvent * e ) +{ + if( canClose ) { + emit cancelled(); + e->accept(); + } else /* if cancel is not allowed, we disable */ + e->ignore(); /* the window closing [x] also */ +} + +void KRPleaseWait::incProgress(int howMuch){ + setProgress(progress()+howMuch); +} + +void KRPleaseWait::cycleProgress(){ + if (inc) setProgress(progress()+1); + else setProgress(progress()-1); + if ( progress() >= 9 ) inc = false; + if ( progress() <= 0 ) inc = true; +} + +KRPleaseWaitHandler::KRPleaseWaitHandler() : TQObject(), job(), dlg( 0 ) { +} + +void KRPleaseWaitHandler::stopWait(){ + if( dlg != 0 ) delete dlg; + dlg=0; + cycleMutex=incMutex=false; + // return cursor to normal arrow + krApp->setCursor(KCursor::arrowCursor()); +} + + +void KRPleaseWaitHandler::startWaiting( TQString msg, int count , bool cancel){ + if ( dlg == 0 ){ + dlg = new KRPleaseWait( msg , count, cancel); + connect( dlg,TQ_SIGNAL(cancelled()),this,TQ_SLOT(killJob()) ); + } + incMutex=cycleMutex=_wasCancelled=false; + dlg->setProgress(0); + + dlg->setLabelText(msg); + if ( count == 0) { + dlg->setTotalSteps(10); + cycle = true ; + cycleProgress(); + } + else { + dlg->setTotalSteps(count); + cycle = false; + } +} + +void KRPleaseWaitHandler::cycleProgress(){ + if (cycleMutex) return; + cycleMutex=true; + if (dlg) dlg->cycleProgress(); + if (cycle) TQTimer::singleShot(2000,this,TQ_SLOT(cycleProgress())); + cycleMutex=false; +} + +void KRPleaseWaitHandler::killJob(){ + if( !job.isNull() ) job->kill(false); + stopWait(); + _wasCancelled = true; +} + +void KRPleaseWaitHandler::setJob(TDEIO::Job* j){ job=j; } + +void KRPleaseWaitHandler::incProgress(int i){ + if (incMutex) return; + incMutex=true; + if(dlg) dlg->incProgress(i); + incMutex=false; +} + +void KRPleaseWaitHandler::incProgress( TDEProcess *, char *buffer, int buflen ) { + int howMuch = 0; + for ( int i = 0 ; i < buflen; ++i ) + if ( buffer[ i ] == '\n' ) + ++howMuch; + + incProgress( howMuch ); +} + +#include "krpleasewait.moc" diff --git a/src/app/Dialogs/krpleasewait.h b/src/app/Dialogs/krpleasewait.h new file mode 100644 index 0000000..246ef3c --- /dev/null +++ b/src/app/Dialogs/krpleasewait.h @@ -0,0 +1,84 @@ +/*************************************************************************** + krpleasewait.h + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 KRPLEASEWAIT_H +#define KRPLEASEWAIT_H + +#include +#include +#include +#include + +class TDEProcess; +class KRPleaseWait; + +class KRPleaseWaitHandler : public TQObject { + TQ_OBJECT + + +public: + KRPleaseWaitHandler(); + +public slots: + + void startWaiting(TQString msg, int count = 0, bool cancel = false); + void stopWait(); + void cycleProgress(); + void incProgress(int i); + void incProgress( TDEProcess *, char *buffer, int buflen ); + void killJob(); + void setJob(TDEIO::Job* j); + bool wasCancelled() const { return _wasCancelled; } + +private: + TQGuardedPtr job; + KRPleaseWait * dlg; + bool cycle, cycleMutex, incMutex, _wasCancelled; +}; + + +class KRPleaseWait : public TQProgressDialog { + TQ_OBJECT + +public: + KRPleaseWait( TQString msg, int count = 0 ,bool cancel = false ); + +public slots: + void incProgress(int howMuch); + void cycleProgress(); + +protected: + bool inc; + TQTimer* timer; + virtual void closeEvent ( TQCloseEvent * e ); + bool canClose; +}; + +#endif diff --git a/src/app/Dialogs/krprogress.cpp b/src/app/Dialogs/krprogress.cpp new file mode 100644 index 0000000..1d489d5 --- /dev/null +++ b/src/app/Dialogs/krprogress.cpp @@ -0,0 +1,270 @@ +/* This file is part of the KDE libraries + Copyright (C) 2000 Matej Koss + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "krprogress.h" +#include "../krusader.h" + +KrProgress::KrProgress( TDEIO::Job* job ) + : ProgressBase( krApp ), + m_iTotalSize(0), m_iTotalFiles(0), m_iTotalDirs(0), + m_iProcessedSize(0), m_iProcessedDirs(0), m_iProcessedFiles(0){ + +#ifdef TQ_WS_X11 //FIXME(E): Remove once all the KWin::foo calls have been ported to TQWS + // Set a useful icon for this window! + KWin::setIcons( winId(), + TDEGlobal::iconLoader()->loadIcon( "document-save", TDEIcon::NoGroup, 32 ), + TDEGlobal::iconLoader()->loadIcon( "document-save", TDEIcon::NoGroup, 16 ) ); +#endif + + TQVBoxLayout *topLayout = new TQVBoxLayout( this, KDialog::marginHint(), + KDialog::spacingHint() ); + topLayout->addStrut( 360 ); // makes dlg at least that wide + + TQGridLayout *grid = new TQGridLayout( 2, 3 ); + topLayout->addLayout(grid); + grid->addColSpacing(1, KDialog::spacingHint()); + // filenames or action name + grid->addWidget(new TQLabel(i18n("Source:"), this), 0, 0); + + sourceLabel = new KSqueezedTextLabel(this); + grid->addWidget(sourceLabel, 0, 2); + + destInvite = new TQLabel(i18n("Destination:"), this); + grid->addWidget(destInvite, 1, 0); + + destLabel = new KSqueezedTextLabel(this); + grid->addWidget(destLabel, 1, 2); + + m_pProgressBar = new KProgress(this); + topLayout->addWidget( m_pProgressBar ); + + // processed info + TQHBoxLayout *hBox = new TQHBoxLayout(); + topLayout->addLayout(hBox); + + sizeLabel = new TQLabel(this); + hBox->addWidget(sizeLabel); + + resumeLabel = new TQLabel(this); + hBox->addWidget(resumeLabel); + + progressLabel = new TQLabel( this ); +/* progressLabel->setSizePolicy( TQSizePolicy( TQSizePolicy::MinimumExpanding, + TQSizePolicy::Preferred ) );*/ + progressLabel->setAlignment( TQLabel::AlignRight ); + hBox->addWidget( progressLabel ); + + hBox = new TQHBoxLayout(); + topLayout->addLayout(hBox); + + speedLabel = new TQLabel(this); + hBox->addWidget(speedLabel, 1); + + TQFrame *line = new TQFrame( this ); + line->setFrameShape( TQFrame::HLine ); + line->setFrameShadow( TQFrame::Sunken ); + topLayout->addWidget( line ); + + hBox = new TQHBoxLayout(); + topLayout->addLayout(hBox); + + hBox->addStretch(1); + + KPushButton *pb = new KPushButton( KStdGuiItem::cancel(), this ); + connect( pb, TQ_SIGNAL( clicked() ), TQ_SLOT( slotStop() ) ); + hBox->addWidget( pb ); + + resize( sizeHint() ); + setMaximumHeight(sizeHint().height()); + + setCaption(i18n("Krusader Progress")); // show something better than tdeio_uiserver + + setJob(job); + setOnlyClean(false); + setStopOnClose(true); + // Connect global progress info signals + connect( job, TQ_SIGNAL( percent( TDEIO::Job*, unsigned long ) ), + TQ_SLOT( slotPercent( TDEIO::Job*, unsigned long ) ) ); + connect( job, TQ_SIGNAL( infoMessage( TDEIO::Job*, const TQString & ) ), + TQ_SLOT( slotInfoMessage( TDEIO::Job*, const TQString & ) ) ); + connect( job, TQ_SIGNAL( totalSize( TDEIO::Job*, TDEIO::filesize_t ) ), + TQ_SLOT( slotTotalSize( TDEIO::Job*, TDEIO::filesize_t ) ) ); + connect( job, TQ_SIGNAL( processedSize( TDEIO::Job*, TDEIO::filesize_t ) ), + TQ_SLOT( slotProcessedSize( TDEIO::Job*, TDEIO::filesize_t ) ) ); + connect( job, TQ_SIGNAL( speed( TDEIO::Job*, unsigned long ) ), + TQ_SLOT( slotSpeed( TDEIO::Job*, unsigned long ) ) ); + + // change to modal & move to Krusader's center + TQPoint center((krApp->width()-width())/2,(krApp->height()-height())/2); + center = center+(krApp->pos()); + reparent(krApp,WType_Modal,center); + //setWFlags(WType_Modal); + //move((krApp->width()-width())/2,(krApp->height()-height())/2); + show(); +} + +KrProgress::~KrProgress(){} + +void KrProgress::slotTotalSize( TDEIO::Job*, TDEIO::filesize_t bytes ){ + m_iTotalSize = bytes; +} + + +void KrProgress::slotTotalFiles( TDEIO::Job*, unsigned long files ){ + m_iTotalFiles = files; + showTotals(); +} + + +void KrProgress::slotTotalDirs( TDEIO::Job*, unsigned long dirs ){ + m_iTotalDirs = dirs; + showTotals(); +} + +void KrProgress::showTotals(){ + // Show the totals in the progress label, if we still haven't + // processed anything. This is useful when the stat'ing phase + // of CopyJob takes a long time (e.g. over networks). + if ( m_iProcessedFiles == 0 && m_iProcessedDirs == 0 ) + { + TQString tmps; + if ( m_iTotalDirs > 1 ) + // that we have a singular to translate looks weired but is only logical + tmps = i18n("%n directory", "%n directories", m_iTotalDirs) + " "; + tmps += i18n("%n file", "%n files", m_iTotalFiles); + progressLabel->setText( tmps ); + } +} + +void KrProgress::slotPercent( TDEIO::Job*, unsigned long percent ){ + TQString tmp(i18n( "%1% of %2 ").arg( percent ).arg( TDEIO::convertSize(m_iTotalSize))); + m_pProgressBar->setValue( percent ); + tmp.append(i18n(" (Reading)")); + + setCaption( tmp ); +} + + +void KrProgress::slotInfoMessage( TDEIO::Job*, const TQString & msg ) +{ + speedLabel->setText( msg ); + speedLabel->setAlignment( speedLabel->alignment() & ~TQt::WordBreak ); +} + + +void KrProgress::slotProcessedSize( TDEIO::Job*, TDEIO::filesize_t bytes ) { + m_iProcessedSize = bytes; + + TQString tmp; + tmp = i18n( "%1 of %2 complete").arg( TDEIO::convertSize(bytes) ).arg( TDEIO::convertSize(m_iTotalSize)); + sizeLabel->setText( tmp ); +} + + +void KrProgress::slotProcessedDirs( TDEIO::Job*, unsigned long dirs ) +{ + m_iProcessedDirs = dirs; + + TQString tmps; + tmps = i18n("%1 / %n directory", "%1 / %n directories", m_iTotalDirs).arg( m_iProcessedDirs ); + tmps += " "; + tmps += i18n("%1 / %n file", "%1 / %n files", m_iTotalFiles).arg( m_iProcessedFiles ); + progressLabel->setText( tmps ); +} + + +void KrProgress::slotProcessedFiles( TDEIO::Job*, unsigned long files ) +{ + m_iProcessedFiles = files; + + TQString tmps; + if ( m_iTotalDirs > 1 ) { + tmps = i18n("%1 / %n directory", "%1 / %n directories", m_iTotalDirs).arg( m_iProcessedDirs ); + tmps += " "; + } + tmps += i18n("%1 / %n file", "%1 / %n files", m_iTotalFiles).arg( m_iProcessedFiles ); + progressLabel->setText( tmps ); +} + + +void KrProgress::slotSpeed( TDEIO::Job*, unsigned long bytes_per_second ) +{ + if ( bytes_per_second == 0 ) { + speedLabel->setText( i18n( "Working") ); + } else { +#if KDE_IS_VERSION(3,4,0) + unsigned int seconds = TDEIO::calculateRemainingSeconds( m_iTotalSize, m_iProcessedSize, bytes_per_second ); + TQString remaining = TDEIO::convertSeconds(seconds); +#else + TQString remaining = TDEIO::calculateRemaining( m_iTotalSize, m_iProcessedSize, bytes_per_second ).toString(); +#endif + speedLabel->setText( i18n( "%1/s ( %2 remaining )").arg( TDEIO::convertSize( bytes_per_second )).arg( remaining ) ); + } +} + + +void KrProgress::setDestVisible( bool visible ) +{ + // We can't hide the destInvite/destLabel labels, + // because it screws up the TQGridLayout. + if (visible) + { + destInvite->setText( i18n("Destination:") ); + } + else + { + destInvite->setText( TQString() ); + destLabel->setText( TQString() ); + } +} + +void KrProgress::virtual_hook( int id, void* data ){ + ProgressBase::virtual_hook( id, data ); +} + +void KrProgress::slotStop(){ + if ( m_pJob ) { + m_pJob->kill(false); // this will call slotFinished + m_pJob = 0L; + } else { + slotFinished( 0 ); // here we call it ourselves + } + + emit stopped(); +} + +void KrProgress::closeEvent( TQCloseEvent* ) { hide(); slotStop(); } + +#include "krprogress.moc" diff --git a/src/app/Dialogs/krprogress.h b/src/app/Dialogs/krprogress.h new file mode 100644 index 0000000..70196df --- /dev/null +++ b/src/app/Dialogs/krprogress.h @@ -0,0 +1,87 @@ +/* This file is part of the KDE libraries + Copyright (C) 2000 Matej Koss + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +/** This file was modified for Krusader by Shie Erlich & Rafi Yanai **/ + +#ifndef __kr_progress_h__ +#define __kr_progress_h__ + +#include + +#include + +#include +#include + +#include + +#include + +class KrProgress : public TDEIO::ProgressBase { + TQ_OBJECT + +public: + + KrProgress(TDEIO::Job* job); + virtual ~KrProgress(); + +public slots: + virtual void slotTotalSize( TDEIO::Job*, TDEIO::filesize_t bytes ); + virtual void slotTotalFiles( TDEIO::Job*, unsigned long files ); + virtual void slotTotalDirs( TDEIO::Job*, unsigned long dirs ); + + virtual void slotProcessedSize( TDEIO::Job*, TDEIO::filesize_t bytes ); + virtual void slotProcessedFiles( TDEIO::Job*, unsigned long files ); + virtual void slotProcessedDirs( TDEIO::Job*, unsigned long dirs ); + + virtual void slotSpeed( TDEIO::Job*, unsigned long bytes_per_second ); + virtual void slotPercent( TDEIO::Job*, unsigned long percent ); + virtual void slotInfoMessage( TDEIO::Job*, const TQString & msg ); + + virtual void slotStop(); + virtual void closeEvent( TQCloseEvent* ); + +protected: + void showTotals(); + void setDestVisible( bool visible ); + + KSqueezedTextLabel* sourceLabel; + KSqueezedTextLabel* destLabel; + TQLabel* progressLabel; + TQLabel* destInvite; + TQLabel* speedLabel; + TQLabel* sizeLabel; + TQLabel* resumeLabel; + + KProgress* m_pProgressBar; + + TDEIO::filesize_t m_iTotalSize; + unsigned long m_iTotalFiles; + unsigned long m_iTotalDirs; + + TDEIO::filesize_t m_iProcessedSize; + unsigned long m_iProcessedDirs; + unsigned long m_iProcessedFiles; + +protected: + virtual void virtual_hook( int id, void* data ); +}; + + +#endif // __kr_progress_h__ + diff --git a/src/app/Dialogs/krspecialwidgets.cpp b/src/app/Dialogs/krspecialwidgets.cpp new file mode 100644 index 0000000..ecc5e28 --- /dev/null +++ b/src/app/Dialogs/krspecialwidgets.cpp @@ -0,0 +1,239 @@ +/*************************************************************************** + krspecialwidgets.cpp + ------------------- +copyright : (C) 2000 by Shie Erlich & Rafi Yanai +e-mail : krusader@users.sourceforge.net +web site : http://krusader.sourceforge.net +--------------------------------------------------------------------------- +Description +*************************************************************************** + +A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + +*************************************************************************** +* * +* 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. * +* * +***************************************************************************/ + + + +#include "krspecialwidgets.h" +#include "krmaskchoice.h" +#include "newftpgui.h" +#include "../krusader.h" +#include "../MountMan/kmountman.h" +#include +#include +#include +#include +#include + +///////////////////////////////////////////////////////////////////////////// +/////////////////////// Pie related widgets ///////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +// The pie-related widgets use hard-coded coordinates to create the look. +// This is ok since the whole widget is fitted into an existing view and thus +// no re-alignments are needed. + +#define LEFT 10 +#define BOTTOM 150 +#define WIDTH 120 +#define HEIGHT 40 +#define Z_HEIGHT 10 +#define STARTANGLE 0 +#define DEG(x) (16*(x)) + +TQColor KRPie::colors[ 12 ] = {TQt::red, TQt::blue, TQt::green, TQt::cyan, TQt::magenta, TQt::gray, + TQt::black, TQt::white, TQt::darkRed, TQt::darkBlue, TQt::darkMagenta, + TQt::darkCyan}; + +////////////////////////////////////////////////////////////////////////////// +/////////////// KRFSDisplay - Filesystem / Freespace Display ///////////////// +////////////////////////////////////////////////////////////////////////////// +// This is the full constructor: use it for a mounted filesystem +KRFSDisplay::KRFSDisplay( TQWidget *parent, TQString _alias, TQString _realName, + TDEIO::filesize_t _total, TDEIO::filesize_t _free ) : TQWidget( parent ), totalSpace( _total ), + freeSpace( _free ), alias( _alias ), realName( _realName ), mounted( true ), +empty( false ), supermount( false ) { + resize( 150, 200 ); + show(); +} + +// Use this one for an unmounted filesystem +KRFSDisplay::KRFSDisplay( TQWidget *parent, TQString _alias, TQString _realName, bool sm ) : + TQWidget( parent ), alias( _alias ), realName( _realName ), mounted( false ), +empty( false ), supermount( sm ) { + resize( 150, 200 ); + show(); +} + +// This is used only when an empty widget needs to be displayed (for example: +// when filesystem statistics haven't been calculated yet) +KRFSDisplay::KRFSDisplay( TQWidget *parent ) : TQWidget( parent ), empty( true ) { + resize( 150, 200 ); + show(); +} + + +// The main painter! +void KRFSDisplay::paintEvent( TQPaintEvent * ) { + TQPainter paint( this ); + if ( !empty ) { + // create the text + // first, name and location + paint.setFont( TQFont( "helvetica", 12, TQFont::Bold ) ); + paint.drawText( 10, 20, alias ); + paint.setFont( TQFont( "helvetica", 12, TQFont::Normal ) ); + paint.drawText( 10, 37, "(" + realName + ")" ); + if ( mounted ) { // incase the filesystem is already mounted + // second, the capacity + paint.drawText( 10, 70, i18n( "Capacity: " ) + TDEIO::convertSizeFromKB( totalSpace ) ); + // third, the 2 boxes (used, free) + TQPen systemPen = paint.pen(); + paint.setPen( TQt::black ); + paint.drawRect( 10, 90, 10, 10 ); + paint.fillRect( 11, 91, 8, 8, TQBrush( TQt::gray ) ); + paint.drawRect( 10, 110, 10, 10 ); + paint.fillRect( 11, 111, 8, 8, TQBrush( TQt::white ) ); + // now, the text for the boxes + paint.setPen( systemPen ); + paint.drawText( 25, 100, i18n( "Used: " ) + TDEIO::convertSizeFromKB( totalSpace - freeSpace ) ); + paint.drawText( 25, 120, i18n( "Free: " ) + TDEIO::convertSizeFromKB( freeSpace ) ); + // first, create the empty pie + // bottom... + paint.setPen( TQt::black ); + paint.setBrush( TQt::white ); + paint.drawPie( LEFT, BOTTOM, WIDTH, HEIGHT, STARTANGLE, DEG( 360 ) ); + // body... + paint.setPen( TQt::lightGray ); + for ( int i = 1; i < Z_HEIGHT; ++i ) + paint.drawPie( LEFT, BOTTOM - i, WIDTH, HEIGHT, STARTANGLE, DEG( 360 ) ); + // side lines... + paint.setPen( TQt::black ); + paint.drawLine( LEFT, BOTTOM + HEIGHT / 2, LEFT, BOTTOM + HEIGHT / 2 - Z_HEIGHT ); + paint.drawLine( LEFT + WIDTH, BOTTOM + HEIGHT / 2, LEFT + WIDTH, BOTTOM + HEIGHT / 2 - Z_HEIGHT ); + // top of the pie + paint.drawPie( LEFT, BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, DEG( 360 ) ); + // the "used space" slice + float i = ( ( float ) ( totalSpace - freeSpace ) / ( totalSpace ) ) * 360.0; + paint.setBrush( TQt::gray ); + paint.drawPie( LEFT, BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, ( int ) DEG( i ) ); + // if we need to draw a 3d stripe ... + if ( i > 180.0 ) { + for ( int j = 1; j < Z_HEIGHT; ++j ) + paint.drawArc( LEFT, BOTTOM - j, WIDTH, HEIGHT, STARTANGLE - 16 * 180, ( int ) ( DEG( i - 180.0 ) ) ); + } + } else { // if the filesystem is unmounted... + paint.setFont( TQFont( "helvetica", 12, TQFont::Bold ) ); + paint.drawText( 10, 60, i18n( "Not mounted." ) ); + } + } else { // if the widget is in empty situation... + + } +} + +//////////////////////////////////////////////////////////////////////////////// +KRPie::KRPie( TDEIO::filesize_t _totalSize, TQWidget *parent ) : TQWidget( parent, 0 ), totalSize( _totalSize ) { + slices.setAutoDelete( true ); // kill items when they are removed + slices.append( new KRPieSlice( 100, TQt::yellow, "DEFAULT" ) ); + sizeLeft = totalSize; + resize( 300, 300 ); +} + +void KRPie::paintEvent( TQPaintEvent * ) { + TQPainter paint( this ); + // now create the slices + KRPieSlice *slice; + float sAngle = STARTANGLE; + for ( slice = slices.first(); slice != 0; slice = slices.next() ) { + paint.setBrush( slice->getColor() ); + paint.setPen( slice->getColor() ); + // angles are negative to create a clock-wise drawing of slices + float angle = -( slice->getPerct() / 100 * 360 ) * 16; + for ( int i = 1; i < Z_HEIGHT; ++i ) + paint.drawPie( LEFT, BOTTOM + i, WIDTH, HEIGHT, ( int ) sAngle, ( int ) angle ); + sAngle += angle; + } + paint.setPen( TQt::yellow ); // pen + paint.setBrush( TQt::yellow ); // fill + // for (int i=1; igetColor() ); + paint.setPen( slice->getColor() ); + // angles are negative to create a clock-wise drawing of slices + float angle = -( slice->getPerct() / 100 * 360 ) * 16; + paint.drawPie( LEFT, BOTTOM, WIDTH, HEIGHT, ( int ) sAngle, ( int ) angle ); + sAngle += angle; + } + + + paint.setPen( TQt::black ); + // the pie + // paint.drawPie(LEFT,BOTTOM,WIDTH,HEIGHT,STARTANGLE,360*16); + ///////////////////////// end of empty pie ///////////////////////// + // now, the pie is ready to draw slices on... + // to make a good look on the perimiter, draw another black circle + paint.setPen( TQt::black ); + paint.drawArc( LEFT, BOTTOM, WIDTH, HEIGHT, STARTANGLE, 360 * 16 ); + +} + +void KRPie::addSlice( TDEIO::filesize_t size, TQString label ) { + int i = ( slices.count() % 12 ); + slices.removeLast(); + slices.append( new KRPieSlice( size * 100 / totalSize, colors[ i ], label ) ); + sizeLeft -= size; + slices.append( new KRPieSlice( sizeLeft * 100 / totalSize, TQt::yellow, "DEFAULT" ) ); +} + +//////////////////////////////////////////////////// +/////////////////// KrQuickSearch ///////////////// +//////////////////////////////////////////////////// +KrQuickSearch::KrQuickSearch( TQWidget *parent, const char * name ) : KLineEdit( parent, name ) {} + +void KrQuickSearch::myKeyPressEvent( TQKeyEvent *e ) { + switch ( e->key() ) { + case Key_Escape: + emit stop( 0 ); + break; + case Key_Return: + case Key_Enter: + case Key_Tab: + case Key_Right: + case Key_Left: + emit stop( e ); + break; + case Key_Down: + otherMatching( text(), 1 ); + break; + case Key_Up: + otherMatching( text(), -1 ); + break; + case Key_Insert: + case Key_Home: + case Key_End: + process( e ); + break; + default: + keyPressEvent( e ); + } +} + + + +#include "krspecialwidgets.moc" diff --git a/src/app/Dialogs/krspecialwidgets.h b/src/app/Dialogs/krspecialwidgets.h new file mode 100644 index 0000000..bcb8d0f --- /dev/null +++ b/src/app/Dialogs/krspecialwidgets.h @@ -0,0 +1,129 @@ +/*************************************************************************** + krspecialwidgets.h + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net +--------------------------------------------------------------------------- +Description +*************************************************************************** + +A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + +*************************************************************************** +* * +* 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 KRSPECIALWIDGETS_H +#define KRSPECIALWIDGETS_H + +#include +#include +#include +#include +#include +#include +#include + +class KRPieSlice; + +class KRPie : public TQWidget { + TQ_OBJECT + + public: + KRPie( TDEIO::filesize_t _totalSize, TQWidget *parent = 0 ); + void addSlice( TDEIO::filesize_t size, TQString label ); + + protected: + void paintEvent( TQPaintEvent * ); + + private: + TQPtrList slices; + TDEIO::filesize_t totalSize, sizeLeft; + static TQColor colors[ 12 ]; +}; + +class KRFSDisplay : public TQWidget { + TQ_OBJECT + + public: + // this constructor is used for a mounted filesystem + KRFSDisplay( TQWidget *parent, TQString _alias, TQString _realName, + TDEIO::filesize_t _total, TDEIO::filesize_t _free ); + // this one is for an unmounted/supermount file system + KRFSDisplay( TQWidget *parent, TQString _alias, TQString _realName, bool sm = false ); + // the last one is used inside MountMan(R), when no filesystem is selected + KRFSDisplay( TQWidget *parent ); + inline void setTotalSpace( TDEIO::filesize_t t ) { totalSpace = t; } + inline void setFreeSpace( TDEIO::filesize_t t ) { freeSpace = t; } + inline void setAlias( TQString a ) { alias = a; } + inline void setRealName( TQString r ) { realName = r; } + inline void setMounted( bool m ) { mounted = m; } + inline void setEmpty( bool e ) { empty = e; } + inline void setSupermount( bool s ) { supermount = s; } + + protected: + void paintEvent( TQPaintEvent * ); + + private: + TDEIO::filesize_t totalSpace, freeSpace; + TQString alias, realName; + bool mounted, empty, supermount; +}; + +class KRPieSlice { + public: + KRPieSlice( float _perct, TQColor _color, TQString _label ) : + perct( _perct ), color( _color ), label( _label ) {} + inline TQColor getColor() { return color; } + inline float getPerct() { return perct; } + inline TQString getLabel() { return label; } + inline void setPerct( float _perct ) { perct = _perct; } + inline void setLabel( TQString _label ) { label = _label; } + + private: + float perct; + TQColor color; + TQString label; +}; + +class KrQuickSearch: public KLineEdit { + TQ_OBJECT + + public: + KrQuickSearch(TQWidget *parent, const char * name = 0); + void addText(const TQString &str) { setText(text()+str); } + void myKeyPressEvent(TQKeyEvent *e); + void myIMStartEvent(TQIMEvent* e) { + imStartEvent(e); + } + void myIMEndEvent(TQIMEvent* e) { + imEndEvent(e); + } + void myIMComposeEvent(TQIMEvent* e) { + imComposeEvent(e); + } + + signals: + void stop(TQKeyEvent *e); + void process(TQKeyEvent *e); + void otherMatching(const TQString &, int); + +}; + +#endif diff --git a/src/app/Dialogs/krspwidgets.cpp b/src/app/Dialogs/krspwidgets.cpp new file mode 100644 index 0000000..b0fcf5d --- /dev/null +++ b/src/app/Dialogs/krspwidgets.cpp @@ -0,0 +1,316 @@ +/*************************************************************************** + krspwidgets.cpp + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "krspwidgets.h" +#include "../krusader.h" +#include "../krusaderview.h" +#include "../Panel/listpanel.h" +#include "../kicons.h" +#include "../Filter/filtertabs.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../resources.h" + +///////////////////// initiation of the static members //////////////////////// +TQStrList KRSpWidgets::maskList; + +/////////////////////////////////////////////////////////////////////////////// + +KRSpWidgets::KRSpWidgets(){ +} + +KRQuery KRSpWidgets::getMask(TQString caption, bool nameOnly ) { + if( !nameOnly ) { + return FilterTabs::getQuery(); + } + else { + KRMaskChoiceSub *p=new KRMaskChoiceSub(); + p->setCaption(caption); + p->exec(); + if (p->selection->currentText()=="") return KRQuery(); + else return KRQuery( p->selection->currentText() ); + } +} + +/////////////////////////// newFTP //////////////////////////////////////// +KURL KRSpWidgets::newFTP() { + newFTPSub *p=new newFTPSub(); + p->exec(); + if (p->url->currentText()=="") return KURL(); // empty url + KURL url; + + TQString protocol = p->prefix->currentText(); + protocol.truncate(protocol.length() - 3); // remove the trailing :// + TQString username = p->username->text().simplifyWhiteSpace(); + TQString password = p->password->text().simplifyWhiteSpace(); + TQString uri = p->url->currentText(); + + int uriStart = uri.findRev( '@' ); /* lets the user enter user and password in the URI field */ + if( uriStart != -1 ) { + TQString uriUser = uri.left( uriStart ); + TQString uriPsw = TQString(); + uri = uri.mid( uriStart + 1 ); + + int pswStart = uriUser.find( ':' ); /* getting the password name from the URL */ + if( pswStart != -1 ) { + uriPsw = uriUser.mid( pswStart + 1 ); + uriUser = uriUser.left( pswStart ); + } + + if( !uriUser.isEmpty() ) /* handling the ftp proxy username and password also */ + username = username.isEmpty() ? uriUser : username + "@" + uriUser; + + if( !uriPsw.isEmpty() ) /* handling the ftp proxy username and password also */ + password = password.isEmpty() ? uriPsw : password + "@" + uriPsw; + } + + TQString host = uri; /* separating the hostname and path from the uri */ + TQString path = TQString(); + int pathStart = uri.find( "/" ); + if( pathStart != -1 ) { + path = host.mid( pathStart ); + host = host.left( pathStart ); + } + + /* setting the parameters of the URL */ + url.setProtocol(protocol); + url.setHost( host ); + url.setPath( path ); + if ( protocol == "ftp" || protocol == "fish" || protocol == "sftp" ) + url.setPort(p->port->cleanText().toInt()); + if (!username.isEmpty()) + url.setUser( username ); + if (!password.isEmpty()) + url.setPass( password ); + + return url; +} + +newFTPSub::newFTPSub() : newFTPGUI(0,0,true) { + url->setFocus(); + setGeometry(krApp->x()+krApp->width()/2-width()/2,krApp->y()+krApp->height()/2-height()/2,width(),height()); +} + +void newFTPSub::accept() { + url->addToHistory( url->currentText() ); + // save the history and completion list when the history combo is + // destroyed + krConfig->setGroup("Private"); + TQStringList list = url->completionObject()->items(); + krConfig->writeEntry( "newFTP Completion list", list ); + list = url->historyItems(); + krConfig->writeEntry( "newFTP History list", list ); + + newFTPGUI::accept(); +} + +void newFTPSub::reject() { + url->setCurrentText(""); + newFTPGUI::reject(); +} + +/////////////////////////// KRMaskChoiceSub /////////////////////////////// +KRMaskChoiceSub::KRMaskChoiceSub() : KRMaskChoice(0,0,true) { + PixmapLabel1->setPixmap(krLoader->loadIcon("kr_select", TDEIcon::Desktop, 32)); + label->setText(i18n("Enter a selection:")); + // the predefined selections list + krConfig->setGroup("Private"); + TQStrList lst; + int i=krConfig->readListEntry("Predefined Selections",lst); + if (i>0) preSelections->insertStrList(lst); + // the combo-box tweaks + selection->setDuplicatesEnabled(false); + selection->insertStrList(KRSpWidgets::maskList); + selection->lineEdit()->setText("*"); + selection->lineEdit()->selectAll(); + selection->setFocus(); +} + +void KRMaskChoiceSub::reject() { + selection->clear(); + KRMaskChoice::reject(); +} + +void KRMaskChoiceSub::accept() { + bool add = true; + char *tmp; + // make sure we don't have that already + for ( tmp = KRSpWidgets::maskList.first(); tmp ; tmp = KRSpWidgets::maskList.next() ) + if (TQString(tmp).simplifyWhiteSpace() == selection->currentText().simplifyWhiteSpace()) { + // break if we found one such as this + add = false; + break; + } + + if (add) + KRSpWidgets::maskList.insert(0,selection->currentText().local8Bit()); + // write down the predefined selections list + TQStrList list; + TQListBoxItem *i=preSelections->firstItem(); + while (i!=0) { + if (i->text().find(i18n("compare mode"))==-1) + list.append(i->text().local8Bit()); + i=i->next(); + } + krConfig->setGroup("Private"); + krConfig->writeEntry("Predefined Selections",list); + KRMaskChoice::accept(); +} + +void KRMaskChoiceSub::addSelection() { + TQString temp=selection->currentText(); + bool itemExists=false; + TQListBoxItem *i=preSelections->firstItem(); + // check if the selection already exists + while (i!=0) + if (i->text()==temp) { + itemExists=true; + break; + } else i=i->next(); + if (temp!="" && !itemExists) { + preSelections->insertItem(selection->currentText()); + preSelections->update(); + } +} + +void KRMaskChoiceSub::deleteSelection() { + if (preSelections->currentItem()!=-1 && + preSelections->currentText().find(i18n("compare mode"))==-1) { + preSelections->removeItem(preSelections->currentItem()); + preSelections->update(); + } +} + +void KRMaskChoiceSub::clearSelections() { + preSelections->clear(); + preSelections->update(); +} + +void KRMaskChoiceSub::acceptFromList(TQListBoxItem *i) { + selection->insertItem(i->text(),0); + accept(); +} + +////////////////////////// QuickNavLineEdit //////////////////// + +QuickNavLineEdit::QuickNavLineEdit(const TQString &string, TQWidget *parent, const char *name): + KLineEdit(string, parent, name) { init(); } + +QuickNavLineEdit::QuickNavLineEdit(TQWidget *parent, const char *name): + KLineEdit(parent, name) { init(); } + +int QuickNavLineEdit::findCharFromPos(const TQString & str, const TQFontMetrics & metrics, int pos) +{ + if (pos < 0) + return -1; + for (int i = 1; i <= (int)str.length(); ++i) + if (metrics.width(str, i) > pos) + return i; + return str.length(); +} + +void QuickNavLineEdit::init() { + _numOfSelectedChars=0; + _dummyDisplayed=false; + _pop=0; + //setCompletionMode( TDEGlobalSettings::CompletionPopupAuto ); ==> removed by public demand +} + +void QuickNavLineEdit::leaveEvent(TQEvent *) { + clearAll(); +} + +void QuickNavLineEdit::mousePressEvent( TQMouseEvent *m ) { + if (m->state()!=ControlButton) clearAll(); + else + { + if (!_numOfSelectedChars) + { + _numOfSelectedChars = charCount(m); + if (_numOfSelectedChars < 0) + _numOfSelectedChars = 0; + } + if (_numOfSelectedChars) + emit returnPressed(text().left(_numOfSelectedChars)); + } + KLineEdit::mousePressEvent(m); +} + +int QuickNavLineEdit::charCount(const TQMouseEvent * const m,TQString * const str) { + // find how much of the string we've selected (approx) + // and select from from the start to the closet slash (on the right) + const TQString tx = text().simplifyWhiteSpace(); + if (tx.isEmpty()) { + clearAll(); + return -1; + } + + int numOfChars = findCharFromPos(tx, fontMetrics(), m->x() - 5); + if(str) *str=tx; + return tx.find('/', numOfChars); +} + +void QuickNavLineEdit::mouseMoveEvent( TQMouseEvent *m) { + if (m->state()!=ControlButton) { // works only with ctrl pressed + clearAll(); + KLineEdit::mouseMoveEvent(m); + return; + } + TQString tx; + int idx=charCount(m,&tx); + if (idx == -1 && !_dummyDisplayed) { // pointing on or after the current directory + if (_pop) delete _pop; + _pop = KPassivePopup::message( i18n("Quick Navigation"), + "" + i18n("Already at %1").arg(tx.left(idx)) + "", + *(KCursor::handCursor().bitmap()), this); + + _dummyDisplayed=true; + _numOfSelectedChars=0; + } else if (idx>0 && idx!=_numOfSelectedChars) { + _numOfSelectedChars=idx; + if (_pop) delete _pop; + _dummyDisplayed=false; + + _pop = KPassivePopup::message( i18n("Quick Navigation"), + "" + i18n("Click to go to %1").arg(tx.left(idx)) + "", + *(KCursor::handCursor().bitmap()), this ); + } + KLineEdit::mouseMoveEvent(m); +} + diff --git a/src/app/Dialogs/krspwidgets.h b/src/app/Dialogs/krspwidgets.h new file mode 100644 index 0000000..13098dc --- /dev/null +++ b/src/app/Dialogs/krspwidgets.h @@ -0,0 +1,110 @@ +/*************************************************************************** + krspwidgets.h + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 KRSPWIDGETS_H +#define KRSPWIDGETS_H + +#include +#include +#include "krmaskchoice.h" +#include "newftpgui.h" +#include "../VFS/krquery.h" +#include +#include + +class newFTPGUI; + +class KRMaskChoiceSub; + +class KRSpWidgets { + friend class KRMaskChoiceSub; + +public: + KRSpWidgets(); + + static KRQuery getMask( TQString caption, bool nameOnly=false ); // get file-mask for (un)selecting files + static KURL newFTP(); + +private: + static TQStrList maskList; // used by KRMaskChoiceSub +}; + +/////////////////////////// newFTPSub /////////////////////////////////////// +class newFTPSub : public newFTPGUI { +public: + newFTPSub(); + +protected: + void reject(); + void accept(); +}; + +/////////////////////////// KRMaskChoiceSub ///////////////////////////////// +// Inherits KRMaskChoice's generated code to fully implement the functions // +///////////////////////////////////////////////////////////////////////////// +class KRMaskChoiceSub : public KRMaskChoice { +public: + KRMaskChoiceSub(); + +public slots: + void addSelection(); + void deleteSelection(); + void clearSelections(); + void acceptFromList(TQListBoxItem *i); + +protected: + void reject(); + void accept(); +}; + +/////////////////////////// QuickNavLineEdit ////////////////////////// +// same as line edit, but hold ctrl while pointing to it... and see! // +/////////////////////////////////////////////////////////////////////// + +class QuickNavLineEdit: public KLineEdit { +public: + QuickNavLineEdit(const TQString &string, TQWidget *parent, const char *name=0); + QuickNavLineEdit(TQWidget *parent=0, const char *name=0); + virtual ~QuickNavLineEdit() {} + static int findCharFromPos(const TQString &, const TQFontMetrics &, int pos); +protected: + void mouseMoveEvent( TQMouseEvent *m); + void leaveEvent( TQEvent * ); + void mousePressEvent( TQMouseEvent *m ); + inline void clearAll() { _numOfSelectedChars = 0; if (_pop) delete _pop; _dummyDisplayed=false; } + void init(); + +private: + int charCount(const TQMouseEvent * const , TQString* const =0) ; + int _numOfSelectedChars; + bool _dummyDisplayed; + TQGuardedPtr _pop; +}; + +#endif diff --git a/src/app/Dialogs/krsqueezedtextlabel.cpp b/src/app/Dialogs/krsqueezedtextlabel.cpp new file mode 100644 index 0000000..7a5ef8d --- /dev/null +++ b/src/app/Dialogs/krsqueezedtextlabel.cpp @@ -0,0 +1,80 @@ +#include "krsqueezedtextlabel.h" +#include +#include +#include + +KrSqueezedTextLabel::KrSqueezedTextLabel(TQWidget *parent, const char *name): + KSqueezedTextLabel(parent, name), acceptDrops( false ), _index(-1), _length(-1) { +} + + +KrSqueezedTextLabel::~KrSqueezedTextLabel() { +} + +void KrSqueezedTextLabel::mousePressEvent(TQMouseEvent *) { + emit clicked(); + +} + +void KrSqueezedTextLabel::enableDrops( bool flag ) +{ + setAcceptDrops( acceptDrops = flag ); +} + +void KrSqueezedTextLabel::dropEvent(TQDropEvent *e) { + emit dropped(e); +} + +void KrSqueezedTextLabel::dragEnterEvent(TQDragEnterEvent *e) { + if( acceptDrops ) + e->accept( KURLDrag::canDecode( e ) ); + else + KSqueezedTextLabel::dragEnterEvent( e ); +} + +void KrSqueezedTextLabel::squeezeTextToLabel(int index, int length) { + if (index==-1 || length==-1) + KSqueezedTextLabel::squeezeTextToLabel(); + else { + TQString sqtext=fullText; + TQFontMetrics fm(fontMetrics()); + int labelWidth = size().width(); + int textWidth = fm.width(sqtext); + if (textWidth > labelWidth) { + int avgCharSize = textWidth / sqtext.length(); + int numOfExtraChars = (textWidth-labelWidth)/avgCharSize; + int delta; + + // remove as much as possible from the left, and then from the right + if (index>3) { + delta=TQMIN(index, numOfExtraChars); + numOfExtraChars -= delta; + sqtext.replace(0, delta, "..."); + } + + if (numOfExtraChars>0 && ((int)sqtext.length() > length+3)) { + delta = TQMIN(numOfExtraChars, (int)sqtext.length() - (length+3)); + sqtext.replace(sqtext.length()-delta, delta, "..."); + } + TQLabel::setText(sqtext); + + TQToolTip::remove( this ); + TQToolTip::add( this, fullText ); + } else { + TQLabel::setText(fullText); + + TQToolTip::remove( this ); + TQToolTip::hide(); + } + } +} + +void KrSqueezedTextLabel::setText( const TQString &text, int index, int length ) { + _index=index; + _length=length; + fullText = text; + squeezeTextToLabel(_index,_length); +} + +#include "krsqueezedtextlabel.moc" + diff --git a/src/app/Dialogs/krsqueezedtextlabel.h b/src/app/Dialogs/krsqueezedtextlabel.h new file mode 100644 index 0000000..320953f --- /dev/null +++ b/src/app/Dialogs/krsqueezedtextlabel.h @@ -0,0 +1,45 @@ +#ifndef KRSQUEEZEDTEXTLABEL_H +#define KRSQUEEZEDTEXTLABEL_H + +#include + +class TQMouseEvent; +class TQDropEvent; +class TQDragEnterEvent; + +/** +This class overloads KSqueezedTextLabel and simply adds a clicked signal, +so that users will be able to click the label and switch focus between panels. + +NEW: a special setText() method allows to choose which part of the string should + be displayed (example: make sure that search results won't be cut out) +*/ +class KrSqueezedTextLabel : public KSqueezedTextLabel { +TQ_OBJECT + + public: + KrSqueezedTextLabel(TQWidget *parent = 0, const char *name = 0); + ~KrSqueezedTextLabel(); + + void enableDrops( bool flag ); + + public slots: + void setText( const TQString &text, int index=-1, int length=-1 ); + + signals: + void clicked(); /**< emitted when someone clicks on the label */ + void dropped(TQDropEvent *); /**< emitted when someone drops URL onto the label */ + + protected: + void resizeEvent( TQResizeEvent * ) { squeezeTextToLabel(_index, _length); } + virtual void mousePressEvent(TQMouseEvent *e); + virtual void dropEvent(TQDropEvent *e); + virtual void dragEnterEvent(TQDragEnterEvent *e); + void squeezeTextToLabel(int index=-1, int length=-1); + + private: + bool acceptDrops; + int _index, _length; +}; + +#endif diff --git a/src/app/Dialogs/kurllistrequester.cpp b/src/app/Dialogs/kurllistrequester.cpp new file mode 100644 index 0000000..449da8f --- /dev/null +++ b/src/app/Dialogs/kurllistrequester.cpp @@ -0,0 +1,202 @@ +/*************************************************************************** + kurllistrequester.cpp - description + ------------------- + copyright : (C) 2005 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "kurllistrequester.h" +#include "../VFS/vfs.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define DELETE_ITEM_ID 100 + +KURLListRequester::KURLListRequester( TQWidget *parent, const char * name ) : TQWidget( parent, name ) +{ + TDEIconLoader *iconLoader = new TDEIconLoader(); + TQPixmap imageAdd = iconLoader->loadIcon( "1downarrow", TDEIcon::Panel, 16 ); + TQPixmap imageFolder = iconLoader->loadIcon( "folder", TDEIcon::Panel, 16 ); + + // Creating the widget + + TQGridLayout *urlListRequesterGrid = new TQGridLayout( this ); + urlListRequesterGrid->setSpacing( 0 ); + urlListRequesterGrid->setMargin( 0 ); + + urlLineEdit = new KLineEdit( this, "urlLineEdit" ); + urlListRequesterGrid->addWidget( urlLineEdit, 0, 0 ); + + urlListBox = new TQListBox( this, "urlListBox" ); + urlListBox->setSelectionMode( TQListBox::Extended ); + urlListRequesterGrid->addMultiCellWidget( urlListBox, 1, 1, 0, 2 ); + + urlAddBtn = new TQToolButton( this, "urlAddBtn" ); + urlAddBtn->setText( "" ); + urlAddBtn->setPixmap( imageAdd ); + urlListRequesterGrid->addWidget( urlAddBtn, 0, 1 ); + + urlBrowseBtn = new TQToolButton( this, "urlBrowseBtn" ); + urlBrowseBtn->setText( "" ); + urlBrowseBtn->setPixmap( imageFolder ); + urlListRequesterGrid->addWidget( urlBrowseBtn, 0, 2 ); + + // add shell completion + + completion.setMode( KURLCompletion::FileCompletion ); + urlLineEdit->setCompletionObject( &completion ); + + // connection table + + connect( urlAddBtn, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotAdd() ) ); + connect( urlBrowseBtn, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotBrowse() ) ); + connect( urlLineEdit, TQ_SIGNAL( returnPressed(const TQString&) ), this, TQ_SLOT( slotAdd() ) ); + connect( urlListBox, TQ_SIGNAL( rightButtonClicked ( TQListBoxItem *, const TQPoint & ) ), this, + TQ_SLOT( slotRightClicked( TQListBoxItem * ) ) ); +} + +void KURLListRequester::slotAdd() +{ + TQString text = urlLineEdit->text().simplifyWhiteSpace(); + if( text.length() ) + { + TQString error = TQString(); + emit checkValidity( text, error ); + + if( !error.isNull() ) + KMessageBox::error( this, error ); + else + { + urlListBox->insertItem( text ); + urlLineEdit->clear(); + } + } +} + +void KURLListRequester::slotBrowse() +{ + KURL url = KFileDialog::getExistingURL( TQString(), this ); + if( !url.isEmpty()) + urlLineEdit->setText( vfs::pathOrURL( url ) ); + urlLineEdit->setFocus(); +} + +void KURLListRequester::keyPressEvent(TQKeyEvent *e) +{ + if( e->key() == Key_Delete ) + { + if( urlListBox->hasFocus() ) + { + deleteSelectedItems(); + return; + } + } + + TQWidget::keyPressEvent( e ); +} + +void KURLListRequester::deleteSelectedItems() +{ + int i=0; + TQListBoxItem *item; + + while( (item = urlListBox->item(i)) ) + { + if( item->isSelected() ) + { + urlListBox->removeItem( i ); + continue; + } + i++; + } +} + +void KURLListRequester::slotRightClicked( TQListBoxItem *item ) +{ + if( item == 0 ) + return; + + TDEPopupMenu popupMenu( this ); + popupMenu.insertItem( i18n( "Delete" ), DELETE_ITEM_ID ); + + switch( popupMenu.exec( TQCursor::pos() ) ) + { + case DELETE_ITEM_ID: + if( item->isSelected() ) + deleteSelectedItems(); + else + urlListBox->removeItem( urlListBox->index( item ) ); + break; + } +} + +KURL::List KURLListRequester::urlList() +{ + KURL::List urls; + + TQString text = urlLineEdit->text().simplifyWhiteSpace(); + if (!text.isEmpty()) + { + TQString error = TQString(); + emit checkValidity( text, error ); + if( error.isNull() ) + urls.append( vfs::fromPathOrURL( text ) ); + } + + TQListBoxItem *item = urlListBox->firstItem(); + while ( item ) + { + TQString text = item->text().simplifyWhiteSpace(); + + TQString error = TQString(); + emit checkValidity( text, error ); + if( error.isNull() ) + urls.append( vfs::fromPathOrURL( text ) ); + + item = item->next(); + } + + return urls; +} + +void KURLListRequester::setUrlList( KURL::List urlList ) +{ + urlLineEdit->clear(); + urlListBox->clear(); + + KURL::List::iterator it; + + for ( it = urlList.begin(); it != urlList.end(); ++it ) + urlListBox->insertItem( vfs::pathOrURL(*it) ); +} + +#include "kurllistrequester.moc" diff --git a/src/app/Dialogs/kurllistrequester.h b/src/app/Dialogs/kurllistrequester.h new file mode 100644 index 0000000..8c49611 --- /dev/null +++ b/src/app/Dialogs/kurllistrequester.h @@ -0,0 +1,77 @@ +/*************************************************************************** + kurllistrequester.h - description + ------------------- + copyright : (C) 2005 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 __KURLLISTREQUESTER_H__ +#define __KURLLISTREQUESTER_H__ + +#include +#include +#include +#include +#include +#include + +class KURLListRequester : public TQWidget +{ + TQ_OBJECT + + +public: + KURLListRequester( TQWidget *parent = 0, const char * name = 0 ); + + KURL::List urlList(); + void setUrlList( KURL::List ); + + KLineEdit *lineEdit() {return urlLineEdit;} + TQListBox *listBox() {return urlListBox;} + + void setCompletionDir( TQString dir ) { completion.setDir( dir ); } + +signals: + void checkValidity( TQString &text, TQString &error ); + +protected slots: + void slotAdd(); + void slotBrowse(); + void slotRightClicked( TQListBoxItem * ); + +protected: + virtual void keyPressEvent(TQKeyEvent *e); + void deleteSelectedItems(); + + KLineEdit *urlLineEdit; + TQListBox *urlListBox; + TQToolButton *urlAddBtn; + TQToolButton *urlBrowseBtn; + + KURLCompletion completion; +}; + +#endif /* __KURLLISTREQUESTER_H__ */ diff --git a/src/app/Dialogs/newftpgui.cpp b/src/app/Dialogs/newftpgui.cpp new file mode 100644 index 0000000..56eef7c --- /dev/null +++ b/src/app/Dialogs/newftpgui.cpp @@ -0,0 +1,182 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'newftpgui.ui' +** +** Created: Fri Oct 27 23:47:10 2000 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "newftpgui.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../krusader.h" + + +/* + * Constructs a newFTPGUI which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * true to construct a modal dialog. + */ + + #define SIZE_MINIMUM TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0 ) + +newFTPGUI::newFTPGUI( TQWidget* parent, const char* name, bool modal, WFlags fl ) + : TQDialog( parent, name, modal, fl ){ + + TQVBoxLayout * layout = new TQVBoxLayout( this, 11, 6, "newFTPGUI_layout" ); + layout->setAutoAdd(true); + + if ( !name ) + setName( "newFTPGUI" ); + resize( 342, 261 ); + setCaption( i18n( "New Network Connection" ) ); +// setSizeGripEnabled( true ); + setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)5, (TQSizePolicy::SizeType)5, sizePolicy().hasHeightForWidth() ) ); + setMinimumSize( TQSize( 342, 261 ) ); + + + TQHBox* hbox_image = new TQHBox( this, "hbox_image" ); + hbox_image->setSpacing( 6 ); + + PixmapLabel1 = new TQLabel( hbox_image, "PixmapLabel1" ); + PixmapLabel1->setPixmap( krLoader->loadIcon("network", TDEIcon::Desktop, 32) ); + PixmapLabel1->setSizePolicy( SIZE_MINIMUM ); + + TextLabel3 = new TQLabel( i18n( "About to connect to..." ), hbox_image, "TextLabel3" ); + TQFont TextLabel3_font( TextLabel3->font() ); + TextLabel3_font.setBold( true ); + TextLabel3->setFont( TextLabel3_font ); + + + TQGrid* grid_host = new TQGrid( 3, this, "grid_host" ); + + TextLabel1 = new TQLabel( i18n( "Protocol:" ), grid_host, "TextLabel1" ); + TextLabel1_22 = new TQLabel( i18n( "Host:"), grid_host, "TextLabel_2" ); + TextLabel1_3 = new TQLabel( i18n( "Port:" ), grid_host, "TextLabel1_3" ); + + TQStringList protocols = KProtocolInfo::protocols(); + + prefix = new KComboBox( false, grid_host, "protocol" ); + if( protocols.contains("ftp") ) + prefix->insertItem( i18n( "ftp://" ) ); + if( protocols.contains("smb") ) + prefix->insertItem( i18n( "smb://" ) ); + if( protocols.contains("fish") ) + prefix->insertItem( i18n( "fish://" )); + if( protocols.contains("sftp") ) + prefix->insertItem( i18n( "sftp://" )); + prefix->setAcceptDrops( false ); + prefix->setEnabled( true ); + prefix->setSizePolicy( SIZE_MINIMUM ); + connect( prefix,TQ_SIGNAL(activated(const TQString& )), + this,TQ_SLOT(slotTextChanged(const TQString& ))); + + url = new KHistoryCombo( grid_host, "url" ); + url->setMaximumHeight( 20 ); + url->setMaxCount( 25 ); + url->setDuplicatesEnabled( false ); + connect( url, TQ_SIGNAL( activated( const TQString& )), + url, TQ_SLOT( addToHistory( const TQString& ))); + // load the history and completion list after creating the history combo + krConfig->setGroup("Private"); + TQStringList list = krConfig->readListEntry( "newFTP Completion list" ); + url->completionObject()->setItems( list ); + list = krConfig->readListEntry( "newFTP History list" ); + url->setHistoryItems( list ); + + port = new TQSpinBox( grid_host, "port" ); + port->setMaxValue( 65535 ); + port->setValue( 21 ); + port->setSizePolicy( SIZE_MINIMUM ); + + + TextLabel1_2 = new TQLabel( i18n( "Username:" ), this, "TextLabel1_2" ); + username = new TQLineEdit( this, "username" ); + TextLabel1_2_2 = new TQLabel( i18n( "Password:" ), this, "TextLabel1_2_2" ); + password = new TQLineEdit( this, "password" ); + password->setEchoMode( TQLineEdit::Password ); + + + TQWidget* Layout6 = new TQWidget( this, "Layout6" ); + hbox = new TQHBoxLayout( Layout6 ); + hbox->setSpacing( 6 ); + hbox->setMargin( 0 ); + + hbox->addItem(new TQSpacerItem(1,1,TQSizePolicy::Expanding)); + + connectBtn = new TQPushButton( i18n( "&Connect" ), Layout6, "connectBtn" ); + connectBtn->setAutoDefault( true ); + connectBtn->setDefault( true ); + hbox->addWidget( connectBtn ); + + //saveBtn = new TQPushButton( i18n( "&Save" ), Layout6, "saveBtn" ); + //saveBtn->setAutoDefault( true ); + //hbox->addWidget( saveBtn ); + + cancelBtn = new TQPushButton( i18n( "&Cancel" ), Layout6, "cancelBtn" ); + cancelBtn->setAutoDefault( true ); + hbox->addWidget( cancelBtn ); + + // signals and slots connections + connect( connectBtn, TQ_SIGNAL( clicked() ), this, TQ_SLOT( accept() ) ); + connect( cancelBtn, TQ_SIGNAL( clicked() ), this, TQ_SLOT( reject() ) ); + + // tab order + setTabOrder( url, username ); + setTabOrder( username, password ); + setTabOrder( password, connectBtn ); + setTabOrder( connectBtn, cancelBtn ); + setTabOrder( cancelBtn, prefix ); + setTabOrder( prefix, url ); +} + +/* + * Destroys the object and frees any allocated resources + */ +newFTPGUI::~newFTPGUI(){ + // no need to delete child widgets, TQt does it all for us +} + +void newFTPGUI::slotTextChanged(const TQString& string){ + if( string.startsWith("ftp") || string.startsWith("sftp") || string.startsWith("fish") ) + { + if( port->value() == 21 || port->value() == 22 ) + port->setValue( string.startsWith("ftp") ? 21 : 22 ); + port->setEnabled(true); + } + else + port->setEnabled(false); +} + +/* + * Main event handler. Reimplemented to handle application + * font changes + */ +bool newFTPGUI::event( TQEvent* ev ) { + bool ret = TQDialog::event( ev ); + if ( ev->type() == TQEvent::ApplicationFontChange ) { + TQFont TextLabel3_font( TextLabel3->font() ); + TextLabel3_font.setBold( true ); + TextLabel3->setFont( TextLabel3_font ); + } + return ret; +} + +#include "newftpgui.moc" diff --git a/src/app/Dialogs/newftpgui.h b/src/app/Dialogs/newftpgui.h new file mode 100644 index 0000000..d3808e5 --- /dev/null +++ b/src/app/Dialogs/newftpgui.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'newftpgui.ui' +** +** Created: Fri Oct 27 23:47:08 2000 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef NEWFTPGUI_H +#define NEWFTPGUI_H + +#include +#include +class TQVBoxLayout; +class TQHBoxLayout; +class TQGridLayout; +class TQLabel; +class TQLineEdit; +class TQPushButton; +class TQSpinBox; +class KComboBox; +class KHistoryCombo; + +class newFTPGUI : public TQDialog { + TQ_OBJECT + +public: + newFTPGUI( TQWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); + ~newFTPGUI(); + + TQLabel* TextLabel1; + KComboBox* prefix; + TQLabel* TextLabel1_2_2; + TQLabel* TextLabel1_22; + TQLabel* TextLabel1_2; + TQLabel* TextLabel1_3; + TQSpinBox* port; + TQLineEdit* password; + TQPushButton* connectBtn; + TQPushButton* saveBtn; + TQPushButton* cancelBtn; + TQLabel* PixmapLabel1; + TQLabel* TextLabel3; + TQLineEdit* username; + KHistoryCombo* url; + +public slots: + void slotTextChanged(const TQString& string); + +protected: + TQHBoxLayout* hbox; + bool event( TQEvent* ); +}; + +#endif // NEWFTPGUI_H diff --git a/src/app/Dialogs/packgui.cpp b/src/app/Dialogs/packgui.cpp new file mode 100644 index 0000000..e479060 --- /dev/null +++ b/src/app/Dialogs/packgui.cpp @@ -0,0 +1,122 @@ +/*************************************************************************** + packgui.cpp + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "packgui.h" +#include +#include "../krusader.h" +#include "../defaults.h" +#include +#include +#include +#include +#include + +#define PS(x) lst.contains(x)>0 + +// clear the statics first +TQString PackGUI::filename=0; +TQString PackGUI::destination=0; +TQString PackGUI::type=0; +TQMap PackGUI::extraProps; + +PackGUI::PackGUI(TQString defaultName, TQString defaultPath, int noOfFiles, TQString filename) : + PackGUIBase(0,0,true) { + // first, fill the WhatToPack textfield with information + if(noOfFiles == 1) + TextLabel1->setText( i18n("Pack %1").arg(filename) ); + else + TextLabel1->setText( i18n("Pack %n file", "Pack %n files", noOfFiles) ); + + // now, according to the Konfigurator, fill the combobox with the information + // about what kind of packing we can do + krConfig->setGroup("Archives"); + TQStringList lst=krConfig->readListEntry("Supported Packers"); + // now, clear the type combo and begin... + typeData->clear(); + if (PS("tar")) typeData->insertItem("tar"); + if (PS("tar") && PS("gzip")) typeData->insertItem("tar.gz"); + if (PS("tar") && PS("bzip2")) typeData->insertItem("tar.bz2"); + if (PS("tar") && PS("xz")) typeData->insertItem("tar.xz"); + if (PS("zip")) typeData->insertItem("zip"); + if (PS("rar")) typeData->insertItem("rar"); + if (PS("lha")) typeData->insertItem("lha"); + if (PS("arj")) typeData->insertItem("arj"); + if (PS("7z")) typeData->insertItem("7z"); + if (PS("xz")) typeData->insertItem("xz"); + // set the last used packer as the top one + TQString tmp=krConfig->readEntry("lastUsedPacker",TQString()); + if (tmp!=TQString()) { + for (unsigned int i=0; i< typeData->listBox()->count(); ++i) + if (typeData->listBox()->item(i)->text() == tmp) { + typeData->listBox()->removeItem(i); + typeData->listBox()->insertItem(tmp,0); + break; + } + } + checkConsistency(); + + // and go on with the normal stuff + dirData->setText(defaultPath); + nameData->setText(defaultName); + nameData->setFocus(); + if (typeData->listBox()->count()==0) // if no packers are availble + okButton->setEnabled(false); + setGeometry(krApp->x()+krApp->width()/2-width()/2,krApp->y()+krApp->height()/2-height()/2,width(),height()); + exec(); +} + +void PackGUI::browse() { + TQString temp=KFileDialog::getExistingDirectory(dirData->text(),0,i18n("Please select a directory")); + if (temp != TQString()) + dirData->setText(temp); +} + +void PackGUI::accept() { + if( !extraProperties( extraProps ) ) + return; + + filename=nameData->text(); + destination=dirData->text(); + type=typeData->currentText(); + // write down the packer chosen, to be lastUsedPacker + krConfig->setGroup("Archives"); + krConfig->writeEntry("lastUsedPacker",type); + krConfig->sync(); + PackGUIBase::accept(); +} + +void PackGUI::reject() { + filename=TQString(); + destination=TQString(); + type=TQString(); + PackGUIBase::reject(); +} + +#include "packgui.moc" diff --git a/src/app/Dialogs/packgui.h b/src/app/Dialogs/packgui.h new file mode 100644 index 0000000..2601b25 --- /dev/null +++ b/src/app/Dialogs/packgui.h @@ -0,0 +1,54 @@ +/*************************************************************************** + packgui.h + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 PACKGUI_H +#define PACKGUI_H + +#include "packguibase.h" + +class PackGUI : public PackGUIBase { + TQ_OBJECT + +public: + PackGUI(TQString defaultName, TQString defaultPath, int noOfFiles, TQString filename=""); + +public slots: + void browse(); + +protected slots: + void accept(); + void reject(); + +public: + static TQString filename, destination, type; + static TQMap extraProps; +}; + +#endif diff --git a/src/app/Dialogs/packguibase.cpp b/src/app/Dialogs/packguibase.cpp new file mode 100644 index 0000000..1d66cd4 --- /dev/null +++ b/src/app/Dialogs/packguibase.cpp @@ -0,0 +1,468 @@ +/*************************************************************************** + packguibase.cpp + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ +#include "packguibase.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../krusader.h" + +/* + * Constructs a PackGUIBase which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * true to construct a modal dialog. + */ +PackGUIBase::PackGUIBase( TQWidget* parent, const char* name, bool modal, WFlags fl ) + : TQDialog( parent, name, modal, fl ), expanded( false ) +{ + if ( !name ) + setName( "PackGUIBase" ); + resize( 430, 140 ); + setCaption( i18n( "Pack" ) ); + grid = new TQGridLayout( this ); + grid->setSpacing( 6 ); + grid->setMargin( 11 ); + + hbox = new TQHBoxLayout; + hbox->setSpacing( 6 ); + hbox->setMargin( 0 ); + + TextLabel3 = new TQLabel( this, "TextLabel3" ); + TextLabel3->setText( i18n( "To archive" ) ); + hbox->addWidget( TextLabel3 ); + + nameData = new TQLineEdit( this, "nameData" ); + hbox->addWidget( nameData ); + + typeData = new TQComboBox( false, this, "typeData" ); + typeData->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0 ) ); + connect( typeData, TQ_SIGNAL( activated( const TQString & ) ), this, TQ_SLOT( checkConsistency() ) ); + connect( typeData, TQ_SIGNAL( highlighted( const TQString & ) ), this, TQ_SLOT( checkConsistency() ) ); + hbox->addWidget( typeData ); + + grid->addLayout( hbox, 1, 0 ); + + hbox_2 = new TQHBoxLayout; + hbox_2->setSpacing( 6 ); + hbox_2->setMargin( 0 ); + + TextLabel5 = new TQLabel( this, "TextLabel5" ); + TextLabel5->setText( i18n( "In directory" ) ); + hbox_2->addWidget( TextLabel5 ); + + dirData = new TQLineEdit( this, "dirData" ); + hbox_2->addWidget( dirData ); + + browseButton = new TQToolButton( this, "browseButton" ); + browseButton->setIconSet( SmallIcon( "document-open" ) ); + hbox_2->addWidget( browseButton ); + TQSpacerItem* spacer = new TQSpacerItem( 48, 20, TQSizePolicy::Fixed, TQSizePolicy::Fixed ); + hbox_2->addItem( spacer ); + + grid->addLayout( hbox_2, 2, 0 ); + + hbox_3 = new TQHBoxLayout; + hbox_3->setSpacing( 6 ); + hbox_3->setMargin( 0 ); + + PixmapLabel1 = new TQLabel( this, "PixmapLabel1" ); + PixmapLabel1->setPixmap( krLoader->loadIcon("package", TDEIcon::Desktop, 32) ); + PixmapLabel1->setScaledContents( true ); + PixmapLabel1->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0 ) ); + hbox_3->addWidget( PixmapLabel1 ); + + TextLabel1 = new TQLabel( this, "TextLabel1" ); + TextLabel1->setText( i18n( "Pack" ) ); + hbox_3->addWidget( TextLabel1 ); + + grid->addLayout( hbox_3, 0, 0 ); + + + hbox_4 = new TQHBoxLayout; + hbox_4->setSpacing( 6 ); + hbox_4->setMargin( 0 ); + + TQSpacerItem* spacer_3 = new TQSpacerItem( 20, 26, TQSizePolicy::Fixed, TQSizePolicy::Expanding ); + hbox_4->addItem( spacer_3 ); + grid->addLayout( hbox_4, 3, 0 ); + + advancedWidget = new TQWidget( this, "advancedWidget" ); + + hbox_5 = new TQGridLayout( advancedWidget ); + hbox_5->setSpacing( 6 ); + hbox_5->setMargin( 0 ); + + + TQVBoxLayout *compressLayout = new TQVBoxLayout; + compressLayout->setSpacing( 6 ); + compressLayout->setMargin( 0 ); + + multipleVolume = new TQCheckBox( i18n( "Multiple volume archive" ), advancedWidget, "multipleVolume" ); + connect( multipleVolume, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( checkConsistency() ) ); + compressLayout->addWidget( multipleVolume, 0, 0 ); + + TQHBoxLayout * volumeHbox = new TQHBoxLayout; + + TQSpacerItem* spacer_5 = new TQSpacerItem( 20, 26, TQSizePolicy::Fixed, TQSizePolicy::Fixed ); + volumeHbox->addItem( spacer_5 ); + + TextLabel7 = new TQLabel( i18n("Size:" ), advancedWidget, "TextLabel7" ); + volumeHbox->addWidget( TextLabel7 ); + + volumeSpinBox = new TQSpinBox( advancedWidget, "volumeSpinBox" ); + volumeSpinBox->setMinValue( 1 ); + volumeSpinBox->setMaxValue( 9999 ); + volumeSpinBox->setValue( 1440 ); + volumeHbox->addWidget( volumeSpinBox ); + + volumeUnitCombo = new TQComboBox( false, advancedWidget, "volumeUnitCombo" ); + volumeUnitCombo->insertItem( "B" ); + volumeUnitCombo->insertItem( "KB" ); + volumeUnitCombo->insertItem( "MB" ); + volumeUnitCombo->setCurrentItem( 1 ); + volumeHbox->addWidget( volumeUnitCombo ); + + compressLayout->addLayout ( volumeHbox ); + + setCompressionLevel = new TQCheckBox( i18n( "Set compression level" ), advancedWidget, "multipleVolume" ); + connect( setCompressionLevel, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( checkConsistency() ) ); + compressLayout->addWidget( setCompressionLevel, 0, 0 ); + + TQHBoxLayout * sliderHbox = new TQHBoxLayout; + + TQSpacerItem* spacer_6 = new TQSpacerItem( 20, 26, TQSizePolicy::Fixed, TQSizePolicy::Fixed ); + sliderHbox->addItem( spacer_6 ); + + TQVBox * sliderVBox = new TQVBox( advancedWidget ); + + compressionSlider = new TQSlider( 1, 9, 1, 5, TQt::Horizontal, sliderVBox, "compressionSlider" ); + compressionSlider->setTickmarks( TQSlider::Below ); + + TQHBox * minmaxHBox = new TQHBox( sliderVBox ); + minLabel = new TQLabel( i18n("MIN"), minmaxHBox ); + maxLabel = new TQLabel( i18n("MAX"), minmaxHBox ); + maxLabel->setSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ); + + sliderHbox->addWidget( sliderVBox ); + + compressLayout->addLayout( sliderHbox ); + + compressLayout->addStretch( 0 ); + hbox_5->addLayout( compressLayout, 0, 0 ); + + TQFrame *vline = new TQFrame( advancedWidget, "vline" ); + vline->setFrameStyle( TQFrame::VLine | TQFrame::Sunken ); + vline->setMinimumWidth( 20 ); + hbox_5->addWidget( vline, 0, 1 ); + + + TQGridLayout * passwordGrid = new TQGridLayout; + passwordGrid->setSpacing( 6 ); + passwordGrid->setMargin( 0 ); + + TextLabel4 = new TQLabel( advancedWidget, "TextLabel4" ); + TextLabel4->setText( i18n( "Password" ) ); + passwordGrid->addWidget( TextLabel4, 0, 0 ); + + password = new TQLineEdit( advancedWidget, "password" ); + password->setEchoMode( TQLineEdit::Password ); + connect( password, TQ_SIGNAL( textChanged ( const TQString & ) ), this, TQ_SLOT( checkConsistency() ) ); + + passwordGrid->addWidget( password, 0, 1 ); + + TextLabel6 = new TQLabel( advancedWidget, "TextLabel6" ); + TextLabel6->setText( i18n( "Again" ) ); + passwordGrid->addWidget( TextLabel6, 1, 0 ); + + passwordAgain = new TQLineEdit( advancedWidget, "password" ); + passwordAgain->setEchoMode( TQLineEdit::Password ); + connect( passwordAgain, TQ_SIGNAL( textChanged ( const TQString & ) ), this, TQ_SLOT( checkConsistency() ) ); + + passwordGrid->addWidget( passwordAgain, 1, 1 ); + + TQHBoxLayout *consistencyHbox = new TQHBoxLayout; + + TQSpacerItem* spacer_cons = new TQSpacerItem( 48, 20, TQSizePolicy::Expanding, TQSizePolicy::Fixed ); + consistencyHbox->addItem( spacer_cons ); + + passwordConsistencyLabel = new TQLabel( advancedWidget, "passwordConsistencyLabel" ); + consistencyHbox->addWidget( passwordConsistencyLabel ); + passwordGrid->addMultiCellLayout ( consistencyHbox, 2, 2, 0, 1 ); + + encryptHeaders = new TQCheckBox( i18n( "Encrypt headers" ), advancedWidget, "encryptHeaders" ); + passwordGrid->addMultiCellWidget ( encryptHeaders, 3, 3, 0, 1 ); + + TQSpacerItem* spacer_psw = new TQSpacerItem( 20, 20, TQSizePolicy::Fixed, TQSizePolicy::Expanding ); + passwordGrid->addItem( spacer_psw, 4, 0 ); + + hbox_5->addLayout( passwordGrid, 0, 2 ); + + hbox_7 = new TQHBoxLayout; + hbox_7->setSpacing( 6 ); + hbox_7->setMargin( 0 ); + + TextLabel8 = new TQLabel( i18n( "Command line switches:" ), advancedWidget, "TextLabel8" ); + TextLabel8->setSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ); + hbox_7->addWidget( TextLabel8 ); + + commandLineSwitches = new KHistoryCombo( advancedWidget, "commandLineSwitches" ); + commandLineSwitches->setMaxCount(25); // remember 25 items + commandLineSwitches->setDuplicatesEnabled(false); + krConfig->setGroup("Archives"); + TQStringList list = krConfig->readListEntry("Command Line Switches"); + commandLineSwitches->setHistoryItems(list); + + hbox_7->addWidget( commandLineSwitches ); + + hbox_5->addMultiCellLayout( hbox_7, 1, 1, 0, 2 ); + + + advancedWidget->hide(); + checkConsistency(); + + grid->addWidget( advancedWidget, 4, 0 ); + + hbox_6 = new TQHBoxLayout; + hbox_6->setSpacing( 6 ); + hbox_6->setMargin( 0 ); + + advancedButton = new TQPushButton( this, "advancedButton" ); + advancedButton->setText( i18n( "&Advanced" ) + " >>" ); + hbox_6->addWidget( advancedButton ); + + TQSpacerItem* spacer_2 = new TQSpacerItem( 140, 20, TQSizePolicy::Expanding, TQSizePolicy::Fixed ); + hbox_6->addItem( spacer_2 ); + + okButton = new TQPushButton( this, "okButton" ); + okButton->setText( i18n( "Ok" ) ); + okButton->setDefault( true ); + hbox_6->addWidget( okButton ); + + cancelButton = new TQPushButton( this, "cancelButton" ); + cancelButton->setText( i18n( "Cancel" ) ); + hbox_6->addWidget( cancelButton ); + + grid->addLayout( hbox_6, 6, 0 ); + + // signals and slots connections + connect( okButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( accept() ) ); + connect( advancedButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( expand() ) ); + connect( cancelButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( reject() ) ); + connect( browseButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( browse() ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +PackGUIBase::~PackGUIBase() +{ + // no need to delete child widgets, TQt does it all for us +} + +void PackGUIBase::browse() +{ + tqWarning( "PackGUIBase::browse(): Not implemented yet!" ); +} + +void PackGUIBase::expand() { + expanded = !expanded; + + advancedButton->setText( i18n( "&Advanced" ) + ( expanded ? " <<" : " >>" ) ); + + if( expanded ) + advancedWidget->show(); + else { + advancedWidget->hide(); + layout()->activate(); + TQSize minSize = minimumSize(); + resize( width(), minSize.height() ); + } + show(); +} + +void PackGUIBase::checkConsistency() { + if( password->text().isEmpty() && passwordAgain->text().isEmpty()) { + passwordConsistencyLabel->setPaletteForegroundColor( TDEGlobalSettings::textColor() ); + passwordConsistencyLabel->setText( i18n( "No password specified" ) ); + } + else + if( password->text() == passwordAgain->text() ) { + passwordConsistencyLabel->setPaletteForegroundColor( TDEGlobalSettings::textColor() ); + passwordConsistencyLabel->setText( i18n( "The passwords are equal" ) ); + } + else { + passwordConsistencyLabel->setPaletteForegroundColor( TQt::red ); + passwordConsistencyLabel->setText( i18n( "The passwords are different" ) ); + } + + TQString packer = typeData->currentText(); + + bool passworded = false; + if( packer == "7z" || packer == "rar" || packer == "zip" || packer == "arj" ) + passworded = true; + + passwordConsistencyLabel->setEnabled( passworded ); + password->setEnabled( passworded ); + passwordAgain->setEnabled( passworded ); + TextLabel4->setEnabled( passworded ); + TextLabel6->setEnabled( passworded ); + + encryptHeaders->setEnabled( packer == "rar" ); + + multipleVolume->setEnabled( packer == "rar" || packer == "arj" ); + bool volumeEnabled = multipleVolume->isEnabled() && multipleVolume->isChecked(); + volumeSpinBox->setEnabled( volumeEnabled ); + volumeUnitCombo->setEnabled( volumeEnabled ); + TextLabel7->setEnabled( volumeEnabled ); + + /* TODO */ + setCompressionLevel->setEnabled( packer == "rar" || packer == "arj" || packer == "zip" || + packer == "7z" ); + bool sliderEnabled = setCompressionLevel->isEnabled() && setCompressionLevel->isChecked(); + compressionSlider->setEnabled( sliderEnabled ); + minLabel->setEnabled( sliderEnabled ); + maxLabel->setEnabled( sliderEnabled ); +} + +bool PackGUIBase::extraProperties( TQMap & inMap ) { + inMap.clear(); + + if( password->isEnabled() && passwordAgain->isEnabled() ) { + if( password->text() != passwordAgain->text() ) { + KMessageBox::error( this, i18n( "Cannot pack! The passwords are different!" ) ); + return false; + } + + if( !password->text().isEmpty() ) { + inMap[ "Password" ] = password->text(); + + if( encryptHeaders->isEnabled() && encryptHeaders->isChecked() ) + inMap[ "EncryptHeaders" ] = "1"; + } + } + + if( multipleVolume->isEnabled() && multipleVolume->isChecked() ) { + TDEIO::filesize_t size = volumeSpinBox->value(); + + switch( volumeUnitCombo->currentItem() ) { + case 2: + size *= 1000; + case 1: + size *= 1000; + default: + break; + } + + if( size < 10000 ) { + KMessageBox::error( this, i18n( "Invalid volume size!" ) ); + return false; + } + + TQString sbuffer; + sbuffer.sprintf("%llu",size); + + inMap[ "VolumeSize" ] = sbuffer; + } + + if( setCompressionLevel->isEnabled() && setCompressionLevel->isChecked() ) { + inMap[ "CompressionLevel" ] = TQString("%1").arg( compressionSlider->value() ); + } + + TQString cmdArgs = commandLineSwitches->currentText().stripWhiteSpace(); + if( !cmdArgs.isEmpty() ) { + bool firstChar = true; + TQChar quote = '\0'; + + for( unsigned i=0; i < cmdArgs.length(); i++ ) { + TQChar ch( cmdArgs[ i ] ); + if( ch.isSpace() ) + continue; + + if( ch == quote ) { + quote = '\0'; + continue; + } + + if( firstChar && ch != '-' ) { + KMessageBox::error( this, i18n( "Invalid command line switch!\nSwitch must start with '-'!" ) ); + return false; + } + + firstChar = false; + + if( quote == '"' ) + continue; + if( quote == '\0' && ( ch == '\'' || ch == '"' ) ) + quote = ch; + if( ch == '\\' ) { + if( i == cmdArgs.length() - 1 ) { + KMessageBox::error( this, i18n( "Invalid command line switch!\nBackslash cannot be the last character" ) ); + return false; + } + i++; + } + } + + if( quote != '\0' ) { + KMessageBox::error( this, i18n( "Invalid command line switch!\nUnclosed quotation mark!" ) ); + return false; + } + + commandLineSwitches->addToHistory( cmdArgs ); + TQStringList list = commandLineSwitches->historyItems(); + krConfig->setGroup("Archives"); + krConfig->writeEntry("Command Line Switches", list); + + inMap[ "CommandLineSwitches" ] = cmdArgs; + } + return true; +} + +#include "packguibase.moc" diff --git a/src/app/Dialogs/packguibase.h b/src/app/Dialogs/packguibase.h new file mode 100644 index 0000000..202f67f --- /dev/null +++ b/src/app/Dialogs/packguibase.h @@ -0,0 +1,110 @@ +/*************************************************************************** + packguibase.h + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + email : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 PACKGUIBASE_H +#define PACKGUIBASE_H + +#include +#include +#include + + +class TQVBoxLayout; +class TQHBoxLayout; +class TQGridLayout; +class TQCheckBox; +class TQComboBox; +class TQLabel; +class TQLineEdit; +class TQPushButton; +class TQToolButton; +class TQSpinBox; +class TQSlider; +class KHistoryCombo; + +class PackGUIBase : public TQDialog +{ + TQ_OBJECT + + +public: + PackGUIBase( TQWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); + ~PackGUIBase(); + + TQLabel* TextLabel3; + TQLineEdit* nameData; + TQComboBox* typeData; + TQLabel* TextLabel5; + TQLineEdit* dirData; + TQToolButton* browseButton; + TQWidget* advancedWidget; + TQLabel* PixmapLabel1; + TQLabel* TextLabel1; + TQLabel* TextLabel4; + TQLabel* TextLabel6; + TQLabel* TextLabel7; + TQLabel* TextLabel8; + TQLabel* minLabel; + TQLabel* maxLabel; + TQLineEdit* password; + TQLineEdit* passwordAgain; + TQLabel* passwordConsistencyLabel; + TQPushButton* okButton; + TQPushButton* cancelButton; + TQPushButton* advancedButton; + TQCheckBox* encryptHeaders; + TQCheckBox* multipleVolume; + TQSpinBox* volumeSpinBox; + TQComboBox* volumeUnitCombo; + TQCheckBox* setCompressionLevel; + TQSlider* compressionSlider; + KHistoryCombo *commandLineSwitches; + +public slots: + virtual void browse(); + virtual bool extraProperties( TQMap & ); + + void expand(); + void checkConsistency(); + +protected: + TQHBoxLayout* hbox; + TQHBoxLayout* hbox_2; + TQHBoxLayout* hbox_3; + TQHBoxLayout* hbox_4; + TQGridLayout* hbox_5; + TQHBoxLayout* hbox_6; + TQHBoxLayout* hbox_7; + TQGridLayout* grid; + +private: + bool expanded; +}; + +#endif // PACKGUIBASE_H diff --git a/src/app/Dialogs/percentalsplitter.cpp b/src/app/Dialogs/percentalsplitter.cpp new file mode 100644 index 0000000..4aefc41 --- /dev/null +++ b/src/app/Dialogs/percentalsplitter.cpp @@ -0,0 +1,193 @@ +/*************************************************************************** + percentalsplitter.h - description + ------------------- + copyright : (C) 2006 + by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "percentalsplitter.h" +#include +#include +#include + +class PercentalSplitterToolTip : public TQToolTip { +public: + PercentalSplitterToolTip( TQWidget * parent ) : TQToolTip( parent ) { + } + + virtual ~PercentalSplitterToolTip() { + remove( parentWidget() ); + } + + void maybeTip( const TQPoint & point ) { + if( parentWidget()->inherits( "PercentalSplitter" ) ) { + PercentalSplitter *splitter = (PercentalSplitter *)parentWidget(); + + TQString tipString = splitter->toolTipString(); + TQRect rect = TQRect( parentWidget()->rect() ); + + if( splitter->orientation() == TQt::Vertical ) { + rect.setY( splitter->sizes()[ 0 ] ); + rect.setHeight( splitter->handleWidth() ); + } + else { + rect.setX( splitter->sizes()[ 0 ] ); + rect.setWidth( splitter->handleWidth() ); + } + if( rect.contains( point ) ) + tip( rect, tipString ); + } + } +}; + +PercentalSplitter::PercentalSplitter( TQWidget * parent, const char * name ) : TQSplitter( parent, name ), label( 0 ), opaqueOldPos( -1 ) { + toolTip = new PercentalSplitterToolTip( this ); +} + +PercentalSplitter::~PercentalSplitter() { + delete toolTip; +} + +TQString PercentalSplitter::toolTipString( int p ) { + TQValueList values = sizes(); + if( values.count() == 2 && ( values[ 0 ] + values[ 1 ] != 0 ) ) { + if( p < 0 ) + p = values[ 0 ]; + int percent = (int)(((double)p / (double)( values[ 0 ] + values[ 1 ] )) * 10000. + 0.5); + return TQString( "%1.%2%3" ).arg( percent / 100 ).arg( ( percent / 10 )%10 ).arg( percent % 10 ) + "%"; + } + return TQString(); +} + +void PercentalSplitter::setRubberband ( int p ) { + if( p == opaqueOldPos ) + return; + + TQPainter paint( this ); + paint.setPen( gray ); + paint.setBrush( gray ); + paint.setRasterOp( XorROP ); + TQRect r = contentsRect(); + const int rBord = 3; // customizable? + int hw = handleWidth(); + + if( orientation() == TQt::Horizontal ) { + if ( opaqueOldPos >= 0 ) { + if( label == 0 ) + paint.drawRect( opaqueOldPos + hw / 2 - rBord, r.y(), 2 * rBord, r.height() ); + else { + TQPoint labelLoc = mapFromGlobal( labelLocation ); + if( labelLoc.y() > r.y() ) + paint.drawRect( opaqueOldPos + hw / 2 - rBord, r.y(), 2 * rBord, labelLoc.y() ); + if( labelLoc.y() + label->height() < r.height() ) + paint.drawRect( opaqueOldPos + hw / 2 - rBord, labelLoc.y() + label->height(), 2 * rBord, r.height() - labelLoc.y() - label->height() ); + } + } + } else { + if ( opaqueOldPos >= 0 ) { + if( label == 0 ) + paint.drawRect( r.x(), opaqueOldPos + hw / 2 - rBord, r.width(), 2 * rBord ); + else { + TQPoint labelLoc = mapFromGlobal( labelLocation ); + if( labelLoc.x() > r.x() ) + paint.drawRect( r.x(), opaqueOldPos + hw / 2 - rBord, labelLoc.x(), 2 * rBord ); + if( labelLoc.x() + label->width() < r.width() ) + paint.drawRect( labelLoc.x() + label->width(), opaqueOldPos + hw / 2 - rBord, r.width() - labelLoc.x() - label->width(), 2 * rBord ); + } + } + } + + if( p < 0 ) { + if( label ) { + delete label; + label = 0; + } + } + else { + int scr = TQApplication::desktop()->screenNumber( this ); + + if( label == 0 ) { + label = new TQLabel( TQApplication::desktop()->screen( scr ), "SplitterPercent", WStyle_StaysOnTop | + WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WX11BypassWM ); + label->setMargin(1); + label->setAutoMask( false ); + label->setFrameStyle( TQFrame::Plain | TQFrame::Box ); + label->setLineWidth( 1 ); + label->setAlignment( AlignAuto | AlignTop ); + label->setIndent(0); + + TQFontMetrics fm = label->fontMetrics(); + label->setMinimumWidth( fm.width( "99.99%" ) + 5 ); + + label->polish(); + } + + label->setText( toolTipString( p ) ); + label->adjustSize(); + + if( orientation() == TQt::Horizontal ) { + labelLocation = mapToGlobal( TQPoint( p - label->width()/2, r.y() + r.height()/2 ) ); + if( labelLocation.x() < 0 ) + labelLocation.setX( 0 ); + } else { + labelLocation = mapToGlobal( TQPoint( r.x() + r.width()/2, p - label->height()/2 ) ); + if( labelLocation.y() < 0 ) + labelLocation.setY( 0 ); + } + +#ifdef TQ_WS_MAC + TQRect screen = TQApplication::desktop()->availableGeometry( scr ); +#else + TQRect screen = TQApplication::desktop()->screenGeometry( scr ); +#endif + + TQPoint labelLoc = mapFromGlobal( labelLocation ); + if( orientation() == TQt::Horizontal ) { + if( labelLocation.x() + label->width() > screen.width() ) + labelLocation.setX( screen.width() - label->width() ); + label->move( labelLocation ); + label->show(); + + if( labelLoc.y() > r.y() ) + paint.drawRect( p + hw / 2 - rBord, r.y(), 2 * rBord, labelLoc.y() ); + if( labelLoc.y() + label->height() < r.height() ) + paint.drawRect( p + hw / 2 - rBord, labelLoc.y() + label->height(), 2 * rBord, r.height() - labelLoc.y() - label->height() ); + } else { + if( labelLocation.y() + label->height() > screen.height() ) + labelLocation.setY( screen.height() - label->height() ); + label->move( labelLocation ); + label->show(); + + if( labelLoc.x() > r.x() ) + paint.drawRect( r.x(), p + hw / 2 - rBord, labelLoc.x(), 2 * rBord ); + if( labelLoc.x() + label->width() < r.width() ) + paint.drawRect( labelLoc.x() + label->width(), p + hw / 2 - rBord, r.width() - labelLoc.x() - label->width(), 2 * rBord ); + } + } + opaqueOldPos = p; +} + +#include "percentalsplitter.moc" diff --git a/src/app/Dialogs/percentalsplitter.h b/src/app/Dialogs/percentalsplitter.h new file mode 100644 index 0000000..414f133 --- /dev/null +++ b/src/app/Dialogs/percentalsplitter.h @@ -0,0 +1,59 @@ +/*************************************************************************** + percentalsplitter.h - description + ------------------- + copyright : (C) 2006 + by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 __PERCENTAL_SPLITTER__ +#define __PERCENTAL_SPLITTER__ + +#include +#include + +class PercentalSplitterToolTip; + +class PercentalSplitter : public TQSplitter { + TQ_OBJECT + + +public: + PercentalSplitter( TQWidget * parent = 0, const char * name = 0 ); + virtual ~PercentalSplitter(); + + TQString toolTipString( int p = -1 ); + +protected: + virtual void setRubberband ( int p ); + +private: + PercentalSplitterToolTip * toolTip; + TQLabel * label; + int opaqueOldPos; + TQPoint labelLocation; +}; + +#endif /* __PERCENTAL_SPLITTER__ */ diff --git a/src/app/Dialogs/popularurls.cpp b/src/app/Dialogs/popularurls.cpp new file mode 100644 index 0000000..9fe2184 --- /dev/null +++ b/src/app/Dialogs/popularurls.cpp @@ -0,0 +1,307 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../krusader.h" +#include "../krslots.h" +#include "popularurls.h" + +#define STARTING_RANK 20 +#define INCREASE 2 +#define DECREASE 1 + +PopularUrls::PopularUrls(TQObject *parent, const char *name) : TQObject(parent, name), + head(0), tail(0), count(0) { + dlg = new PopularUrlsDlg(); +} + +PopularUrls::~PopularUrls() { + clearList(); + delete dlg; +} + +void PopularUrls::clearList() { + if (head) { + UrlNodeP p=head, tmp; + while (p) { + tmp = p; + p=p->next; + delete tmp; + } + } + ranks.clear(); + head = tail = 0; +} + +void PopularUrls::save() { + TDEConfigGroupSaver svr(krConfig, "Private"); + // prepare the string list containing urls and int list with ranks + TQStringList urlList; + TQValueList rankList; + UrlNodeP p = head; + while (p) { + urlList << p->url.prettyURL(); + rankList << p->rank; + p = p->next; + } + krConfig->writeEntry("PopularUrls", urlList); + krConfig->writeEntry("PopularUrlsRank", rankList); +} + +void PopularUrls::load() { + TDEConfigGroupSaver svr(krConfig, "Private"); + TQStringList urlList = krConfig->readListEntry("PopularUrls"); + TQValueList rankList = krConfig->readIntListEntry("PopularUrlsRank"); + if (urlList.count() != rankList.count()) { + KMessageBox::error(krApp, i18n("Saved 'Popular Urls' are invalid. List will be cleared")); + return; + } + clearList(); + count = 0; + // iterate through both lists and + TQStringList::Iterator uit; + TQValueList::Iterator rit; + for (uit=urlList.begin(), rit=rankList.begin(); uit!=urlList.end() && rit!=rankList.end(); ++uit, ++rit) { + UrlNodeP node = new UrlNode; + node->url = KURL::fromPathOrURL( *uit ); + node->rank = *rit; + appendNode(node); + ranks.insert(*uit, node); + } +} + + +// returns a url list with the 'max' top popular urls +KURL::List PopularUrls::getMostPopularUrls(int max) { + // get at most 'max' urls + KURL::List list; + UrlNodeP p = head; + int tmp = 0; + if (maxUrls < max) max = maxUrls; // don't give more than maxUrls + while (p && tmp < max) { + list << p->url; + p = p->next; + ++tmp; + } + + return list; +} + +// adds a url to the list, or increase rank of an existing url, making +// sure to bump it up the list if needed +void PopularUrls::addUrl(const KURL& url) { + KURL tmpurl = url; + tmpurl.adjustPath(1); // make a uniform trailing slash policy + UrlNodeP pnode; + + decreaseRanks(); + if (!head) { // if the list is empty ... (assumes dict to be empty as well) + pnode = new UrlNode; + pnode->rank = STARTING_RANK; + pnode->url = tmpurl; + appendNode(pnode); + ranks.insert(tmpurl.url(), head); + } else { + pnode = ranks.find(tmpurl.url()); + if (!pnode) { // is the added url new? if so, append it + pnode = new UrlNode; + pnode->rank = STARTING_RANK; + pnode->url = tmpurl; + appendNode(pnode); + ranks.insert(tmpurl.url(), pnode); + } else { + pnode->rank += INCREASE; + } + } + + // do we need to change location for this one? + relocateIfNeeded(pnode); + + // too many urls? + if (count > maxUrls) removeNode(tail); + + //dumpList(); +} + +// checks if 'node' needs to be bumped-up the ranking list and does it if needed +void PopularUrls::relocateIfNeeded(UrlNodeP node) { + if (node->prev && (node->prev->rank < node->rank)) { + // iterate until we find the correct place to put it + UrlNodeP tmp = node->prev->prev; + while (tmp) { + if (tmp->rank >= node->rank) + break; // found it! + else tmp = tmp->prev; + } + // now, if tmp isn't null, we need to move node to tmp->next + // else move it to become head + removeNode(node); + insertNode(node, tmp); + } +} + + +// iterate over the list, decreasing each url's rank +// this is very naive, but a 1..30 for loop is acceptable (i hope) +void PopularUrls::decreaseRanks() { + if (head) { + UrlNodeP p=head; + while (p) { + if (p->rank-DECREASE>=0) + p->rank -= DECREASE; + else p->rank = 0; + p=p->next; + } + } +} + +// removes a node from the list, but doesn't free memory! +// note: this will be buggy in case the list becomes empty (which should never happen) +void PopularUrls::removeNode(UrlNodeP node) { + if (node->prev) { + if (tail == node) tail = node->prev; + node->prev->next = node->next; + } + if (node->next) { + if (head == node) head = node->next; + node->next->prev = node->prev; + } + --count; +} + +void PopularUrls::insertNode(UrlNodeP node, UrlNodeP after) { + if (!after) { // make node head + node->next = head; + node->prev = 0; + head->prev = node; + head = node; + } else { + if (tail == after) tail = node; + node->prev = after; + node->next = after->next; + if( node->next ) { + after->next->prev = node; + after->next = node; + } + } + ++count; +} + +// appends 'node' to the end of the list, collecting garbage if needed +void PopularUrls::appendNode(UrlNodeP node) { + if (!tail) { // creating the first element + head = tail = node; + node->prev = node->next = 0; + } else { + node->next = 0; + node->prev = tail; + tail->next = node; + tail = node; + } + ++count; +} + +void PopularUrls::dumpList() { + UrlNodeP p = head; + printf("====start %d====\n",count); + while (p) { + printf("%d : %s\n", p->rank, p->url.url().latin1()); + p = p->next; + } + fflush(stdout); +} + +void PopularUrls::showDialog() { + KURL::List list = getMostPopularUrls(maxUrls); + dlg->run(list); + if (dlg->result() == -1) return; + SLOTS->refresh(list[dlg->result()]); + //printf("running %s\n", list[dlg->result()].url().latin1());fflush(stdout); +} + +// ===================================== PopularUrlsDlg ====================================== +PopularUrlsDlg::PopularUrlsDlg(): + KDialogBase(Plain, i18n("Popular Urls"), Close, KDialogBase::NoDefault, krApp) { + TQGridLayout *layout = new TQGridLayout( plainPage(), 0, KDialog::spacingHint() ); + + // listview to contain the urls + urls = new TDEListView(plainPage()); + urls->header()->hide(); + urls->addColumn(""); + urls->setSorting(-1); + urls->setVScrollBarMode(TQScrollView::AlwaysOn); + + // quick search + TQToolButton *btn = new TQToolButton(plainPage()); + btn->setIconSet(SmallIcon("locationbar_erase")); + search = new TDEListViewSearchLine(plainPage(), urls); + search->setTrapReturnKey(true); + TQLabel *lbl = new TQLabel(search, i18n(" &Search: "), plainPage()); + + layout->addWidget(btn,0,0); + layout->addWidget(lbl,0,1); + layout->addWidget(search,0,2); + layout->addMultiCellWidget(urls,1,1,0,2); + setMaximumSize(600, 500); + + setTabOrder(search, urls); + setTabOrder(urls, actionButton(Close)); + + connect(urls, TQ_SIGNAL(executed(TQListViewItem*)), + this, TQ_SLOT(slotItemSelected(TQListViewItem*))); + connect(urls, TQ_SIGNAL(returnPressed(TQListViewItem*)), + this, TQ_SLOT(slotItemSelected(TQListViewItem*))); + connect(btn, TQ_SIGNAL(clicked()), search, TQ_SLOT(clear())); + connect(search, TQ_SIGNAL(returnPressed(const TQString&)), + this, TQ_SLOT(slotSearchReturnPressed(const TQString&))); +} + +void PopularUrlsDlg::slotItemSelected(TQListViewItem *it) { + selection = urls->itemIndex(it); + accept(); +} + +void PopularUrlsDlg::slotSearchReturnPressed(const TQString&) { + urls->setFocus(); + // select the first visible item + TQListViewItemIterator it( urls ); + while ( it.current() ) { + if ( it.current()->isVisible() ) { + urls->setSelected(it.current(), true); + urls->setCurrentItem(it.current()); + break; + } else ++it; + } +} + +PopularUrlsDlg::~PopularUrlsDlg() { + delete search; + delete urls; +} + +void PopularUrlsDlg::run(KURL::List list) { + // populate the listview + urls->clear(); + KURL::List::Iterator it; + for (it = list.begin(); it!=list.end(); ++it) { + TDEListViewItem *item = new TDEListViewItem(urls, urls->lastItem()); + item->setText(0, (*it).isLocalFile() ? (*it).path() : (*it).prettyURL()); + item->setPixmap(0, (*it).isLocalFile() ? SmallIcon("folder") : SmallIcon("folder_html")); + } + //urls->setCurrentItem(urls->firstChild()); + //urls->setSelected(urls->firstChild(), true); + setMinimumSize(urls->sizeHint().width()+45, 400); + + search->clear(); + search->setFocus(); + selection = -1; + exec(); +} + +#include "popularurls.moc" diff --git a/src/app/Dialogs/popularurls.h b/src/app/Dialogs/popularurls.h new file mode 100644 index 0000000..775a356 --- /dev/null +++ b/src/app/Dialogs/popularurls.h @@ -0,0 +1,86 @@ +#ifndef POPULARURLS_H +#define POPULARURLS_H + +#include +#include +#include +#include + +// the class holds a list of most popular links in a dual data structure +// * linked list, with head and tail: for fast append/prepend support +// * dictionary that maps urls to list nodes: to save the need to iterate +// over the list in order to find the correct node for each new url +// +// also, the class holds a maximum number of urls. two variables affect this: +// * maxUrls - the num. of urls the user can see +// * hardLimit - the actual number of urls kept. +// when the number of urls reaches hardLimit, a garbage collection is done and +// the bottom (hardLimit-maxUrls) entries are removed from the list +typedef struct _UrlNode* UrlNodeP; +typedef struct _UrlNode { + UrlNodeP prev; + KURL url; + int rank; + UrlNodeP next; +} UrlNode; + +class PopularUrlsDlg; + +class PopularUrls : public TQObject { + TQ_OBJECT + +public: + PopularUrls(TQObject *parent = 0, const char *name = 0); + ~PopularUrls(); + void save(); + void load(); + void addUrl(const KURL& url); + KURL::List getMostPopularUrls(int max); + +public slots: + void showDialog(); + +protected: + // NOTE: the following methods append/insert/remove a node to the list + // but NEVER free memory or allocate memory! + void appendNode(UrlNodeP node); + void insertNode(UrlNodeP node, UrlNodeP after); + void removeNode(UrlNodeP node); + void relocateIfNeeded(UrlNodeP node); + void clearList(); + void dumpList(); + void decreaseRanks(); + +private: + UrlNodeP head, tail; + TQDict ranks; // actually holds UrlNode* + int count; + static const int maxUrls = 30; + PopularUrlsDlg *dlg; +}; + +class TDEListView; +class TDEListViewSearchLine; + +class PopularUrlsDlg: public KDialogBase { + TQ_OBJECT + +public: + PopularUrlsDlg(); + ~PopularUrlsDlg(); + void run(KURL::List list); // use this to open the dialog + inline int result() const { return selection; } // returns index 0 - topmost, or -1 + + +protected slots: + void slotSearchReturnPressed(const TQString&); + void slotItemSelected(TQListViewItem *it); + +private: + TDEListView *urls; + TDEListViewSearchLine *search; + int selection; +}; + + +#endif diff --git a/src/app/DiskUsage/Makefile.am b/src/app/DiskUsage/Makefile.am new file mode 100644 index 0000000..691d045 --- /dev/null +++ b/src/app/DiskUsage/Makefile.am @@ -0,0 +1,17 @@ +SUBDIRS = \ + radialMap \ + filelightParts + + +noinst_LIBRARIES = libDiskUsage.a + +INCLUDES = $(all_includes) + +libDiskUsage_a_METASOURCES = AUTO + +libDiskUsage_a_SOURCES = \ + diskusagegui.cpp \ + diskusage.cpp \ + dulistview.cpp \ + dulines.cpp \ + dufilelight.cpp diff --git a/src/app/DiskUsage/diskusage.cpp b/src/app/DiskUsage/diskusage.cpp new file mode 100644 index 0000000..c372e8c --- /dev/null +++ b/src/app/DiskUsage/diskusage.cpp @@ -0,0 +1,1147 @@ +/*************************************************************************** + diskusage.cpp - description + ------------------- + copyright : (C) 2004 + by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "diskusage.h" +#include "../VFS/krpermhandler.h" +#include "../VFS/krvfshandler.h" +#include "../kicons.h" +#include "../defaults.h" +#include "../krusader.h" +#include "../krusaderview.h" +#include "../Panel/listpanel.h" +#include "../Panel/panelfunc.h" +#include "filelightParts/Config.h" + +#include "dulines.h" +#include "dulistview.h" +#include "dufilelight.h" + +// these are the values that will exist in the menu +#define DELETE_ID 90 +#define EXCLUDE_ID 91 +#define PARENT_DIR_ID 92 +#define NEW_SEARCH_ID 93 +#define REFRESH_ID 94 +#define STEP_INTO_ID 95 +#define INCLUDE_ALL_ID 96 +#define VIEW_POPUP_ID 97 +#define LINES_VIEW_ID 98 +#define DETAILED_VIEW_ID 99 +#define FILELIGHT_VIEW_ID 100 +#define NEXT_VIEW_ID 101 +#define PREVIOUS_VIEW_ID 102 +#define ADDITIONAL_POPUP_ID 103 + +#define MAX_FILENUM 100 + +LoaderWidget::LoaderWidget( TQWidget *parent, const char *name ) : TQScrollView( parent, name ), cancelled( false ) +{ + viewport()->setEraseColor( TQt::white ); + widget = new TQWidget( parent ); + + TQGridLayout *loaderLayout = new TQGridLayout( widget ); + loaderLayout->setSpacing( 0 ); + loaderLayout->setMargin( 0 ); + + TQGroupBox *loaderBox = new TQGroupBox( widget, "loaderGroupBox" ); + loaderBox->setFrameShape( TQGroupBox::Box ); + loaderBox->setFrameShadow( TQGroupBox::Sunken ); + loaderBox->setColumnLayout(0, TQt::Vertical ); + loaderBox->layout()->setSpacing( 0 ); + loaderBox->layout()->setMargin( 0 ); + loaderBox->setSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ); + loaderBox->setFrameStyle( TQFrame::Panel + TQFrame::Raised ); + loaderBox->setLineWidth( 2 ); + + TQGridLayout *synchGrid = new TQGridLayout( loaderBox->layout() ); + synchGrid->setSpacing( 6 ); + synchGrid->setMargin( 11 ); + + TQLabel *titleLabel = new TQLabel( i18n( "Loading Usage Information" ), loaderBox, "titleLabel" ); + titleLabel->setAlignment( TQt::AlignHCenter ); + synchGrid->addMultiCellWidget( titleLabel, 0, 0, 0, 1 ); + + TQLabel *filesLabel = new TQLabel( i18n( "Files:" ), loaderBox, "filesLabel" ); + filesLabel->setFrameShape( TQLabel::StyledPanel ); + filesLabel->setFrameShadow( TQLabel::Sunken ); + synchGrid->addWidget( filesLabel, 1, 0 ); + + TQLabel *directoriesLabel = new TQLabel( i18n( "Directories:" ), loaderBox, "directoriesLabel" ); + directoriesLabel->setFrameShape( TQLabel::StyledPanel ); + directoriesLabel->setFrameShadow( TQLabel::Sunken ); + synchGrid->addWidget( directoriesLabel, 2, 0 ); + + TQLabel *totalSizeLabel = new TQLabel( i18n( "Total Size:" ), loaderBox, "totalSizeLabel" ); + totalSizeLabel->setFrameShape( TQLabel::StyledPanel ); + totalSizeLabel->setFrameShadow( TQLabel::Sunken ); + synchGrid->addWidget( totalSizeLabel, 3, 0 ); + + files = new TQLabel( loaderBox, "files" ); + files->setFrameShape( TQLabel::StyledPanel ); + files->setFrameShadow( TQLabel::Sunken ); + files->setAlignment( TQt::AlignRight ); + synchGrid->addWidget( files, 1, 1 ); + + directories = new TQLabel( loaderBox, "directories" ); + directories->setFrameShape( TQLabel::StyledPanel ); + directories->setFrameShadow( TQLabel::Sunken ); + directories->setAlignment( TQt::AlignRight ); + synchGrid->addWidget( directories, 2, 1 ); + + totalSize = new TQLabel( loaderBox, "totalSize" ); + totalSize->setFrameShape( TQLabel::StyledPanel ); + totalSize->setFrameShadow( TQLabel::Sunken ); + totalSize->setAlignment( TQt::AlignRight ); + synchGrid->addWidget( totalSize, 3, 1 ); + + int width; + searchedDirectory = new KSqueezedTextLabel( loaderBox, "searchedDirectory" ); + searchedDirectory->setFrameShape( TQLabel::StyledPanel ); + searchedDirectory->setFrameShadow( TQLabel::Sunken ); + searchedDirectory->setMinimumWidth( width = TQFontMetrics(searchedDirectory->font()).width("W") * 30 ); + searchedDirectory->setMaximumWidth( width ); + synchGrid->addMultiCellWidget( searchedDirectory, 4, 4, 0, 1 ); + + TQFrame *line = new TQFrame( loaderBox, "duLine" ); + line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken ); + synchGrid->addMultiCellWidget( line, 5, 5, 0, 1 ); + + TQHBox *hbox = new TQHBox( loaderBox, "hbox" ); + TQSpacerItem* spacer = new TQSpacerItem( 0, 0, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + hbox->layout()->addItem( spacer ); + TQPushButton *cancelButton = new TQPushButton( hbox, "cancelButton" ); + cancelButton->setText( i18n( "Cancel" ) ); + synchGrid->addWidget( hbox, 6, 1 ); + + loaderLayout->addWidget( loaderBox, 0, 0 ); + + addChild( widget ); + + connect( cancelButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotCancelled() ) ); +} + +void LoaderWidget::resizeEvent ( TQResizeEvent *e ) +{ + TQScrollView::resizeEvent( e ); + + int x = ( viewport()->width() - widget->width() ) / 2; + int y = ( viewport()->height() - widget->height() ) / 2; + if( x < 0 ) x=0; + if( y < 0 ) y=0; + + moveChild( widget, x, y ); +} + +void LoaderWidget::init() +{ + cancelled = false; +} + +void LoaderWidget::setCurrentURL( KURL url ) +{ + searchedDirectory->setText( vfs::pathOrURL( url, 1) ); +} + +void LoaderWidget::setValues( int fileNum, int dirNum, TDEIO::filesize_t total ) +{ + files->setText( TQString("%1").arg( fileNum ) ); + directories->setText( TQString("%1").arg( dirNum ) ); + totalSize->setText( TQString("%1").arg( KRpermHandler::parseSize( total ).stripWhiteSpace() ) ); +} + +void LoaderWidget::slotCancelled() +{ + cancelled = true; +} + +DiskUsage::DiskUsage( TQString confGroup, TQWidget *parent, char *name ) : TQWidgetStack( parent, name ), + currentDirectory( 0 ), root( 0 ), configGroup( confGroup ), loading( false ), + abortLoading( false ), clearAfterAbort( false ), deleting( false ), searchVfs( 0 ) +{ + listView = new DUListView( this, "DU ListView" ); + lineView = new DULines( this, "DU LineView" ); + filelightView = new DUFilelight( this, "Filelight canvas" ); + loaderView = new LoaderWidget( this, "Loading view" ); + + addWidget( listView ); + addWidget( lineView ); + addWidget( filelightView ); + addWidget( loaderView ); + + setView( VIEW_LINES ); + + Filelight::Config::read(); + propertyMap.setAutoDelete( true ); + + connect( &loadingTimer, TQ_SIGNAL( timeout() ), this, TQ_SLOT( slotLoadDirectory() ) ); +} + +DiskUsage::~DiskUsage() +{ + if( root ) + delete root; + + if( listView ) // don't remove these lines. The module will crash at exit if removed + delete listView; + if( lineView ) + delete lineView; + if( filelightView ) + delete filelightView; +} + +void DiskUsage::load( KURL baseDir ) +{ + if( searchVfs && !searchVfs->vfs_canDelete() ) { + return; + } + + fileNum = dirNum = 0; + currentSize = 0; + + emit status( i18n( "Loading the disk usage information..." ) ); + + clear(); + + baseURL = baseDir; + baseURL.setPath( baseDir.path( -1 ) ); + + root = new Directory( baseURL.fileName(), vfs::pathOrURL( baseDir ) ); + + directoryStack.clear(); + parentStack.clear(); + + directoryStack.push( "" ); + parentStack.push( root ); + + if( searchVfs ) + { + delete searchVfs; + searchVfs = 0; + } + searchVfs = KrVfsHandler::getVfs( baseDir ); + if( searchVfs == 0 ) + { + loading = abortLoading = clearAfterAbort = false; + emit loadFinished( false ); + return; + } + + searchVfs->vfs_setQuiet( true ); + currentVfile = 0; + + if( !loading ) + { + viewBeforeLoad = activeView; + setView( VIEW_LOADER ); + } + + loading = true; + + loaderView->init(); + loaderView->setCurrentURL( baseURL ); + loaderView->setValues( fileNum, dirNum, currentSize ); + + loadingTimer.start( 0, true ); +} + +void DiskUsage::slotLoadDirectory() +{ + if( searchVfs && !searchVfs->vfs_canDelete() ) { // recursive call from slotLoadDirectory? + loadingTimer.start( 100, true ); // as it can cause crash, ignore it and wait while + return; // the recursion finishes + } + if( ( currentVfile == 0 && directoryStack.isEmpty() ) || loaderView->wasCancelled() || abortLoading ) + { + if( searchVfs ) + delete searchVfs; + + searchVfs = 0; + currentVfile = 0; + + setView( viewBeforeLoad ); + + if( clearAfterAbort ) + clear(); + else { + calculateSizes(); + changeDirectory( root ); + } + + emit loadFinished( !( loaderView->wasCancelled() || abortLoading ) ); + + loading = abortLoading = clearAfterAbort = false; + } + else if( loading ) + { + for( int counter = 0; counter != MAX_FILENUM; counter ++ ) + { + if( currentVfile == 0 ) + { + if( directoryStack.isEmpty() ) + break; + + dirToCheck = directoryStack.pop(); + currentParent = parentStack.pop(); + + contentMap.insert( dirToCheck, currentParent ); + + KURL url = baseURL; + + if( !dirToCheck.isEmpty() ) + url.addPath( dirToCheck ); + +#if defined(BSD) + if ( url.isLocalFile() && url.path().left( 7 ) == "/procfs" ) + break; +#else + if ( url.isLocalFile() && url.path().left( 5 ) == "/proc" ) + break; +#endif + + loaderView->setCurrentURL( url ); + + if( !searchVfs->vfs_refresh( url ) ) + break; + + dirNum++; + + currentVfile = searchVfs->vfs_getFirstFile(); + } + else + { + fileNum++; + File *newItem = 0; + + TQString mime = currentVfile->vfile_getMime(true); // fast == not using mimetype magic + + if( currentVfile->vfile_isDir() && !currentVfile->vfile_isSymLink() ) + { + newItem = new Directory( currentParent, currentVfile->vfile_getName(), dirToCheck, currentVfile->vfile_getSize(), + currentVfile->vfile_getMode(), currentVfile->vfile_getOwner(), currentVfile->vfile_getGroup(), + currentVfile->vfile_getPerm(), currentVfile->vfile_getTime_t(), currentVfile->vfile_isSymLink(), + mime ); + directoryStack.push( (dirToCheck.isEmpty() ? "" : dirToCheck + "/" )+ currentVfile->vfile_getName() ); + parentStack.push( dynamic_cast( newItem ) ); + } + else + { + newItem = new File( currentParent, currentVfile->vfile_getName(), dirToCheck, currentVfile->vfile_getSize(), + currentVfile->vfile_getMode(), currentVfile->vfile_getOwner(), currentVfile->vfile_getGroup(), + currentVfile->vfile_getPerm(), currentVfile->vfile_getTime_t(), currentVfile->vfile_isSymLink(), + mime ); + currentSize += currentVfile->vfile_getSize(); + } + currentParent->append( newItem ); + + currentVfile = searchVfs->vfs_getNextFile(); + } + } + + loaderView->setValues( fileNum, dirNum, currentSize ); + loadingTimer.start( 0, true ); + } +} + +void DiskUsage::stopLoad() +{ + abortLoading = true; +} + +void DiskUsage::close() +{ + if( loading ) + { + abortLoading = true; + clearAfterAbort = true; + } +} + +void DiskUsage::dirUp() +{ + if( currentDirectory != 0 ) + { + if ( currentDirectory->parent() != 0 ) + changeDirectory( (Directory *)(currentDirectory->parent()) ); + else + { + KURL up = baseURL.upURL(); + + if( KMessageBox::questionYesNo( this, i18n( "Stepping into the parent directory requires " + "loading the content of the \"%1\" URL. Do you wish " + "to continue?" ) + .arg( vfs::pathOrURL( up ) ), + i18n( "Krusader::DiskUsage" ), KStdGuiItem::yes(), + KStdGuiItem::no(), "DiskUsageLoadParentDir" + ) == KMessageBox::Yes ) + load( up ); + } + } +} + +Directory * DiskUsage::getDirectory( TQString dir ) +{ + while( dir.endsWith( "/" ) ) + dir.truncate( dir.length() - 1 ); + + if( dir.isEmpty() ) + return root; + + return contentMap.find( dir ); +} + +File * DiskUsage::getFile( TQString path ) +{ + if( path == "" ) + return root; + + TQString dir = path; + + int ndx = path.findRev( '/' ); + TQString file = path.mid( ndx + 1 ); + + if( ndx == -1 ) + dir = ""; + else + dir.truncate( ndx ); + + Directory *dirEntry = getDirectory( dir ); + if( dirEntry == 0 ) + return 0; + + for( Iterator it = dirEntry->iterator(); it != dirEntry->end(); ++it ) + if( (*it)->name() == file ) + return *it; + + return 0; +} + +void DiskUsage::clear() +{ + baseURL = KURL(); + emit clearing(); + propertyMap.clear(); + contentMap.clear(); + if( root ) + delete root; + root = currentDirectory = 0; +} + +int DiskUsage::calculateSizes( Directory *dirEntry, bool emitSig, int depth ) +{ + int changeNr = 0; + + if( dirEntry == 0 ) + dirEntry = root; + + TDEIO::filesize_t own = 0, total = 0; + + for( Iterator it = dirEntry->iterator(); it != dirEntry->end(); ++it ) + { + File * item = *it; + + if( !item->isExcluded() ) + { + if( item->isDir() ) + changeNr += calculateSizes( dynamic_cast( item ), emitSig, depth + 1 ); + else + own += item->size(); + + total += item->size(); + } + } + + TDEIO::filesize_t oldOwn = dirEntry->ownSize(), oldTotal = dirEntry->size(); + dirEntry->setSizes( total, own ); + + if( dirEntry == currentDirectory ) + currentSize = total; + + if( emitSig && ( own != oldOwn || total != oldTotal ) ) { + emit changed( dirEntry ); + changeNr++; + } + + if( depth == 0 && changeNr != 0 ) + emit changeFinished(); + return changeNr; +} + +int DiskUsage::exclude( File *file, bool calcPercents, int depth ) +{ + int changeNr = 0; + + if( !file->isExcluded() ) + { + file->exclude( true ); + emit changed( file ); + changeNr++; + + if( file->isDir() ) + { + Directory *dir = dynamic_cast( file ); + for( Iterator it = dir->iterator(); it != dir->end(); ++it ) + changeNr += exclude( *it, false, depth + 1 ); + } + } + + if( calcPercents ) + { + calculateSizes( root, true ); + calculatePercents( true ); + createStatus(); + } + + if( depth == 0 && changeNr != 0 ) + emit changeFinished(); + + return changeNr; +} + +int DiskUsage::include( Directory *dir, int depth ) +{ + int changeNr = 0; + + if( dir == 0 ) + return 0; + + for( Iterator it = dir->iterator(); it != dir->end(); ++it ) + { + File *item = *it; + + if( item->isDir() ) + changeNr += include( dynamic_cast( item ), depth + 1 ); + + if( item->isExcluded() ) + { + item->exclude( false ); + emit changed( item ); + changeNr++; + } + } + + if( depth == 0 && changeNr != 0 ) + emit changeFinished(); + + return changeNr; +} + +void DiskUsage::includeAll() +{ + include( root ); + calculateSizes( root, true ); + calculatePercents( true ); + createStatus(); +} + +int DiskUsage::del( File *file, bool calcPercents, int depth ) +{ + int deleteNr = 0; + + if( file == root ) + return 0; + + krConfig->setGroup( "General" ); + bool trash = krConfig->readBoolEntry( "Move To Trash", _MoveToTrash ); + KURL url = vfs::fromPathOrURL( file->fullPath() ); + + if( calcPercents ) + { + // now ask the user if he want to delete: + krConfig->setGroup( "Advanced" ); + if ( krConfig->readBoolEntry( "Confirm Delete", _ConfirmDelete ) ) { + TQString s, b; + if ( trash && url.isLocalFile() ) { + s = i18n( "Do you really want to move this item to the trash?" ); + b = i18n( "&Trash" ); + } else { + s = i18n( "Do you really want to delete this item?" ); + b = i18n( "&Delete" ); + } + + TQStringList name; + name.append( file->fullPath() ); + // show message + // note: i'm using continue and not yes/no because the yes/no has cancel as default button + if ( KMessageBox::warningContinueCancelList( krApp, s, name, i18n( "Warning" ), b ) != KMessageBox::Continue ) + return 0; + } + + emit status( i18n( "Deleting %1..." ).arg( file->name() ) ); + } + + if( file == currentDirectory ) + dirUp(); + + if( file->isDir() ) + { + Directory *dir = dynamic_cast( file ); + + Iterator it; + while( ( it = dir->iterator() ) != dir->end() ) + deleteNr += del( *it, false, depth + 1 ); + + TQString path; + for( const Directory *d = (Directory*)file; d != root && d && d->parent() != 0; d = d->parent() ) + { + if( !path.isEmpty() ) + path = "/" + path; + + path = d->name() + path; + } + + contentMap.remove( path ); + } + + emit deleted( file ); + deleteNr++; + + TQGuardedPtr job; + + if( trash ) + { +#if KDE_IS_VERSION(3,4,0) + job = TDEIO::trash( url, true ); +#else + job = new TDEIO::CopyJob( url,TDEGlobalSettings::trashPath(),TDEIO::CopyJob::Move,false,true ); +#endif + connect(job,TQ_SIGNAL(result(TDEIO::Job*)),krApp,TQ_SLOT(changeTrashIcon())); + } + else + { + job = new TDEIO::DeleteJob( vfs::fromPathOrURL( file->fullPath() ), false, false); + } + + deleting = true; // during tqApp->processEvent strange things can occur + grabMouse(); // that's why we disable the mouse and keyboard events + grabKeyboard(); + + while( !job.isNull() ) + tqApp->processEvents(); + + releaseMouse(); + releaseKeyboard(); + deleting = false; + + ((Directory *)(file->parent()))->remove( file ); + delete file; + + if( depth == 0 ) + createStatus(); + + if( calcPercents ) + { + calculateSizes( root, true ); + calculatePercents( true ); + createStatus(); + emit enteringDirectory( currentDirectory ); + } + + if( depth == 0 && deleteNr != 0 ) + emit deleteFinished(); + + return deleteNr; +} + +void * DiskUsage::getProperty( File *item, TQString key ) +{ + Properties * props = propertyMap.find( item ); + if( props == 0 ) + return 0; + return props->find( key ); +} + +void DiskUsage::addProperty( File *item, TQString key, void * prop ) +{ + Properties * props = propertyMap.find( item ); + if( props == 0 ) + { + props = new Properties(); + propertyMap.insert( item, props ); + } + props->insert( key, prop ); +} + +void DiskUsage::removeProperty( File *item, TQString key ) +{ + Properties * props = propertyMap.find( item ); + if( props == 0 ) + return; + props->remove( key ); + if( props->count() == 0 ) + propertyMap.remove( item ); +} + +void DiskUsage::createStatus() +{ + Directory *dirEntry = currentDirectory; + + if( dirEntry == 0 ) + return; + + KURL url = baseURL; + if( dirEntry != root ) + url.addPath( dirEntry->directory() ); + + emit status( i18n( "Current directory:%1, Total size:%2, Own size:%3" ) + .arg( vfs::pathOrURL( url, -1 ) ) + .arg( " "+KRpermHandler::parseSize( dirEntry->size() ) ) + .arg( " "+KRpermHandler::parseSize( dirEntry->ownSize() ) ) ); +} + +void DiskUsage::changeDirectory( Directory *dir ) +{ + currentDirectory = dir; + + currentSize = dir->size(); + calculatePercents( true, dir ); + + createStatus(); + emit enteringDirectory( dir ); +} + +Directory* DiskUsage::getCurrentDir() +{ + return currentDirectory; +} + +void DiskUsage::rightClickMenu( File *fileItem, TDEPopupMenu *addPopup, TQString addPopupName ) +{ + TDEPopupMenu popup( this ); + + popup.insertTitle( i18n("Disk Usage")); + + if( fileItem != 0 ) + { + popup.insertItem( i18n("Delete"), DELETE_ID); + popup.setAccel( Key_Delete, DELETE_ID ); + popup.insertItem( i18n("Exclude"), EXCLUDE_ID); + popup.setAccel( CTRL + Key_E, EXCLUDE_ID ); + popup.insertSeparator(); + } + + popup.insertItem( i18n("Up one directory"), PARENT_DIR_ID); + popup.setAccel( SHIFT + Key_Up, PARENT_DIR_ID ); + popup.insertItem( i18n("New search"), NEW_SEARCH_ID); + popup.setAccel( CTRL + Key_N, NEW_SEARCH_ID ); + popup.insertItem( i18n("Refresh"), REFRESH_ID); + popup.setAccel( CTRL + Key_R, REFRESH_ID ); + popup.insertItem( i18n("Include all"), INCLUDE_ALL_ID); + popup.setAccel( CTRL + Key_I, INCLUDE_ALL_ID ); + popup.insertItem( i18n("Step into"), STEP_INTO_ID); + popup.setAccel( SHIFT + Key_Down, STEP_INTO_ID ); + popup.insertSeparator(); + + + if( addPopup != 0 ) + { + popup.insertItem( TQPixmap(), addPopup, ADDITIONAL_POPUP_ID ); + popup.changeItem( ADDITIONAL_POPUP_ID, addPopupName ); + } + + TDEPopupMenu viewPopup; + viewPopup.insertItem(i18n("Lines"), LINES_VIEW_ID); + viewPopup.setAccel( CTRL + Key_L, LINES_VIEW_ID ); + viewPopup.insertItem(i18n("Detailed"), DETAILED_VIEW_ID); + viewPopup.setAccel( CTRL + Key_D, DETAILED_VIEW_ID ); + viewPopup.insertItem(i18n("Filelight"), FILELIGHT_VIEW_ID); + viewPopup.setAccel( CTRL + Key_F, FILELIGHT_VIEW_ID ); + viewPopup.insertSeparator(); + viewPopup.insertItem(i18n("Next"), NEXT_VIEW_ID); + viewPopup.setAccel( SHIFT + Key_Right, NEXT_VIEW_ID ); + viewPopup.insertItem(i18n("Previous"), PREVIOUS_VIEW_ID); + viewPopup.setAccel( SHIFT + Key_Left, PREVIOUS_VIEW_ID ); + + popup.insertItem( TQPixmap(), &viewPopup, VIEW_POPUP_ID ); + popup.changeItem( VIEW_POPUP_ID, i18n( "View" ) ); + + int result=popup.exec(TQCursor::pos()); + + executeAction( result, fileItem ); +} + +void DiskUsage::executeAction( int action, File * fileItem ) +{ + // check out the user's option + switch ( action ) + { + case DELETE_ID: + if( fileItem ) + del( fileItem ); + break; + case EXCLUDE_ID: + if( fileItem ) + exclude( fileItem ); + break; + case PARENT_DIR_ID: + dirUp(); + break; + case NEW_SEARCH_ID: + emit newSearch(); + break; + case REFRESH_ID: + load( baseURL ); + break; + case INCLUDE_ALL_ID: + includeAll(); + break; + case STEP_INTO_ID: + { + TQString uri; + if( fileItem && fileItem->isDir() ) + uri = fileItem->fullPath(); + else + uri = currentDirectory->fullPath(); + ACTIVE_FUNC->openUrl(vfs::fromPathOrURL( uri )); + } + break; + case LINES_VIEW_ID: + setView( VIEW_LINES ); + break; + case DETAILED_VIEW_ID: + setView( VIEW_DETAILED ); + break; + case FILELIGHT_VIEW_ID: + setView( VIEW_FILELIGHT ); + break; + case NEXT_VIEW_ID: + setView( ( activeView + 1 ) % 3 ); + break; + case PREVIOUS_VIEW_ID: + setView( ( activeView + 2 ) % 3 ); + break; + } + visibleWidget()->setFocus(); +} + +void DiskUsage::keyPressEvent( TQKeyEvent *e ) +{ + if( activeView != VIEW_LOADER ) + { + switch ( e->key() ) + { + case Key_E: + if( e->state() == ControlButton ) + { + executeAction( EXCLUDE_ID, getCurrentFile() ); + return; + } + case Key_D: + if( e->state() == ControlButton ) + { + executeAction( DETAILED_VIEW_ID ); + return; + } + case Key_F: + if( e->state() == ControlButton ) + { + executeAction( FILELIGHT_VIEW_ID ); + return; + } + case Key_I: + if( e->state() == ControlButton ) + { + executeAction( INCLUDE_ALL_ID ); + return; + } + break; + case Key_L: + if( e->state() == ControlButton ) + { + executeAction( LINES_VIEW_ID ); + return; + } + case Key_N: + if( e->state() == ControlButton ) + { + executeAction( NEW_SEARCH_ID ); + return; + } + break; + case Key_R: + if( e->state() == ControlButton ) + { + executeAction( REFRESH_ID ); + return; + } + break; + case Key_Up: + if( e->state() == ShiftButton ) + { + executeAction( PARENT_DIR_ID ); + return; + } + break; + case Key_Down: + if( e->state() == ShiftButton ) + { + executeAction( STEP_INTO_ID ); + return; + } + break; + case Key_Left: + if( e->state() == ShiftButton ) + { + executeAction( PREVIOUS_VIEW_ID ); + return; + } + break; + case Key_Right: + if( e->state() == ShiftButton ) + { + executeAction( NEXT_VIEW_ID ); + return; + } + break; + case Key_Delete: + if( !e->state() ) + { + executeAction( DELETE_ID, getCurrentFile() ); + return; + } + case Key_Plus: + if( activeView == VIEW_FILELIGHT ) + { + filelightView->zoomIn(); + return; + } + break; + case Key_Minus: + if( activeView == VIEW_FILELIGHT ) + { + filelightView->zoomOut(); + return; + } + break; + } + } + TQWidgetStack::keyPressEvent( e ); +} + +TQPixmap DiskUsage::getIcon( TQString mime ) +{ + TQPixmap icon; + + if ( !TQPixmapCache::find( mime, icon ) ) + { + // get the icon. + if ( mime == "Broken Link !" ) + icon = FL_LOADICON( "file_broken" ); + else + icon = FL_LOADICON( KMimeType::mimeType( mime ) ->icon( TQString(), true ) ); + + // insert it into the cache + TQPixmapCache::insert( mime, icon ); + } + return icon; +} + +int DiskUsage::calculatePercents( bool emitSig, Directory *dirEntry, int depth ) +{ + int changeNr = 0; + + if( dirEntry == 0 ) + dirEntry = root; + + for( Iterator it = dirEntry->iterator(); it != dirEntry->end(); ++it ) + { + File *item = *it; + + if( !item->isExcluded() ) + { + int newPerc; + + if( dirEntry->size() == 0 && item->size() == 0 ) + newPerc = 0; + else if( dirEntry->size() == 0 ) + newPerc = -1; + else + newPerc = (int)((double)item->size() / (double)currentSize * 10000. + 0.5); + + int oldPerc = item->intPercent(); + item->setPercent( newPerc ); + + if( emitSig && newPerc != oldPerc ) { + emit changed( item ); + changeNr++; + } + + if( item->isDir() ) + changeNr += calculatePercents( emitSig, dynamic_cast( item ), depth + 1 ); + } + } + + if( depth == 0 && changeNr != 0 ) + emit changeFinished(); + return changeNr; +} + +TQString DiskUsage::getToolTip( File *item ) +{ + KMimeType::Ptr mimePtr = KMimeType::mimeType( item->mime() ); + TQString mime = mimePtr->comment(); + + time_t tma = item->time(); + struct tm* t=localtime((time_t *)&tma); + TQDateTime tmp(TQDate(t->tm_year+1900, t->tm_mon+1, t->tm_mday), TQTime(t->tm_hour, t->tm_min)); + TQString date = TDEGlobal::locale()->formatDateTime(tmp); + + TQString str = "
"+ + ""+ + ""; + + if( item->isDir() ) + str += ""; + + str += ""+ + ""+ + ""+ + "
" + i18n( "Name:" ) + "" + item->name() + "
" + i18n( "Type:" ) + "" + mime + "
" + i18n( "Size:" ) + "" + KRpermHandler::parseSize( item->size() ) + "
" + i18n( "Own size:" ) + "" + KRpermHandler::parseSize( item->ownSize() ) + "
" + i18n( "Last modified:" ) + "" + date + "
" + i18n( "Permissions:" ) + "" + item->perm() + "
" + i18n( "Owner:" ) + "" + item->owner() + " - " + item->group() + "
"; + str.replace( " ", " " ); + return str; +} + +void DiskUsage::setView( int view ) +{ + switch( view ) + { + case VIEW_LINES: + raiseWidget( lineView ); + break; + case VIEW_DETAILED: + raiseWidget( listView ); + break; + case VIEW_FILELIGHT: + raiseWidget( filelightView ); + break; + case VIEW_LOADER: + raiseWidget( loaderView ); + break; + } + + visibleWidget()->setFocus(); + emit viewChanged( activeView = view ); +} + +File * DiskUsage::getCurrentFile() +{ + File * file = 0; + + switch( activeView ) + { + case VIEW_LINES: + file = lineView->getCurrentFile(); + break; + case VIEW_DETAILED: + file = listView->getCurrentFile(); + break; + case VIEW_FILELIGHT: + file = filelightView->getCurrentFile(); + break; + } + + return file; +} + +bool DiskUsage::event( TQEvent * e ) +{ + if( deleting ) { // if we are deleting, disable the mouse and + switch( e->type() ) { // keyboard events + case TQEvent::MouseButtonPress: + case TQEvent::MouseButtonRelease: + case TQEvent::MouseButtonDblClick: + case TQEvent::MouseMove: + case TQEvent::KeyPress: + case TQEvent::KeyRelease: + return true; + default: + break; + } + } + + if ( e->type() == TQEvent::AccelOverride ) + { + TQKeyEvent* ke = (TQKeyEvent*) e; + + if ( ke->state() == TQt::NoButton || ke->state() == Keypad ) + { + switch ( ke->key() ) + { + case Key_Delete: + case Key_Plus: + case Key_Minus: + ke->accept(); + break; + } + }else if( ke->state() == ShiftButton ) + { + switch ( ke->key() ) + { + case Key_Left: + case Key_Right: + case Key_Up: + case Key_Down: + ke->accept(); + break; + } + }else if ( ke->state() & ControlButton ) + { + switch ( ke->key() ) + { + case Key_D: + case Key_E: + case Key_F: + case Key_I: + case Key_L: + case Key_N: + case Key_R: + ke->accept(); + break; + } + } + } + return TQWidgetStack::event( e ); +} + +#include "diskusage.moc" diff --git a/src/app/DiskUsage/diskusage.h b/src/app/DiskUsage/diskusage.h new file mode 100644 index 0000000..ae70bdd --- /dev/null +++ b/src/app/DiskUsage/diskusage.h @@ -0,0 +1,206 @@ +/*************************************************************************** + diskusage.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 __DISK_USAGE_H__ +#define __DISK_USAGE_H__ + +#include "../VFS/vfs.h" +#include "filelightParts/fileTree.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define VIEW_LINES 0 +#define VIEW_DETAILED 1 +#define VIEW_FILELIGHT 2 +#define VIEW_LOADER 3 + +typedef TQDict Properties; + +class DUListView; +class DULines; +class DUFilelight; +class TDEPopupMenu; +class LoaderWidget; + +class DiskUsage : public TQWidgetStack +{ + TQ_OBJECT + + +public: + DiskUsage( TQString confGroup, TQWidget *parent = 0, char *name = 0); + ~DiskUsage(); + + void load( KURL dirName ); + void close(); + void stopLoad(); + bool isLoading() { return loading; } + + void setView( int view ); + int getActiveView() { return activeView; } + + Directory* getDirectory( TQString path ); + File * getFile( TQString path ); + + TQString getConfigGroup() { return configGroup; } + + void * getProperty( File *, TQString ); + void addProperty( File *, TQString, void * ); + void removeProperty( File *, TQString ); + + int exclude( File *file, bool calcPercents = true, int depth = 0 ); + void includeAll(); + + int del( File *file, bool calcPercents = true, int depth = 0 ); + + TQString getToolTip( File * ); + + void rightClickMenu( File *, TDEPopupMenu * = 0, TQString = TQString() ); + + void changeDirectory( Directory *dir ); + + Directory* getCurrentDir(); + File* getCurrentFile(); + + TQPixmap getIcon( TQString mime ); + + KURL getBaseURL() { return baseURL; } + +public slots: + void dirUp(); + void clear(); + +signals: + void enteringDirectory( Directory * ); + void clearing(); + void changed( File * ); + void changeFinished(); + void deleted( File * ); + void deleteFinished(); + void status( TQString ); + void viewChanged( int ); + void loadFinished( bool ); + void newSearch(); + +protected slots: + void slotLoadDirectory(); + +protected: + TQDict< Directory > contentMap; + TQPtrDict propertyMap; + + Directory* currentDirectory; + TDEIO::filesize_t currentSize; + + virtual void keyPressEvent( TQKeyEvent * ); + virtual bool event( TQEvent * ); + + int calculateSizes( Directory *dir = 0, bool emitSig = false, int depth = 0 ); + int calculatePercents( bool emitSig = false, Directory *dir = 0 , int depth = 0 ); + int include( Directory *dir, int depth = 0 ); + void createStatus(); + void executeAction( int, File * = 0 ); + + KURL baseURL; //< the base URL of loading + + DUListView *listView; + DULines *lineView; + DUFilelight *filelightView; + LoaderWidget *loaderView; + + Directory *root; + + int activeView; + + TQString configGroup; + + bool first; + bool loading; + bool abortLoading; + bool clearAfterAbort; + bool deleting; + + TQValueStack directoryStack; + TQPtrStack parentStack; + + vfs * searchVfs; + vfile * currentVfile; + Directory * currentParent; + TQString dirToCheck; + + int fileNum; + int dirNum; + int viewBeforeLoad; + + TQTimer loadingTimer; +}; + + +class LoaderWidget : public TQScrollView +{ + TQ_OBJECT + + +public: + LoaderWidget( TQWidget *parent = 0, const char *name = 0 ); + + void init(); + void setCurrentURL( KURL url ); + void setValues( int fileNum, int dirNum, TDEIO::filesize_t total ); + bool wasCancelled() { return cancelled; } + +public slots: + void slotCancelled(); + +protected: + virtual void resizeEvent ( TQResizeEvent *e ); + + TQLabel *totalSize; + TQLabel *files; + TQLabel *directories; + + KSqueezedTextLabel *searchedDirectory; + TQWidget *widget; + + bool cancelled; +}; + +#endif /* __DISK_USAGE_GUI_H__ */ diff --git a/src/app/DiskUsage/diskusagegui.cpp b/src/app/DiskUsage/diskusagegui.cpp new file mode 100644 index 0000000..28b52ce --- /dev/null +++ b/src/app/DiskUsage/diskusagegui.cpp @@ -0,0 +1,227 @@ +/*************************************************************************** + diskusagegui.cpp - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "diskusagegui.h" +#include "../kicons.h" +#include "../krusader.h" +#include "../VFS/vfs.h" +#include "../Dialogs/krdialogs.h" + +#include +#include +#include +#include + +DiskUsageGUI::DiskUsageGUI( KURL openDir, TQWidget* parent, const char *name ) + : TQDialog( parent, name, false, 0 ), exitAtFailure( true ) +{ + setCaption( i18n("Krusader::Disk Usage") ); + + baseDirectory = openDir; + if( !newSearch() ) + return; + + TQGridLayout *duGrid = new TQGridLayout( this ); + duGrid->setSpacing( 6 ); + duGrid->setMargin( 11 ); + + TQHBox *duTools = new TQHBox( this, "duTools" ); + duTools->setSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ); + + btnNewSearch = new TQToolButton( duTools, "btnNewSearch" ); + btnNewSearch->setIconSet( TQIconSet(krLoader->loadIcon("document-open",TDEIcon::Desktop)) ); + TQToolTip::add( btnNewSearch, i18n( "Start new disk usage search" ) ); + + btnRefresh = new TQToolButton( duTools, "btnRefresh" ); + btnRefresh->setIconSet( TQIconSet(krLoader->loadIcon("reload",TDEIcon::Desktop)) ); + TQToolTip::add( btnRefresh, i18n( "Refresh" ) ); + + btnDirUp = new TQToolButton( duTools, "btnDirUp" ); + btnDirUp->setIconSet( TQIconSet(krLoader->loadIcon("go-up",TDEIcon::Desktop)) ); + TQToolTip::add( btnDirUp, i18n( "Parent directory" ) ); + + TQWidget * separatorWidget = new TQWidget( duTools, "separatorWidget" ); + separatorWidget->setMinimumWidth( 10 ); + + btnLines = new TQToolButton( duTools, "btnLines" ); + btnLines->setIconSet( TQIconSet(krLoader->loadIcon("format-justify-left",TDEIcon::Desktop)) ); + btnLines->setToggleButton( true ); + TQToolTip::add( btnLines, i18n( "Line view" ) ); + + btnDetailed = new TQToolButton( duTools, "btnDetailed" ); + btnDetailed->setIconSet( TQIconSet(krLoader->loadIcon("view_detailed",TDEIcon::Desktop)) ); + btnDetailed->setToggleButton( true ); + TQToolTip::add( btnDetailed, i18n( "Detailed view" ) ); + + btnFilelight = new TQToolButton( duTools, "btnFilelight" ); + btnFilelight->setIconSet( TQIconSet(krLoader->loadIcon("kr_diskusage",TDEIcon::Desktop)) ); + btnFilelight->setToggleButton( true ); + TQToolTip::add( btnFilelight, i18n( "Filelight view" ) ); + + TQWidget *spacerWidget = new TQWidget( duTools, "spacerWidget" ); + TQHBoxLayout *hboxlayout = new TQHBoxLayout( spacerWidget ); + TQSpacerItem* spacer = new TQSpacerItem( 0, 0, TQSizePolicy::Expanding, TQSizePolicy::Fixed ); + hboxlayout->addItem( spacer ); + + duGrid->addWidget( duTools, 0, 0 ); + + diskUsage = new DiskUsage( "DiskUsage", this ); + duGrid->addWidget( diskUsage, 1, 0 ); + + status = new KSqueezedTextLabel( this ); + status->setFrameShape( TQLabel::StyledPanel ); + status->setFrameShadow( TQLabel::Sunken ); + duGrid->addWidget( status, 2, 0 ); + + connect( diskUsage, TQ_SIGNAL( status( TQString ) ), this, TQ_SLOT( setStatus( TQString ) ) ); + connect( diskUsage, TQ_SIGNAL( viewChanged( int ) ), this, TQ_SLOT( slotViewChanged( int ) ) ); + connect( diskUsage, TQ_SIGNAL( newSearch() ), this, TQ_SLOT( newSearch() ) ); + connect( diskUsage, TQ_SIGNAL( loadFinished( bool ) ), this, TQ_SLOT( slotLoadFinished( bool ) ) ); + connect( btnNewSearch, TQ_SIGNAL( clicked() ), this, TQ_SLOT( newSearch() ) ); + connect( btnRefresh, TQ_SIGNAL( clicked() ), this, TQ_SLOT( loadUsageInfo() ) ); + connect( btnDirUp, TQ_SIGNAL( clicked() ), diskUsage, TQ_SLOT( dirUp() ) ); + connect( btnLines, TQ_SIGNAL( clicked() ), this, TQ_SLOT( selectLinesView() ) ); + connect( btnDetailed, TQ_SIGNAL( clicked() ), this, TQ_SLOT( selectListView() ) ); + connect( btnFilelight, TQ_SIGNAL( clicked() ), this, TQ_SLOT( selectFilelightView() ) ); + + krConfig->setGroup( "DiskUsage" ); + + int view = krConfig->readNumEntry( "View", VIEW_LINES ); + if( view < VIEW_LINES || view > VIEW_FILELIGHT ) + view = VIEW_LINES; + diskUsage->setView( view ); + + sizeX = krConfig->readNumEntry( "Window Width", TQFontMetrics(font()).width("W") * 70 ); + sizeY = krConfig->readNumEntry( "Window Height", TQFontMetrics(font()).height() * 25 ); + resize( sizeX, sizeY ); + + if( krConfig->readBoolEntry( "Window Maximized", false ) ) + showMaximized(); + else + show(); + + exec(); +} + +DiskUsageGUI::~DiskUsageGUI() +{ +} + +void DiskUsageGUI::slotLoadFinished( bool result ) +{ + if( exitAtFailure && !result ) + reject(); + else + exitAtFailure = false; +} + +void DiskUsageGUI::enableButtons( bool isOn ) +{ + btnNewSearch->setEnabled( isOn ); + btnRefresh->setEnabled( isOn ); + btnDirUp->setEnabled( isOn ); + btnLines->setEnabled( isOn ); + btnDetailed->setEnabled( isOn ); + btnFilelight->setEnabled( isOn ); +} + +void DiskUsageGUI::resizeEvent( TQResizeEvent *e ) +{ + if( !isMaximized() ) + { + sizeX = e->size().width(); + sizeY = e->size().height(); + } + TQDialog::resizeEvent( e ); +} + +void DiskUsageGUI::reject() +{ + krConfig->setGroup( "DiskUsage" ); + krConfig->writeEntry("Window Width", sizeX ); + krConfig->writeEntry("Window Height", sizeY ); + krConfig->writeEntry("Window Maximized", isMaximized() ); + krConfig->writeEntry("View", diskUsage->getActiveView() ); + + TQDialog::reject(); +} + +void DiskUsageGUI::loadUsageInfo() +{ + diskUsage->load( baseDirectory ); +} + +void DiskUsageGUI::setStatus( TQString stat ) +{ + status->setText( stat ); +} + +void DiskUsageGUI::slotViewChanged( int view ) +{ + if( view == VIEW_LOADER ) + { + enableButtons( false ); + return; + } + enableButtons( true ); + + btnLines->setOn( false ); + btnDetailed->setOn( false ); + btnFilelight->setOn( false ); + + switch( view ) + { + case VIEW_LINES: + btnLines->setOn( true ); + break; + case VIEW_DETAILED: + btnDetailed->setOn( true ); + break; + case VIEW_FILELIGHT: + btnFilelight->setOn( true ); + break; + case VIEW_LOADER: + break; + } +} + +bool DiskUsageGUI::newSearch() +{ + // ask the user for the copy dest + + KURL tmp = KChooseDir::getDir(i18n( "Viewing the usage of directory:" ), baseDirectory, baseDirectory); + if (tmp.isEmpty()) return false; + baseDirectory = tmp; + + TQTimer::singleShot( 0, this, TQ_SLOT( loadUsageInfo() ) ); + return true; +} + +#include "diskusagegui.moc" diff --git a/src/app/DiskUsage/diskusagegui.h b/src/app/DiskUsage/diskusagegui.h new file mode 100644 index 0000000..1c75a79 --- /dev/null +++ b/src/app/DiskUsage/diskusagegui.h @@ -0,0 +1,90 @@ +/*************************************************************************** + diskusagegui.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 __DISK_USAGE_GUI_H__ +#define __DISK_USAGE_GUI_H__ + +#include +#include +#include +#include +#include + +#include "diskusage.h" + +class DiskUsageGUI : public TQDialog +{ + TQ_OBJECT + + +public: + DiskUsageGUI( KURL openDir, TQWidget* parent=0, const char *name = 0 ); + ~DiskUsageGUI(); + + +public slots: + void loadUsageInfo(); + bool newSearch(); + void setStatus( TQString ); + + void selectLinesView() { diskUsage->setView( VIEW_LINES ); } + void selectListView() { diskUsage->setView( VIEW_DETAILED ); } + void selectFilelightView() { diskUsage->setView( VIEW_FILELIGHT ); } + +protected slots: + virtual void reject(); + void slotViewChanged( int view ); + void enableButtons( bool ); + void slotLoadFinished( bool ); + +protected: + virtual void resizeEvent( TQResizeEvent *e ); + + DiskUsage *diskUsage; + KURL baseDirectory; + + KSqueezedTextLabel *status; + + TQToolButton *btnNewSearch; + TQToolButton *btnRefresh; + TQToolButton *btnDirUp; + + TQToolButton *btnLines; + TQToolButton *btnDetailed; + TQToolButton *btnFilelight; + + int sizeX; + int sizeY; + + bool exitAtFailure; +}; + +#endif /* __DISK_USAGE_GUI_H__ */ + diff --git a/src/app/DiskUsage/dufilelight.cpp b/src/app/DiskUsage/dufilelight.cpp new file mode 100644 index 0000000..debdb06 --- /dev/null +++ b/src/app/DiskUsage/dufilelight.cpp @@ -0,0 +1,236 @@ +/*************************************************************************** + dufilelight.cpp - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "dufilelight.h" +#include "radialMap/radialMap.h" +#include +#include +#include + +#define SCHEME_POPUP_ID 6730 + +DUFilelight::DUFilelight( DiskUsage *usage, const char *name ) + : RadialMap::Widget( usage, name ), diskUsage( usage ), currentDir( 0 ), refreshNeeded( true ) +{ + setFocusPolicy( TQWidget::StrongFocus ); + + connect( diskUsage, TQ_SIGNAL( enteringDirectory( Directory * ) ), this, TQ_SLOT( slotDirChanged( Directory * ) ) ); + connect( diskUsage, TQ_SIGNAL( clearing() ), this, TQ_SLOT( clear() ) ); + connect( diskUsage, TQ_SIGNAL( changed( File * ) ), this, TQ_SLOT( slotChanged( File * ) ) ); + connect( diskUsage, TQ_SIGNAL( deleted( File * ) ), this, TQ_SLOT( slotChanged( File * ) ) ); + connect( diskUsage, TQ_SIGNAL( changeFinished() ), this, TQ_SLOT( slotRefresh() ) ); + connect( diskUsage, TQ_SIGNAL( deleteFinished() ), this, TQ_SLOT( slotRefresh() ) ); + connect( diskUsage, TQ_SIGNAL( aboutToShow( TQWidget * ) ), this, TQ_SLOT( slotAboutToShow( TQWidget * ) ) ); +} + +void DUFilelight::slotDirChanged( Directory *dir ) +{ + if( diskUsage->visibleWidget() != this ) + return; + + if( currentDir != dir ) + { + currentDir = dir; + + invalidate( false ); + create( dir ); + refreshNeeded = false; + } +} + +void DUFilelight::clear() +{ + invalidate( false ); + currentDir = 0; +} + +File * DUFilelight::getCurrentFile() +{ + const RadialMap::Segment * focus = focusSegment(); + + if( !focus || focus->isFake() || focus->file() == currentDir ) + return 0; + + return (File *)focus->file(); +} + +void DUFilelight::mousePressEvent( TQMouseEvent *event ) +{ + if( event->button() == TQt::RightButton ) + { + File * file = 0; + + const RadialMap::Segment * focus = focusSegment(); + + if( focus && !focus->isFake() && focus->file() != currentDir ) + file = (File *)focus->file(); + + TDEPopupMenu filelightPopup; + filelightPopup.insertItem( i18n("Zoom In"), this, TQ_SLOT( zoomIn() ), Key_Plus ); + filelightPopup.insertItem( i18n("Zoom Out"), this, TQ_SLOT( zoomOut() ), Key_Minus ); + + TDEPopupMenu schemePopup; + schemePopup.insertItem( i18n("Rainbow"), this, TQ_SLOT( schemeRainbow() ) ); + schemePopup.insertItem( i18n("High Contrast"), this, TQ_SLOT( schemeHighContrast() ) ); + schemePopup.insertItem( i18n("TDE"), this, TQ_SLOT( schemeKDE() ) ); + + filelightPopup.insertItem( TQPixmap(), &schemePopup, SCHEME_POPUP_ID ); + filelightPopup.changeItem( SCHEME_POPUP_ID, i18n( "Scheme" ) ); + + filelightPopup.insertItem( i18n("Increase contrast"), this, TQ_SLOT( increaseContrast() ) ); + filelightPopup.insertItem( i18n("Decrease contrast"), this, TQ_SLOT( decreaseContrast() ) ); + + int aid = filelightPopup.insertItem( i18n("Use anti-aliasing" ), this, TQ_SLOT( changeAntiAlias() ) ); + filelightPopup.setItemChecked( aid, Filelight::Config::antiAliasFactor > 1 ); + + int sid = filelightPopup.insertItem( i18n("Show small files" ), this, TQ_SLOT( showSmallFiles() ) ); + filelightPopup.setItemChecked( sid, Filelight::Config::showSmallFiles ); + + int vid = filelightPopup.insertItem( i18n("Vary label font sizes" ), this, TQ_SLOT( varyLabelFontSizes() ) ); + filelightPopup.setItemChecked( vid, Filelight::Config::varyLabelFontSizes ); + + filelightPopup.insertItem( i18n("Minimum font size"), this, TQ_SLOT( minFontSize() ) ); + + diskUsage->rightClickMenu( file, &filelightPopup, i18n( "Filelight" ) ); + return; + }else if( event->button() == TQt::LeftButton ) + { + const RadialMap::Segment * focus = focusSegment(); + + if( focus && !focus->isFake() && focus->file() == currentDir ) + { + diskUsage->dirUp(); + return; + } + else if( focus && !focus->isFake() && focus->file()->isDir() ) + { + diskUsage->changeDirectory( (Directory *)focus->file() ); + return; + } + } + + RadialMap::Widget::mousePressEvent( event ); +} + +void DUFilelight::setScheme( Filelight::MapScheme scheme ) +{ + Filelight::Config::scheme = scheme; + Filelight::Config::write(); + slotRefresh(); +} + +void DUFilelight::increaseContrast() +{ + if( ( Filelight::Config::contrast += 10 ) > 100 ) + Filelight::Config::contrast = 100; + + Filelight::Config::write(); + slotRefresh(); +} + +void DUFilelight::decreaseContrast() +{ + if( ( Filelight::Config::contrast -= 10 ) > 100 ) + Filelight::Config::contrast = 0; + + Filelight::Config::write(); + slotRefresh(); +} + +void DUFilelight::changeAntiAlias() +{ + Filelight::Config::antiAliasFactor = 1 + ( Filelight::Config::antiAliasFactor == 1 ); + Filelight::Config::write(); + slotRefresh(); +} + +void DUFilelight::showSmallFiles() +{ + Filelight::Config::showSmallFiles = !Filelight::Config::showSmallFiles; + Filelight::Config::write(); + slotRefresh(); +} + +void DUFilelight::varyLabelFontSizes() +{ + Filelight::Config::varyLabelFontSizes = !Filelight::Config::varyLabelFontSizes; + Filelight::Config::write(); + slotRefresh(); +} + +void DUFilelight::minFontSize() +{ + bool ok = false; + + int result = KInputDialog::getInteger( i18n( "Krusader::Filelight" ), + i18n( "Minimum font size" ), (int)Filelight::Config::minFontPitch, 1, 100, 1, &ok, this ); + + if ( ok ) + { + Filelight::Config::minFontPitch = (uint)result; + + Filelight::Config::write(); + slotRefresh(); + } +} + +void DUFilelight::slotAboutToShow( TQWidget *widget ) +{ + if( widget == this && ( diskUsage->getCurrentDir() != currentDir || refreshNeeded ) ) + { + refreshNeeded = false; + if( ( currentDir = diskUsage->getCurrentDir() ) != 0 ) + { + invalidate( false ); + create( currentDir ); + } + } +} + +void DUFilelight::slotRefresh() +{ + if( diskUsage->visibleWidget() != this ) + return; + + refreshNeeded = false; + if( currentDir && currentDir == diskUsage->getCurrentDir() ) + { + invalidate( false ); + create( currentDir ); + } +} + +void DUFilelight::slotChanged( File * ) +{ + if( !refreshNeeded ) + refreshNeeded = true; +} + +#include "dufilelight.moc" diff --git a/src/app/DiskUsage/dufilelight.h b/src/app/DiskUsage/dufilelight.h new file mode 100644 index 0000000..9ef8ccb --- /dev/null +++ b/src/app/DiskUsage/dufilelight.h @@ -0,0 +1,81 @@ +/*************************************************************************** + dufilelight.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 __DU_FILELIGHT_H__ +#define __DU_FILELIGHT_H__ + +#include "diskusage.h" +#include "radialMap/widget.h" +#include "filelightParts/Config.h" + +class DUFilelight : public RadialMap::Widget +{ + TQ_OBJECT + + +public: + DUFilelight( DiskUsage *usage, const char *name ); + + File * getCurrentFile(); + +public slots: + void slotDirChanged( Directory * ); + void clear(); + void slotChanged( File * ); + void slotRefresh(); + +protected slots: + void slotAboutToShow( TQWidget *widget ); + + void schemeRainbow() { setScheme( Filelight::Rainbow ); } + void schemeHighContrast() { setScheme( Filelight::HighContrast ); } + void schemeKDE() { setScheme( Filelight::KDE ); } + + void increaseContrast(); + void decreaseContrast(); + void changeAntiAlias(); + void showSmallFiles(); + void varyLabelFontSizes(); + void minFontSize(); + +protected: + virtual void mousePressEvent( TQMouseEvent* ); + + void setScheme( Filelight::MapScheme ); + + DiskUsage *diskUsage; + Directory *currentDir; + +private: + bool refreshNeeded; +}; + +#endif /* __DU_FILELIGHT_H__ */ + diff --git a/src/app/DiskUsage/dulines.cpp b/src/app/DiskUsage/dulines.cpp new file mode 100644 index 0000000..ba10a04 --- /dev/null +++ b/src/app/DiskUsage/dulines.cpp @@ -0,0 +1,522 @@ +/*************************************************************************** + dulines.cpp - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "dulines.h" +#include "../kicons.h" +#include "../krusader.h" +#include "../VFS/krpermhandler.h" +#include +#include +#include +#include +#include +#include +#include +#include + +class DULinesItem : public TQListViewItem +{ +public: + DULinesItem( DiskUsage *diskUsageIn, File *fileItem, TQListView * parent, TQString label1, + TQString label2, TQString label3, unsigned int italicPos ) : TQListViewItem( parent, label1, label2, label3 ), + diskUsage( diskUsageIn ), file( fileItem ), isTruncated( false ), italicTextPos( italicPos ) {} + DULinesItem( DiskUsage *diskUsageIn, File *fileItem, TQListView * parent, TQListViewItem * after, + TQString label1, TQString label2, TQString label3, unsigned int italicPos ) : TQListViewItem( parent, after, label1, + label2, label3 ), diskUsage( diskUsageIn ), file( fileItem ), isTruncated( false ), italicTextPos( italicPos ) {} + + virtual int compare ( TQListViewItem * i, int col, bool ascending ) const + { + if( text(0) == ".." ) return ascending ? -1 : 1; + if( i->text(0) == "..") return ascending ? 1 : -1; + + DULinesItem *compWith = dynamic_cast< DULinesItem * >( i ); + + TQString buf1,buf2; + + switch( col ) + { + case 0: + case 1: + buf1.sprintf("%025llu",file->size()); + buf2.sprintf("%025llu",compWith->file->size()); + return -TQString::compare( buf1, buf2 ); + default: + return TQListViewItem::compare( i, col, ascending ); + } + } + + virtual void paintCell( TQPainter * p, const TQColorGroup & cg, int column, int width, int align ) + { + if( column == 2 ) + { + if ( isSelected() ) + p->fillRect( 0, 0, width, height(), cg.brush( TQColorGroup::Highlight ) ); + else + p->fillRect( 0, 0, width, height(), cg.brush( TQColorGroup::Base ) ); + + TQListView *lv = listView(); + + int pos = lv->itemMargin(); + + const TQPixmap *icon = pixmap( column ); + if( icon ) + { + int iconWidth = icon->width() + lv->itemMargin(); + int xo = pos; + int yo = ( height() - icon->height() ) / 2; + + p->drawPixmap( xo, yo, *icon ); + + pos += iconWidth; + } + + TQFontMetrics fm( p->fontMetrics() ); + + if( isSelected() ) + p->setPen( cg.highlightedText() ); + else + p->setPen( cg.text() ); + + TQString t = text( column ); + TQString b; + + if( t.length() > italicTextPos ) + { + b = t.mid( italicTextPos ); + t.truncate( italicTextPos ); + } + + isTruncated = false; + if( !t.isEmpty() ) + { + int remWidth = width-pos; + + if( fm.width( t ) > remWidth ) + { + while( !t.isEmpty() ) + { + t.truncate( t.length() - 1 ); + if( fm.width( t + "..." ) <= remWidth ) + break; + } + t += "..."; + isTruncated = true; + } + + p->drawText( pos, 0, width, height(), align, t ); + pos += fm.width( t ); + } + + if( !b.isEmpty() && !isTruncated ) + { + TQFont font( p->font() ); + font.setItalic( true ); + p->setFont( font ); + + TQFontMetrics fm2( p->fontMetrics() ); + + int remWidth = width-pos; + + if( fm2.width( b ) > remWidth ) + { + while( !b.isEmpty() ) + { + b.truncate( b.length() - 1 ); + if( fm2.width( b + "..." ) <= remWidth ) + break; + } + b += "..."; + isTruncated = true; + } + + p->drawText( pos, 0, width, height(), align, b ); + } + } + else + TQListViewItem::paintCell( p, cg, column, width, align ); + } + + inline File * getFile() { return file; } + +private: + DiskUsage *diskUsage; + File *file; + + bool isTruncated; + unsigned int italicTextPos; +}; + +class DULinesToolTip : public TQToolTip +{ +public: + DULinesToolTip( DiskUsage *usage, TQWidget *parent, TQListView *lv ); + void maybeTip( const TQPoint &pos ); + + virtual ~DULinesToolTip() {} +private: + TQListView *view; + DiskUsage *diskUsage; +}; + +DULinesToolTip::DULinesToolTip( DiskUsage *usage, TQWidget *parent, TQListView *lv ) + : TQToolTip( parent ), view( lv ), diskUsage( usage ) +{ +} + +void DULinesToolTip::maybeTip( const TQPoint &pos ) +{ + TQListViewItem *item = view->itemAt( pos ); + TQPoint contentsPos = view->viewportToContents( pos ); + if ( !item ) + return; + + int col = view->header()->sectionAt( contentsPos.x() ); + + int width = item->width( TQFontMetrics( view->font() ), view, col ); + + TQRect r = view->itemRect( item ); + int headerPos = view->header()->sectionPos( col ); + r.setLeft( headerPos ); + r.setRight( headerPos + view->header()->sectionSize( col ) ); + + if( col != 0 && width > view->columnWidth( col ) ) + tip( r, item->text( col ) ); + else if( col == 1 && item->text( 0 ) != ".." ) + { + File *fileItem = ((DULinesItem *)item)->getFile(); + tip( r, diskUsage->getToolTip( fileItem ) ); + } +} + +DULines::DULines( DiskUsage *usage, const char *name ) + : TQListView( usage, name ), diskUsage( usage ), refreshNeeded( false ) +{ + setAllColumnsShowFocus(true); + setVScrollBarMode(TQScrollView::Auto); + setHScrollBarMode(TQScrollView::Auto); + setShowSortIndicator(true); + setTreeStepSize( 10 ); + + int defaultSize = TQFontMetrics(font()).width("W"); + + krConfig->setGroup( diskUsage->getConfigGroup() ); + + showFileSize = krConfig->readBoolEntry( "L Show File Size", true ); + + int lineWidth = krConfig->readNumEntry("L Line Width", defaultSize * 20 ); + addColumn( i18n("Line View"), lineWidth ); + setColumnWidthMode(0,TQListView::Manual); + int precentWidth = krConfig->readNumEntry("L Percent Width", defaultSize * 6 ); + addColumn( i18n("Percent"), precentWidth ); + setColumnWidthMode(1,TQListView::Manual); + int nameWidth = krConfig->readNumEntry("L Name Width", defaultSize * 20 ); + addColumn( i18n("Name"), nameWidth ); + setColumnWidthMode(2,TQListView::Manual); + + setColumnAlignment( 1, TQt::AlignRight ); + + header()->setStretchEnabled( true, 0 ); + + setSorting( 1 ); + + toolTip = new DULinesToolTip( diskUsage, viewport(), this ); + + connect( diskUsage, TQ_SIGNAL( enteringDirectory( Directory * ) ), this, TQ_SLOT( slotDirChanged( Directory * ) ) ); + connect( diskUsage, TQ_SIGNAL( clearing() ), this, TQ_SLOT( clear() ) ); + + connect( header(), TQ_SIGNAL( sizeChange( int, int, int ) ), this, TQ_SLOT( sectionResized( int ) ) ); + + connect( this, TQ_SIGNAL(rightButtonPressed(TQListViewItem *, const TQPoint &, int)), + this, TQ_SLOT( slotRightClicked(TQListViewItem *) ) ); + connect( diskUsage, TQ_SIGNAL( changed( File * ) ), this, TQ_SLOT( slotChanged( File * ) ) ); + connect( diskUsage, TQ_SIGNAL( deleted( File * ) ), this, TQ_SLOT( slotDeleted( File * ) ) ); +} + +DULines::~DULines() +{ + krConfig->setGroup( diskUsage->getConfigGroup() ); + krConfig->writeEntry("L Line Width", columnWidth( 0 ) ); + krConfig->writeEntry("L Percent Width", columnWidth( 1 ) ); + krConfig->writeEntry("L Name Width", columnWidth( 2 ) ); + krConfig->writeEntry("L Show File Size", showFileSize ); + + delete toolTip; +} + +void DULines::slotDirChanged( Directory *dirEntry ) +{ + clear(); + + TQListViewItem * lastItem = 0; + + if( ! ( dirEntry->parent() == 0 ) ) + { + lastItem = new TQListViewItem( this, ".." ); + lastItem->setPixmap( 0, FL_LOADICON( "go-up" ) ); + lastItem->setSelectable( false ); + } + + int maxPercent = -1; + for( Iterator it = dirEntry->iterator(); it != dirEntry->end(); ++it ) + { + File *item = *it; + if( !item->isExcluded() && item->intPercent() > maxPercent ) + maxPercent = item->intPercent(); + } + + for( Iterator it = dirEntry->iterator(); it != dirEntry->end(); ++it ) + { + File *item = *it; + + TQString fileName = item->name(); + + unsigned int italicStart = fileName.length(); + + if( showFileSize ) + fileName += " [" + TDEIO::convertSize( item->size() ) + "]"; + + if( lastItem == 0 ) + lastItem = new DULinesItem( diskUsage, item, this, "", item->percent() + " ", fileName, italicStart ); + else + lastItem = new DULinesItem( diskUsage, item, this, lastItem, "", item->percent() + " ", fileName, italicStart ); + + if( item->isExcluded() ) + lastItem->setVisible( false ); + + lastItem->setPixmap( 2, diskUsage->getIcon( item->mime() ) ); + lastItem->setPixmap( 0, createPixmap( item->intPercent(), maxPercent, columnWidth( 0 ) - itemMargin() ) ); + } + + setCurrentItem( firstChild() ); +} + +TQPixmap DULines::createPixmap( int percent, int maxPercent, int maxWidth ) +{ + if( percent < 0 || percent > maxPercent || maxWidth < 2 || maxPercent == 0 ) + return TQPixmap(); + maxWidth -= 2; + + int actualWidth = maxWidth*percent/maxPercent; + if( actualWidth == 0 ) + return TQPixmap(); + + TQPen pen; + pen.setColor( TQt::black ); + TQPainter painter; + + int size = TQFontMetrics(font()).height()-2; + TQRect rect( 0, 0, actualWidth, size ); + TQPixmap pixmap( rect.width(), rect.height() ); + + painter.begin( &pixmap ); + painter.setPen( pen ); + + for( int i = 1; i < actualWidth - 1; i++ ) + { + int color = (511*i/maxWidth); + if( color < 256 ) + pen.setColor( TQColor( 255-color, 255, 0 ) ); + else + pen.setColor( TQColor( color-256, 511-color, 0 ) ); + + painter.setPen( pen ); + painter.drawLine( i, 1, i, size-1 ); + } + + pen.setColor( TQt::black ); + painter.setPen( pen ); + painter.drawRect( rect ); + painter.end(); + pixmap.detach(); + return pixmap; +} + +void DULines::sectionResized( int column ) +{ + if( childCount() == 0 || column != 0 ) + return; + + Directory * currentDir = diskUsage->getCurrentDir(); + if( currentDir == 0 ) + return; + + int maxPercent = -1; + for( Iterator it = currentDir->iterator(); it != currentDir->end(); ++it ) + { + File *item = *it; + + if( !item->isExcluded() && item->intPercent() > maxPercent ) + maxPercent = item->intPercent(); + } + + DULinesItem *duItem = (DULinesItem *)firstChild(); + while( duItem ) + { + if( duItem->text( 0 ) != ".." ) + duItem->setPixmap( 0, createPixmap( duItem->getFile()->intPercent(), maxPercent, columnWidth( 0 ) ) ); + duItem = (DULinesItem *)duItem->nextSibling(); + } +} + +bool DULines::doubleClicked( TQListViewItem * item ) +{ + if( item ) + { + if( item->text( 0 ) != ".." ) + { + File *fileItem = ((DULinesItem *)item)->getFile(); + if( fileItem->isDir() ) + diskUsage->changeDirectory( dynamic_cast ( fileItem ) ); + return true; + } + else + { + Directory *upDir = (Directory *)diskUsage->getCurrentDir()->parent(); + + if( upDir ) + diskUsage->changeDirectory( upDir ); + return true; + } + } + return false; +} + +void DULines::contentsMouseDoubleClickEvent ( TQMouseEvent * e ) +{ + if ( e || e->button() == TQt::LeftButton ) + { + TQPoint vp = contentsToViewport(e->pos()); + TQListViewItem * item = itemAt( vp ); + + if( doubleClicked( item ) ) + return; + + } + TQListView::contentsMouseDoubleClickEvent( e ); +} + + +void DULines::keyPressEvent( TQKeyEvent *e ) +{ + switch ( e->key() ) + { + case Key_Return : + case Key_Enter : + if( doubleClicked( currentItem() ) ) + return; + break; + case Key_Left : + case Key_Right : + case Key_Up : + case Key_Down : + if( e->state() == ShiftButton ) + { + e->ignore(); + return; + } + break; + case Key_Delete : + e->ignore(); + return; + } + TQListView::keyPressEvent( e ); +} + +void DULines::slotRightClicked( TQListViewItem *item ) +{ + File * file = 0; + + if ( item && item->text( 0 ) != ".." ) + file = ((DULinesItem *)item)->getFile(); + + TDEPopupMenu linesPopup; + int lid = linesPopup.insertItem( i18n("Show file sizes"), this, TQ_SLOT( slotShowFileSizes() ) ); + linesPopup.setItemChecked( lid, showFileSize ); + + diskUsage->rightClickMenu( file, &linesPopup, i18n( "Lines" ) ); +} + +void DULines::slotShowFileSizes() +{ + showFileSize = !showFileSize; + slotDirChanged( diskUsage->getCurrentDir() ); +} + +File * DULines::getCurrentFile() +{ + TQListViewItem *item = currentItem(); + + if( item == 0 || item->text( 0 ) == ".." ) + return 0; + + return ((DULinesItem *)item)->getFile(); +} + +void DULines::slotChanged( File * item ) +{ + TQListViewItem *lvitem = firstChild(); + while( lvitem ) + { + if( lvitem->text( 0 ) != ".." ) { + DULinesItem *duItem = (DULinesItem *)( lvitem ); + if( duItem->getFile() == item ) + { + duItem->setVisible( !item->isExcluded() ); + duItem->setText( 1, item->percent() ); + if( !refreshNeeded ) + { + refreshNeeded = true; + TQTimer::singleShot( 0, this, TQ_SLOT( slotRefresh() ) ); + } + break; + } + } + lvitem = lvitem->nextSibling(); + } +} + +void DULines::slotDeleted( File * item ) +{ + TQListViewItem *lvitem = firstChild(); + while( lvitem ) + { + if( lvitem->text( 0 ) != ".." ) { + DULinesItem *duItem = (DULinesItem *)( lvitem ); + if( duItem->getFile() == item ) + { + delete duItem; + break; + } + } + lvitem = lvitem->nextSibling(); + } +} + +#include "dulines.moc" diff --git a/src/app/DiskUsage/dulines.h b/src/app/DiskUsage/dulines.h new file mode 100644 index 0000000..7531c86 --- /dev/null +++ b/src/app/DiskUsage/dulines.h @@ -0,0 +1,79 @@ +/*************************************************************************** + dulines.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 __DU_LINES_H__ +#define __DU_LINES_H__ + +#include +#include +#include "diskusage.h" + +class DULinesToolTip; + +class DULines : public TQListView +{ + TQ_OBJECT + + +public: + DULines( DiskUsage *usage, const char *name ); + ~DULines(); + + File * getCurrentFile(); + +public slots: + void slotDirChanged( Directory *dirEntry ); + void sectionResized( int ); + void slotRightClicked(TQListViewItem *); + void slotChanged( File * ); + void slotDeleted( File * ); + void slotShowFileSizes(); + void slotRefresh() { refreshNeeded = false; sectionResized( 0 ); } + +protected: + DiskUsage *diskUsage; + + virtual void contentsMouseDoubleClickEvent ( TQMouseEvent * e ); + virtual void keyPressEvent( TQKeyEvent *e ); + +private: + TQPixmap createPixmap( int percent, int maxPercent, int maxWidth ); + + bool doubleClicked( TQListViewItem * item ); + + bool refreshNeeded; + + bool showFileSize; + + DULinesToolTip *toolTip; +}; + +#endif /* __DU_LINES_H__ */ + diff --git a/src/app/DiskUsage/dulistview.cpp b/src/app/DiskUsage/dulistview.cpp new file mode 100644 index 0000000..dc40690 --- /dev/null +++ b/src/app/DiskUsage/dulistview.cpp @@ -0,0 +1,293 @@ +/*************************************************************************** + dulistview.cpp - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "dulistview.h" +#include "../krusader.h" +#include "../kicons.h" +#include "../VFS/krpermhandler.h" +#include +#include +#include +#include +#include +#include + +DUListView::DUListView( DiskUsage *usage, const char *name ) + : TQListView( usage, name ), diskUsage( usage ) +{ + setAllColumnsShowFocus(true); + setVScrollBarMode(TQScrollView::Auto); + setHScrollBarMode(TQScrollView::Auto); + setShowSortIndicator(true); + setRootIsDecorated( true ); + setTreeStepSize( 10 ); + + int defaultSize = TQFontMetrics(font()).width("W"); + + krConfig->setGroup( diskUsage->getConfigGroup() ); + int nameWidth = krConfig->readNumEntry("D Name Width", defaultSize * 20 ); + addColumn( i18n("Name"), nameWidth ); + setColumnWidthMode(0,TQListView::Manual); + int percentWidth = krConfig->readNumEntry("D Percent Width", defaultSize * 5 ); + addColumn( i18n("Percent"), percentWidth ); + setColumnWidthMode(1,TQListView::Manual); + int totalSizeWidth = krConfig->readNumEntry("D Total Size Width", defaultSize * 10 ); + addColumn( i18n("Total size"), totalSizeWidth ); + setColumnWidthMode(1,TQListView::Manual); + int ownSizeWidth = krConfig->readNumEntry("D Own Size Width", defaultSize * 10 ); + addColumn( i18n("Own size"), ownSizeWidth ); + setColumnWidthMode(2,TQListView::Manual); + int typeWidth = krConfig->readNumEntry("D Type Width", defaultSize * 10 ); + addColumn( i18n("Type"), typeWidth ); + setColumnWidthMode(3,TQListView::Manual); + int dateWidth = krConfig->readNumEntry("D Date Width", defaultSize * 10 ); + addColumn( i18n("Date"), dateWidth ); + setColumnWidthMode(4,TQListView::Manual); + int permissionsWidth = krConfig->readNumEntry("D Permissions Width", defaultSize * 6 ); + addColumn( i18n("Permissions"), permissionsWidth ); + setColumnWidthMode(5,TQListView::Manual); + int ownerWidth = krConfig->readNumEntry("D Owner Width", defaultSize * 5 ); + addColumn( i18n("Owner"), ownerWidth ); + setColumnWidthMode(6,TQListView::Manual); + int groupWidth = krConfig->readNumEntry("D Group Width", defaultSize * 5 ); + addColumn( i18n("Group"), groupWidth ); + setColumnWidthMode(7,TQListView::Manual); + + setColumnAlignment( 1, TQt::AlignRight ); + setColumnAlignment( 2, TQt::AlignRight ); + setColumnAlignment( 3, TQt::AlignRight ); + + setSorting( 2 ); + + connect( diskUsage, TQ_SIGNAL( enteringDirectory( Directory * ) ), this, TQ_SLOT( slotDirChanged( Directory * ) ) ); + connect( diskUsage, TQ_SIGNAL( clearing() ), this, TQ_SLOT( clear() ) ); + connect( diskUsage, TQ_SIGNAL( changed( File * ) ), this, TQ_SLOT( slotChanged( File * ) ) ); + connect( diskUsage, TQ_SIGNAL( deleted( File * ) ), this, TQ_SLOT( slotDeleted( File * ) ) ); + + connect( this, TQ_SIGNAL(rightButtonPressed(TQListViewItem *, const TQPoint &, int)), + this, TQ_SLOT( slotRightClicked(TQListViewItem *) ) ); + connect( this, TQ_SIGNAL( expanded ( TQListViewItem * ) ), + this, TQ_SLOT( slotExpanded( TQListViewItem * ) ) ); +} + +DUListView::~ DUListView() +{ + krConfig->setGroup( diskUsage->getConfigGroup() ); + krConfig->writeEntry("D Name Width", columnWidth( 0 ) ); + krConfig->writeEntry("D Percent Width", columnWidth( 1 ) ); + krConfig->writeEntry("D Total Size Width", columnWidth( 2 ) ); + krConfig->writeEntry("D Own Size Width", columnWidth( 3 ) ); + krConfig->writeEntry("D Type Width", columnWidth( 4 ) ); + krConfig->writeEntry("D Date Width", columnWidth( 5 ) ); + krConfig->writeEntry("D Permissions Width", columnWidth( 6 ) ); + krConfig->writeEntry("D Owner Width", columnWidth( 7 ) ); + krConfig->writeEntry("D Group Width", columnWidth( 8 ) ); +} + +void DUListView::addDirectory( Directory *dirEntry, TQListViewItem *parent ) +{ + TQListViewItem * lastItem = 0; + + if( parent == 0 && ! ( dirEntry->parent() == 0 ) ) + { + lastItem = new TQListViewItem( this, ".." ); + lastItem->setPixmap( 0, FL_LOADICON( "go-up" ) ); + lastItem->setSelectable( false ); + } + + for( Iterator it = dirEntry->iterator(); it != dirEntry->end(); ++it ) + { + File *item = *it; + + KMimeType::Ptr mimePtr = KMimeType::mimeType( item->mime() ); + TQString mime = mimePtr->comment(); + + time_t tma = item->time(); + struct tm* t=localtime((time_t *)&tma); + TQDateTime tmp(TQDate(t->tm_year+1900, t->tm_mon+1, t->tm_mday), TQTime(t->tm_hour, t->tm_min)); + TQString date = TDEGlobal::locale()->formatDateTime(tmp); + + TQString totalSize = KRpermHandler::parseSize( item->size() ) + " "; + TQString ownSize = KRpermHandler::parseSize( item->ownSize() ) + " "; + TQString percent = item->percent(); + + if( lastItem == 0 && parent == 0 ) + lastItem = new DUListViewItem( diskUsage, item, this, item->name(), percent, totalSize, ownSize, + mime, date, item->perm(), item->owner(), item->group() ); + else if ( lastItem == 0 ) + lastItem = new DUListViewItem( diskUsage, item, parent, item->name(), percent, totalSize, ownSize, + mime, date, item->perm(), item->owner(), item->group() ); + else if ( parent == 0 ) + lastItem = new DUListViewItem( diskUsage, item, this, lastItem, item->name(), percent, totalSize, + ownSize, mime, date, item->perm(), item->owner(), item->group() ); + else + lastItem = new DUListViewItem( diskUsage, item, parent, lastItem, item->name(), percent, totalSize, + ownSize, mime, date, item->perm(), item->owner(), item->group() ); + + if( item->isExcluded() ) + lastItem->setVisible( false ); + + lastItem->setPixmap( 0, diskUsage->getIcon( item->mime() ) ); + + if( item->isDir() && !item->isSymLink() ) + lastItem->setExpandable( true ); + } + + TQListViewItem *first = firstChild(); + if( first ) + setCurrentItem( first ); +} + +void DUListView::slotDirChanged( Directory *dirEntry ) +{ + clear(); + addDirectory( dirEntry, 0 ); +} + +File * DUListView::getCurrentFile() +{ + TQListViewItem *item = currentItem(); + + if( item == 0 || item->text( 0 ) == ".." ) + return 0; + + return ((DUListViewItem *)item)->getFile(); +} + +void DUListView::slotChanged( File * item ) +{ + void * itemPtr = diskUsage->getProperty( item, "ListView-Ref" ); + if( itemPtr == 0 ) + return; + + DUListViewItem *duItem = (DUListViewItem *)itemPtr; + duItem->setVisible( !item->isExcluded() ); + duItem->setText( 1, item->percent() ); + duItem->setText( 2, KRpermHandler::parseSize( item->size() ) + " " ); + duItem->setText( 3, KRpermHandler::parseSize( item->ownSize() ) + " " ); +} + +void DUListView::slotDeleted( File * item ) +{ + void * itemPtr = diskUsage->getProperty( item, "ListView-Ref" ); + if( itemPtr == 0 ) + return; + + DUListViewItem *duItem = (DUListViewItem *)itemPtr; + delete duItem; +} + +void DUListView::slotRightClicked( TQListViewItem *item ) +{ + File * file = 0; + + if ( item && item->text( 0 ) != ".." ) + file = ((DUListViewItem *)item)->getFile(); + + diskUsage->rightClickMenu( file ); +} + +bool DUListView::doubleClicked( TQListViewItem * item ) +{ + if( item ) + { + if( item->text( 0 ) != ".." ) + { + File *fileItem = ((DUListViewItem *)item)->getFile(); + if( fileItem->isDir() ) + diskUsage->changeDirectory( dynamic_cast ( fileItem ) ); + return true; + } + else + { + Directory *upDir = (Directory *)diskUsage->getCurrentDir()->parent(); + + if( upDir ) + diskUsage->changeDirectory( upDir ); + return true; + } + } + return false; +} + +void DUListView::contentsMouseDoubleClickEvent ( TQMouseEvent * e ) +{ + if ( e || e->button() == TQt::LeftButton ) + { + TQPoint vp = contentsToViewport(e->pos()); + TQListViewItem * item = itemAt( vp ); + + if( doubleClicked( item ) ) + return; + + } + TQListView::contentsMouseDoubleClickEvent( e ); +} + +void DUListView::keyPressEvent( TQKeyEvent *e ) +{ + switch ( e->key() ) + { + case Key_Return : + case Key_Enter : + if( doubleClicked( currentItem() ) ) + return; + break; + case Key_Left : + case Key_Right : + case Key_Up : + case Key_Down : + if( e->state() == ShiftButton ) + { + e->ignore(); + return; + } + break; + case Key_Delete : + e->ignore(); + return; + } + TQListView::keyPressEvent( e ); +} + +void DUListView::slotExpanded( TQListViewItem *item ) +{ + if( item == 0 || item->text( 0 ) == ".." ) + return; + + if( item->childCount() == 0 ) + { + File *fileItem = ((DUListViewItem *)item)->getFile(); + if( fileItem->isDir() ) + addDirectory( dynamic_cast( fileItem ), item ); + } +} + +#include "dulistview.moc" diff --git a/src/app/DiskUsage/dulistview.h b/src/app/DiskUsage/dulistview.h new file mode 100644 index 0000000..9e9fdb4 --- /dev/null +++ b/src/app/DiskUsage/dulistview.h @@ -0,0 +1,145 @@ +/*************************************************************************** + dulistview.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * 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 __DU_LISTVIEW_H__ +#define __DU_LISTVIEW_H__ + +#include +#include "diskusage.h" + +class DUListViewItem : public TQListViewItem +{ +public: + DUListViewItem( DiskUsage *diskUsageIn, File *fileIn, TQListView * parent, TQString label1, + TQString label2, TQString label3, TQString label4, TQString label5, TQString label6, + TQString label7, TQString label8, TQString label9 ) + : TQListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8), + diskUsage( diskUsageIn ), file( fileIn ) + { + setText( 8, label9 ); + diskUsage->addProperty( file, "ListView-Ref", this ); + } + DUListViewItem( DiskUsage *diskUsageIn, File *fileIn, TQListViewItem * parent, TQString label1, + TQString label2, TQString label3, TQString label4, TQString label5, TQString label6, + TQString label7, TQString label8, TQString label9 ) + : TQListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8), + diskUsage( diskUsageIn ), file( fileIn ) + { + setText( 8, label9 ); + diskUsage->addProperty( file, "ListView-Ref", this ); + } + DUListViewItem( DiskUsage *diskUsageIn, File *fileIn, TQListView * parent, TQListViewItem * after, + TQString label1, TQString label2, TQString label3, TQString label4, TQString label5, + TQString label6, TQString label7, TQString label8, TQString label9 ) + : TQListViewItem( parent, after, label1, label2, label3, label4, label5, label6, label7, label8), + diskUsage( diskUsageIn ), file( fileIn ) + { + setText( 8, label9 ); + diskUsage->addProperty( file, "ListView-Ref", this ); + } + DUListViewItem( DiskUsage *diskUsageIn, File *fileIn, TQListViewItem * parent, TQListViewItem * after, + TQString label1, TQString label2, TQString label3, TQString label4, TQString label5, + TQString label6, TQString label7, TQString label8, TQString label9 ) + : TQListViewItem( parent, after, label1, label2, label3, label4, label5, label6, label7, label8), + diskUsage( diskUsageIn ), file( fileIn ) + { + setText( 8, label9 ); + diskUsage->addProperty( file, "ListView-Ref", this ); + } + ~DUListViewItem() + { + diskUsage->removeProperty( file, "ListView-Ref" ); + } + + virtual int compare ( TQListViewItem * i, int col, bool ascending ) const + { + if( text(0) == ".." ) return ascending ? -1 : 1; + if( i->text(0) == "..") return ascending ? 1 : -1; + + DUListViewItem *compWith = dynamic_cast< DUListViewItem * >( i ); + + TQString buf1,buf2; + + switch( col ) + { + case 1: + case 2: + buf1.sprintf("%025llu",file->size()); + buf2.sprintf("%025llu",compWith->file->size()); + return -TQString::compare( buf1, buf2 ); + case 3: + buf1.sprintf("%025llu",file->ownSize()); + buf2.sprintf("%025llu",compWith->file->ownSize()); + return -TQString::compare( buf1, buf2 ); + case 5: + return TQListViewItem::compare( i, col, !ascending ); + default: + return TQListViewItem::compare( i, col, ascending ); + } + } + + inline File * getFile() { return file; } + +private: + DiskUsage *diskUsage; + File *file; +}; + +class DUListView : public TQListView +{ + TQ_OBJECT + + +public: + DUListView( DiskUsage *usage, const char *name ); + ~DUListView(); + + File * getCurrentFile(); + +public slots: + void slotDirChanged( Directory * ); + void slotChanged( File * ); + void slotDeleted( File * ); + void slotRightClicked(TQListViewItem *); + void slotExpanded( TQListViewItem * ); + +protected: + DiskUsage *diskUsage; + + virtual void contentsMouseDoubleClickEvent ( TQMouseEvent * e ); + virtual void keyPressEvent( TQKeyEvent *e ); + +private: + void addDirectory( Directory *dirEntry, TQListViewItem *parent ); + bool doubleClicked( TQListViewItem * item ); +}; + +#endif /* __DU_LISTVIEW_H__ */ + diff --git a/src/app/DiskUsage/filelightParts/Config.cpp b/src/app/DiskUsage/filelightParts/Config.cpp new file mode 100644 index 0000000..bf25a29 --- /dev/null +++ b/src/app/DiskUsage/filelightParts/Config.cpp @@ -0,0 +1,50 @@ + +#include "Config.h" +#include +#include + + +bool Config::varyLabelFontSizes = true; +bool Config::showSmallFiles = false; +uint Config::contrast = 50; +uint Config::antiAliasFactor = 2; +uint Config::minFontPitch = 10; +uint Config::defaultRingDepth = 4; +Filelight::MapScheme Config::scheme; + + +inline TDEConfig& +Filelight::Config::tdeconfig() +{ + TDEConfig *config = TDEGlobal::config(); + config->setGroup( "DiskUsage" ); + return *config; +} + +void +Filelight::Config::read() +{ + const TDEConfig &config = tdeconfig(); + + varyLabelFontSizes = config.readBoolEntry( "varyLabelFontSizes", true ); + showSmallFiles = config.readBoolEntry( "showSmallFiles", false ); + contrast = config.readNumEntry( "contrast", 50 ); + antiAliasFactor = config.readNumEntry( "antiAliasFactor", 2 ); + minFontPitch = config.readNumEntry( "minFontPitch", TQFont().pointSize() - 3); + scheme = (MapScheme) config.readNumEntry( "scheme", 0 ); + + defaultRingDepth = 4; +} + +void +Filelight::Config::write() +{ + TDEConfig &config = tdeconfig(); + + config.writeEntry( "varyLabelFontSizes", varyLabelFontSizes ); + config.writeEntry( "showSmallFiles", showSmallFiles); + config.writeEntry( "contrast", contrast ); + config.writeEntry( "antiAliasFactor", antiAliasFactor ); + config.writeEntry( "minFontPitch", minFontPitch ); + config.writeEntry( "scheme", scheme ); +} diff --git a/src/app/DiskUsage/filelightParts/Config.h b/src/app/DiskUsage/filelightParts/Config.h new file mode 100644 index 0000000..52a98b7 --- /dev/null +++ b/src/app/DiskUsage/filelightParts/Config.h @@ -0,0 +1,37 @@ + +#ifndef Config_H +#define Config_H + +#include + +class TDEConfig; + + +namespace Filelight +{ + enum MapScheme { Rainbow, HighContrast, KDE, FileDensity, ModTime }; + + class Config + { + static TDEConfig& tdeconfig(); + + public: + static void read(); + static void write(); + + //keep everything positive, avoid using DON'T, NOT or NO + + static bool varyLabelFontSizes; + static bool showSmallFiles; + static uint contrast; + static uint antiAliasFactor; + static uint minFontPitch; + static uint defaultRingDepth; + + static MapScheme scheme; + }; +} + +using Filelight::Config; + +#endif diff --git a/src/app/DiskUsage/filelightParts/Makefile.am b/src/app/DiskUsage/filelightParts/Makefile.am new file mode 100644 index 0000000..002f461 --- /dev/null +++ b/src/app/DiskUsage/filelightParts/Makefile.am @@ -0,0 +1,9 @@ +noinst_LIBRARIES = libfilelightparts.a + +INCLUDES = $(all_includes) + +METASOURCES = AUTO + +libfilelightparts_a_SOURCES = \ + Config.cpp \ + fileTree.cpp diff --git a/src/app/DiskUsage/filelightParts/debug.h b/src/app/DiskUsage/filelightParts/debug.h new file mode 100644 index 0000000..252a001 --- /dev/null +++ b/src/app/DiskUsage/filelightParts/debug.h @@ -0,0 +1,14 @@ +//Author: Max Howell , (C) 2003-4 +//Copyright: See COPYING file that comes with this distribution + +#ifndef DEBUG_H +#define DEBUG_H + +#include + +#define debug kdDebug +#define error kdError +#define fatal kdFatal +#define warning kdWarning + +#endif diff --git a/src/app/DiskUsage/filelightParts/fileTree.cpp b/src/app/DiskUsage/filelightParts/fileTree.cpp new file mode 100644 index 0000000..0afd4d4 --- /dev/null +++ b/src/app/DiskUsage/filelightParts/fileTree.cpp @@ -0,0 +1,78 @@ +//Author: Max Howell , (C) 2004 +//Copyright: See COPYING file that comes with this distribution + +#include "fileTree.h" +#include +#include +#include + +//static definitions +const FileSize File::DENOMINATOR[4] = { 1ull, 1ull<<10, 1ull<<20, 1ull<<30 }; +const char File::PREFIX[5][2] = { "", "K", "M", "G", "T" }; + +TQString +File::fullPath( const Directory *root /*= 0*/ ) const +{ + TQString path; + + if( root == this ) root = 0; //prevent returning empty string when there is something we could return + + const File *d; + + for( d = this; d != root && d && d->parent() != 0; d = d->parent() ) + { + if( !path.isEmpty() ) + path = "/" + path; + + path = d->name() + path; + } + + if( d ) + { + while( d->parent() ) + d = d->parent(); + + if( d->directory().endsWith( "/" ) ) + return d->directory() + path; + else + return d->directory() + "/" + path; + } + else + return path; +} + +TQString +File::humanReadableSize( UnitPrefix key /*= mega*/ ) const //FIXME inline +{ + return humanReadableSize( m_size, key ); +} + +TQString +File::humanReadableSize( FileSize size, UnitPrefix key /*= mega*/ ) //static +{ + TQString s; + double prettySize = (double)size / (double)DENOMINATOR[key]; + const TDELocale &locale = *TDEGlobal::locale(); + + if( prettySize >= 0.01 ) + { + if( prettySize < 1 ) s = locale.formatNumber( prettySize, 2 ); + else if( prettySize < 100 ) s = locale.formatNumber( prettySize, 1 ); + else s = locale.formatNumber( prettySize, 0 ); + + s += ' '; + s += PREFIX[key]; + s += 'B'; + } + + if( prettySize < 0.1 ) + { + s += " ("; + s += locale.formatNumber( size / DENOMINATOR[ key ? key - 1 : 0 ], 0 ); + s += ' '; + s += PREFIX[key]; + s += "B)"; + } + + return s; +} diff --git a/src/app/DiskUsage/filelightParts/fileTree.h b/src/app/DiskUsage/filelightParts/fileTree.h new file mode 100644 index 0000000..2ba79ae --- /dev/null +++ b/src/app/DiskUsage/filelightParts/fileTree.h @@ -0,0 +1,299 @@ +//Author: Max Howell , (C) 2004 +//Copyright: See COPYING file that comes with this distribution + +#ifndef FILETREE_H +#define FILETREE_H + +#include +#include +#include + +//TODO these are pointlessly general purpose now, make them incredibly specific + + + +typedef TDEIO::filesize_t FileSize; + +template class Iterator; +template class ConstIterator; +template class Chain; + +template +class Link +{ +public: + Link( T* const t ) : prev( this ), next( this ), data( t ) {} + Link() : prev( this ), next( this ), data( 0 ) {} + + //TODO unlinking is slow and you don't use it very much in this context. + // ** Perhaps you can make a faster deletion system that doesn't bother tidying up first + // ** and then you MUST call some kind of detach() function when you remove elements otherwise + ~Link() { delete data; unlink(); } + + friend class Iterator; + friend class ConstIterator; + friend class Chain; + +private: + void unlink() { prev->next = next; next->prev = prev; prev = next = this; } + + Link* prev; + Link* next; + + T* data; //ensure only iterators have access to this +}; + + +template +class Iterator +{ +public: + Iterator() : link( 0 ) { } //**** remove this, remove this REMOVE THIS!!! dangerous as your implementation doesn't test for null links, always assumes they can be derefenced + Iterator( Link *p ) : link( p ) { } + + bool operator==( const Iterator& it ) const { return link == it.link; } + bool operator!=( const Iterator& it ) const { return link != it.link; } + bool operator!=( const Link *p ) const { return p != link; } + + //here we have a choice, really I should make two classes one const the other not + const T* operator*() const { return link->data; } + T* operator*() { return link->data; } + + Iterator& operator++() { link = link->next; return *this; } //**** does it waste time returning in places where we don't use the retval? + + bool isNull() const { return (link == 0); } //REMOVE WITH ABOVE REMOVAL you don't want null iterators to be possible + + void transferTo( Chain &chain ) + { + chain.append( remove() ); + } + + T* const remove() //remove from list, delete Link, data is returned NOT deleted + { + T* const d = link->data; + Link* const p = link->prev; + + link->data = 0; + delete link; + link = p; //make iterator point to previous element, YOU must check this points to an element + + return d; + } + +private: + Link *link; +}; + + +template +class ConstIterator +{ +public: + ConstIterator( Link *p ) : link( p ) { } + + bool operator==( const Iterator& it ) const { return link == it.link; } + bool operator!=( const Iterator& it ) const { return link != it.link; } + bool operator!=( const Link *p ) const { return p != link; } + + const T* operator*() const { return link->data; } + + ConstIterator& operator++() { link = link->next; return *this; } + +private: + const Link *link; +}; + +//**** try to make a generic list class and then a brief full list template that inlines +// thus reducing code bloat +template +class Chain +{ +public: + Chain() { } + virtual ~Chain() { empty(); } + + void append( T* const data ) + { + Link* const link = new Link( data ); + + link->prev = head.prev; + link->next = &head; + + head.prev->next = link; + head.prev = link; + } + + void transferTo( Chain &c ) + { + if( isEmpty() ) return; + + Link* const first = head.next; + Link* const last = head.prev; + + head.unlink(); + + first->prev = c.head.prev; + c.head.prev->next = first; + + last->next = &c.head; + c.head.prev = last; + } + + void empty() { while( head.next != &head ) { delete head.next; } } + + Iterator iterator() const { return Iterator( head.next ); } + ConstIterator constIterator() const { return ConstIterator( head.next ); } + const Link *end() const { return &head; } + bool isEmpty() const { return ( head.next == &head ); } + +private: + Link head; + void operator=( const Chain& ) {} +}; + + +class Directory; +class TQString; +class KURL; + +class File +{ +protected: + Directory *m_parent; //0 if this is treeRoot + TQString m_name; //< file name + TQString m_directory;//< the directory of the file + FileSize m_size; //< size with subdirectories + FileSize m_ownSize; //< size without subdirectories + mode_t m_mode; //< file mode + TQString m_owner; //< file owner name + TQString m_group; //< file group name + TQString m_perm; //< file permissions string + time_t m_time; //< file modification in time_t format + bool m_symLink; //< true if the file is a symlink + TQString m_mimeType; //< file mimetype + bool m_excluded; //< flag if the file is excluded from du + int m_percent; //< percent flag + +public: + File( Directory *parentIn, const TQString &nameIn, const TQString &dir, FileSize sizeIn, mode_t modeIn, + const TQString &ownerIn, const TQString &groupIn, const TQString &permIn, time_t timeIn, bool symLinkIn, + const TQString &mimeTypeIn ) + : m_parent( parentIn ), m_name( nameIn ), m_directory( dir ), m_size( sizeIn ), m_ownSize( sizeIn ), m_mode( modeIn ), + m_owner( ownerIn ), m_group( groupIn ), m_perm( permIn ), m_time( timeIn ), m_symLink( symLinkIn ), + m_mimeType( mimeTypeIn ), m_excluded( false ), m_percent( -1 ) {} + + File( const TQString &nameIn, FileSize sizeIn ) + : m_parent( 0 ), m_name( nameIn ), m_directory( TQString() ), m_size( sizeIn ), m_ownSize( sizeIn ), m_mode( 0 ), + m_owner( TQString() ), m_group( TQString() ), m_perm( TQString() ), m_time( -1 ), + m_symLink( false ), m_mimeType( TQString() ), m_excluded( false ), m_percent( -1 ) + { + } + + virtual ~File() {} + + inline const TQString & name() const {return m_name;} + inline const TQString & directory() const {return m_directory;} + inline const FileSize size() const {return m_excluded ? 0 : m_size;} + inline const FileSize ownSize() const {return m_excluded ? 0 : m_ownSize;} + inline const mode_t mode() const {return m_mode;} + inline const TQString & owner() const {return m_owner;} + inline const TQString & group() const {return m_group;} + inline const TQString & perm() const {return m_perm;} + inline const time_t time() const {return m_time;} + inline const TQString & mime() const {return m_mimeType;} + inline const bool isSymLink() const {return m_symLink;} + virtual const bool isDir() const {return false;} + inline const bool isExcluded() const {return m_excluded;} + inline void exclude( bool flag ) {m_excluded = flag;} + inline const int intPercent() const {return m_percent;} + inline const TQString percent() const {if( m_percent < 0 ) + return "INV"; + TQString buf; + buf.sprintf( "%d.%02d%%", m_percent / 100, m_percent % 100 ); + return buf;} + inline void setPercent( int p ) {m_percent = p;} + inline const Directory* parent() const {return m_parent;} + + inline void setSizes( TDEIO::filesize_t totalSize, TDEIO::filesize_t ownSize ) + { + m_ownSize = ownSize; + m_size = totalSize; + } + + enum UnitPrefix { kilo, mega, giga, tera }; + + static const FileSize DENOMINATOR[4]; + static const char PREFIX[5][2]; + + TQString fullPath( const Directory* = 0 ) const; + TQString humanReadableSize( UnitPrefix key = mega ) const; + + static TQString humanReadableSize( FileSize size, UnitPrefix Key = mega ); + + friend class Directory; +}; + + +//TODO when you modify this to take into account hardlinks you should make the Chain layered not inherited +class Directory : public Chain, public File +{ +public: + Directory( Directory *parentIn, const TQString &nameIn, const TQString &dir, FileSize sizeIn, mode_t modeIn, + const TQString &ownerIn, const TQString &groupIn, const TQString &permIn, time_t timeIn, bool symLinkIn, + const TQString &mimeTypeIn ) + : File( parentIn, nameIn, dir, sizeIn, modeIn, ownerIn, groupIn, permIn, timeIn, symLinkIn, mimeTypeIn ), + m_fileCount( 0 ) + {} + + Directory( const TQString &name, TQString url ) : File( name, 0 ), m_fileCount( 0 ) + { + m_directory = url; + } + + virtual ~Directory() {} + virtual const bool isDir() const {return true;} + + void append( File *p ) + { + ++m_fileCount; + + Directory *parent = m_parent; + while( parent ) + { + parent->m_fileCount++; + parent = parent->m_parent; + } + + Chain::append( p ); + p->m_parent = this; + } + + void remove( File *p ) + { + for( Iterator it = Chain::iterator(); it != Chain::end(); ++it ) + if( (*it) == p ) + { + --m_fileCount; + + Directory *parent = m_parent; + while( parent ) + { + parent->m_fileCount--; + parent = parent->m_parent; + } + + it.remove(); + break; + } + } + + uint fileCount() const { return m_fileCount; } + +private: + Directory( const Directory& ); + void operator=( const Directory& ); + + uint m_fileCount; +}; + +#endif diff --git a/src/app/DiskUsage/radialMap/Makefile.am b/src/app/DiskUsage/radialMap/Makefile.am new file mode 100644 index 0000000..ab5effd --- /dev/null +++ b/src/app/DiskUsage/radialMap/Makefile.am @@ -0,0 +1,13 @@ +noinst_LIBRARIES = libradialmap.a + +INCLUDES = -I$(top_srcdir)/src/app/DiskUsage/filelightParts $(all_includes) + +METASOURCES = AUTO + +libradialmap_a_SOURCES = \ + widget.cpp \ + builder.cpp \ + map.cpp \ + widgetEvents.cpp \ + labels.cpp \ + segmentTip.cpp diff --git a/src/app/DiskUsage/radialMap/builder.cpp b/src/app/DiskUsage/radialMap/builder.cpp new file mode 100644 index 0000000..8edb70c --- /dev/null +++ b/src/app/DiskUsage/radialMap/builder.cpp @@ -0,0 +1,139 @@ +//Author: Max Howell , (C) 2003-4 +//Copyright: See COPYING file that comes with this distribution + +#include "builder.h" +#include "Config.h" +#include "fileTree.h" +#include //locale object +#include +#include "widget.h" + + +//**** REMOVE NEED FOR the +1 with MAX_RING_DEPTH uses +//**** add some angle bounds checking (possibly in Segment ctor? can I delete in a ctor?) +//**** this class is a mess + +RadialMap::Builder::Builder( RadialMap::Map *m, const Directory* const d, bool fast ) + : m_map( m ) + , m_root( d ) + , m_minSize( static_cast((d->size() * 3) / (PI * m->height() - m->MAP_2MARGIN )) ) + , m_depth( &m->m_visibleDepth ) +{ + m_signature = new Chain [*m_depth + 1]; + + if( !fast )//|| *m_depth == 0 ) //depth 0 is special case usability-wise //**** WHY?! + { + //determine depth rather than use old one + findVisibleDepth( d ); //sets m_depth + } + + m_map->setRingBreadth(); + setLimits( m_map->m_ringBreadth ); + build( d ); + + m_map->m_signature = m_signature; + + delete []m_limits; +} + + +void +RadialMap::Builder::findVisibleDepth( const Directory* const dir, const unsigned int depth ) +{ + //**** because I don't use the same minimumSize criteria as in the visual function + // this can lead to incorrect visual representation + //**** BUT, you can't set those limits until you know m_depth! + + //**** also this function doesn't check to see if anything is actually visible + // it just assumes that when it reaches a new level everything in it is visible + // automatically. This isn't right especially as there might be no files in the + // dir provided to this function! + + static uint stopDepth = 0; + + if( dir == m_root ) + { + stopDepth = *m_depth; + *m_depth = 0; + } + + if( *m_depth < depth ) *m_depth = depth; + if( *m_depth >= stopDepth ) return; + + for( ConstIterator it = dir->constIterator(); it != dir->end(); ++it ) + if( (*it)->isDir() && (*it)->size() > m_minSize ) + findVisibleDepth( (Directory *)*it, depth + 1 ); //if no files greater than min size the depth is still recorded +} + +void +RadialMap::Builder::setLimits( const uint &b ) //b = breadth? +{ + double size3 = m_root->size() * 3; + double pi2B = PI * 2 * b; + + m_limits = new FileSize [*m_depth + 1]; //FIXME delete! + + for( unsigned int d = 0; d <= *m_depth; ++d ) + m_limits[d] = (FileSize)(size3 / (double)(pi2B * (d + 1))); //min is angle that gives 3px outer diameter for that depth +} + + +//**** segments currently overlap at edges (i.e. end of first is start of next) +bool +RadialMap::Builder::build( const Directory* const dir, const unsigned int depth, unsigned int a_start, const unsigned int a_end ) +{ + //first iteration: dir == m_root + + if( dir->fileCount() == 0 ) //we do fileCount rather than size to avoid chance of divide by zero later + return false; + + FileSize hiddenSize = 0; + uint hiddenFileCount = 0; + + for( ConstIterator it = dir->constIterator(); it != dir->end(); ++it ) + { + if( (*it)->size() > m_limits[depth] ) + { + unsigned int a_len = (unsigned int)(5760 * ((double)(*it)->size() / (double)m_root->size())); + + Segment *s = new Segment( *it, a_start, a_len ); + + (m_signature + depth)->append( s ); + + if( (*it)->isDir() ) + { + if( depth != *m_depth ) + { + //recurse + s->m_hasHiddenChildren = build( (Directory*)*it, depth + 1, a_start, a_start + a_len ); + } + else s->m_hasHiddenChildren = true; + } + + a_start += a_len; //**** should we add 1? + + } else { + + hiddenSize += (*it)->size(); + + if( (*it)->isDir() ) //**** considered virtual, but dir wouldn't count itself! + hiddenFileCount += static_cast(*it)->fileCount(); //need to add one to count the dir as well + + ++hiddenFileCount; + } + } + + if( hiddenFileCount == dir->fileCount() && !Config::showSmallFiles ) + + return true; + + else if( (Config::showSmallFiles && hiddenSize > m_limits[depth]) || (depth == 0 && (hiddenSize > dir->size()/8)) /*|| > size() * 0.75*/ ) + { + //append a segment for unrepresented space - a "fake" segment + + const TQString s = i18n( "%1 files: ~ %2" ).arg( TDEGlobal::locale()->formatNumber( hiddenFileCount, 0 ) ).arg( File::humanReadableSize( hiddenSize/hiddenFileCount ) ); + (m_signature + depth)->append( new Segment( new File( s, hiddenSize ), a_start, a_end - a_start, true ) ); + } + + return false; +} diff --git a/src/app/DiskUsage/radialMap/builder.h b/src/app/DiskUsage/radialMap/builder.h new file mode 100644 index 0000000..2fddbe0 --- /dev/null +++ b/src/app/DiskUsage/radialMap/builder.h @@ -0,0 +1,37 @@ +//Author: Max Howell , (C) 2003-4 +//Copyright: See COPYING file that comes with this distribution + +#ifndef BUILDER_H +#define BUILDER_H + +#include "radialMap.h" //Segment, defines +#include "fileTree.h" + +template class Chain; + +namespace RadialMap +{ + class Map; + + //temporary class that builds the Map signature + + class Builder + { + public: + Builder( Map*, const Directory* const, bool fast=false ); + + private: + void findVisibleDepth( const Directory* const dir, const uint=0 ); + void setLimits( const uint& ); + bool build( const Directory* const, const uint=0, uint=0, const uint=5760 ); + + Map *m_map; + const Directory* const m_root; + const FileSize m_minSize; + uint *m_depth; + Chain *m_signature; + FileSize *m_limits; + }; +} + +#endif diff --git a/src/app/DiskUsage/radialMap/labels.cpp b/src/app/DiskUsage/radialMap/labels.cpp new file mode 100644 index 0000000..5d61b7a --- /dev/null +++ b/src/app/DiskUsage/radialMap/labels.cpp @@ -0,0 +1,342 @@ +//Author: Max Howell , (C) 2003-4 +//Copyright: See COPYING file that comes with this distribution + +#include +#include +#include +#include +#include + +#include "Config.h" +#include "fileTree.h" +#include "radialMap.h" +#include "sincos.h" +#include "widget.h" + + + +namespace RadialMap +{ + struct Label + { + Label( const RadialMap::Segment *s, int l ) : segment( s ), lvl( l ), a( segment->start() + (segment->length() / 2) ) { } + + bool tooClose( const int &aa ) const { return ( a > aa - LABEL_ANGLE_MARGIN && a < aa + LABEL_ANGLE_MARGIN ); } + + const RadialMap::Segment *segment; + const unsigned int lvl; + const int a; + + int x1, y1, x2, y2, x3; + int tx, ty; + + TQString qs; + }; + + class LabelList : public TQPtrList