summaryrefslogtreecommitdiffstats
path: root/src/svnfrontend/copymoveview_impl.cpp
blob: 98e3d6088f67bd95a7863dd8b0331b68619965b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/***************************************************************************
 *   Copyright (C) 2005-2007 by Rajko Albrecht                             *
 *   ral@alwins-world.de                                                   *
 *                                                                         *
 *   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  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/


#include "copymoveview_impl.h"
#include <ksqueezedtextlabel.h>
#include <tqcheckbox.h>
#include <tqlabel.h>
#include <klineedit.h>
#include <klocale.h>
#include <kdialogbase.h>
#include <tqvbox.h>

CopyMoveView_impl::CopyMoveView_impl(const TQString&baseName,const TQString&sourceName,bool move,TQWidget* parent, const char* name, WFlags fl)
: CopyMoveView(parent,name,fl)
{
    m_BaseName = baseName;
    if (m_BaseName.length()>0 && !m_BaseName.endsWith("/")) {
        m_BaseName+="/";
    }
    m_PrefixLabel->setText(m_BaseName);
    m_OldNameLabel->setText("<b>"+sourceName+"</b>");
    m_OldName = sourceName;
    if (m_BaseName.length()>0) {
        TQString t = m_OldName.right(m_OldName.length()-m_BaseName.length());
        m_NewNameInput->setText(t);
    } else {
        m_PrefixLabel->hide();
        m_NewNameInput->setText(sourceName);
    }
    if (move) {
        m_HeadOneLabel->setText(i18n("Rename/move"));
    } else {
        m_HeadOneLabel->setText(i18n("Copy"));
        m_ForceBox->hide();
    }
}

CopyMoveView_impl::~CopyMoveView_impl()
{
}


/*!
    \fn CopyMoveView_impl::newName()
 */
TQString CopyMoveView_impl::newName()
{
    return m_BaseName+m_NewNameInput->text();
}


/*!
    \fn CopyMoveView_impl::force()
 */
bool CopyMoveView_impl::force()
{
    return m_ForceBox->isChecked();
}


/*!
    \fn CopyMoveView_impl::getMoveCopyTo(bool*ok,bool*force,const TQString&old,const TQString&base,TQWidget*)
 */
TQString CopyMoveView_impl::getMoveCopyTo(bool*ok,bool*force,bool move,
    const TQString&old,const TQString&base,TQWidget*parent,const char*name)
{
    KDialogBase dlg(parent,name,true,(move?i18n("Move/Rename file/dir"):i18n("Copy file/dir")),
            KDialogBase::Ok|KDialogBase::Cancel,
            KDialogBase::NoDefault);
    TQWidget* Dialog1Layout = dlg.makeVBoxMainWidget();
    CopyMoveView_impl*ptr=new CopyMoveView_impl(base,old,(move),Dialog1Layout);
    TQString nName = TQString();
    dlg.resize( TQSize(500,160).expandedTo(dlg.tqminimumSizeHint()) );
    if (dlg.exec()!=TQDialog::Accepted) {
        if (ok) *ok = false;
    } else {
        if (force) *force = ptr->force();
        nName = ptr->newName();
        if (ok) *ok=true;
    }
    return nName;
}

#include "copymoveview_impl.moc"