File indexing completed on 2024-04-28 05:42:00

0001 /***************************************************************************
0002  *   Copyright (C) 2005-2009 by Rajko Albrecht                             *
0003  *   ral@alwins-world.de                                                   *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0019  ***************************************************************************/
0020 
0021 #include "copymoveview_impl.h"
0022 #include "ksvnwidgets/ksvndialog.h"
0023 
0024 #include <KLocalizedString>
0025 
0026 CopyMoveView_impl::CopyMoveView_impl(const QString &baseName, const QString &sourceName, bool move, QWidget *parent)
0027     : QWidget(parent)
0028 {
0029     setupUi(this);
0030 
0031     m_BaseName = baseName;
0032     if (!m_BaseName.isEmpty() && !m_BaseName.endsWith(QLatin1Char('/'))) {
0033         m_BaseName += QLatin1Char('/');
0034     }
0035     m_PrefixLabel->setText(m_BaseName);
0036     m_OldNameLabel->setText("<b>" + sourceName + "</b>");
0037     m_OldName = sourceName;
0038     if (m_BaseName.length() > 0) {
0039         QString t = m_OldName.right(m_OldName.length() - m_BaseName.length());
0040         m_NewNameInput->setText(t);
0041     } else {
0042         m_PrefixLabel->hide();
0043         m_NewNameInput->setText(sourceName);
0044     }
0045     if (move) {
0046         m_HeadOneLabel->setText(i18n("Rename/move"));
0047     } else {
0048         m_HeadOneLabel->setText(i18n("Copy"));
0049     }
0050 }
0051 
0052 CopyMoveView_impl::~CopyMoveView_impl()
0053 {
0054 }
0055 
0056 /*!
0057     \fn CopyMoveView_impl::newName()
0058  */
0059 QString CopyMoveView_impl::newName() const
0060 {
0061     return m_BaseName + m_NewNameInput->text();
0062 }
0063 
0064 /*!
0065     \fn CopyMoveView_impl::getMoveCopyTo(bool*ok,const QString&old,const QString&base,QWidget*)
0066  */
0067 QString CopyMoveView_impl::getMoveCopyTo(bool *ok, bool move, const QString &old, const QString &base, QWidget *parent)
0068 {
0069     QPointer<KSvnSimpleOkDialog> dlg(new KSvnSimpleOkDialog(QStringLiteral("copy_move_dlg"), parent));
0070     dlg->setWindowTitle(move ? i18nc("@title:window", "Move/Rename File/Directory") : i18nc("@title:window", "Copy File/Directory"));
0071     dlg->setWithCancelButton();
0072 
0073     CopyMoveView_impl *ptr = new CopyMoveView_impl(base, old, (move), dlg);
0074     dlg->addWidget(ptr);
0075     QString nName;
0076     if (dlg->exec() != QDialog::Accepted) {
0077         if (ok) {
0078             *ok = false;
0079         }
0080     } else {
0081         nName = ptr->newName();
0082         if (ok) {
0083             *ok = true;
0084         }
0085     }
0086     delete dlg;
0087     return nName;
0088 }
0089 
0090 #include "moc_copymoveview_impl.cpp"