mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
extract method renameItem, factorizes the common code
This commit is contained in:
parent
b258dcbbe9
commit
dacded2afd
2 changed files with 17 additions and 19 deletions
|
@ -128,16 +128,11 @@ RenameDialog::~RenameDialog()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenameDialog::slotButtonClicked(int button)
|
void RenameDialog::renameItem(const KFileItem &item, const QString& newName)
|
||||||
{
|
{
|
||||||
if (button == KDialog::Ok) {
|
const KUrl oldUrl = item.url();
|
||||||
m_newName = m_lineEdit->text();
|
|
||||||
|
|
||||||
if (m_renameOneItem) {
|
|
||||||
Q_ASSERT(m_items.count() == 1);
|
|
||||||
const KUrl oldUrl = m_items.first().url();
|
|
||||||
KUrl newUrl = oldUrl;
|
KUrl newUrl = oldUrl;
|
||||||
newUrl.setFileName(KIO::encodeFileName(m_newName));
|
newUrl.setFileName(KIO::encodeFileName(newName));
|
||||||
|
|
||||||
QWidget* widget = parentWidget();
|
QWidget* widget = parentWidget();
|
||||||
if (!widget) {
|
if (!widget) {
|
||||||
|
@ -145,6 +140,16 @@ void RenameDialog::slotButtonClicked(int button)
|
||||||
}
|
}
|
||||||
|
|
||||||
KonqOperations::rename(widget, oldUrl, newUrl);
|
KonqOperations::rename(widget, oldUrl, newUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenameDialog::slotButtonClicked(int button)
|
||||||
|
{
|
||||||
|
if (button == KDialog::Ok) {
|
||||||
|
m_newName = m_lineEdit->text();
|
||||||
|
|
||||||
|
if (m_renameOneItem) {
|
||||||
|
Q_ASSERT(m_items.count() == 1);
|
||||||
|
renameItem(m_items.first(), m_newName);
|
||||||
} else {
|
} else {
|
||||||
renameItems();
|
renameItems();
|
||||||
}
|
}
|
||||||
|
@ -187,15 +192,7 @@ void RenameDialog::renameItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldUrl.fileName() != newName) {
|
if (oldUrl.fileName() != newName) {
|
||||||
KUrl newUrl = oldUrl;
|
renameItem(item, newName);
|
||||||
newUrl.setFileName(KIO::encodeFileName(newName));
|
|
||||||
|
|
||||||
QWidget* widget = parentWidget();
|
|
||||||
if (!widget) {
|
|
||||||
widget = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
KonqOperations::rename(widget, oldUrl, newUrl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void renameItems();
|
void renameItems();
|
||||||
|
void renameItem(const KFileItem &item, const QString& newName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the string \p name, where the characters represented by
|
* @return Returns the string \p name, where the characters represented by
|
||||||
|
|
Loading…
Reference in a new issue