diff options
| author | Peter Penz <[email protected]> | 2010-10-05 16:30:03 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2010-10-05 16:30:03 +0000 |
| commit | 828ba8902ce16819a385832b487e60eab36e54ca (patch) | |
| tree | 429a18e73be3cc5b61a48a31385f021a7d29f9de /src/views/renamedialog.h | |
| parent | 7fcab3c7839d46592dc821b12c572a7040435a38 (diff) | |
- Integrate the patch from Matthias Fuchs from http://reviewboard.kde.org/r/5496 to allow having leading zeros when renaming files: E.g. Using the name "A ###.jpg" results in the filenames "A 001.jpg", "A 002.jpg"... The patch could be simplified a little bit by guaranting only one connective sequence of #'s.
- Move the renaming code into the RenameDialog
CCMAIL: [email protected]
BUG: 226761
FIXED-IN: 4.6.0
svn path=/trunk/KDE/kdebase/apps/; revision=1182776
Diffstat (limited to 'src/views/renamedialog.h')
| -rw-r--r-- | src/views/renamedialog.h | 72 |
1 files changed, 20 insertions, 52 deletions
diff --git a/src/views/renamedialog.h b/src/views/renamedialog.h index 5015b51bd..73414093c 100644 --- a/src/views/renamedialog.h +++ b/src/views/renamedialog.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz ([email protected]) * + * Copyright (C) 2006-2010 by Peter Penz ([email protected]) * * * * 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 * @@ -16,86 +16,54 @@ * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ + #ifndef RENAMEDIALOG_H #define RENAMEDIALOG_H #include "libdolphin_export.h" #include <kdialog.h> -#include <kurl.h> +#include <kfileitem.h> -class KFileItem; -class KFileItemList; class KLineEdit; #include <QString> /** * @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(); - * 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 - * } - * } - * \endcode */ class LIBDOLPHINPRIVATE_EXPORT RenameDialog : public KDialog { Q_OBJECT public: - explicit RenameDialog(QWidget *parent, const KFileItemList& items); + explicit RenameDialog(QWidget* parent, const KFileItemList& items); virtual ~RenameDialog(); - /** - * 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 than one item should be - * renamed). - */ - QString newName() const; - - /** - * Returns the error string, if Dialog::newName() returned an empty string. - */ - QString errorString() const; - protected slots: virtual void slotButtonClicked(int button); private slots: - void slotTextChanged(const QString &newName); + void slotTextChanged(const QString& newName); private: - bool m_renameOneItem; - KLineEdit* m_lineEdit; - QString m_newName; - QString m_errorString; + void renameItems(); - friend class RenameDialogTest; // allow access for unit testing -}; -inline QString RenameDialog::newName() const -{ - return m_newName; -} + /** + * @return Returns the string \p name, where the characters represented by + * \p indexPlaceHolder get replaced by the index \p index. + * E. g. Calling indexedName("Test #.jpg", 12, '#') returns "Test 12.jpg". + * A connected sequence of placeholders results in leading zeros: + * indexedName("Test ####.jpg", 12, '#') returns "Test 0012.jpg". + */ + static QString indexedName(const QString& name, int index, const QChar& indexPlaceHolder); -inline QString RenameDialog::errorString() const -{ - return m_errorString; -} +private: + bool m_renameOneItem; + QString m_newName; + KLineEdit* m_lineEdit; + KFileItemList m_items; +}; #endif |
