File indexing completed on 2024-04-28 05:42:00
0001 /*************************************************************************** 0002 * Copyright (C) 2006-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 "createrepodlg.h" 0021 #include "ui_createrepodlg.h" 0022 0023 #include "svnqt/repoparameter.h" 0024 #include "svnqt/version_check.h" 0025 0026 class RecurseCheck 0027 { 0028 bool &value; 0029 0030 public: 0031 explicit RecurseCheck(bool &aValue) 0032 : value(aValue) 0033 { 0034 value = true; 0035 } 0036 ~RecurseCheck() 0037 { 0038 value = false; 0039 } 0040 }; 0041 0042 CreaterepoDlg::CreaterepoDlg(QWidget *parent) 0043 : KSvnDialog(QLatin1String("create_repo"), parent) 0044 , m_inChangeCompat(false) 0045 , m_ui(new Ui::CreateRepoDlg) 0046 { 0047 m_ui->setupUi(this); 0048 setDefaultButton(m_ui->buttonBox->button(QDialogButtonBox::Ok)); 0049 0050 const bool bGE15 = (svn::Version::version_major() > 1 || svn::Version::version_minor() >= 5); 0051 m_ui->m_presvn15compat->setEnabled(bGE15); 0052 m_ui->m_presvn15compat->setVisible(bGE15); 0053 0054 const bool bGE16 = (svn::Version::version_major() > 1 || svn::Version::version_minor() >= 6); 0055 m_ui->m_presvn16compat->setEnabled(bGE16); 0056 m_ui->m_presvn16compat->setVisible(bGE16); 0057 0058 const bool bGE18 = (svn::Version::version_major() > 1 || svn::Version::version_minor() >= 8); 0059 m_ui->m_presvn18compat->setEnabled(bGE18); 0060 m_ui->m_presvn18compat->setVisible(bGE18); 0061 0062 connect(m_ui->m_presvn15compat, &QAbstractButton::clicked, this, &CreaterepoDlg::compatChanged15); 0063 connect(m_ui->m_presvn16compat, &QAbstractButton::clicked, this, &CreaterepoDlg::compatChanged16); 0064 connect(m_ui->m_presvn18compat, &QAbstractButton::clicked, this, &CreaterepoDlg::compatChanged18); 0065 connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); 0066 connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); 0067 } 0068 0069 CreaterepoDlg::~CreaterepoDlg() 0070 { 0071 delete m_ui; 0072 } 0073 0074 void CreaterepoDlg::fsTypeChanged(int which) 0075 { 0076 m_ui->m_DisableFsync->setEnabled(which == 1); 0077 m_ui->m_LogKeep->setEnabled(which == 1); 0078 } 0079 0080 QString CreaterepoDlg::targetDir() const 0081 { 0082 // Local only 0083 return m_ui->m_ReposPathinput->url().toLocalFile(); 0084 } 0085 0086 bool CreaterepoDlg::createMain() const 0087 { 0088 return m_ui->m_CreateMainDirs->isChecked(); 0089 } 0090 0091 void CreaterepoDlg::compatChanged15() 0092 { 0093 if (m_inChangeCompat) { 0094 return; 0095 } 0096 RecurseCheck rc(m_inChangeCompat); 0097 if (m_ui->m_presvn15compat->isChecked()) { 0098 m_ui->m_presvn16compat->setChecked(false); 0099 m_ui->m_presvn18compat->setChecked(false); 0100 } 0101 } 0102 0103 void CreaterepoDlg::compatChanged16() 0104 { 0105 if (m_inChangeCompat) { 0106 return; 0107 } 0108 RecurseCheck rc(m_inChangeCompat); 0109 if (m_ui->m_presvn16compat->isChecked()) { 0110 m_ui->m_presvn15compat->setChecked(false); 0111 m_ui->m_presvn18compat->setChecked(false); 0112 } 0113 } 0114 0115 void CreaterepoDlg::compatChanged18() 0116 { 0117 if (m_inChangeCompat) { 0118 return; 0119 } 0120 RecurseCheck rc(m_inChangeCompat); 0121 if (m_ui->m_presvn18compat->isChecked()) { 0122 m_ui->m_presvn15compat->setChecked(false); 0123 m_ui->m_presvn16compat->setChecked(false); 0124 } 0125 } 0126 0127 svn::repository::CreateRepoParameter CreaterepoDlg::parameter() const 0128 { 0129 svn::repository::CreateRepoParameter params; 0130 params.path(targetDir()); 0131 params.pre15_compat(m_ui->m_presvn15compat->isChecked()); 0132 params.pre16_compat(m_ui->m_presvn16compat->isChecked()); 0133 params.pre18_compat(m_ui->m_presvn18compat->isChecked()); 0134 params.fstype(m_ui->m_FilesystemSelector->currentText()); 0135 params.bdbnosync(m_ui->m_DisableFsync->isChecked()); 0136 params.bdbautologremove(!m_ui->m_LogKeep->isChecked()); 0137 return params; 0138 } 0139 0140 #include "moc_createrepodlg.cpp"