From bd9e6617827818fd043452c08c606f07b78014a0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- cervisia/patchoptiondlg.cpp | 115 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 cervisia/patchoptiondlg.cpp (limited to 'cervisia/patchoptiondlg.cpp') diff --git a/cervisia/patchoptiondlg.cpp b/cervisia/patchoptiondlg.cpp new file mode 100644 index 00000000..9e6f92d1 --- /dev/null +++ b/cervisia/patchoptiondlg.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2004 Christian Loose + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "patchoptiondlg.h" +using Cervisia::PatchOptionDialog; + +#include +#include +#include +#include +#include +#include +#include + + +PatchOptionDialog::PatchOptionDialog(QWidget* parent, const char* name) + : KDialogBase(parent, name, true/*modal*/, QString::null, + Ok | Cancel | Help, Ok, true/*separator*/) +{ + QFrame* mainWidget = makeMainWidget(); + QBoxLayout* topLayout = new QVBoxLayout(mainWidget, 0, spacingHint()); + + m_formatBtnGroup = new QVButtonGroup(i18n("Output Format"), mainWidget, ""); + topLayout->addWidget(m_formatBtnGroup); + + connect(m_formatBtnGroup, SIGNAL(clicked(int)), + this, SLOT(formatChanged(int))); + + new QRadioButton(i18n( "Context" ), m_formatBtnGroup); + new QRadioButton(i18n( "Normal" ), m_formatBtnGroup); + QRadioButton* unifiedFormatBtn = new QRadioButton(i18n( "Unified" ), m_formatBtnGroup); + unifiedFormatBtn->setChecked(true); + + QLabel* contextLinesLbl = new QLabel(i18n("&Number of context lines:"), + mainWidget); + m_contextLines = new KIntNumInput(3, mainWidget); + m_contextLines->setRange(2, 65535, 1, false); + contextLinesLbl->setBuddy(m_contextLines); + + QBoxLayout* contextLinesLayout = new QHBoxLayout(topLayout); + contextLinesLayout->addWidget(contextLinesLbl); + contextLinesLayout->addWidget(m_contextLines); + + QVButtonGroup* ignoreBtnGroup = new QVButtonGroup(i18n("Ignore Options"), mainWidget); + topLayout->addWidget(ignoreBtnGroup); + + m_blankLineChk = new QCheckBox(i18n("Ignore added or removed empty lines"), + ignoreBtnGroup); + m_spaceChangeChk = new QCheckBox(i18n("Ignore changes in the amount of whitespace"), + ignoreBtnGroup); + m_allSpaceChk = new QCheckBox(i18n("Ignore all whitespace"), ignoreBtnGroup); + m_caseChangesChk = new QCheckBox(i18n("Ignore changes in case"), ignoreBtnGroup); +} + + +PatchOptionDialog::~PatchOptionDialog() +{ +} + + +QString PatchOptionDialog::diffOptions() const +{ + QString options; + + if( m_blankLineChk->isChecked() ) + options += " -B "; + + if( m_spaceChangeChk->isChecked() ) + options += " -b "; + + if( m_allSpaceChk->isChecked() ) + options += " -w "; + + if( m_caseChangesChk->isChecked() ) + options += " -i "; + + return options; +} + + +QString PatchOptionDialog::formatOption() const +{ + switch( m_formatBtnGroup->selectedId() ) + { + case 0: return "-C " + QString::number(m_contextLines->value()); + case 1: return ""; + case 2: return "-U " + QString::number(m_contextLines->value()); + } + + return ""; +} + + +void PatchOptionDialog::formatChanged(int buttonId) +{ + bool enabled = ( buttonId == 0 || buttonId == 2 ); + m_contextLines->setEnabled(enabled); +} + +#include "patchoptiondlg.moc" -- cgit v1.2.1