summaryrefslogtreecommitdiffstats
path: root/src/ksvnwidgets/depthselector.cpp
blob: 78c1a7d520f78e86b7f473d95f68469ff9523a7d (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
/***************************************************************************
 *   Copyright (C) 2007 by Rajko Albrecht  ral@alwins-world.de             *
 *   http://tdesvn.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 "depthselector.h"
#include "version_check.h"

#include <tdelocale.h>

#include <tqbuttongroup.h>
#include <tqcheckbox.h>
#include <tqlayout.h>
#include <tqcombobox.h>


DepthSelector::DepthSelector(TQWidget *parent, const char *name)
    :DepthSettings(parent, name)
{
    if (svn::Version::version_major()>1|| svn::Version::version_minor()>4 ) {
        m_recurse = 0L;
        m_DepthCombo->setCurrentItem(3);
    } else {
        delete m_DepthCombo;
        m_DepthCombo=0;
        DepthFormLayout->removeItem(m_leftspacer);
        m_recurse = new TQCheckBox( this, "m_RecursiveButton" );
        m_recurse->setChecked( TRUE );
        m_recurse->setText(i18n( "Recursive" ));
        DepthFormLayout->addWidget( m_recurse );
        m_recurse->setSizePolicy(TQSizePolicy::Fixed,TQSizePolicy::Fixed);
        DepthFormLayout->addItem(m_leftspacer);
    }
    DepthFormLayout->setMargin(0);
    setMinimumSize(minimumSizeHint());
    adjustSize();
}

DepthSelector::~DepthSelector()
{
}
void DepthSelector::addItemWidget(TQWidget*aWidget)
{
    DepthFormLayout->removeItem(m_leftspacer);
    aWidget->reparent(this,geometry().topLeft());
    DepthFormLayout->addWidget(aWidget);
    aWidget->setSizePolicy(TQSizePolicy::Fixed,TQSizePolicy::Fixed);
    DepthFormLayout->addItem(m_leftspacer);
    setMinimumSize(minimumSizeHint());
}

/*!
    \fn DepthSelector::getDepth()const
 */
svn::Depth DepthSelector::getDepth()const
{
    if (m_DepthCombo) {
        switch (m_DepthCombo->currentItem()){
            case 0:
                return svn::DepthEmpty;
                break;
            case 1:
                return svn::DepthFiles;
                break;
            case 2:
                return svn::DepthImmediates;
                break;
            case 3:
            default:
                return svn::DepthInfinity;
        }
    } else {
        return (m_recurse->isChecked()?svn::DepthInfinity:svn::DepthEmpty);
    }
}

void DepthSelector::hideDepth(bool hide)
{
    TQWidget*w = m_DepthCombo? (TQWidget*)m_DepthCombo:(TQWidget*)m_recurse;
    if (hide) w->hide(); else w->show();
}

#include "depthselector.moc"