File indexing completed on 2024-05-12 05:44:24
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht ral@alwins-world.de * 0003 * https://kde.org/applications/development/org.kde.kdesvn * 0004 * * 0005 * This program is free software; you can redistribute it and/or * 0006 * modify it under the terms of the GNU General Public * 0007 * License as published by the Free Software Foundation; either * 0008 * version 2.1 of the License, or (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 GNU * 0013 * General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public * 0016 * License along with this program (in the file GPL.txt); if not, * 0017 * write to the Free Software Foundation, Inc., 51 Franklin St, * 0018 * Fifth Floor, Boston, MA 02110-1301 USA * 0019 * * 0020 * This software consists of voluntary contributions made by many * 0021 * individuals. For exact contribution history, see the revision * 0022 * history and logs, available at https://commits.kde.org/kdesvn. * 0023 ***************************************************************************/ 0024 #include "dbsettings.h" 0025 #include "ui_dbsettings.h" 0026 0027 #include "svnqt/cache/ReposConfig.h" 0028 #include <QPointer> 0029 0030 DbSettings::DbSettings(const QString &repository, QWidget *parent) 0031 : KSvnDialog(QLatin1String("db_settings_dlg"), parent) 0032 , m_repository(repository) 0033 , m_ui(new Ui::DbSettings) 0034 { 0035 m_ui->setupUi(this); 0036 setDefaultButton(m_ui->buttonBox->button(QDialogButtonBox::Ok)); 0037 connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &DbSettings::accept); 0038 connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &DbSettings::reject); 0039 setWindowTitle(i18nc("@title:window", "Settings for %1", repository)); 0040 init(); 0041 } 0042 0043 DbSettings::~DbSettings() 0044 { 0045 delete m_ui; 0046 } 0047 0048 void DbSettings::init() 0049 { 0050 m_ui->dbcfg_exclude_box->setItems(svn::cache::ReposConfig::self()->readEntry(m_repository, "tree_exclude_list", QStringList())); 0051 m_ui->dbcfg_exclude_userslog->setItems(svn::cache::ReposConfig::self()->readEntry(m_repository, "exclude_log_users", QStringList())); 0052 m_ui->dbcfg_exclude_log_pattern->setItems(svn::cache::ReposConfig::self()->readEntry(m_repository, "exclude_log_pattern", QStringList())); 0053 m_ui->dbcfg_noCacheUpdate->setChecked(svn::cache::ReposConfig::self()->readEntry(m_repository, "no_update_cache", false)); 0054 m_ui->dbcfg_filter_empty_author->setChecked(svn::cache::ReposConfig::self()->readEntry(m_repository, "filter_empty_author", false)); 0055 } 0056 0057 void DbSettings::store_list(KEditListWidget *which, const QString &key) 0058 { 0059 if (!which || key.isEmpty()) { 0060 return; 0061 } 0062 const QStringList _v = which->items(); 0063 if (!_v.isEmpty()) { 0064 svn::cache::ReposConfig::self()->setValue(m_repository, key, _v); 0065 } else { 0066 svn::cache::ReposConfig::self()->eraseValue(m_repository, key); 0067 } 0068 } 0069 0070 void DbSettings::accept() 0071 { 0072 store_list(m_ui->dbcfg_exclude_box, "tree_exclude_list"); 0073 store_list(m_ui->dbcfg_exclude_userslog, "exclude_log_users"); 0074 store_list(m_ui->dbcfg_exclude_log_pattern, "exclude_log_pattern"); 0075 svn::cache::ReposConfig::self()->setValue(m_repository, "no_update_cache", m_ui->dbcfg_noCacheUpdate->isChecked()); 0076 svn::cache::ReposConfig::self()->setValue(m_repository, "filter_empty_author", m_ui->dbcfg_filter_empty_author->isChecked()); 0077 KSvnDialog::accept(); 0078 } 0079 0080 void DbSettings::showSettings(const QString &repository, QWidget *parent) 0081 { 0082 QPointer<DbSettings> dlg(new DbSettings(repository, parent ? parent : QApplication::activeModalWidget())); 0083 dlg->exec(); 0084 delete dlg; 0085 } 0086 0087 #include "moc_dbsettings.cpp"