Changeset View
Changeset View
Standalone View
Standalone View
src/views/renamedialog.h
Show All 23 Lines | |||||
24 | 24 | | |||
25 | #include <QDialog> | 25 | #include <QDialog> | ||
26 | #include <KFileItem> | 26 | #include <KFileItem> | ||
27 | #include <QString> | 27 | #include <QString> | ||
28 | 28 | | |||
29 | class QLineEdit; | 29 | class QLineEdit; | ||
30 | class QSpinBox; | 30 | class QSpinBox; | ||
31 | class QPushButton; | 31 | class QPushButton; | ||
32 | 32 | class KJob; | |||
33 | /** | 33 | /** | ||
34 | * @brief Dialog for renaming a variable number of files. | 34 | * @brief Dialog for renaming a variable number of files. | ||
35 | */ | 35 | */ | ||
36 | class DOLPHIN_EXPORT RenameDialog : public QDialog | 36 | class DOLPHIN_EXPORT RenameDialog : public QDialog | ||
37 | { | 37 | { | ||
38 | Q_OBJECT | 38 | Q_OBJECT | ||
39 | 39 | | |||
40 | public: | 40 | public: | ||
41 | explicit RenameDialog(QWidget* parent, const KFileItemList& items); | 41 | explicit RenameDialog(QWidget* parent, const KFileItemList& items); | ||
42 | ~RenameDialog() override; | 42 | ~RenameDialog() override; | ||
43 | 43 | | |||
44 | signals: | 44 | signals: | ||
45 | void renamingFinished(const QList<QUrl>& urls); | 45 | void renamingFinished(const QList<QUrl>& urls); | ||
46 | 46 | | |||
47 | private slots: | 47 | private slots: | ||
48 | void slotAccepted(); | 48 | void slotAccepted(); | ||
49 | void slotTextChanged(const QString& newName); | 49 | void slotTextChanged(const QString& newName); | ||
50 | void slotFileRenamed(const QUrl& oldUrl, const QUrl& newUrl); | ||||
51 | void slotResult(KJob* job); | ||||
50 | 52 | | |||
51 | protected: | 53 | protected: | ||
52 | void showEvent(QShowEvent* event) override; | 54 | void showEvent(QShowEvent* event) override; | ||
53 | 55 | | |||
54 | private: | 56 | private: | ||
55 | void renameItems(); | | |||
56 | void renameItem(const KFileItem &item, const QString& newName); | | |||
57 | | ||||
58 | /** | | |||
59 | * @return Returns the string \p name, where the characters represented by | | |||
60 | * \p indexPlaceHolder get replaced by the index \p index. | | |||
61 | * E. g. Calling indexedName("Test #.jpg", 12, '#') returns "Test 12.jpg". | | |||
62 | * A connected sequence of placeholders results in leading zeros: | | |||
63 | * indexedName("Test ####.jpg", 12, '#') returns "Test 0012.jpg". | | |||
64 | */ | | |||
65 | static QString indexedName(const QString& name, int index, const QChar& indexPlaceHolder); | | |||
66 | | ||||
67 | private: | | |||
68 | bool m_renameOneItem; | 57 | bool m_renameOneItem; | ||
69 | QList<QUrl> m_renamedItems; | 58 | QList<QUrl> m_renamedItems; | ||
70 | QString m_newName; | 59 | QString m_newName; | ||
71 | QLineEdit* m_lineEdit; | 60 | QLineEdit* m_lineEdit; | ||
72 | KFileItemList m_items; | 61 | KFileItemList m_items; | ||
73 | bool m_allExtensionsDifferent; | 62 | bool m_allExtensionsDifferent; | ||
74 | QSpinBox* m_spinBox; | 63 | QSpinBox* m_spinBox; | ||
75 | QPushButton* m_okButton; | 64 | QPushButton* m_okButton; | ||
76 | }; | 65 | }; | ||
77 | 66 | | |||
78 | #endif | 67 | #endif |