File indexing completed on 2024-05-12 05:44:24
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 #include "rangeinput_impl.h" 0021 #include <QPointer> 0022 #include <ksvnwidgets/ksvndialog.h> 0023 0024 Rangeinput_impl::Rangeinput_impl(QWidget *parent) 0025 : QWidget(parent) 0026 , m_StartOnly(false) 0027 { 0028 setupUi(this); 0029 0030 m_startRevInput->setRange(0, INT_MAX); 0031 m_startRevInput->setSingleStep(1); 0032 m_startRevInput->setValue(1); 0033 m_endRevInput->setRange(0, INT_MAX); 0034 m_endRevInput->setSingleStep(1); 0035 m_endRevInput->setValue(1); 0036 m_startDateInput->setDateTime(QDateTime::currentDateTime()); 0037 m_stopDateInput->setDateTime(QDateTime::currentDateTime()); 0038 m_stopDateInput->setEnabled(false); 0039 m_startDateInput->setEnabled(false); 0040 m_stopHeadButton->setChecked(true); 0041 0042 const int minHeight = qMax(m_startRevInput->height(), m_startDateInput->height()); 0043 m_startNumberButton->setMinimumHeight(minHeight); 0044 m_startDateButton->setMinimumHeight(minHeight); 0045 m_startStartButton->setMinimumHeight(minHeight); 0046 m_startHeadButton->setMinimumHeight(minHeight); 0047 m_startWorkingButton->setMinimumHeight(minHeight); 0048 m_stopNumberButton->setMinimumHeight(minHeight); 0049 m_stopDateButton->setMinimumHeight(minHeight); 0050 m_stopStartButton->setMinimumHeight(minHeight); 0051 m_stopHeadButton->setMinimumHeight(minHeight); 0052 m_stopWorkingButton->setMinimumHeight(minHeight); 0053 } 0054 0055 bool Rangeinput_impl::getRevisionRange(revision_range &range, bool bWithWorking, bool bStartOnly, const svn::Revision &preset, QWidget *parent) 0056 { 0057 QPointer<KSvnSimpleOkDialog> dlg(new KSvnSimpleOkDialog(QStringLiteral("revisions_dlg"), parent)); 0058 dlg->setWindowTitle(i18nc("@title:window", "Select Revisions")); 0059 dlg->setWithCancelButton(); 0060 Rangeinput_impl *rdlg(new Rangeinput_impl(dlg)); 0061 rdlg->setNoWorking(!bWithWorking); 0062 rdlg->setStartOnly(bStartOnly); 0063 rdlg->m_startRevInput->setValue(preset.revnum()); 0064 dlg->addWidget(rdlg); 0065 if (dlg->exec() == QDialog::Accepted) { 0066 range = rdlg->getRange(); 0067 delete dlg; 0068 return true; 0069 } 0070 delete dlg; 0071 return false; 0072 } 0073 0074 void Rangeinput_impl::startNumberToggled(bool how) 0075 { 0076 m_startRevInput->setEnabled(how); 0077 if (how) { 0078 m_startDateInput->setEnabled(!how); 0079 } 0080 } 0081 0082 void Rangeinput_impl::startBaseToggled(bool how) 0083 { 0084 if (how) { 0085 m_startRevInput->setEnabled(!how); 0086 m_startDateInput->setEnabled(!how); 0087 } 0088 } 0089 0090 void Rangeinput_impl::startHeadToggled(bool how) 0091 { 0092 if (how) { 0093 m_startRevInput->setEnabled(!how); 0094 m_startDateInput->setEnabled(!how); 0095 } 0096 } 0097 0098 void Rangeinput_impl::setNoWorking(bool aValue) 0099 { 0100 if (!aValue) { 0101 if (m_startWorkingButton->isChecked()) { 0102 m_startHeadButton->setChecked(false); 0103 } 0104 if (m_stopWorkingButton->isChecked()) { 0105 m_stopHeadButton->setChecked(false); 0106 } 0107 } 0108 m_startWorkingButton->setEnabled(!aValue); 0109 m_stopWorkingButton->setEnabled(!aValue); 0110 } 0111 0112 void Rangeinput_impl::onHelp() 0113 { 0114 } 0115 0116 void Rangeinput_impl::stopHeadToggled(bool how) 0117 { 0118 if (how) { 0119 m_endRevInput->setEnabled(!how); 0120 m_stopDateInput->setEnabled(!how); 0121 } 0122 } 0123 0124 void Rangeinput_impl::stopBaseToggled(bool how) 0125 { 0126 if (how) { 0127 m_endRevInput->setEnabled(!how); 0128 m_stopDateInput->setEnabled(!how); 0129 } 0130 } 0131 0132 void Rangeinput_impl::stopNumberToggled(bool how) 0133 { 0134 m_endRevInput->setEnabled(how); 0135 if (how) { 0136 m_stopDateInput->setEnabled(!how); 0137 } 0138 } 0139 0140 Rangeinput_impl::revision_range Rangeinput_impl::getRange() const 0141 { 0142 revision_range ret; 0143 if (m_startStartButton->isChecked()) { 0144 ret.first = svn::Revision::START; 0145 } else if (m_startHeadButton->isChecked()) { 0146 ret.first = svn::Revision::HEAD; 0147 } else if (m_startNumberButton->isChecked()) { 0148 ret.first = m_startRevInput->value(); 0149 } else if (m_startDateButton->isChecked()) { 0150 ret.first = m_startDateInput->dateTime(); 0151 } else if (m_startWorkingButton->isChecked()) { 0152 ret.first = svn::Revision::WORKING; 0153 } 0154 if (m_stopStartButton->isChecked()) { 0155 ret.second = svn::Revision::START; 0156 } else if (m_stopHeadButton->isChecked()) { 0157 ret.second = svn::Revision::HEAD; 0158 } else if (m_stopNumberButton->isChecked()) { 0159 ret.second = m_endRevInput->value(); 0160 } else if (m_stopDateButton->isChecked()) { 0161 ret.second = m_stopDateInput->dateTime(); 0162 } else if (m_stopWorkingButton->isChecked()) { 0163 ret.second = svn::Revision::WORKING; 0164 } 0165 return ret; 0166 } 0167 0168 void Rangeinput_impl::stopDateToggled(bool how) 0169 { 0170 m_stopDateInput->setEnabled(how); 0171 if (how) { 0172 m_endRevInput->setEnabled(!how); 0173 } 0174 } 0175 0176 void Rangeinput_impl::startDateToggled(bool how) 0177 { 0178 m_startDateInput->setEnabled(how); 0179 if (how) { 0180 m_startRevInput->setEnabled(!how); 0181 } 0182 } 0183 0184 bool Rangeinput_impl::StartOnly() const 0185 { 0186 return m_StartOnly; 0187 } 0188 0189 void Rangeinput_impl::setHeadDefault() 0190 { 0191 m_stopHeadButton->setChecked(true); 0192 m_startHeadButton->setChecked(true); 0193 } 0194 0195 void Rangeinput_impl::setStartOnly(bool theValue) 0196 { 0197 m_StartOnly = theValue; 0198 if (m_StartOnly) { 0199 layout()->removeWidget(m_stopRevBox); 0200 m_stopRevBox->hide(); 0201 m_startRevBox->setTitle(i18n("Select revision")); 0202 } else { 0203 layout()->addWidget(m_stopRevBox); 0204 m_stopRevBox->show(); 0205 m_startRevBox->setTitle(i18n("Start with revision")); 0206 } 0207 updateGeometry(); 0208 setMinimumSize(minimumSizeHint()); 0209 resize(QSize(397, 272).expandedTo(minimumSizeHint())); 0210 } 0211 0212 #include "moc_rangeinput_impl.cpp"