2006-11-21 06:02:05 +00:00
|
|
|
/***************************************************************************
|
2007-03-13 17:31:54 +00:00
|
|
|
* Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
|
2006-11-21 06:02:05 +00:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
2007-01-10 00:04:16 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
2006-11-21 06:02:05 +00:00
|
|
|
***************************************************************************/
|
|
|
|
#ifndef RENAMEDIALOG_H
|
|
|
|
#define RENAMEDIALOG_H
|
|
|
|
|
2007-05-19 08:03:39 +00:00
|
|
|
#include "libdolphin_export.h"
|
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
#include <kdialog.h>
|
|
|
|
#include <kurl.h>
|
2007-03-13 17:31:54 +00:00
|
|
|
|
2007-04-22 11:14:24 +00:00
|
|
|
|
2007-08-14 16:46:06 +00:00
|
|
|
class KFileItem;
|
2006-11-21 06:02:05 +00:00
|
|
|
class KLineEdit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Dialog for renaming a variable number of files.
|
|
|
|
*
|
|
|
|
* The renaming is not done by the dialog, the invoker
|
|
|
|
* must do this itself:
|
|
|
|
* \code
|
|
|
|
* RenameDialog dialog(...);
|
|
|
|
* if (dialog.exec() == QDialog::Accepted) {
|
|
|
|
* const QString& newName = dialog.newName();
|
2007-03-13 17:31:54 +00:00
|
|
|
* if (newName.isEmpty()) {
|
|
|
|
* // an invalid name has been chosen, use
|
|
|
|
* // dialog.errorString() to tell the user about this
|
|
|
|
* }
|
|
|
|
* else {
|
|
|
|
* // rename items corresponding to the new name
|
|
|
|
* }
|
2006-11-21 06:02:05 +00:00
|
|
|
* }
|
|
|
|
* \endcode
|
|
|
|
*/
|
2007-05-19 08:03:39 +00:00
|
|
|
class LIBDOLPHINPRIVATE_EXPORT RenameDialog : public KDialog
|
2006-11-21 06:02:05 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2007-08-16 13:22:18 +00:00
|
|
|
explicit RenameDialog(const QList<KFileItem>& items);
|
2006-11-21 06:02:05 +00:00
|
|
|
virtual ~RenameDialog();
|
|
|
|
|
|
|
|
/**
|
2007-03-13 18:33:00 +00:00
|
|
|
* Returns the new name of the items. If more than one
|
|
|
|
* item should be renamed, then it is assured that the # character
|
|
|
|
* is part of the returned string. If the returned string is empty,
|
|
|
|
* then RenameDialog::errorString() should be used to show the reason
|
|
|
|
* of having an empty string (e. g. if the # character has
|
|
|
|
* been deleted by the user, although more then one item should be
|
|
|
|
* renamed).
|
2006-11-21 06:02:05 +00:00
|
|
|
*/
|
2007-04-09 19:12:54 +00:00
|
|
|
const QString& newName() const
|
|
|
|
{
|
|
|
|
return m_newName;
|
|
|
|
}
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-03-13 17:31:54 +00:00
|
|
|
/**
|
|
|
|
* Returns the error string, if Dialog::newName() returned an empty string.
|
|
|
|
*/
|
2007-04-09 19:12:54 +00:00
|
|
|
const QString& errorString() const
|
|
|
|
{
|
|
|
|
return m_errorString;
|
|
|
|
}
|
2007-03-13 17:31:54 +00:00
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
protected slots:
|
2006-11-22 11:34:19 +00:00
|
|
|
virtual void slotButtonClicked(int button);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-05-18 20:52:48 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Returns the extension string for a filename, which contains all
|
|
|
|
* file extensions. Version numbers like in "cmake-2.4.5" don't count
|
|
|
|
* as file extension. If the version numbers follow after a valid extension, they
|
|
|
|
* are part of the extension string.
|
|
|
|
*
|
|
|
|
* Examples (name -> extension string):
|
|
|
|
* "Image.gif" -> ".gif"
|
|
|
|
* "package.tar.gz" -> ".tar.gz"
|
|
|
|
* "cmake-2.4.5" -> ""
|
|
|
|
* "Image.1.12.gif" -> ".gif"
|
|
|
|
* "Image.tar.1.12.gz" -> ".tar.1.12.gz"
|
|
|
|
*/
|
2007-05-18 23:36:58 +00:00
|
|
|
static QString extensionString(const QString& name);
|
2007-05-18 20:52:48 +00:00
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
private:
|
2007-03-13 18:33:00 +00:00
|
|
|
bool m_renameOneItem;
|
2006-11-21 06:02:05 +00:00
|
|
|
KLineEdit* m_lineEdit;
|
|
|
|
QString m_newName;
|
2007-03-13 17:31:54 +00:00
|
|
|
QString m_errorString;
|
2007-05-18 23:36:58 +00:00
|
|
|
|
|
|
|
friend class RenameDialogTest; // allow access for unit testing
|
2006-11-21 06:02:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|