summaryrefslogtreecommitdiffstats
path: root/src/svnfrontend/mergedlg_impl.cpp
blob: b0c1d871c6de2d18e8a3314f04269ccbdbe6b000 (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
212
213
/***************************************************************************
 *   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 "mergedlg_impl.h"
#include "rangeinput_impl.h"
#include "svnqt/url.hpp"
#include "ktranslateurl.h"
#include "tdesvnsettings.h"

#include <kurlrequester.h>
#include <kdialogbase.h>
#include <klocale.h>
#include <kdebug.h>
#include <tqlabel.h>
#include <tqcheckbox.h>
#include <tqvbox.h>

MergeDlg_impl::MergeDlg_impl(TQWidget *parent, const char *name,bool src1,bool src2,bool out)
    :MergeDlg(parent, name)
{
    m_SrcOneInput->setMode(KFile::Directory|KFile::File);
    if (!src1) {
        m_SrcOneInput->setEnabled(false);
        m_SrcOneInput->hide();
        m_SrcOneLabel->hide();
    }
    m_SrcTwoInput->setMode(KFile::Directory|KFile::File);
    if (!src2) {
        m_SrcTwoInput->setEnabled(false);
        m_SrcTwoInput->hide();
        m_SrcTwoLabel->hide();
    }
    m_OutInput->setMode(KFile::LocalOnly|KFile::Directory|KFile::File);
    if (!out) {
        m_OutInput->setEnabled(false);
        m_OutInput->hide();
        m_OutLabel->hide();
    }
    adjustSize();
    setMinimumSize(minimumSizeHint());
    m_useExternMerge->setChecked(Kdesvnsettings::extern_merge_default());
}

MergeDlg_impl::~MergeDlg_impl()
{
}

void MergeDlg_impl::setSrc1(const TQString&what)
{
    if (what.isEmpty()) {
        m_SrcOneInput->setURL("");
        return;
    }
    KURL uri(what);
    kdDebug()<<"What: "<<what << " URL: "<<uri<<endl;
    if (uri.protocol()=="file") {
        if (what.startsWith("file:")) {
            uri.setProtocol("ksvn+file");
        } else {
            uri.setProtocol("");
        }
    } else {
        uri.setProtocol(helpers::KTranslateUrl::makeKdeUrl(uri.protocol()));
    }
    m_SrcOneInput->setURL(uri.url());
}

void MergeDlg_impl::setSrc2(const TQString&what)
{
    if (what.isEmpty()) {
        m_SrcTwoInput->setURL("");
        return;
    }
    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_SrcTwoInput->setURL(uri.url());
}

void MergeDlg_impl::setDest(const TQString&what)
{
    if (what.isEmpty()) {
        m_OutInput->setURL("");
        return;
    }
    KURL uri(what);
    uri.setProtocol("");
    m_OutInput->setURL(uri.url());
}

bool MergeDlg_impl::recursive()const
{
    return m_RecursiveCheck->isChecked();
}

bool MergeDlg_impl::force()const
{
    return m_ForceCheck->isChecked();
}

bool MergeDlg_impl::ignorerelated()const
{
    return m_RelatedCheck->isChecked();
}

bool MergeDlg_impl::dryrun()const
{
    return m_DryCheck->isChecked();
}

bool MergeDlg_impl::useExtern()const
{
    return m_useExternMerge->isChecked();
}

TQString MergeDlg_impl::Src1()const
{
    KURL uri(m_SrcOneInput->url());
    TQString proto = svn::Url::transformProtokoll(uri.protocol());
    if (proto=="file"&&!m_SrcOneInput->url().startsWith("ksvn+file:")) {
        uri.setProtocol("");
    } else {
        uri.setProtocol(proto);
    }
    return uri.url();
}

TQString MergeDlg_impl::Src2()const
{
    if (m_SrcTwoInput->url().isEmpty()) {
        return "";
    }
    KURL uri(m_SrcTwoInput->url());
    TQString proto = svn::Url::transformProtokoll(uri.protocol());
    if (proto=="file"&&!m_SrcTwoInput->url().startsWith("ksvn+file:")) {
        uri.setProtocol("");
    } else {
        uri.setProtocol(proto);
    }
    return uri.url();
}

TQString MergeDlg_impl::Dest()const
{
    KURL uri(m_OutInput->url());
    uri.setProtocol("");
    return uri.url();
}

Rangeinput_impl::revision_range MergeDlg_impl::getRange()const
{
    return m_RangeInput->getRange();
}


/*!
    \fn MergeDlg_impl::getMergeRange(bool*force,bool*recursive,bool*related,bool*dry)
 */
bool MergeDlg_impl::getMergeRange(Rangeinput_impl::revision_range&range,bool*force,bool*recursive,bool*ignorerelated,bool*dry,
    bool*useExternal,
    TQWidget*parent,const char*name)
{
    MergeDlg_impl*ptr = 0;
    KDialogBase dlg(parent,name,true,i18n("Enter merge range"),
            KDialogBase::Ok|KDialogBase::Cancel|KDialogBase::Help,
            KDialogBase::Ok,true);
    dlg.setHelp("merging-items","tdesvn");
    TQWidget* Dialog1Layout = dlg.makeVBoxMainWidget();
    ptr = new MergeDlg_impl(Dialog1Layout,"merge_range_dlg",false,false,false);
    dlg.resize( TQSize(480,360).expandedTo(dlg.minimumSizeHint()) );
    if (dlg.exec()!=TQDialog::Accepted) {
        return false;
    }
    range = ptr->getRange();
    *force = ptr->force();
    *recursive=ptr->recursive();
    *ignorerelated=ptr->ignorerelated();
    *dry = ptr->dryrun();
    *useExternal = ptr->useExtern();
    return true;
}

void MergeDlg_impl::externDisplayToggled(bool how)
{
    m_DryCheck->setEnabled(!how);
    m_RelatedCheck->setEnabled(!how);
    m_ForceCheck->setEnabled(!how);
}

#include "mergedlg_impl.moc"