From d9ac44e08f8d2abe7104c20e308d05038e1896da Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Tue, 13 Mar 2007 17:31:54 +0000 Subject: Allow renaming of items (note that currently the "rename multiple files" dialog is temporary used for this until KFileItemDelegate offers editing functionality). svn path=/trunk/KDE/kdebase/apps/; revision=642219 --- src/renamedialog.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/renamedialog.cpp') diff --git a/src/renamedialog.cpp b/src/renamedialog.cpp index 8aabb2f83..e68feff8d 100644 --- a/src/renamedialog.cpp +++ b/src/renamedialog.cpp @@ -1,6 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz * - * peter.penz@gmx.at * + * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) * * * * 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 * @@ -19,14 +18,12 @@ ***************************************************************************/ #include "renamedialog.h" -#include -#include -#include -#include -//Added by qt3to4: -#include -#include + #include +#include + +#include +#include RenameDialog::RenameDialog(const KUrl::List& items) : KDialog() @@ -37,19 +34,23 @@ RenameDialog::RenameDialog(const KUrl::List& items) : setButtonGuiItem(Ok, KGuiItem(i18n("Rename"), "dialog-apply")); - QWidget *page = new QWidget(this); + QWidget* page = new QWidget(this); setMainWidget(page); - Q3VBoxLayout* topLayout = new Q3VBoxLayout(page, 0, spacingHint()); + QVBoxLayout* topLayout = new QVBoxLayout(page); topLayout->setMargin(KDialog::marginHint()); const int itemCount = items.count(); - QLabel* editLabel = new QLabel(i18n("Rename the %1 selected items to:",itemCount), + QLabel* editLabel = new QLabel(i18n("Rename the %1 selected items to:", itemCount), page); m_lineEdit = new KLineEdit(page); m_newName = i18n("New name #"); - assert(itemCount > 1); + + // TODO: reactivate assertion as soon as KFileItemDelegate supports renaming of + // single items + //Q_ASSERT(itemCount > 1); + QString postfix(items[0].prettyUrl().section('.',1)); if (postfix.length() > 0) { // The first item seems to have a postfix (e. g. 'jpg' or 'txt'). Now @@ -88,8 +89,12 @@ void RenameDialog::slotButtonClicked(int button) { if (button==Ok) { m_newName = m_lineEdit->text(); - if (m_newName.contains('#') != 1) { + if (m_newName.isEmpty()) { + m_errorString = i18n("The new name is empty. A name with at least one character must be entered."); + } + else if (m_newName.contains('#') != 1) { m_newName.truncate(0); + m_errorString = i18n("The name must contain exactly one # character."); } } -- cgit v1.3