KRename – powerful batch renamer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dsdirselectdialog.cpp 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /***************************************************************************
  2. dsdirselectdialog.cpp - description
  3. -------------------
  4. begin : Sat Jan 03 2004
  5. copyright : (C) 2004 by Dominik Seichter
  6. email : domseichter@web.de
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #include "dsdirselectdialog.h"
  17. // TQt includes
  18. #include <tqcheckbox.h>
  19. #include <tqhbox.h>
  20. #include <tqlabel.h>
  21. #include <tqlayout.h>
  22. #include <tqtooltip.h>
  23. #include <tqvbox.h>
  24. // KDE includes
  25. #include <tdediroperator.h>
  26. #include <tdelocale.h>
  27. #include <kurlcombobox.h>
  28. DSDirSelectDialog::DSDirSelectDialog( TQWidget* parent )
  29. : KFileDialog( ":KRename", "*", parent, 0, false )
  30. {
  31. setOperationMode( KFileDialog::Opening );
  32. setMode( KFile::Files | KFile::ExistingOnly );
  33. TQVBox* vbox = new TQVBox( this );
  34. if( layout() )
  35. layout()->add( vbox );
  36. else
  37. tqDebug("KFileDialog does not have a layout!!!");
  38. checkDir = new TQCheckBox( i18n("Add directory names &with filenames"), vbox );
  39. check = new TQCheckBox( i18n("Add subdirectories &recursively"), vbox );
  40. TQHBox* hbox = new TQHBox( vbox );
  41. TQWidget* spacer = new TQWidget( hbox );
  42. spacer->setMinimumWidth( 20 );
  43. checkHidden = new TQCheckBox( i18n("Add &hidden directories"), hbox );
  44. hbox->setStretchFactor( checkHidden, 4 );
  45. checkOnlyDir = new TQCheckBox( i18n("Add directory names only"), vbox );
  46. connect( check, TQT_SIGNAL( clicked() ), this, TQT_SLOT( enableControls() ));
  47. TQToolTip::add( check, i18n("Walk recursively through the directory tree and add also the content of all subdirectories to the list of files to rename.") );
  48. TQToolTip::add( checkHidden, i18n("If not checked, KRename will ignore directories starting with a dot during recursive adding.") );
  49. TQToolTip::add( checkOnlyDir, i18n("Add only the directory names and not the names of the files in the directory to KRename.") );
  50. TQToolTip::add( checkDir, i18n("This option causes KRename to add also the name of the base directory of the selected files to its list.") );
  51. enableControls();
  52. }
  53. bool DSDirSelectDialog::recursively() const
  54. {
  55. return check->isChecked();
  56. }
  57. bool DSDirSelectDialog::hidden() const
  58. {
  59. return checkHidden->isChecked();
  60. }
  61. bool DSDirSelectDialog::dirs() const
  62. {
  63. return checkDir->isChecked();
  64. }
  65. bool DSDirSelectDialog::onlyDirs() const
  66. {
  67. return checkOnlyDir->isChecked();
  68. }
  69. void DSDirSelectDialog::setRecursively( bool b )
  70. {
  71. check->setChecked( b );
  72. }
  73. void DSDirSelectDialog::enableControls()
  74. {
  75. checkHidden->setEnabled( check->isChecked() );
  76. }
  77. void DSDirSelectDialog::slotOk()
  78. {
  79. const KFileItemList *items = ops->selectedItems();
  80. if ( !items || items->isEmpty() )
  81. {
  82. KDialogBase::accept();
  83. } else
  84. KFileDialog::slotOk();
  85. }
  86. KURL::List DSDirSelectDialog::selectedURLs()
  87. {
  88. KURL::List list = KFileDialog::selectedURLs();
  89. if( list.isEmpty() )
  90. list.append( baseURL() );
  91. return list;
  92. }
  93. #include "dsdirselectdialog.moc"