Warning, file /sdk/cervisia/updatedialog.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (C) 1999-2002 Bernd Gehrmann 0003 * bernd@mail.berlios.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 Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "updatedialog.h" 0021 0022 #include <KComboBox> 0023 #include <QBoxLayout> 0024 #include <QDialogButtonBox> 0025 #include <QLineEdit> 0026 #include <QPushButton> 0027 #include <QVBoxLayout> 0028 #include <qbuttongroup.h> 0029 #include <qpushbutton.h> 0030 #include <qradiobutton.h> 0031 #include <qstyle.h> 0032 0033 #include <KLocalizedString> 0034 0035 #include "cvsserviceinterface.h" 0036 #include "misc.h" 0037 0038 UpdateDialog::UpdateDialog(OrgKdeCervisia5CvsserviceCvsserviceInterface *service, QWidget *parent) 0039 : QDialog(parent) 0040 , cvsService(service) 0041 { 0042 setWindowTitle(i18n("CVS Update")); 0043 setModal(true); 0044 0045 auto mainLayout = new QVBoxLayout; 0046 setLayout(mainLayout); 0047 0048 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 0049 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); 0050 okButton->setShortcut(Qt::CTRL | Qt::Key_Return); 0051 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); 0052 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); 0053 0054 const int iComboBoxMinWidth(40 * fontMetrics().width('0')); 0055 const int iWidgetIndent(style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth) + 6); 0056 0057 bybranch_button = new QRadioButton(i18n("Update to &branch: ")); 0058 mainLayout->addWidget(bybranch_button); 0059 bybranch_button->setChecked(true); 0060 0061 branch_combo = new KComboBox; 0062 mainLayout->addWidget(branch_combo); 0063 branch_combo->setEditable(true); 0064 branch_combo->setMinimumWidth(iComboBoxMinWidth); 0065 0066 branch_button = new QPushButton(i18n("Fetch &List")); 0067 mainLayout->addWidget(branch_button); 0068 connect(branch_button, SIGNAL(clicked()), this, SLOT(branchButtonClicked())); 0069 0070 QBoxLayout *branchedit_layout = new QHBoxLayout; 0071 branchedit_layout->addSpacing(iWidgetIndent); 0072 branchedit_layout->addWidget(branch_combo); 0073 branchedit_layout->addWidget(branch_button); 0074 mainLayout->addLayout(branchedit_layout); 0075 0076 bytag_button = new QRadioButton(i18n("Update to &tag: ")); 0077 mainLayout->addWidget(bytag_button); 0078 0079 tag_combo = new KComboBox; 0080 tag_combo->setEditable(true); 0081 tag_combo->setMinimumWidth(iComboBoxMinWidth); 0082 mainLayout->addWidget(tag_combo); 0083 0084 tag_button = new QPushButton(i18n("Fetch L&ist")); 0085 mainLayout->addWidget(tag_button); 0086 connect(tag_button, SIGNAL(clicked()), this, SLOT(tagButtonClicked())); 0087 0088 QBoxLayout *tagedit_layout = new QHBoxLayout(); 0089 tagedit_layout->addSpacing(iWidgetIndent); 0090 tagedit_layout->addWidget(tag_combo); 0091 tagedit_layout->addWidget(tag_button); 0092 mainLayout->addLayout(tagedit_layout); 0093 0094 bydate_button = new QRadioButton(i18n("Update to &date ('yyyy-mm-dd'):")); 0095 mainLayout->addWidget(bydate_button); 0096 0097 date_edit = new QLineEdit; 0098 mainLayout->addWidget(date_edit); 0099 0100 QBoxLayout *dateedit_layout = new QHBoxLayout; 0101 dateedit_layout->addSpacing(iWidgetIndent); 0102 dateedit_layout->addWidget(date_edit); 0103 mainLayout->addLayout(dateedit_layout); 0104 0105 auto group = new QButtonGroup(this); 0106 group->addButton(bytag_button); 0107 group->addButton(bybranch_button); 0108 group->addButton(bydate_button); 0109 connect(group, SIGNAL(buttonClicked(int)), this, SLOT(toggled())); 0110 0111 mainLayout->addWidget(buttonBox); 0112 0113 // dis-/enable the widgets 0114 toggled(); 0115 } 0116 0117 bool UpdateDialog::byTag() const 0118 { 0119 return bybranch_button->isChecked() || bytag_button->isChecked(); 0120 } 0121 0122 QString UpdateDialog::tag() const 0123 { 0124 return bybranch_button->isChecked() ? branch_combo->currentText() : tag_combo->currentText(); 0125 } 0126 0127 QString UpdateDialog::date() const 0128 { 0129 return date_edit->text(); 0130 } 0131 0132 void UpdateDialog::tagButtonClicked() 0133 { 0134 tag_combo->clear(); 0135 tag_combo->addItems(::fetchTags(cvsService, this)); 0136 } 0137 0138 void UpdateDialog::branchButtonClicked() 0139 { 0140 branch_combo->clear(); 0141 branch_combo->addItems(::fetchBranches(cvsService, this)); 0142 } 0143 0144 void UpdateDialog::toggled() 0145 { 0146 bool bytag = bytag_button->isChecked(); 0147 tag_combo->setEnabled(bytag); 0148 tag_button->setEnabled(bytag); 0149 if (bytag) 0150 tag_combo->setFocus(); 0151 0152 bool bybranch = bybranch_button->isChecked(); 0153 branch_combo->setEnabled(bybranch); 0154 branch_button->setEnabled(bybranch); 0155 if (bybranch) 0156 branch_combo->setFocus(); 0157 0158 bool bydate = bydate_button->isChecked(); 0159 date_edit->setEnabled(bydate); 0160 if (bydate) 0161 date_edit->setFocus(); 0162 } 0163 0164 // Local Variables: 0165 // c-basic-offset: 4 0166 // End: