Warning, file /sdk/cervisia/watchdialog.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 "watchdialog.h" 0021 0022 #include <QGridLayout> 0023 #include <qbuttongroup.h> 0024 #include <qcheckbox.h> 0025 #include <qlabel.h> 0026 #include <qradiobutton.h> 0027 0028 #include <KHelpClient> 0029 #include <KLocalizedString> 0030 0031 #include <QDialogButtonBox> 0032 #include <QPushButton> 0033 #include <QVBoxLayout> 0034 0035 WatchDialog::WatchDialog(ActionType action, QWidget *parent) 0036 : QDialog(parent) 0037 { 0038 setWindowTitle((action == Add) ? i18n("CVS Watch Add") : i18n("CVS Watch Remove")); 0039 setModal(true); 0040 0041 auto mainLayout = new QVBoxLayout; 0042 setLayout(mainLayout); 0043 0044 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help); 0045 connect(buttonBox, &QDialogButtonBox::helpRequested, this, &WatchDialog::slotHelp); 0046 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); 0047 okButton->setShortcut(Qt::CTRL | Qt::Key_Return); 0048 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); 0049 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); 0050 0051 auto textlabel = new QLabel((action == Add) ? i18n("Add watches for the following events:") : i18n("Remove watches for the following events:")); 0052 mainLayout->addWidget(textlabel); 0053 0054 all_button = new QRadioButton(i18n("&All")); 0055 mainLayout->addWidget(all_button); 0056 all_button->setFocus(); 0057 all_button->setChecked(true); 0058 0059 only_button = new QRadioButton(i18n("&Only:")); 0060 mainLayout->addWidget(only_button); 0061 0062 auto eventslayout = new QGridLayout(); 0063 mainLayout->addLayout(eventslayout); 0064 eventslayout->addItem(new QSpacerItem(20, 0), 0, 0); 0065 eventslayout->setColumnStretch(0, 0); 0066 eventslayout->setColumnStretch(1, 1); 0067 0068 commitbox = new QCheckBox(i18n("&Commits")); 0069 commitbox->setEnabled(false); 0070 eventslayout->addWidget(commitbox, 0, 1); 0071 0072 editbox = new QCheckBox(i18n("&Edits")); 0073 editbox->setEnabled(false); 0074 eventslayout->addWidget(editbox, 1, 1); 0075 0076 uneditbox = new QCheckBox(i18n("&Unedits")); 0077 uneditbox->setEnabled(false); 0078 eventslayout->addWidget(uneditbox, 2, 1); 0079 0080 auto group = new QButtonGroup(this); 0081 group->addButton(all_button); 0082 group->addButton(only_button); 0083 0084 mainLayout->addWidget(buttonBox); 0085 0086 connect(only_button, SIGNAL(toggled(bool)), commitbox, SLOT(setEnabled(bool))); 0087 connect(only_button, SIGNAL(toggled(bool)), editbox, SLOT(setEnabled(bool))); 0088 connect(only_button, SIGNAL(toggled(bool)), uneditbox, SLOT(setEnabled(bool))); 0089 } 0090 0091 void WatchDialog::slotHelp() 0092 { 0093 KHelpClient::invokeHelp(QLatin1String("watches")); 0094 } 0095 0096 WatchDialog::Events WatchDialog::events() const 0097 { 0098 Events res = None; 0099 if (all_button->isChecked()) 0100 res = All; 0101 else { 0102 if (commitbox->isChecked()) 0103 res = Events(res | Commits); 0104 if (editbox->isChecked()) 0105 res = Events(res | Edits); 0106 if (uneditbox->isChecked()) 0107 res = Events(res | Unedits); 0108 } 0109 return res; 0110 } 0111 0112 // Local Variables: 0113 // c-basic-offset: 4 0114 // End: