Warning, file /sdk/cervisia/mergedialog.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 "mergedialog.h"
0021 
0022 #include <QDialogButtonBox>
0023 #include <QGridLayout>
0024 #include <QPushButton>
0025 #include <QVBoxLayout>
0026 #include <qbuttongroup.h>
0027 #include <qlabel.h>
0028 #include <qradiobutton.h>
0029 #include <qstyle.h>
0030 
0031 #include <KComboBox>
0032 #include <KLocalizedString>
0033 
0034 #include "cvsserviceinterface.h"
0035 #include "misc.h"
0036 
0037 MergeDialog::MergeDialog(OrgKdeCervisia5CvsserviceCvsserviceInterface *service, QWidget *parent)
0038     : QDialog(parent)
0039     , cvsService(service)
0040 {
0041     setWindowTitle(i18n("CVS Merge"));
0042     setModal(true);
0043 
0044     auto mainLayout = new QVBoxLayout;
0045     setLayout(mainLayout);
0046 
0047     auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
0048     QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
0049     okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0050     connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
0051     connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
0052 
0053     const int iComboBoxMinWidth(30 * fontMetrics().width('0'));
0054     const int iWidgetIndent(style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth) + 6);
0055 
0056     bybranch_button = new QRadioButton(i18n("Merge from &branch:"));
0057     bybranch_button->setChecked(true);
0058     mainLayout->addWidget(bybranch_button);
0059 
0060     branch_combo = new KComboBox;
0061     branch_combo->setEditable(true);
0062     branch_combo->setMinimumWidth(iComboBoxMinWidth);
0063     mainLayout->addWidget(branch_combo);
0064 
0065     branch_button = new QPushButton(i18n("Fetch &List"));
0066     mainLayout->addWidget(branch_button);
0067     connect(branch_button, SIGNAL(clicked()), this, SLOT(branchButtonClicked()));
0068 
0069     QBoxLayout *branchedit_layout = new QHBoxLayout();
0070     branchedit_layout->addSpacing(iWidgetIndent);
0071     branchedit_layout->addWidget(branch_combo, 2);
0072     branchedit_layout->addWidget(branch_button, 0);
0073     mainLayout->addLayout(branchedit_layout);
0074 
0075     bytags_button = new QRadioButton(i18n("Merge &modifications:"));
0076     mainLayout->addWidget(bytags_button);
0077 
0078     auto tag1_label = new QLabel(i18n("between tag: "));
0079 
0080     tag1_combo = new KComboBox;
0081     tag1_combo->setEditable(true);
0082     tag1_combo->setMinimumWidth(iComboBoxMinWidth);
0083 
0084     auto tag2_label = new QLabel(i18n("and tag: "));
0085 
0086     tag2_combo = new KComboBox;
0087     tag2_combo->setEditable(true);
0088     tag2_combo->setMinimumWidth(iComboBoxMinWidth);
0089 
0090     tag_button = new QPushButton(i18n("Fetch L&ist"));
0091     connect(tag_button, SIGNAL(clicked()), this, SLOT(tagButtonClicked()));
0092 
0093     auto tagsedit_layout = new QGridLayout();
0094     tagsedit_layout->addItem(new QSpacerItem(iWidgetIndent, 0), 0, 0);
0095     tagsedit_layout->setColumnStretch(0, 0);
0096     tagsedit_layout->setColumnStretch(1, 1);
0097     tagsedit_layout->setColumnStretch(2, 2);
0098     tagsedit_layout->setColumnStretch(3, 0);
0099     tagsedit_layout->addWidget(tag1_label, 0, 1);
0100     tagsedit_layout->addWidget(tag1_combo, 0, 2);
0101     tagsedit_layout->addWidget(tag2_label, 1, 1);
0102     tagsedit_layout->addWidget(tag2_combo, 1, 2);
0103     tagsedit_layout->addWidget(tag_button, 0, 3, 2, 1);
0104     mainLayout->addLayout(tagsedit_layout);
0105 
0106     auto group = new QButtonGroup(this);
0107     group->addButton(bybranch_button);
0108     group->addButton(bytags_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 MergeDialog::byBranch() const
0118 {
0119     return bybranch_button->isChecked();
0120 }
0121 
0122 QString MergeDialog::branch() const
0123 {
0124     return branch_combo->currentText();
0125 }
0126 
0127 QString MergeDialog::tag1() const
0128 {
0129     return tag1_combo->currentText();
0130 }
0131 
0132 QString MergeDialog::tag2() const
0133 {
0134     return tag2_combo->currentText();
0135 }
0136 
0137 void MergeDialog::tagButtonClicked()
0138 {
0139     QStringList const listTags(::fetchTags(cvsService, this));
0140     tag1_combo->clear();
0141     tag1_combo->addItems(listTags);
0142     tag2_combo->clear();
0143     tag2_combo->addItems(listTags);
0144 }
0145 
0146 void MergeDialog::branchButtonClicked()
0147 {
0148     branch_combo->clear();
0149     branch_combo->addItems(::fetchBranches(cvsService, this));
0150 }
0151 
0152 void MergeDialog::toggled()
0153 {
0154     bool bybranch = bybranch_button->isChecked();
0155     branch_combo->setEnabled(bybranch);
0156     branch_button->setEnabled(bybranch);
0157     tag1_combo->setEnabled(!bybranch);
0158     tag2_combo->setEnabled(!bybranch);
0159     tag_button->setEnabled(!bybranch);
0160     if (bybranch)
0161         branch_combo->setFocus();
0162     else
0163         tag1_combo->setFocus();
0164 }
0165 
0166 // Local Variables:
0167 // c-basic-offset: 4
0168 // End: