TDE core libraries
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.

renamedlg.h 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* This file is part of the KDE libraries
  2. Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
  3. David Faure <faure@kde.org>
  4. 2001 Holger Freyther <freyther@kde.org>
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public License
  14. along with this library; see the file COPYING.LIB. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef __tdeio_rename_dlg__
  19. #define __tdeio_rename_dlg__
  20. #include <kurl.h>
  21. #include <tqdialog.h>
  22. #include <tqstring.h>
  23. #include <sys/types.h>
  24. #include <tdeio/global.h>
  25. namespace TDEIO {
  26. // KDE4: get rid of M_OVERWRITE_ITSELF, trigger it internally if src==dest
  27. enum RenameDlg_Mode { M_OVERWRITE = 1, M_OVERWRITE_ITSELF = 2, M_SKIP = 4, M_SINGLE = 8, M_MULTI = 16, M_RESUME = 32, M_NORENAME = 64 };
  28. /**
  29. * The result of open_RenameDlg().
  30. */
  31. enum RenameDlg_Result { R_RESUME = 6, R_RESUME_ALL = 7, R_OVERWRITE = 4, R_OVERWRITE_ALL = 5, R_SKIP = 2, R_AUTO_SKIP = 3, R_RENAME = 1, R_CANCEL = 0 };
  32. /**
  33. * A dialog for the options to rename two files.
  34. * @short A dialog for renaming files.
  35. * @since 3.1
  36. */
  37. class TDEIO_EXPORT RenameDlg : public TQDialog
  38. {
  39. Q_OBJECT
  40. public:
  41. /**
  42. * Construct a "rename" dialog.
  43. * @param parent parent widget (often 0)
  44. * @param caption the caption for the dialog box
  45. * @param src the url to the file/dir we're trying to copy, as it's part of the text message
  46. * @param dest the path to destination file/dir, i.e. the one that already exists
  47. * @param mode parameters for the dialog (which buttons to show...),
  48. * @param sizeSrc size of source file
  49. * @param sizeDest size of destination file
  50. * @param ctimeSrc creation time of source file
  51. * @param ctimeDest creation time of destination file
  52. * @param mtimeSrc modification time of source file
  53. * @param mtimeDest modification time of destination file
  54. * @param modal set to true for a modal dialog
  55. * @see RenameDlg_Mode
  56. */
  57. RenameDlg( TQWidget *parent, const TQString & caption,
  58. // KDE4: make those KURLs, and use pathOrURL() internally.
  59. const TQString & src, const TQString & dest,
  60. RenameDlg_Mode mode,
  61. TDEIO::filesize_t sizeSrc = (TDEIO::filesize_t) -1,
  62. TDEIO::filesize_t sizeDest = (TDEIO::filesize_t) -1,
  63. time_t ctimeSrc = (time_t) -1,
  64. time_t ctimeDest = (time_t) -1,
  65. time_t mtimeSrc = (time_t) -1,
  66. time_t mtimeDest = (time_t) -1,
  67. bool modal = false );
  68. ~RenameDlg();
  69. /**
  70. * @return the new destination
  71. * valid only if RENAME was chosen
  72. */
  73. KURL newDestURL();
  74. /**
  75. * Given a directory path and a filename (which usually exists already),
  76. * this function returns a suggested name for a file that doesn't exist
  77. * in that directory. The existence is only checked for local urls though.
  78. * The suggested file name is of the form foo_1 foo_2 etc.
  79. * @since 3.4
  80. */
  81. static TQString suggestName(const KURL& baseURL, const TQString& oldName);
  82. public slots:
  83. /// KDE4: rename to cancelPressed(), renamePressed() etc.
  84. void b0Pressed();
  85. void b1Pressed();
  86. void b2Pressed();
  87. void b3Pressed();
  88. void b4Pressed();
  89. void b5Pressed();
  90. void b6Pressed();
  91. void b7Pressed();
  92. void b8Pressed();
  93. protected slots:
  94. void enableRenameButton(const TQString &);
  95. private:
  96. class RenameDlgPrivate;
  97. RenameDlgPrivate *d;
  98. void pluginHandling( );
  99. };
  100. /**
  101. * \addtogroup renamedlg "RenameDlg related Functions"
  102. * @{
  103. * \relates TDEIO::RenameDlg
  104. * Construct a modal, parent-less "rename" dialog, and return
  105. * a result code, as well as the new dest. Much easier to use than the
  106. * class RenameDlg directly.
  107. * @param caption the caption for the dialog box
  108. * @param src the URL of the file/dir we're trying to copy, as it's part of the text message
  109. * @param dest the URL of the destination file/dir, i.e. the one that already exists
  110. * @param mode parameters for the dialog (which buttons to show...),
  111. * see RenameDlg_Mode
  112. * @param newDest the new destination path, valid if R_RENAME was returned.
  113. * @param sizeSrc size of source file
  114. * @param sizeDest size of destination file
  115. * @param ctimeSrc creation time of source file
  116. * @param ctimeDest creation time of destination file
  117. * @param mtimeSrc modification time of source file
  118. * @param mtimeDest modification time of destination file
  119. * @return the result
  120. */
  121. TDEIO_EXPORT RenameDlg_Result open_RenameDlg( const TQString & caption,
  122. // KDE4: make those KURLs
  123. const TQString& src, const TQString & dest,
  124. RenameDlg_Mode mode, TQString& newDestPath,
  125. TDEIO::filesize_t sizeSrc = (TDEIO::filesize_t) -1,
  126. TDEIO::filesize_t sizeDest = (TDEIO::filesize_t) -1,
  127. time_t ctimeSrc = (time_t) -1,
  128. time_t ctimeDest = (time_t) -1,
  129. time_t mtimeSrc = (time_t) -1,
  130. time_t mtimeDest = (time_t) -1
  131. );
  132. /*! @} */
  133. }
  134. #endif