diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bd9e6617827818fd043452c08c606f07b78014a0 (patch) | |
tree | 425bb4c3168f9c02f10150f235d2cb998dcc6108 /kompare/libdialogpages | |
download | tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.zip |
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
Diffstat (limited to 'kompare/libdialogpages')
-rw-r--r-- | kompare/libdialogpages/Makefile.am | 32 | ||||
-rw-r--r-- | kompare/libdialogpages/diffpage.cpp | 355 | ||||
-rw-r--r-- | kompare/libdialogpages/diffpage.h | 100 | ||||
-rw-r--r-- | kompare/libdialogpages/diffsettings.cpp | 108 | ||||
-rw-r--r-- | kompare/libdialogpages/diffsettings.h | 66 | ||||
-rw-r--r-- | kompare/libdialogpages/filespage.cpp | 170 | ||||
-rw-r--r-- | kompare/libdialogpages/filespage.h | 83 | ||||
-rw-r--r-- | kompare/libdialogpages/filessettings.cpp | 60 | ||||
-rw-r--r-- | kompare/libdialogpages/filessettings.h | 53 | ||||
-rw-r--r-- | kompare/libdialogpages/pagebase.cpp | 104 | ||||
-rw-r--r-- | kompare/libdialogpages/pagebase.h | 49 | ||||
-rw-r--r-- | kompare/libdialogpages/settingsbase.cpp | 42 | ||||
-rw-r--r-- | kompare/libdialogpages/settingsbase.h | 42 | ||||
-rw-r--r-- | kompare/libdialogpages/viewpage.cpp | 179 | ||||
-rw-r--r-- | kompare/libdialogpages/viewpage.h | 64 | ||||
-rw-r--r-- | kompare/libdialogpages/viewsettings.cpp | 101 | ||||
-rw-r--r-- | kompare/libdialogpages/viewsettings.h | 61 |
17 files changed, 1669 insertions, 0 deletions
diff --git a/kompare/libdialogpages/Makefile.am b/kompare/libdialogpages/Makefile.am new file mode 100644 index 00000000..e13405eb --- /dev/null +++ b/kompare/libdialogpages/Makefile.am @@ -0,0 +1,32 @@ +INCLUDES = \ + -I$(top_srcdir)/kompare/libdiff2 \ + $(all_includes) + +noinst_HEADERS = \ + settingsbase.h \ + diffsettings.h \ + filessettings.h \ + viewsettings.h \ + pagebase.h \ + diffpage.h \ + filespage.h \ + viewpage.h + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +noinst_LTLIBRARIES = libdialogpages.la + +# the library's source, library search path, and link libraries +libdialogpages_la_SOURCES = \ + settingsbase.cpp \ + diffsettings.cpp \ + filessettings.cpp \ + viewsettings.cpp \ + pagebase.cpp \ + diffpage.cpp \ + filespage.cpp \ + viewpage.cpp + +libdialogpages_la_LDFLAGS = $(all_libraries) +libdialogpages_la_LIBADD = $(LIB_KFILE) diff --git a/kompare/libdialogpages/diffpage.cpp b/kompare/libdialogpages/diffpage.cpp new file mode 100644 index 00000000..7f805c5b --- /dev/null +++ b/kompare/libdialogpages/diffpage.cpp @@ -0,0 +1,355 @@ +/*************************************************************************** + diffprefs.cpp - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001-2004 Otto Bruggeman + email : otto.bruggeman@home.nl +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#include <qcheckbox.h> +#include <qhgroupbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qradiobutton.h> +#include <qspinbox.h> +#include <qtooltip.h> +#include <qvbuttongroup.h> +#include <qwhatsthis.h> + +#include <kapplication.h> +#include <kcombobox.h> +#include <kdialog.h> +#include <keditlistbox.h> +#include <klineedit.h> +#include <klocale.h> +#include <ktrader.h> +#include <kurlcombobox.h> +#include <kurlrequester.h> + +#include <kparts/componentfactory.h> +#include <kregexpeditorinterface.h> + +#include "diffsettings.h" + +#include "diffpage.h" + +DiffPage::DiffPage( QWidget* parent ) : PageBase( parent ), + m_ignoreRegExpDialog( 0 ) +{ + addDiffTab(); + + addFormatTab(); + + addOptionsTab(); + + addExcludeTab(); +} + +DiffPage::~DiffPage() +{ + m_settings = 0; +} + +void DiffPage::setSettings( DiffSettings* setts ) +{ + m_settings = setts; + + m_diffURLRequester->setURL( m_settings->m_diffProgram ); + + m_smallerCheckBox->setChecked ( m_settings->m_createSmallerDiff ); + m_largerCheckBox->setChecked ( m_settings->m_largeFiles ); + m_tabsCheckBox->setChecked ( m_settings->m_convertTabsToSpaces ); + m_caseCheckBox->setChecked ( m_settings->m_ignoreChangesInCase ); + m_linesCheckBox->setChecked ( m_settings->m_ignoreEmptyLines ); + m_whitespaceCheckBox->setChecked ( m_settings->m_ignoreWhiteSpace ); + m_allWhitespaceCheckBox->setChecked ( m_settings->m_ignoreAllWhiteSpace ); + m_ignoreTabExpansionCheckBox->setChecked( m_settings->m_ignoreChangesDueToTabExpansion ); + + m_ignoreRegExpCheckBox->setChecked ( m_settings->m_ignoreRegExp ); + m_ignoreRegExpEdit->setCompletedItems( m_settings->m_ignoreRegExpTextHistory ); + m_ignoreRegExpEdit->setText ( m_settings->m_ignoreRegExpText ); + + m_locSpinBox->setValue( m_settings->m_linesOfContext ); + + m_modeButtonGroup->setButton( m_settings->m_format ); + + m_excludeFilePatternCheckBox->setChecked ( m_settings->m_excludeFilePattern ); + slotExcludeFilePatternToggled ( m_settings->m_excludeFilePattern ); + m_excludeFilePatternEditListBox->insertStringList( m_settings->m_excludeFilePatternList ); + + m_excludeFileCheckBox->setChecked( m_settings->m_excludeFilesFile ); + slotExcludeFileToggled ( m_settings->m_excludeFilesFile ); + m_excludeFileURLComboBox->setURLs( m_settings->m_excludeFilesFileHistoryList ); + m_excludeFileURLComboBox->setURL ( KURL( m_settings->m_excludeFilesFileURL ) ); +} + +DiffSettings* DiffPage::settings( void ) +{ + return m_settings; +} + +void DiffPage::restore() +{ + // this shouldn't do a thing... +} + +void DiffPage::apply() +{ + m_settings->m_diffProgram = m_diffURLRequester->url(); + + m_settings->m_largeFiles = m_largerCheckBox->isChecked(); + m_settings->m_createSmallerDiff = m_smallerCheckBox->isChecked(); + m_settings->m_convertTabsToSpaces = m_tabsCheckBox->isChecked(); + m_settings->m_ignoreChangesInCase = m_caseCheckBox->isChecked(); + m_settings->m_ignoreEmptyLines = m_linesCheckBox->isChecked(); + m_settings->m_ignoreWhiteSpace = m_whitespaceCheckBox->isChecked(); + m_settings->m_ignoreAllWhiteSpace = m_allWhitespaceCheckBox->isChecked(); + m_settings->m_ignoreChangesDueToTabExpansion = m_ignoreTabExpansionCheckBox->isChecked(); + + m_settings->m_ignoreRegExp = m_ignoreRegExpCheckBox->isChecked(); + m_settings->m_ignoreRegExpText = m_ignoreRegExpEdit->text(); + m_settings->m_ignoreRegExpTextHistory = m_ignoreRegExpEdit->completionObject()->items(); + + m_settings->m_linesOfContext = m_locSpinBox->value(); + + m_settings->m_format = static_cast<Kompare::Format>( m_modeButtonGroup->selectedId() ); + + m_settings->m_excludeFilePattern = m_excludeFilePatternCheckBox->isChecked(); + m_settings->m_excludeFilePatternList = m_excludeFilePatternEditListBox->items(); + + m_settings->m_excludeFilesFile = m_excludeFileCheckBox->isChecked(); + m_settings->m_excludeFilesFileURL = m_excludeFileURLComboBox->currentText(); + m_settings->m_excludeFilesFileHistoryList = m_excludeFileURLComboBox->urls(); + + m_settings->saveSettings( kapp->config() ); +} + +void DiffPage::setDefaults() +{ + m_diffURLRequester->setURL( "diff" ); + m_smallerCheckBox->setChecked( true ); + m_largerCheckBox->setChecked( true ); + m_tabsCheckBox->setChecked( false ); + m_caseCheckBox->setChecked( false ); + m_linesCheckBox->setChecked( false ); + m_whitespaceCheckBox->setChecked( false ); + m_allWhitespaceCheckBox->setChecked( false ); + m_ignoreTabExpansionCheckBox->setChecked( false ); + m_ignoreRegExpCheckBox->setChecked( false ); + + m_ignoreRegExpEdit->setText( QString::null ); + + m_locSpinBox->setValue( 3 ); + + m_modeButtonGroup->setButton( Kompare::Unified ); + + m_excludeFilePatternCheckBox->setChecked( false ); + + m_excludeFileCheckBox->setChecked( false ); +} + +void DiffPage::slotShowRegExpEditor() +{ + if ( ! m_ignoreRegExpDialog ) + m_ignoreRegExpDialog = KParts::ComponentFactory::createInstanceFromQuery<QDialog>( "KRegExpEditor/KRegExpEditor", QString::null, this ); + + KRegExpEditorInterface *iface = static_cast<KRegExpEditorInterface *>( m_ignoreRegExpDialog->qt_cast( "KRegExpEditorInterface" ) ); + + if ( !iface ) + return; + + iface->setRegExp( m_ignoreRegExpEdit->text() ); + bool ok = m_ignoreRegExpDialog->exec(); + + if ( ok ) + m_ignoreRegExpEdit->setText( iface->regExp() ); +} + +void DiffPage::slotExcludeFilePatternToggled( bool on ) +{ + if ( !on ) + { + m_excludeFilePatternEditListBox->setEnabled( false ); + } + else + { + m_excludeFilePatternEditListBox->setEnabled( true ); + } +} + +void DiffPage::slotExcludeFileToggled( bool on ) +{ + if ( !on ) + { + m_excludeFileURLComboBox->setEnabled( false ); + m_excludeFileURLRequester->setEnabled( false ); + } + else + { + m_excludeFileURLComboBox->setEnabled( true ); + m_excludeFileURLRequester->setEnabled( true ); + } +} + +void DiffPage::addDiffTab() +{ + QWidget* page = new QWidget( this ); + QVBoxLayout* layout = new QVBoxLayout( page ); + layout->setSpacing( KDialog::spacingHint() ); + layout->setMargin( KDialog::marginHint() ); + + // add diff program selector + m_diffProgramGroup = new QVButtonGroup( i18n( "Diff Program" ), page ); + layout->addWidget( m_diffProgramGroup ); + m_diffProgramGroup->setMargin( KDialog::marginHint() ); + + m_diffURLRequester = new KURLRequester( m_diffProgramGroup, "diffURLRequester" ); + QWhatsThis::add( m_diffURLRequester, i18n( "You can select a different diff program here. On Solaris the standard diff program does not support all the options that the GNU version does. This way you can select that version." ) ); + + layout->addStretch( 1 ); + page->setMinimumSize( sizeHintForWidget( page ) ); + + addTab( page, i18n( "&Diff" ) ); +} + +void DiffPage::addFormatTab() +{ + QWidget* page = new QWidget( this ); + QVBoxLayout* layout = new QVBoxLayout( page ); + layout->setSpacing( KDialog::spacingHint() ); + layout->setMargin( KDialog::marginHint() ); + + // add diff modes + m_modeButtonGroup = new QVButtonGroup( i18n( "Output Format" ), page ); + QWhatsThis::add( m_modeButtonGroup, i18n( "Select the format of the output generated by diff. Unified is the one that is used most frequently because it is very readable. The KDE developers like this format the best so use it for sending patches." ) ); + layout->addWidget( m_modeButtonGroup ); + m_modeButtonGroup->setMargin( KDialog::marginHint() ); + + QRadioButton* radioButton; + radioButton = new QRadioButton( i18n( "Context" ), m_modeButtonGroup ); + radioButton = new QRadioButton( i18n( "Ed" ), m_modeButtonGroup ); + radioButton->setEnabled( false ); + radioButton = new QRadioButton( i18n( "Normal" ), m_modeButtonGroup ); + radioButton = new QRadioButton( i18n( "RCS" ), m_modeButtonGroup ); + radioButton->setEnabled( false ); + radioButton = new QRadioButton( i18n( "Unified" ), m_modeButtonGroup ); + + // #lines of context (loc) + QHGroupBox* groupBox = new QHGroupBox( i18n( "Lines of Context" ), page ); + layout->addWidget( groupBox ); + groupBox->setMargin( KDialog::marginHint() ); + + QLabel* label = new QLabel( i18n( "Number of context lines:" ), groupBox ); + m_locSpinBox = new QSpinBox( 0, 100, 1, groupBox ); + QWhatsThis::add( m_locSpinBox, i18n( "The number of context lines is normally 2 or 3. This makes the diff readable and applicable in most cases. More than 3 lines will only bloat the diff unnecessarily." ) ); + label->setBuddy( m_locSpinBox ); + + layout->addStretch( 1 ); + page->setMinimumSize( sizeHintForWidget( page ) ); + + addTab( page, i18n( "&Format" ) ); +} + +void DiffPage::addOptionsTab() +{ + QWidget* page = new QWidget( this ); + QVBoxLayout* layout = new QVBoxLayout( page ); + layout->setSpacing( KDialog::spacingHint() ); + layout->setMargin( KDialog::marginHint() ); + + // add diff options + QVButtonGroup* optionButtonGroup = new QVButtonGroup( i18n( "General" ), page ); + layout->addWidget( optionButtonGroup ); + optionButtonGroup->setMargin( KDialog::marginHint() ); + + m_smallerCheckBox = new QCheckBox( i18n( "&Look for smaller changes" ), optionButtonGroup ); + QToolTip::add( m_smallerCheckBox, i18n( "This corresponds to the -d diff option." ) ); + m_largerCheckBox = new QCheckBox( i18n( "O&ptimize for large files" ), optionButtonGroup ); + QToolTip::add( m_largerCheckBox, i18n( "This corresponds to the -H diff option." ) ); + m_caseCheckBox = new QCheckBox( i18n( "&Ignore changes in case" ), optionButtonGroup ); + QToolTip::add( m_caseCheckBox, i18n( "This corresponds to the -i diff option." ) ); + + QHBoxLayout* groupLayout = new QHBoxLayout( layout, -1, "regexp_horizontal_layout" ); + groupLayout->setMargin( KDialog::marginHint() ); + + m_ignoreRegExpCheckBox = new QCheckBox( i18n( "Ignore regexp:" ), page ); + QToolTip::add( m_ignoreRegExpCheckBox, i18n( "This option corresponds to the -I diff option." ) ); + groupLayout->addWidget( m_ignoreRegExpCheckBox ); + m_ignoreRegExpEdit = new KLineEdit( QString::null, page, "regexplineedit" ); + QToolTip::add( m_ignoreRegExpEdit, i18n( "Add the regular expression here that you want to use\nto ignore lines that match it." ) ); + groupLayout->addWidget( m_ignoreRegExpEdit ); + + if ( !KTrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() ) + { + // Ok editor is available, use it + QButton* ignoreRegExpEditButton = new QPushButton( i18n( "&Edit..." ), page, "regexp_editor_button" ); + QToolTip::add( ignoreRegExpEditButton, i18n( "Clicking this will open a regular expression dialog where\nyou can graphically create regular expressions." ) ); + groupLayout->addWidget( ignoreRegExpEditButton ); + connect( ignoreRegExpEditButton, SIGNAL( clicked() ), this, SLOT( slotShowRegExpEditor() ) ); + } + + QVButtonGroup* moreOptionButtonGroup = new QVButtonGroup( i18n( "Whitespace" ), page ); + layout->addWidget( moreOptionButtonGroup ); + moreOptionButtonGroup->setMargin( KDialog::marginHint() ); + + m_tabsCheckBox = new QCheckBox( i18n( "E&xpand tabs to spaces in output" ), moreOptionButtonGroup ); + QToolTip::add( m_tabsCheckBox, i18n( "This option corresponds to the -t diff option." ) ); + m_linesCheckBox = new QCheckBox( i18n( "I&gnore added or removed empty lines" ), moreOptionButtonGroup ); + QToolTip::add( m_linesCheckBox, i18n( "This option corresponds to the -B diff option." ) ); + m_whitespaceCheckBox = new QCheckBox( i18n( "Ig&nore changes in the amount of whitespace" ), moreOptionButtonGroup ); + QToolTip::add( m_whitespaceCheckBox, i18n( "This option corresponds to the -b diff option." ) ); + m_allWhitespaceCheckBox = new QCheckBox( i18n( "Ign&ore all whitespace" ), moreOptionButtonGroup ); + QToolTip::add( m_allWhitespaceCheckBox, i18n( "This option corresponds to the -w diff option." ) ); + m_ignoreTabExpansionCheckBox = new QCheckBox( i18n( "Igno&re changes due to tab expansion" ), moreOptionButtonGroup ); + QToolTip::add( m_ignoreTabExpansionCheckBox, i18n( "This option corresponds to the -E diff option." ) ); + + layout->addStretch( 1 ); + page->setMinimumSize( sizeHintForWidget( page ) ); + + addTab( page, i18n( "O&ptions" ) ); +} + +void DiffPage::addExcludeTab() +{ + QWidget* page = new QWidget( this ); + QVBoxLayout* layout = new QVBoxLayout( page ); + layout->setSpacing( KDialog::spacingHint() ); + layout->setMargin( KDialog::marginHint() ); + + QHGroupBox* excludeFilePatternGroupBox = new QHGroupBox( i18n( "File Pattern to Exclude" ), page ); + m_excludeFilePatternCheckBox = new QCheckBox( "", excludeFilePatternGroupBox ); + QToolTip::add( m_excludeFilePatternCheckBox, i18n( "If this is checked you can enter a shell pattern in the text box on the right or select entries from the list." ) ); + m_excludeFilePatternEditListBox = new KEditListBox( excludeFilePatternGroupBox, "exclude_file_pattern_editlistbox", false, KEditListBox::Add|KEditListBox::Remove ); + QToolTip::add( m_excludeFilePatternEditListBox, i18n( "Here you can enter or remove a shell pattern or select one or more entries from the list." ) ); + layout->addWidget( excludeFilePatternGroupBox ); + + + connect( m_excludeFilePatternCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotExcludeFilePatternToggled(bool))); + + QHGroupBox* excludeFileNameGroupBox = new QHGroupBox( i18n( "File with Filenames to Exclude" ), page ); + m_excludeFileCheckBox = new QCheckBox( "", excludeFileNameGroupBox ); + QToolTip::add( m_excludeFileCheckBox, i18n( "If this is checked you can enter a filename in the combo box on the right." ) ); + m_excludeFileURLComboBox = new KURLComboBox( KURLComboBox::Files, true, excludeFileNameGroupBox, "exclude_file_urlcombo" ); + QToolTip::add( m_excludeFileURLComboBox, i18n( "Here you can enter the URL of a file with shell patterns to ignore during the comparison of the folders." ) ); + m_excludeFileURLRequester = new KURLRequester( m_excludeFileURLComboBox, excludeFileNameGroupBox, "exclude_file_name_urlrequester" ); + QToolTip::add( m_excludeFileURLRequester, i18n( "Any file you select in the dialog that pops up when you click it will be put in the dialog to the left of this button." ) ); + layout->addWidget( excludeFileNameGroupBox ); + + connect( m_excludeFileCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotExcludeFileToggled(bool))); + + layout->addStretch( 1 ); + page->setMinimumSize( sizeHintForWidget( page ) ); + + addTab( page, i18n( "&Exclude" ) ); +} + +#include "diffpage.moc" diff --git a/kompare/libdialogpages/diffpage.h b/kompare/libdialogpages/diffpage.h new file mode 100644 index 00000000..dee23989 --- /dev/null +++ b/kompare/libdialogpages/diffpage.h @@ -0,0 +1,100 @@ +/*************************************************************************** + diffprefs.h - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001-2004 Otto Bruggeman + (C) 2001-2003 John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#ifndef DIFFPAGE_H +#define DIFFPAGE_H + +#include "pagebase.h" + +class QCheckBox; +class QDialog; +class QSpinBox; +class QStringList; +class QVButtonGroup; +class QWidget; + +class KLineEdit; +class KComboBox; +class KEditListBox; +class KURLComboBox; +class KURLRequester; + +class DiffSettings; + +class DiffPage : public PageBase +{ +Q_OBJECT +public: + DiffPage( QWidget* ); + ~DiffPage(); + +public: + void setSettings( DiffSettings* ); + DiffSettings* settings( void ); + +public: + virtual void restore(); + virtual void apply(); + virtual void setDefaults(); + +protected slots: + void slotShowRegExpEditor(); + void slotExcludeFilePatternToggled( bool ); + void slotExcludeFileToggled( bool ); + +private: + void addDiffTab(); + void addFormatTab(); + void addOptionsTab(); + void addExcludeTab(); + +public: + DiffSettings* m_settings; + + KURLRequester* m_diffURLRequester; + + QCheckBox* m_smallerCheckBox; + QCheckBox* m_largerCheckBox; + QCheckBox* m_tabsCheckBox; + QCheckBox* m_caseCheckBox; + QCheckBox* m_linesCheckBox; + QCheckBox* m_whitespaceCheckBox; + QCheckBox* m_allWhitespaceCheckBox; + QCheckBox* m_ignoreTabExpansionCheckBox; + + QCheckBox* m_ignoreRegExpCheckBox; + KLineEdit* m_ignoreRegExpEdit; + QStringList* m_ignoreRegExpEditHistory; + QDialog* m_ignoreRegExpDialog; + + QCheckBox* m_excludeFilePatternCheckBox; + KEditListBox* m_excludeFilePatternEditListBox; + + QCheckBox* m_excludeFileCheckBox; + KURLComboBox* m_excludeFileURLComboBox; + KURLRequester* m_excludeFileURLRequester; + + // loc == lines of context + QSpinBox* m_locSpinBox; + + QVButtonGroup* m_modeButtonGroup; + QVButtonGroup* m_diffProgramGroup; +}; + +#endif diff --git a/kompare/libdialogpages/diffsettings.cpp b/kompare/libdialogpages/diffsettings.cpp new file mode 100644 index 00000000..20504ffe --- /dev/null +++ b/kompare/libdialogpages/diffsettings.cpp @@ -0,0 +1,108 @@ +/*************************************************************************** + diffsettings.cpp - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001-2004 Otto Bruggeman + email : otto.bruggeman@home.nl +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +****************************************************************************/ + +#include <kconfig.h> + +#include "diffsettings.h" + +DiffSettings::DiffSettings( QWidget* parent ) + : SettingsBase( parent ), + m_linesOfContext( 0 ), + m_format( Kompare::Unified ), + m_largeFiles( false ), + m_ignoreWhiteSpace( false ), + m_ignoreAllWhiteSpace( false ), + m_ignoreEmptyLines( false ), + m_ignoreChangesDueToTabExpansion( false ), + m_createSmallerDiff( false ), + m_ignoreChangesInCase( false ), + m_showCFunctionChange( false ), + m_convertTabsToSpaces( false ), + m_ignoreRegExp( false ), + m_recursive( false ), + m_newFiles( false ), + m_excludeFilePattern( false ), + m_excludeFilesFile( false ) +{ +} + +DiffSettings::~DiffSettings() +{ +} + +void DiffSettings::loadSettings( KConfig* config ) +{ + KConfigGroup group( config, "Diff Options" ); + m_diffProgram = group.readEntry ( "DiffProgram", "" ); + m_linesOfContext = group.readNumEntry ( "LinesOfContext", 3 ); + m_largeFiles = group.readBoolEntry( "LargeFiles", true ); + m_ignoreWhiteSpace = group.readBoolEntry( "IgnoreWhiteSpace", false ); + m_ignoreAllWhiteSpace = group.readBoolEntry( "IgnoreAllWhiteSpace", false ); + m_ignoreEmptyLines = group.readBoolEntry( "IgnoreEmptyLines", false ); + m_ignoreChangesDueToTabExpansion = group.readBoolEntry( "IgnoreChangesDueToTabExpansion", false ); + m_ignoreChangesInCase = group.readBoolEntry( "IgnoreChangesInCase", false ); + m_ignoreRegExp = group.readBoolEntry( "IgnoreRegExp", false ); + m_ignoreRegExpText = group.readEntry ( "IgnoreRegExpText", "" ); + m_ignoreRegExpTextHistory = group.readListEntry( "IgnoreRegExpTextHistory" ); + m_createSmallerDiff = group.readBoolEntry( "CreateSmallerDiff", true ); + m_convertTabsToSpaces = group.readBoolEntry( "ConvertTabsToSpaces", false ); + m_showCFunctionChange = group.readBoolEntry( "ShowCFunctionChange", false ); + m_recursive = group.readBoolEntry( "CompareRecursively", true ); + m_newFiles = group.readBoolEntry( "NewFiles", true ); + + m_format = static_cast<Kompare::Format>( group.readNumEntry( "Format", Kompare::Unified ) ); + + KConfigGroup group2 ( config, "Exclude File Options" ); + m_excludeFilePattern = group2.readBoolEntry( "Pattern", false ); + m_excludeFilePatternList = group2.readListEntry( "PatternList" ); + m_excludeFilesFile = group2.readBoolEntry( "File", false ); + m_excludeFilesFileURL = group2.readEntry ( "FileURL", "" ); + m_excludeFilesFileHistoryList = group2.readListEntry( "FileHistoryList" ); +} + +void DiffSettings::saveSettings( KConfig* config ) +{ + KConfigGroup group( config, "Diff Options" ); + group.writeEntry( "DiffProgram", m_diffProgram ); + group.writeEntry( "LinesOfContext", m_linesOfContext ); + group.writeEntry( "Format", m_format ); + group.writeEntry( "LargeFiles", m_largeFiles ); + group.writeEntry( "IgnoreWhiteSpace", m_ignoreWhiteSpace ); + group.writeEntry( "IgnoreAllWhiteSpace", m_ignoreAllWhiteSpace ); + group.writeEntry( "IgnoreEmptyLines", m_ignoreEmptyLines ); + group.writeEntry( "IgnoreChangesInCase", m_ignoreChangesInCase ); + group.writeEntry( "IgnoreChangesDueToTabExpansion", m_ignoreChangesDueToTabExpansion ); + group.writeEntry( "IgnoreRegExp", m_ignoreRegExp ); + group.writeEntry( "IgnoreRegExpText", m_ignoreRegExpText ); + group.writeEntry( "IgnoreRegExpTextHistory", m_ignoreRegExpTextHistory ); + group.writeEntry( "CreateSmallerDiff", m_createSmallerDiff ); + group.writeEntry( "ConvertTabsToSpaces", m_convertTabsToSpaces ); + group.writeEntry( "ShowCFunctionChange", m_showCFunctionChange ); + group.writeEntry( "CompareRecursively", m_recursive ); + group.writeEntry( "NewFiles", m_newFiles ); + group.setDirty( true ); + + KConfigGroup group2( config, "Exclude File Options" ); + group2.writeEntry( "Pattern", m_excludeFilePattern ); + group2.writeEntry( "PatternList", m_excludeFilePatternList ); + group2.writeEntry( "File", m_excludeFilesFile ); + group2.writeEntry( "FileURL", m_excludeFilesFileURL ); + group2.writeEntry( "FileHistoryList", m_excludeFilesFileHistoryList ); + group2.setDirty( true ); +} + +#include "diffsettings.moc" diff --git a/kompare/libdialogpages/diffsettings.h b/kompare/libdialogpages/diffsettings.h new file mode 100644 index 00000000..46962cb8 --- /dev/null +++ b/kompare/libdialogpages/diffsettings.h @@ -0,0 +1,66 @@ +/*************************************************************************** + diffsettings.h - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001-2003 by Otto Bruggeman + and John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#ifndef DIFFSETTINGS_H +#define DIFFSETTINGS_H + +#include <qstringlist.h> +#include <qwidget.h> + +#include "kompare.h" +#include "settingsbase.h" + +class DiffSettings : public SettingsBase +{ +Q_OBJECT +public: + DiffSettings( QWidget* parent ); + virtual ~DiffSettings(); +public: + // some virtual functions that will be overloaded from the base class + virtual void loadSettings( KConfig* config ); + virtual void saveSettings( KConfig* config ); + +public: + QString m_diffProgram; + int m_linesOfContext; + Kompare::Format m_format; + bool m_largeFiles; // -H + bool m_ignoreWhiteSpace; // -b + bool m_ignoreAllWhiteSpace; // -w + bool m_ignoreEmptyLines; // -B + bool m_ignoreChangesDueToTabExpansion; // -E + bool m_createSmallerDiff; // -d + bool m_ignoreChangesInCase; // -i + bool m_showCFunctionChange; // -p + bool m_convertTabsToSpaces; // -t + bool m_ignoreRegExp; // -I + QString m_ignoreRegExpText; // the RE for -I + QStringList m_ignoreRegExpTextHistory; + bool m_recursive; // -r + bool m_newFiles; // -N +// bool m_allText; // -a + bool m_excludeFilePattern; // -x + QStringList m_excludeFilePatternList; // The list of patterns for -x + bool m_excludeFilesFile; // -X + QString m_excludeFilesFileURL; // The filename to -X + QStringList m_excludeFilesFileHistoryList; // The history list of filenames +}; + +#endif diff --git a/kompare/libdialogpages/filespage.cpp b/kompare/libdialogpages/filespage.cpp new file mode 100644 index 00000000..9e15a129 --- /dev/null +++ b/kompare/libdialogpages/filespage.cpp @@ -0,0 +1,170 @@ +/*************************************************************************** + filespage.cpp + ------------------- + begin : Sun Apr 18 2004 + copyright : (C) 2004 Otto Bruggeman + email : otto.bruggeman@home.nl + +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#include <qlayout.h> +#include <qgroupbox.h> + +#include <kapplication.h> +#include <kcharsets.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdialog.h> +#include <klocale.h> +#include <kurlcombobox.h> +#include <kurlrequester.h> + +#include "filessettings.h" +#include "filespage.h" + +FilesPage::FilesPage( QWidget* parent ) : PageBase( parent ), m_URLChanged( false ) +{ + QWidget* page = new QWidget( this ); + QVBoxLayout* layout = new QVBoxLayout( page ); + layout->setSpacing( KDialog::spacingHint() ); + layout->setMargin( KDialog::marginHint() ); + + m_firstGB = new QGroupBox( 1, Qt::Vertical, "You have to set this moron :)", page ); + m_firstURLComboBox = new KURLComboBox( KURLComboBox::Both, true, m_firstGB, "SourceURLComboBox" ); + m_firstURLRequester = new KURLRequester( m_firstURLComboBox, m_firstGB ); + m_firstURLRequester->setFocus(); + + m_secondGB = new QGroupBox( 1, Qt::Vertical, "This too moron !", page ); + m_secondURLComboBox = new KURLComboBox( KURLComboBox::Both, true, m_secondGB, "DestURLComboBox" ); + m_secondURLRequester = new KURLRequester( m_secondURLComboBox, m_secondGB ); + + connect( m_firstURLRequester, SIGNAL( urlSelected( const QString & ) ), SLOT( setSecondURL( const QString & ) ) ); + connect( m_secondURLRequester, SIGNAL( urlSelected( const QString & ) ), SLOT( setFirstURL( const QString & ) ) ); + + m_thirdGB = new QGroupBox( 1, Qt::Vertical, i18n( "Encoding" ), page ); + m_encodingComboBox = new QComboBox( false, m_thirdGB, "encoding_combobox" ); + m_encodingComboBox->insertStringList( KGlobal::charsets()->availableEncodingNames() ); + + layout->addWidget( m_firstGB ); + layout->addWidget( m_secondGB ); + layout->addWidget( m_thirdGB ); + + layout->addStretch( 1 ); + page->setMinimumSize( sizeHintForWidget( page ) ); + + addTab( page, i18n( "&Files" ) ); +} + +FilesPage::~FilesPage() +{ + m_settings = 0; +} + +KURLRequester* FilesPage::firstURLRequester() const +{ + return m_firstURLRequester; +} + +KURLRequester* FilesPage::secondURLRequester() const +{ + return m_secondURLRequester; +} + +QString FilesPage::encoding() const +{ + return m_encodingComboBox->currentText(); +} + +void FilesPage::setFirstGroupBoxTitle( const QString& title ) +{ + m_firstGB->setTitle( title ); +} + +void FilesPage::setSecondGroupBoxTitle( const QString& title ) +{ + m_secondGB->setTitle( title ); +} + +void FilesPage::setURLsInComboBoxes() +{ +// kdDebug() << "first : " << m_firstURLComboBox->currentText() << endl; +// kdDebug() << "second: " << m_secondURLComboBox->currentText() << endl; + m_firstURLComboBox->setURL( KURL( m_firstURLComboBox->currentText() ) ); + m_secondURLComboBox->setURL( KURL( m_secondURLComboBox->currentText() ) ); +} + + +void FilesPage::setFirstURLRequesterMode( unsigned int mode ) +{ + m_firstURLRequester->setMode( mode ); +} + +void FilesPage::setSecondURLRequesterMode( unsigned int mode ) +{ + m_secondURLRequester->setMode( mode ); +} + +void FilesPage::setSettings( FilesSettings* settings ) +{ + m_settings = settings; + + m_firstURLComboBox->setURLs( m_settings->m_recentSources ); + m_firstURLComboBox->setURL( KURL( m_settings->m_lastChosenSourceURL ) ); + m_secondURLComboBox->setURLs( m_settings->m_recentDestinations ); + m_secondURLComboBox->setURL( KURL( m_settings->m_lastChosenDestinationURL ) ); + m_encodingComboBox->setCurrentText( m_settings->m_encoding ); +} + +void FilesPage::restore() +{ + // this shouldn't do a thing... +} + +void FilesPage::apply() +{ + m_settings->m_recentSources = m_firstURLComboBox->urls(); + m_settings->m_lastChosenSourceURL = m_firstURLComboBox->currentText(); + m_settings->m_recentDestinations = m_secondURLComboBox->urls(); + m_settings->m_lastChosenDestinationURL = m_secondURLComboBox->currentText(); + m_settings->m_encoding = m_encodingComboBox->currentText(); +} + +void FilesPage::setDefaults() +{ + m_firstURLComboBox->setURLs( "" ); + m_firstURLComboBox->setURL( KURL( "" ) ); + m_secondURLComboBox->setURLs( "" ); + m_secondURLComboBox->setURL( KURL( "" ) ); + m_encodingComboBox->setCurrentText( "Default" ); +} + +void FilesPage::setFirstURL( const QString &url ) +{ + QString _url = url; + if ( !m_URLChanged ) + { + m_firstURLRequester->setURL( _url.remove( url.section( '/', -1 ) ) ); + m_URLChanged = true; + } +} + +void FilesPage::setSecondURL( const QString &url ) +{ + QString _url = url; + if ( !m_URLChanged ) + { + m_secondURLRequester->setURL( _url.remove( url.section( '/', -1 ) ) ); + m_URLChanged = true; + } +} + +#include "filespage.moc" diff --git a/kompare/libdialogpages/filespage.h b/kompare/libdialogpages/filespage.h new file mode 100644 index 00000000..145c4614 --- /dev/null +++ b/kompare/libdialogpages/filespage.h @@ -0,0 +1,83 @@ +/*************************************************************************** + kcompareurldialog.h - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001-2004 Otto Bruggeman + (C) 2001-2003 John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#ifndef FILESPAGE_H +#define FILESPAGE_H + +#include "pagebase.h" + +class QGroupBox; + +class QComboBox; +class KComboBox; +class KConfig; +class KFileDialog; +class KURLComboBox; +class KURLRequester; + +class FilesSettings; + +class FilesPage : PageBase +{ +Q_OBJECT +public: + FilesPage( QWidget* parent ); + virtual ~FilesPage(); + +public: + KURLRequester* firstURLRequester() const; + KURLRequester* secondURLRequester() const; + + QString encoding() const; + + void setFirstGroupBoxTitle ( const QString& title ); + void setSecondGroupBoxTitle( const QString& title ); + + void setURLsInComboBoxes(); + + void setFirstURLRequesterMode( unsigned int mode ); + void setSecondURLRequesterMode( unsigned int mode ); + +public: + virtual void setSettings( FilesSettings* settings ); + virtual void restore(); + virtual void apply(); + virtual void setDefaults(); + +protected slots: + void setFirstURL( const QString & ); + void setSecondURL( const QString & ); + +private: + QGroupBox* m_firstGB; + QGroupBox* m_secondGB; + QGroupBox* m_thirdGB; + KURLComboBox* m_firstURLComboBox; + KURLComboBox* m_secondURLComboBox; + KURLRequester* m_firstURLRequester; + KURLRequester* m_secondURLRequester; + // Use this bool to lock the connection between both KURLRequesters. + // This prevents annoying behaviour + bool m_URLChanged; + QComboBox* m_encodingComboBox; + + FilesSettings* m_settings; +}; + +#endif diff --git a/kompare/libdialogpages/filessettings.cpp b/kompare/libdialogpages/filessettings.cpp new file mode 100644 index 00000000..d5a94a66 --- /dev/null +++ b/kompare/libdialogpages/filessettings.cpp @@ -0,0 +1,60 @@ +/*************************************************************************** + filessettings.cpp - description + ------------------- + begin : Sun Apr 18 2004 + copyright : (C) 2004 Otto Bruggeman + email : otto.bruggeman@home.nl + +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +****************************************************************************/ + +#include <kapplication.h> +#include <kconfig.h> + +#include "filessettings.h" + +FilesSettings::FilesSettings( QWidget* parent ) + : SettingsBase( parent ) +{ +} + +FilesSettings::~FilesSettings() +{ +} + +void FilesSettings::loadSettings( KConfig* config ) +{ + config->setGroup( m_configGroupName ); + + m_recentSources = config->readListEntry( "Recent Sources" ); + m_lastChosenSourceURL = config->readEntry ( "LastChosenSourceListEntry", "" ); + m_recentDestinations = config->readListEntry( "Recent Destinations" ); + m_lastChosenDestinationURL = config->readEntry ( "LastChosenDestinationListEntry", "" ); + m_encoding = config->readEntry ( "Encoding", "default" ); +} + +void FilesSettings::saveSettings( KConfig* config ) +{ + config->setGroup( m_configGroupName ); + config->writeEntry( "Recent Sources", m_recentSources ); + config->writeEntry( "Recent Destinations", m_recentDestinations ); + config->writeEntry( "LastChosenSourceListEntry", m_lastChosenSourceURL ); + config->writeEntry( "LastChosenDestinationListEntry", m_lastChosenDestinationURL ); + config->writeEntry( "Encoding", m_encoding ); + config->sync(); +} + +void FilesSettings::setGroup( const QString& groupName ) +{ + m_configGroupName = groupName; +} + +#include "filessettings.moc" diff --git a/kompare/libdialogpages/filessettings.h b/kompare/libdialogpages/filessettings.h new file mode 100644 index 00000000..3c394dbb --- /dev/null +++ b/kompare/libdialogpages/filessettings.h @@ -0,0 +1,53 @@ +/*************************************************************************** + filessettings.h - description + ------------------- + begin : Sun Apr 18 2004 + copyright : (C) 2004 Otto Bruggeman + email : otto.bruggeman@home.nl + +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef FILESSETTINGS_H +#define FILESSETTINGS_H + +#include <qstring.h> + +#include "settingsbase.h" + +class KConfig; + +class FilesSettings : public SettingsBase +{ +Q_OBJECT +public: + FilesSettings( QWidget* parent ); + virtual ~FilesSettings(); + +public: + // some virtual functions that will be overloaded from the base class + virtual void loadSettings( KConfig* config ); + virtual void saveSettings( KConfig* config ); + + void setGroup( const QString& groupName ); + +public: + QString m_configGroupName; + + QStringList m_recentSources; + QString m_lastChosenSourceURL; + QStringList m_recentDestinations; + QString m_lastChosenDestinationURL; + QString m_encoding; +}; + +#endif // FILESSETTINGS_H + diff --git a/kompare/libdialogpages/pagebase.cpp b/kompare/libdialogpages/pagebase.cpp new file mode 100644 index 00000000..de062634 --- /dev/null +++ b/kompare/libdialogpages/pagebase.cpp @@ -0,0 +1,104 @@ +/*************************************************************************** + prefsbase.cpp - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001 by Otto Bruggeman + and John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#include <qlayout.h> +#include <qobjectlist.h> + +#include "pagebase.h" + +PageBase::PageBase( QWidget* parent ) : KTabCtl( parent ) +{ + +} + +PageBase::~PageBase() +{ + +} + +/** No descriptions */ +QSize PageBase::sizeHintForWidget( QWidget* widget ) +{ + // + // The size is computed by adding the sizeHint().height() of all + // widget children and taking the width of the widest child and adding + // layout()->margin() and layout()->spacing() + // + + // this code in this method has been ripped out of a file in kbabel + // so copyright goes to the kbabel authors. + + QSize size; + + int numChild = 0; + QObjectList *l = (QObjectList*)(widget->children()); + + for( uint i=0; i < l->count(); i++ ) + { + QObject *o = l->at(i); + if( o->isWidgetType() ) + { + numChild += 1; + QWidget *w=((QWidget*)o); + + QSize s = w->sizeHint(); + if( s.isEmpty() == true ) + { + s = QSize( 50, 100 ); // Default size + } + size.setHeight( size.height() + s.height() ); + if( s.width() > size.width() ) + { + size.setWidth( s.width() ); + } + } + } + + if( numChild > 0 ) + { + size.setHeight( size.height() + widget->layout()->spacing()*(numChild-1) ); + size += QSize( widget->layout()->margin()*2, widget->layout()->margin()*2 + 1 ); + } + else + { + size = QSize( 1, 1 ); + } + + return( size ); +} + +/** No descriptions */ +void PageBase::apply() +{ + +} + +/** No descriptions */ +void PageBase::restore() +{ + +} + +/** No descriptions */ +void PageBase::setDefaults() +{ + +} + +#include "pagebase.moc" diff --git a/kompare/libdialogpages/pagebase.h b/kompare/libdialogpages/pagebase.h new file mode 100644 index 00000000..7aab7b81 --- /dev/null +++ b/kompare/libdialogpages/pagebase.h @@ -0,0 +1,49 @@ +/*************************************************************************** + prefsbase.h - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001 by Otto Bruggeman + and John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#ifndef PAGEBASE_H +#define PAGEBASE_H + +#include <qsize.h> +#include <qwidget.h> + +#include <kconfig.h> +#include <ktabctl.h> + +#include "kompare.h" + +class PageBase : public KTabCtl +{ +Q_OBJECT +public: + PageBase( QWidget* ); + ~PageBase(); + +public: + /** No descriptions */ + QSize sizeHintForWidget( QWidget* widget ); + /** No descriptions */ + virtual void restore(); + /** No descriptions */ + virtual void apply(); + /** No descriptions */ + virtual void setDefaults(); +}; + +#endif diff --git a/kompare/libdialogpages/settingsbase.cpp b/kompare/libdialogpages/settingsbase.cpp new file mode 100644 index 00000000..dc7b64d6 --- /dev/null +++ b/kompare/libdialogpages/settingsbase.cpp @@ -0,0 +1,42 @@ +/*************************************************************************** + settingsbase.cpp - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001 by Otto Bruggeman + and John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#include <qwidget.h> + +#include "settingsbase.h" + +SettingsBase::SettingsBase( QWidget* parent ) : QObject( parent ) +{ + +} + +SettingsBase::~SettingsBase() +{ + +} + +void SettingsBase::loadSettings( KConfig* /* config */ ) +{ +} + +void SettingsBase::saveSettings( KConfig* /* config */ ) +{ +} + +#include "settingsbase.moc" diff --git a/kompare/libdialogpages/settingsbase.h b/kompare/libdialogpages/settingsbase.h new file mode 100644 index 00000000..5ec035ba --- /dev/null +++ b/kompare/libdialogpages/settingsbase.h @@ -0,0 +1,42 @@ +/*************************************************************************** + settingsbase.h - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001 by Otto Bruggeman + and John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#ifndef SETTINGSBASE_H +#define SETTINGSBASE_H + +#include <qobject.h> + +#include "kompare.h" + +class QWidget; +class KConfig; + +class SettingsBase : public QObject +{ +Q_OBJECT +public: + SettingsBase( QWidget* parent ); + ~SettingsBase(); + +public: + virtual void loadSettings( KConfig* config ); + virtual void saveSettings( KConfig* config ); +}; + +#endif diff --git a/kompare/libdialogpages/viewpage.cpp b/kompare/libdialogpages/viewpage.cpp new file mode 100644 index 00000000..c4e61e8d --- /dev/null +++ b/kompare/libdialogpages/viewpage.cpp @@ -0,0 +1,179 @@ +/*************************************************************************** + viewprefs.cpp - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001-2002 by Otto Bruggeman + and John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#include <qcheckbox.h> +#include <qgroupbox.h> +#include <qhgroupbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qspinbox.h> + +#include <kapplication.h> +#include <kcolorbutton.h> +#include <kdialog.h> +#include <kfontcombo.h> +#include <klocale.h> + +#include "viewpage.h" +#include "viewsettings.h" + +ViewPage::ViewPage( QWidget* parent ) : PageBase( parent ) +{ + QWidget* page; + QVBoxLayout* layout; + QGroupBox* colorGroupBox; + QHGroupBox* snolGroupBox; + QHGroupBox* tabGroupBox; + QLabel* label; + + page = new QWidget( this ); + layout = new QVBoxLayout( page ); + layout->setSpacing( KDialog::spacingHint() ); + layout->setMargin( KDialog::marginHint() ); + + // add a groupbox + colorGroupBox = new QGroupBox( 2, Qt::Horizontal, i18n( "Colors" ), page ); + layout->addWidget( colorGroupBox ); + colorGroupBox->setMargin( KDialog::marginHint() ); + + // add the removeColor + label = new QLabel( i18n( "Removed color:" ), colorGroupBox ); + m_removedColorButton = new KColorButton( colorGroupBox ); + label->setBuddy( m_removedColorButton ); + + // add the changeColor + label = new QLabel( i18n( "Changed color:" ), colorGroupBox ); + m_changedColorButton = new KColorButton( colorGroupBox ); + label->setBuddy( m_changedColorButton ); + + // add the addColor + label = new QLabel( i18n( "Added color:" ), colorGroupBox ); + m_addedColorButton = new KColorButton( colorGroupBox ); + label->setBuddy( m_addedColorButton ); + + // add the appliedColor + label = new QLabel( i18n( "Applied color:" ), colorGroupBox ); + m_appliedColorButton = new KColorButton( colorGroupBox ); + label->setBuddy( m_appliedColorButton ); + + // scroll number of lines (snol) + snolGroupBox = new QHGroupBox( i18n( "Mouse Wheel" ), page ); + layout->addWidget( snolGroupBox ); + snolGroupBox->setMargin( KDialog::marginHint() ); + + label = new QLabel( i18n( "Number of lines:" ), snolGroupBox ); + m_snolSpinBox = new QSpinBox( 0, 50, 1, snolGroupBox ); + label->setBuddy( m_snolSpinBox ); + + // Temporarily here for testing... + // number of spaces for a tab character stuff + tabGroupBox = new QHGroupBox( i18n( "Tabs to Spaces" ), page ); + layout->addWidget( tabGroupBox ); + tabGroupBox->setMargin( KDialog::marginHint() ); + + label = new QLabel( i18n( "Number of spaces to convert a tab character to:" ), tabGroupBox ); + m_tabSpinBox = new QSpinBox( 1, 16, 1, tabGroupBox ); + label->setBuddy( m_tabSpinBox ); + + layout->addStretch( 1 ); + page->setMinimumSize( sizeHintForWidget( page ) ); + + addTab( page, i18n( "A&ppearance" ) ); + + page = new QWidget( this ); + layout = new QVBoxLayout( page ); + layout->setSpacing( KDialog::spacingHint() ); + layout->setMargin( KDialog::marginHint() ); + + QHGroupBox* gb = new QHGroupBox( i18n( "Text Font" ), page ); + layout->addWidget( gb ); + gb->setMargin( KDialog::marginHint() ); + + label = new QLabel( i18n( "Font:" ), gb ); + m_fontCombo = new KFontCombo( gb, "fontcombo" ); + label->setBuddy( m_fontCombo ); + + label = new QLabel( i18n( "Size:" ), gb ); + m_fontSizeSpinBox = new QSpinBox( 6, 24, 1, gb, "fontsize" ); + label->setBuddy( m_fontSizeSpinBox ); + + layout->addStretch( 1 ); + page->setMinimumSize( sizeHintForWidget( page ) ); + + addTab( page, i18n( "&Fonts" ) ); +} + +ViewPage::~ViewPage() +{ + +} + +void ViewPage::setSettings( ViewSettings* setts ) +{ + m_settings = setts; + + m_addedColorButton->setColor ( m_settings->m_addColor ); + m_changedColorButton->setColor( m_settings->m_changeColor ); + m_removedColorButton->setColor( m_settings->m_removeColor ); + m_appliedColorButton->setColor( m_settings->m_appliedColor ); + m_snolSpinBox->setValue ( m_settings->m_scrollNoOfLines ); + m_tabSpinBox->setValue ( m_settings->m_tabToNumberOfSpaces ); + + m_fontCombo->setCurrentFont ( m_settings->m_font.family() ); + m_fontSizeSpinBox->setValue ( m_settings->m_font.pointSize() ); +} + +ViewSettings* ViewPage::settings( void ) +{ + return m_settings; +} + +void ViewPage::restore() +{ +} + +void ViewPage::apply() +{ + m_settings->m_addColor = m_addedColorButton->color(); + m_settings->m_changeColor = m_changedColorButton->color(); + m_settings->m_removeColor = m_removedColorButton->color(); + m_settings->m_appliedColor = m_appliedColorButton->color(); + m_settings->m_scrollNoOfLines = m_snolSpinBox->value(); + m_settings->m_tabToNumberOfSpaces = m_tabSpinBox->value(); + + m_settings->m_font = QFont( m_fontCombo->currentFont() ); + m_settings->m_font.setPointSize( m_fontSizeSpinBox->value() ); + + m_settings->saveSettings( kapp->config() ); +} + +void ViewPage::setDefaults() +{ + m_addedColorButton->setColor ( ViewSettings::default_addColor ); + m_changedColorButton->setColor( ViewSettings::default_changeColor ); + m_removedColorButton->setColor( ViewSettings::default_removeColor ); + m_appliedColorButton->setColor( ViewSettings::default_appliedColor ); + m_snolSpinBox->setValue ( 3 ); + m_tabSpinBox->setValue ( 4 ); + + m_fontCombo->setCurrentFont ( KGlobalSettings::fixedFont().family() ); + m_fontSizeSpinBox->setValue ( 10 ); +} + +#include "viewpage.moc" diff --git a/kompare/libdialogpages/viewpage.h b/kompare/libdialogpages/viewpage.h new file mode 100644 index 00000000..30591f4b --- /dev/null +++ b/kompare/libdialogpages/viewpage.h @@ -0,0 +1,64 @@ +/*************************************************************************** + generalprefs.h - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001-2003 by Otto Bruggeman + and John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#ifndef VIEWPAGE_H +#define VIEWPAGE_H + +#include "pagebase.h" + +class QCheckBox; +class QSpinBox; + +class KColorButton; +class KFontCombo; + +class ViewSettings; + +class ViewPage : public PageBase +{ +Q_OBJECT +public: + ViewPage( QWidget* ); + ~ViewPage(); + +public: + void setSettings( ViewSettings* ); + ViewSettings* settings( void ); + +public: + ViewSettings* m_settings; + +public: + virtual void restore(); + virtual void apply(); + virtual void setDefaults(); + +public: + KColorButton* m_removedColorButton; + KColorButton* m_changedColorButton; + KColorButton* m_addedColorButton; + KColorButton* m_appliedColorButton; + // snol == scroll number of lines + QSpinBox* m_snolSpinBox; + QSpinBox* m_tabSpinBox; + KFontCombo* m_fontCombo; + QSpinBox* m_fontSizeSpinBox; +}; + +#endif diff --git a/kompare/libdialogpages/viewsettings.cpp b/kompare/libdialogpages/viewsettings.cpp new file mode 100644 index 00000000..c55dd40e --- /dev/null +++ b/kompare/libdialogpages/viewsettings.cpp @@ -0,0 +1,101 @@ +/*************************************************************************** + generalsettings.cpp - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001-2003 by Otto Bruggeman + and John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#include <qfont.h> + +#include <kconfig.h> +#include <kglobalsettings.h> + +#include "viewsettings.h" + +using namespace Diff2; + +const QColor ViewSettings::default_removeColor (190, 237, 190); +const QColor ViewSettings::default_changeColor (237, 190, 190); +const QColor ViewSettings::default_addColor (190, 190, 237); +const QColor ViewSettings::default_appliedColor(237, 237, 190); + +ViewSettings::ViewSettings( QWidget* parent ) + : SettingsBase( parent ), + m_removeColor( 0, 0, 0 ), + m_changeColor( 0, 0, 0), + m_addColor( 0, 0, 0), + m_appliedColor( 0, 0, 0), + m_scrollNoOfLines( 0 ), + m_tabToNumberOfSpaces( 0 ) +{ +} + +ViewSettings::~ViewSettings() +{ +} + +void ViewSettings::loadSettings( KConfig* config ) +{ + KConfigGroup cfg( config, "View Options" ); + m_removeColor = cfg.readColorEntry( "RemoveColor", &default_removeColor ); + m_changeColor = cfg.readColorEntry( "ChangeColor", &default_changeColor ); + m_addColor = cfg.readColorEntry( "AddColor", &default_addColor ); + m_appliedColor = cfg.readColorEntry( "AppliedColor", &default_appliedColor ); + m_scrollNoOfLines = cfg.readNumEntry ( "ScrollNoOfLines", 3 ); + m_tabToNumberOfSpaces = cfg.readNumEntry ( "TabToNumberOfSpaces", 4 ); + + QFont stdFixed = KGlobalSettings::fixedFont(); + stdFixed.setPointSize( 10 ); + m_font = cfg.readFontEntry ( "TextFont", &stdFixed ); +} + +void ViewSettings::saveSettings( KConfig* config ) +{ + KConfigGroup cfg( config, "View Options" ); + cfg.writeEntry( "RemoveColor", m_removeColor ); + cfg.writeEntry( "ChangeColor", m_changeColor ); + cfg.writeEntry( "AddColor", m_addColor ); + cfg.writeEntry( "AppliedColor", m_appliedColor ); + cfg.writeEntry( "ScrollNoOfLines", m_scrollNoOfLines ); + cfg.writeEntry( "TabToNumberOfSpaces", m_tabToNumberOfSpaces ); + + cfg.writeEntry( "TextFont", m_font ); +} + +QColor ViewSettings::colorForDifferenceType( int type, bool selected, bool applied ) +{ + // FIXME: does not belong here + QColor color; + if( applied ) + color = m_appliedColor; + else + { + type = type & 0xFFFFFFEF; // remove the AppliedByBlend + switch( type ) { + case Difference::Unchanged: color = white; break; + case Difference::Change: color = m_changeColor; break; + case Difference::Insert: color = m_addColor; break; + case Difference::Delete: color = m_removeColor; break; + default: break; + } + } + + if( selected ) + color = color.light( 110 ); + + return color; +} + +#include "viewsettings.moc" diff --git a/kompare/libdialogpages/viewsettings.h b/kompare/libdialogpages/viewsettings.h new file mode 100644 index 00000000..ab0f4d5f --- /dev/null +++ b/kompare/libdialogpages/viewsettings.h @@ -0,0 +1,61 @@ +/*************************************************************************** + generalsettings.h - description + ------------------- + begin : Sun Mar 4 2001 + copyright : (C) 2001-2003 by Otto Bruggeman + and John Firebaugh + email : otto.bruggeman@home.nl + jfirebaugh@kde.org +****************************************************************************/ + +/*************************************************************************** +** +** 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. +** +***************************************************************************/ + +#ifndef VIEWSETTINGS_H +#define VIEWSETTINGS_H + +#include <qcolor.h> +#include <qwidget.h> + +#include "difference.h" +#include "settingsbase.h" + +class ViewSettings : public SettingsBase +{ +Q_OBJECT +public: + static const QColor default_removeColor; + static const QColor default_changeColor; + static const QColor default_addColor; + static const QColor default_appliedColor; + + ViewSettings( QWidget* parent ); + ~ViewSettings(); +public: + // some virtual functions that will be overloaded from the base class + virtual void loadSettings( KConfig* config ); + virtual void saveSettings( KConfig* config ); + QColor colorForDifferenceType( int type, bool selected = false, bool applied = false ); + +public: + QColor m_removeColor; + QColor m_changeColor; + QColor m_addColor; + QColor m_appliedColor; + QColor m_selectedRemoveColor; + QColor m_selectedChangeColor; + QColor m_selectedAddColor; + QColor m_selectedAppliedColor; + int m_scrollNoOfLines; + int m_tabToNumberOfSpaces; + + QFont m_font; +}; + +#endif // VIEWSETTINGS_H |