summaryrefslogtreecommitdiffstats
path: root/src/svnfrontend/fronthelpers/checkoutinfo_impl.cpp
blob: 46b6452331c72fc973dadcc0ed8005abd54e455f (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/***************************************************************************
 *   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 "checkoutinfo_impl.h"
#include "rangeinput_impl.h"
#include "src/ksvnwidgets/depthselector.h"
#include "src/svnqt/url.hpp"
#include "helpers/ktranslateurl.h"
#include <kurlrequester.h>
#include <tqlabel.h>
#include <tqtooltip.h>

#include <klineedit.h>
#include <tqcheckbox.h>
#include <klocale.h>
#include <kdebug.h>

CheckoutInfo_impl::CheckoutInfo_impl(TQWidget *tqparent, const char *name)
    :CheckoutInfo(tqparent, name)
{
    m_RangeInput->setStartOnly(true);
    m_RangeInput->setHeadDefault();
}

CheckoutInfo_impl::~CheckoutInfo_impl()
{
}

svn::Revision CheckoutInfo_impl::toRevision()
{
    return m_RangeInput->getRange().first;
}

TQString CheckoutInfo_impl::reposURL()
{
    KURL uri(m_UrlEdit->url());
    TQString proto = svn::Url::transformProtokoll(uri.protocol());
    if (proto=="file"&&!m_UrlEdit->url().startsWith("ksvn+file:")) {
        uri.setProtocol("");
    } else {
        uri.setProtocol(proto);
    }
    return uri.prettyURL();
}

TQString CheckoutInfo_impl::targetDir()
{
    if (!m_CreateDirButton->isChecked()) {
        return  m_TargetSelector->url();
    }
    TQString _uri = reposURL();
    while (_uri.endsWith("/")) {
        _uri.truncate(_uri.length()-1);
    }
    TQStringList l = TQStringList::split('/',_uri);
    if (l.count()==0) {
        return m_TargetSelector->url();
    }
    return  m_TargetSelector->url()+"/"+l[l.count()-1];
}

bool CheckoutInfo_impl::overwrite()
{
    return m_overwriteButton->isChecked();
}

/*!
    \fn CheckoutInfo_impl::setTargetUrl(const TQString&)
 */
void CheckoutInfo_impl::setTargetUrl(const TQString&what)
{
    m_TargetSelector->setURL(what);
}

void CheckoutInfo_impl::setStartUrl(const TQString&what)
{
    KURL uri(what);
    if (uri.protocol()=="file") {
        if (what.startsWith("file:")) {
            uri.setProtocol("ksvn+file");
        } else {
            uri.setProtocol("");
        }
    } else {
        uri.setProtocol(helpers::KTranslateUrl::makeKdeUrl(uri.protocol()));
    }
    m_UrlEdit->setURL(uri.prettyURL());
}

void CheckoutInfo_impl::hideDepth(bool how,bool overwriteAsRecurse)
{
    if (how) {
        m_DepthSelector->setEnabled(false);
        m_DepthSelector->hide();
        if (overwriteAsRecurse) {
            TQToolTip::add( m_overwriteButton, i18n( "Make operation recursive." ) );
            m_overwriteButton->setText(i18n("Recursive"));
        }
    } else if (!how) {
        m_DepthSelector->setEnabled(false);
        m_DepthSelector->show();
        m_overwriteButton->setText( tr2i18n( "Overwrite existing" ) );
        TQToolTip::add( m_overwriteButton, tr2i18n( "May existing unversioned items ovewritten" ) );
    }
    adjustSize();
}

svn::Depth CheckoutInfo_impl::getDepth()
{
    if (m_DepthSelector->isEnabled()) {
        return m_DepthSelector->getDepth();
    }
    return svn::DepthUnknown;
}

void CheckoutInfo_impl::disableTargetDir(bool how)
{
    if (how) {
        m_TargetSelector->setEnabled(false);
        m_TargetSelector->hide();
        m_TargetLabel->hide();
    } else if (!how) {
        m_TargetSelector->setEnabled(true);
        m_TargetSelector->show();
        m_TargetLabel->show();
    }
}

void CheckoutInfo_impl::disableOpen(bool how)
{
    if (how) {
        m_ShowExplorer->setEnabled(false);
        m_ShowExplorer->hide();
    } else if (!how) {
        m_ShowExplorer->setEnabled(true);
        m_ShowExplorer->show();
    }
}


/*!
    \fn CheckoutInfo_impl::openAfterJob()
 */
bool CheckoutInfo_impl::openAfterJob()
{
    return m_ShowExplorer->isChecked();
}

/*!
    \fn CheckoutInfo_impl::disableRange(bool how)
 */
void CheckoutInfo_impl::disableRange(bool how)
{
    if (how) {
        m_RangeInput->setEnabled(false);
        m_RangeInput->hide();
    } else {
        m_RangeInput->setEnabled(true);
        m_RangeInput->show();
    }
}

void CheckoutInfo_impl::urlChanged(const TQString&)
{
}

void CheckoutInfo_impl::disableAppend(bool how)
{
    m_CreateDirButton->setChecked(!how);
    if (how) {
        m_CreateDirButton->hide();
    } else {
        m_CreateDirButton->show();
    }
}

/*!
    \fn CheckoutInfo_impl::ignoreExternals()
 */
bool CheckoutInfo_impl::ignoreExternals()
{
    return m_ignoreExternals->isChecked();
}

void CheckoutInfo_impl::disableExternals(bool how)
{
    m_ignoreExternals->setChecked(!how);
    if (how) {
        m_ignoreExternals->hide();
    } else {
        m_ignoreExternals->show();
    }
}

#include "checkoutinfo_impl.moc"