Logo Search packages:      
Sourcecode: kdar version File versions  Download package

kdarConfig.cpp

/***************************************************************************
 *   Copyright (C) 2004, 2005 by Johnathan Burchill                        *
 *   jkerrb@users.sourceforge.net                                          *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "kdarConfig.h"

#include "kdar.h"
#include "kdarEnums.h"
#include "KDarInteraction.h"
#include "archiveHandle.h"

#include <kapp.h>
#include <kcombobox.h>
#include <kconfig.h>
#include <kdebug.h>
#include <kfontrequester.h>
#include <kglobal.h>
#include <klineedit.h>
#include <klistbox.h>
#include <klocale.h>
#include <knuminput.h>
#include <kpassdlg.h>
#include <kstandarddirs.h>
#include <kurl.h>
#include <kurlrequester.h>

#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qdir.h>
#include <qfont.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlistview.h>
#include <qradiobutton.h>
#include <qregexp.h>
#include <qspinbox.h>
#include <qvalidator.h>
#include <qvaluelist.h>
#include <qwidgetstack.h>

#include <dar/libdar.hpp>

00054 KDarConfig::KDarConfig (const KDarConfig &_kdc)
  : kdarConfigureDlg(0,0)
  , m_nodialog(true)
  , m_kc(0)
  , m_ZCompression( true )
  , m_BZ2Compression( true )
  , m_strongCrypto ( true )
{
    //set up an integer validator on the slicesize lineEdits
    kdDebug() << "kdarView::kdarView(): integer validator for lineEdits" << endl;
    QRegExp rx("[1-9][0-9]*");
    QRegExpValidator * restrictToWholeNumbers = new QRegExpValidator(rx, this);
    sliceSizeLineEdit->setValidator( restrictToWholeNumbers );
    firstSliceSizeLineEdit->setValidator( restrictToWholeNumbers );
    //Default media types:
    mediaNames << i18n( "media name for custom", "Custom" ) << "DVD (4.7GB)" << "DVD (2GB)" << "CDR (99 min.)"       << "CDR (89 min.)" << "CDR (80 min.)" << "CDR (74 min.)" << "CDR (63 min.)" << "CDR (50 min.)" << "CDR (34 min.)" << "CDR (30 min.)" << "CDR (27 min.)" << "CDR (23 min.)" << "CDR (21 min.)" << "CDR (20 min.)" << "Floppy (1440 kB)" << "Zip (100 MB)";
    statusBarMediaNames << i18n( "statusbar name for custom", "custom" ) << "DVD (4.7GB)" << "DVD (2GB)" << "CDR (870 MB)"       << "CDR (782 MB)" << "CDR (700 MB)" << "CDR (650 MB)" << "CDR (553 MB)" << "CDR (439 MB)" << "CDR (298 MB)" << "CDR (263 MB)" << "CDR (237 MB)" << "CDR (202 MB)" << "CDR (184 MB)" << "CDR (175 MB)" << "Floppy (1440 kB)" << "Zip (100 MB)";
    //These sizes are from xcdroast.
    mediaSizes << "700" << "4400" << "2" << "870" << "782" << "700" << "650" << "553" << "439" << "298" << "263" << "237" << "202" << "184" << "175" << "1440" << "100";
    mediaFirstSizes = mediaSizes;
    mediaSuffices << KDar::MB << KDar::MB << KDar::GB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::KB << KDar::MB;
    mediaFirstSuffices = mediaSuffices;

    //Copy the values:
    setArchiveName( _kdc.archiveName() );
    setArchiveStorageDirectory( _kdc.archiveStorageDirectory() );
    setNewArchiveName( _kdc.newArchiveName() );
    setDirectoryToBackup( _kdc.directoryToBackup() );
    setDifferentialBackup( _kdc.differentialBackup() );
    setDifferentialBackupArchiveName( _kdc.differentialBackupArchiveName() );
    setExtractArchiveDirectory( _kdc.extractArchiveDirectory() );
    setInputPipe( _kdc.inputPipe() );
    setOutputPipe( _kdc.outputPipe() );
    setExecuteCommand( _kdc.executeCommand() );
    setCryptoAlgorithm( _kdc.cryptoAlgorithm() );
    setCryptoBlockSize( _kdc.cryptoBlockSize() );
    setStorePassword( _kdc.storePassword() );
    setExecuteRef( _kdc.executeRef() );
    setPassRef( _kdc.passRef() );

    setVerbose( _kdc.verbose() );
    setAllowOverwrite( _kdc.allowOverwrite() );
    setWarnOnOverwrite( _kdc.warnOnOverwrite() );
    setUserEA( _kdc.userEA() );
    setSystemEA( _kdc.systemEA() );
    setIgnoreID( _kdc.ignoreID() );
    setNoDelete( _kdc.noDelete() );
    setRestoreRecent( _kdc.restoreRecent() );
    setFlatRestore( _kdc.flatRestore() );

    setUseCreateArchiveWizard( _kdc.useCreateArchiveWizard() );
    setSplitArchive( _kdc.splitArchive() );
    setPauseBetweenSlices( _kdc.pauseBetweenSlices() );
    setKeepPruned( _kdc.keepPruned() );
    setIgnoreDump( _kdc.ignoreDump() );
    setMedia( _kdc.media() );
    setSliceSizeString( _kdc.sliceSizeString() );
    setSliceSizeSuffix( _kdc.sliceSizeSuffix() );
    setFirstSliceSizeStrings( _kdc.firstSliceSizeStrings() );
    setFirstSliceSizeSuffices( _kdc.firstSliceSizeSuffices() );
    setCompressionAlgorithm( _kdc.compressionAlgorithm() );
    setCompressionLevel( _kdc.compressionLevel() );
    setMinimumCompressionSizeInt( _kdc.minimumCompressionSizeInt() );
    setHourShiftInt( _kdc.hourShiftInt() );

    setCompressionMaskList(_kdc.compressionMaskList() );
    setDirectoryMaskList( _kdc.directoryMaskList() );
    setFileMaskList( _kdc.fileMaskList() );
    setCompressionMaskType( _kdc.compressionMaskType() );
    setDirectoryMaskTypes( _kdc.directoryMaskTypes() );
    setFileMaskType( _kdc.fileMaskType() );

    setGeneralFont( _kdc.generalFont() );
    setFileBrowserFont( _kdc.fileBrowserFont() );
    setMessageWindowFont( _kdc.messageWindowFont() );
    setStatusBarFont( _kdc.statusBarFont() );

    setShowKDarSplashScreen( _kdc.showKDarSplashScreen() );
    setDryRun( _kdc.dryRun() );
    setIsolationArchiveName( _kdc.isolationArchiveName() );
    setLogFile( _kdc.logFile() );
    setLogLevel( _kdc.logLevel() );

    m_ZCompression = _kdc.ZCompression();
    m_BZ2Compression = _kdc.BZ2Compression();
    m_strongCrypto = _kdc.strongCrypto();
}


00143 KDarConfig::KDarConfig( QWidget *parent, const char *name,
                            KDarConfig *_kdc, bool addHelpButton )
    : kdarConfigureDlg (parent, name), m_nodialog(false)
    , m_kc(0)
    , m_compressionDlg( new kdarCompressionFilterDialog )
    , m_directoryDlg( new kdarDirectoryFilterDialog )
    , m_fileDlg( new kdarFileFilterDialog )
    , m_ZCompression( true )
    , m_BZ2Compression( true )
    , m_strongCrypto ( true )
{
    //set up an integer validator on the slicesize lineEdits
    kdDebug() << "kdarView::kdarView(): integer validator for lineEdits" << endl;
    QRegExp rx("[1-9][0-9]*");
    QRegExpValidator * restrictToWholeNumbers = new QRegExpValidator(rx, this);
    sliceSizeLineEdit->setValidator( restrictToWholeNumbers );
    firstSliceSizeLineEdit->setValidator( restrictToWholeNumbers );
    //Default media types:
    mediaNames << i18n( "media name for custom", "Custom" ) << "DVD (4.7GB)" << "DVD (2GB)" << "CDR (99 min.)"       << "CDR (89 min.)" << "CDR (80 min.)" << "CDR (74 min.)" << "CDR (63 min.)" << "CDR (50 min.)" << "CDR (34 min.)" << "CDR (30 min.)" << "CDR (27 min.)" << "CDR (23 min.)" << "CDR (21 min.)" << "CDR (20 min.)" << "Floppy (1440 kB)" << "Zip (100 MB)";
    statusBarMediaNames << i18n( "statusbar name for custom", "custom" ) << "DVD (4.7GB)" << "DVD (2GB)" << "CDR (870 MB)"       << "CDR (782 MB)" << "CDR (700 MB)" << "CDR (650 MB)" << "CDR (553 MB)" << "CDR (439 MB)" << "CDR (298 MB)" << "CDR (263 MB)" << "CDR (237 MB)" << "CDR (202 MB)" << "CDR (184 MB)" << "CDR (175 MB)" << "Floppy (1440 kB)" << "Zip (100 MB)";
    mediaSizes << "700" << "4400" << "2" << "870" << "782" << "700" << "650" << "553" << "439" << "298" << "263" << "237" << "202" << "184" << "175" << "1440" << "100";
    mediaFirstSizes = mediaSizes;

    mediaSuffices << KDar::MB << KDar::MB << KDar::GB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::MB << KDar::KB << KDar::MB;
    mediaFirstSuffices = mediaSuffices;

    //Clear the default mediaType list
    mediaTypeKComboBox->clear();
    //Load the mediaTypeKComboBox with the enumerated types
    mediaTypeKComboBox->insertStringList( mediaNames );
    //Set the default media to "custom"
    mediaTypeKComboBox->setCurrentItem( KDar::CDR80 );

    //Set the archiveStorageDir KURL Requester mode and caption:
    archiveStorageDirKURLRequester->setMode(18);
    archiveStorageDirKURLRequester->setCaption( i18n( "Please choose (or create) a storage directory" ) );

    m_kc = KGlobal::config();

    connect( this, SIGNAL( compressionMaskListChanged() ), this, SLOT( slotUpdateCompressionMaskList() ) );
    connect( this, SIGNAL( fileMaskListChanged() ), this, SLOT( slotUpdateFileMaskList() ) );
    connect ( this, SIGNAL( directoryMaskListChanged() ), this, SLOT( slotUpdateDirectoryMaskList() ) );

    if( _kdc == 0 )
    {
        readGlobalSettings();
    }
    else
    {
        setArchiveName( _kdc->archiveName() );
        setArchiveStorageDirectory( _kdc->archiveStorageDirectory() );
        setNewArchiveName( _kdc->newArchiveName() );
        setDirectoryToBackup( _kdc->directoryToBackup() );
        setDifferentialBackup( _kdc->differentialBackup() );
        setDifferentialBackupArchiveName( _kdc->differentialBackupArchiveName() );
        setExtractArchiveDirectory( _kdc->extractArchiveDirectory() );
        setInputPipe( _kdc->inputPipe() );
        setOutputPipe( _kdc->outputPipe() );
        setExecuteCommand( _kdc->executeCommand() );
        setCryptoAlgorithm( _kdc->cryptoAlgorithm() );
        setCryptoBlockSize( _kdc->cryptoBlockSize() );
        setStorePassword( _kdc->storePassword() );
        setExecuteRef( _kdc->executeRef() );
        setPassRef( _kdc->passRef() );

        setVerbose( _kdc->verbose() );
        setAllowOverwrite( _kdc->allowOverwrite() );
        setWarnOnOverwrite( _kdc->warnOnOverwrite() );
        setUserEA( _kdc->userEA() );
        setSystemEA( _kdc->systemEA() );
        setIgnoreID( _kdc->ignoreID() );
        setNoDelete( _kdc->noDelete() );
        setRestoreRecent( _kdc->restoreRecent() );
        setFlatRestore( _kdc->flatRestore() );

        setUseCreateArchiveWizard( _kdc->useCreateArchiveWizard() );
        setSplitArchive( _kdc->splitArchive() );
        setPauseBetweenSlices( _kdc->pauseBetweenSlices() );
        setKeepPruned( _kdc->keepPruned() );
        setIgnoreDump( _kdc->ignoreDump() );
        setMedia( _kdc->media() );
        setSliceSizeString( _kdc->sliceSizeString() );
        setSliceSizeSuffix( _kdc->sliceSizeSuffix() );
        setFirstSliceSizeStrings( _kdc->firstSliceSizeStrings() );
        setFirstSliceSizeSuffices( _kdc->firstSliceSizeSuffices() );
        setCompressionAlgorithm( _kdc->compressionAlgorithm() );
        setCompressionLevel( _kdc->compressionLevel() );
        setMinimumCompressionSizeInt( _kdc->minimumCompressionSizeInt() );
        setHourShiftInt( _kdc->hourShiftInt() );

        setCompressionMaskList(_kdc->compressionMaskList() );
        setDirectoryMaskList( _kdc->directoryMaskList() );
        setFileMaskList( _kdc->fileMaskList() );
        setCompressionMaskType( _kdc->compressionMaskType() );
        setDirectoryMaskTypes( _kdc->directoryMaskTypes() );
        setFileMaskType( _kdc->fileMaskType() );

        setGeneralFont( _kdc->generalFont() );
        setFileBrowserFont( _kdc->fileBrowserFont() );
        setMessageWindowFont( _kdc->messageWindowFont() );
        setStatusBarFont( _kdc->statusBarFont() );

        setShowKDarSplashScreen( _kdc->showKDarSplashScreen() );
        setDryRun( _kdc->dryRun() );
        setIsolationArchiveName( _kdc->isolationArchiveName() );
        setLogFile( _kdc->logFile() );
        setLogLevel( _kdc->logLevel() );
        m_ZCompression = _kdc->ZCompression();
        m_BZ2Compression = _kdc->BZ2Compression();
        m_strongCrypto = _kdc->strongCrypto();
    }
    if( addHelpButton == true )
    {
//  QPushButton *pushButton = new KPushButton( KStdGuiItem::help(), this );
//  connect( pushButton, SIGNAL(clicked()), this, SLOT(sHelp()) );
//  glay->addWidget(pushButton, 5, 2);
    }

    fillInDialog();
}

00264 KDarConfig::~KDarConfig()
{
}

00268 bool KDarConfig::readGlobalSettings()
{
    m_kc->setGroup("General");
        setUseCreateArchiveWizard( m_kc->readBoolEntry( "useCreateArchiveWizard", true) );
        setVerbose( m_kc->readBoolEntry( "verbose", true) );
        QString file = m_kc->readEntry( "logFile", "" );
        if ( file.isEmpty() )
        {
            file = KGlobal::dirs()->saveLocation( "data", "kdar/" ) + "kdar.log";
        }
        setLogFile( file );
        setLogLevel( m_kc->readNumEntry( "logLevel", KDar::LOG_BASIC ) );
        kdDebug() << "logFile is " << logFile() << endl;
        setDryRun( m_kc->readBoolEntry( "dryRun", false) );
        setShowKDarSplashScreen( m_kc->readBoolEntry( "showKDarSplashScreen", true ) );
        QString lastArchive = m_kc->readEntry( "lastArchive", "select archive");
        if (lastArchive[0] != '/')
        {
            lastArchive = "select archive";
        }
        setArchiveName( lastArchive );
        setArchiveStorageDirectory( m_kc->readEntry( "archiveStorageDir", "" ) );
        setNewArchiveName( m_kc->readEntry( "newArchiveName", "" ) );
        setDirectoryToBackup( m_kc->readEntry( "directoryToBackup", "" ) );
        setDifferentialBackup( m_kc->readBoolEntry( "differentialBackup", false ) );
        setDifferentialBackupArchiveName( m_kc->readEntry( "differentialBackupArchiveName", "" ) );
    m_kc->setGroup("Filesystem");
        setUserEA( m_kc->readBoolEntry( "userEA", true ) );
        setSystemEA( m_kc->readBoolEntry( "systemEA", true ) );
        setIgnoreID( m_kc->readBoolEntry( "ignoreID", false ) );
    m_kc->setGroup("Create / Isolate");
        setInputPipe( m_kc->readEntry( "inputPipe", "" ) );
        setOutputPipe( m_kc->readEntry( "outputPipe", "" ) );
        setExecuteCommand( m_kc->readEntry( "executeCommand", "" ) );
//        setPasswordString( m_kc->readEntry( "passwordString", "" ) );
        //the password string is a temporary holding string.
        setPasswordString( "" );
        setExecuteRef( m_kc->readEntry( "executeRef", "" ) );
        setPassRef( m_kc->readEntry( "passRef", "" ) );
        setSplitArchive( m_kc->readBoolEntry( "splitArchive", true ) );
        setPauseBetweenSlices( m_kc->readBoolEntry( "pauseBetweenSlices", true ) );
        setKeepPruned( m_kc->readBoolEntry( "keepPruned", true ) );
        setIgnoreDump( m_kc->readBoolEntry( "ignoreDump", false ) );
        setSliceSizeString( m_kc->readEntry( "sliceSizeString", "700" ) );
        setSliceSizeSuffix( m_kc->readNumEntry( "sliceSizeSuffix", KDar::MB ) );
        setFirstSliceSizeStrings( m_kc->readListEntry( "firstSliceSizeStrings" ) );
        setFirstSliceSizeSuffices( m_kc->readIntListEntry( "firstSliceSizeSuffices" ) );
        //Now that the various slice sizes are known, we can set the media type.
        setMedia( m_kc->readNumEntry( "media", KDar::CDR80 ) );
        setCompressionAlgorithm( m_kc->readNumEntry( "compressionAlgorithm", libdar::bzip2 ) );
        setCompressionLevel( m_kc->readNumEntry( "compressionLevel", 9 ) );
        setMinimumCompressionSizeInt( m_kc->readNumEntry( "minimumCompressionSizeInt", 150 ) );
        setCompressionMaskList(m_kc->readListEntry( "compressionMaskList" ) );
        setDirectoryMaskList( m_kc->readListEntry( "directoryMaskList" ) );
        setFileMaskList( m_kc->readListEntry( "fileMaskList" ) );
        setCompressionMaskType( m_kc->readNumEntry( "compressionMaskType", KDar::DO_NOT_INCLUDE ) );
        setDirectoryMaskTypes( m_kc->readListEntry( "directoryMaskTypes" ) );
        setFileMaskType( m_kc->readNumEntry( "fileMaskType", KDar::DO_NOT_INCLUDE ) );
    m_kc->setGroup("Extract");
        setExtractArchiveDirectory( m_kc->readEntry( "extractArchiveDirectory", "" ) );
        setNoDelete( m_kc->readBoolEntry( "noDelete", true ) );
        setRestoreRecent( m_kc->readBoolEntry( "restoreRecent", true ) );
        setFlatRestore( m_kc->readBoolEntry( "flatRestore", false ) );
        setAllowOverwrite( m_kc->readBoolEntry( "allowOverwrite", true ) );
        setWarnOnOverwrite( m_kc->readBoolEntry( "warnOnOverwrite", false ) );
    m_kc->setGroup( "Cryptography" );
        setCryptoAlgorithm( m_kc->readNumEntry( "cryptoAlgorithm", KDar::CRYPTO_NONE ) );
        setCryptoBlockSize( m_kc->readNumEntry( "cryptoBlockSize", 10240 ) );
        setStorePassword( m_kc->readBoolEntry( "storePassword", true ) );
    m_kc->setGroup("Diff");
        setHourShiftInt( m_kc->readNumEntry( "hourShiftInt", 0 ) );
    m_kc->setGroup("Fonts");
        QFont defaultFont = kapp->font();
        setGeneralFont( m_kc->readFontEntry( "generalFont", &defaultFont ) );
        setFileBrowserFont( m_kc->readFontEntry( "fileBrowserFont", &defaultFont ) );
        setMessageWindowFont( m_kc->readFontEntry( "messageWindowFont", &defaultFont ) );
        setStatusBarFont( m_kc->readFontEntry( "statusBarFont", &defaultFont ) );

    return true;
}

00349 bool KDarConfig::writeGlobalSettings ()
{

    m_kc->setGroup("General");
        m_kc->writeEntry( "useCreateArchiveWizard", useCreateArchiveWizard()  );
        m_kc->writeEntry( "verbose", verbose() );
        m_kc->writeEntry( "logFile", logFile() );
        m_kc->writeEntry( "logLevel", logLevel() );
        m_kc->writeEntry( "dryRun", dryRun() );
        m_kc->writeEntry( "showKDarSplashScreen", showKDarSplashScreen() );
        QString lastArchive( archiveName() );
        if (lastArchive[0] != '/' )
        {
            lastArchive = "select archive";
        }
        m_kc->writeEntry( "lastArchive", lastArchive );
        m_kc->writeEntry( "archiveStorageDir", archiveStorageDirectory() );
        m_kc->writeEntry( "newArchiveName", newArchiveName() );
        m_kc->writeEntry( "directoryToBackup", directoryToBackup() );
        m_kc->writeEntry( "differentialBackup", differentialBackup() );
        m_kc->writeEntry( "differentialBackupArchiveName", differentialBackupArchiveName() );
    m_kc->setGroup("Filesystem");
        m_kc->writeEntry( "userEA", userEA() );
        m_kc->writeEntry( "systemEA", systemEA() );
        m_kc->writeEntry( "ignoreID", ignoreID() );
    m_kc->setGroup("Create / Isolate");
        m_kc->writeEntry( "inputPipe", inputPipe() );
        m_kc->writeEntry( "outputPipe", outputPipe() );
        m_kc->writeEntry( "executeCommand", executeCommand() );
        m_kc->writeEntry( "executeRef", executeRef() );
        m_kc->writeEntry( "passRef", passRef() );
        m_kc->writeEntry( "splitArchive", splitArchive() );
        m_kc->writeEntry( "pauseBetweenSlices", pauseBetweenSlices() );
        m_kc->writeEntry( "keepPruned", keepPruned() );
        m_kc->writeEntry( "ignoreDump", ignoreDump() );
        m_kc->writeEntry( "media", media() );
        m_kc->writeEntry( "sliceSizeString", sliceSizeString() );
        m_kc->writeEntry( "sliceSizeSuffix", sliceSizeSuffix() );
        m_kc->writeEntry( "firstSliceSizeStrings", firstSliceSizeStrings() );
        m_kc->writeEntry( "firstSliceSizeSuffices", firstSliceSizeSuffices() );
        m_kc->writeEntry( "compressionAlgorithm", compressionAlgorithm() );
        m_kc->writeEntry( "compressionLevel", compressionLevel() );
        m_kc->writeEntry( "minimumCompressionSizeInt", minimumCompressionSizeInt() );
        m_kc->writeEntry( "compressionMaskList", compressionMaskList() );
        m_kc->writeEntry( "directoryMaskList", directoryMaskList() );
        m_kc->writeEntry( "fileMaskList", fileMaskList() );
        m_kc->writeEntry( "compressionMaskType", compressionMaskType() );
        m_kc->writeEntry( "directoryMaskTypes", directoryMaskTypes() );
        m_kc->writeEntry( "fileMaskType", fileMaskType() );
    m_kc->setGroup("Extract");
        m_kc->writeEntry( "extractArchiveDirectory", extractArchiveDirectory() );
        m_kc->writeEntry( "noDelete", noDelete() );
        m_kc->writeEntry( "restoreRecent", restoreRecent() );
        m_kc->writeEntry( "flatRestore", flatRestore() );
        m_kc->writeEntry( "allowOverwrite", allowOverwrite() );
        m_kc->writeEntry( "warnOnOverwrite", warnOnOverwrite() );
    m_kc->setGroup( "Cryptography" );
        m_kc->writeEntry( "cryptoAlgorithm", cryptoAlgorithm() );
        m_kc->writeEntry( "cryptoBlockSize", cryptoBlockSize() );
        m_kc->writeEntry( "storePassword", storePassword() );
        kdDebug() << "KDarConfig::writeGlobalSettings(): storePassword() is " << storePassword() << endl;

    m_kc->setGroup("Diff");
        m_kc->writeEntry( "hourShiftInt", hourShiftInt() );
    m_kc->setGroup("Fonts");
        m_kc->writeEntry( "generalFont", generalFont() );
        m_kc->writeEntry( "fileBrowserFont", fileBrowserFont() );
        m_kc->writeEntry( "messageWindowFont", messageWindowFont() );
        m_kc->writeEntry( "statusBarFont", statusBarFont() );

    m_kc->sync();
    return true;
}

00423 void KDarConfig::updateGUI()
{
    fillInDialog();
}

00428 QString KDarConfig::cleanPath( const QString & path )
{
    //Leave trailing slashes as they are?
    //This removes trailing slashes...
    bool emptyString = path.isEmpty();
    if ( emptyString )
    {
        //Return the empty path.
        return path;
    }
    else
    {
        return QDir::cleanDirPath( path );
    }
}

00444 QStringList KDarConfig::cleanPath( const QStringList & paths )
{
    //Iterate over the QStringList, cleaning paths as we go:
    QStringList cleanedPaths( paths );
    QStringList::Iterator cleaned = cleanedPaths.begin();
    for ( QStringList::ConstIterator it = paths.begin(); it != paths.end(); ++it )
    {
        ( *cleaned ) = cleanPath( *it );
        ++cleaned;
    }
    return cleanedPaths;
}

00457 void KDarConfig::fillInDialog()
{
    if ( m_nodialog )
    {
        return;
    }
    kdDebug() << "KDarConfig::fillinDialog" << endl;
    //Set all dialog settings here.
    useCreateArchiveWizardCheckBox->setChecked( useCreateArchiveWizard() );
    verboseOutputCheckBox->setChecked( verbose() );
    logFileKURLRequester->lineEdit()->setText( logFile() );
    logNoneRadioButton->setChecked( logLevel() == KDar::LOG_NONE );
    logBasicRadioButton->setChecked( logLevel() == KDar::LOG_BASIC );
    logFullRadioButton->setChecked( logLevel() == KDar::LOG_FULL );
    showKDarSplashCheckBox->setChecked( showKDarSplashScreen() );
    archiveStorageDirKURLRequester->lineEdit()->setText( archiveStorageDirectory() );
    userEACheckBox->setChecked( !userEA() );
    systemEACheckBox->setChecked( !systemEA() );
    ignoreIDCheckBox->setChecked( ignoreID() );
    compressionLevelSpinBox->setValue( compressionLevel() );
    noneRadioButton->setChecked( compressionAlgorithm() == libdar::none );
    gzipRadioButton->setChecked( compressionAlgorithm() == libdar::gzip );
    bzip2RadioButton->setChecked( compressionAlgorithm() == libdar::bzip2 );
    minCompressionSizeSpinBox->setValue( minimumCompressionSizeInt() );
    keepPrunedCheckBox->setChecked( keepPruned() );
    ignoreDumpCheckBox->setChecked( ignoreDump() );
    extractNoDeleteCheckBox->setChecked( noDelete() );
    extractMostRecentCheckBox->setChecked( restoreRecent() );
    extractFlatCheckBox->setChecked( flatRestore() );
    extractAllowOverwriteCheckBox->setChecked( allowOverwrite() );
    extractWarnOverwriteCheckBox->setChecked( warnOnOverwrite() );
    hourShiftBox->setValue( hourShiftInt() );
    generalKFontRequester->setFont( generalFont() );
    fileBrowserKFontRequester->setFont( fileBrowserFont() );
    messageWindowKFontRequester->setFont( messageWindowFont() );
    statusBarKFontRequester->setFont( statusBarFont() );

    //Slice sizes
    splitArchiveCheckBox->setChecked( splitArchive() );
    pauseCheckBox->setChecked( pauseBetweenSlices() );
    mediaTypeKComboBox->setCurrentItem( media() );
    setMediaSize( media() );
    commandBetweenSliceCreationKLineEdit->setText( executeCommand() );
    //Encryption
    int algo = cryptoAlgorithm();
    //Disable scrambling:
    if ( algo == KDar::CRYPTO_BLOWFISH ) algo = 1;
    cryptoAlgorithmKComboBox->setCurrentItem( algo );
    cryptoBlockSizeKIntNumInput->setValue( cryptoBlockSize() );
    cryptoStorePasswordCheckBox->setChecked( storePassword() );
    //Compression filters
    fillListView ( compressionFiltersListView, compressionMaskList() );
    compressionTypeComboBox->setCurrentItem( compressionMaskType() );
    //File filters
    fillListView ( fileFiltersListView, fileMaskList() );
    fileTypeComboBox->setCurrentItem( fileMaskType() );
    //Directories
    loadDirectoryFilters();
}

00517 void KDarConfig::setGlobalConfig( KConfig * kconfig )
{
    m_kc = kconfig;
}

00522 void KDarConfig::setArchiveName( const QString & archiveName )
{
    m_archiveName = cleanPath( archiveName );
}

00527 void KDarConfig::setArchiveStorageDirectory( const QString & archiveStorageDirectory )
{
    m_archiveStorageDirectory = cleanPath( archiveStorageDirectory );
}

00532 void KDarConfig::setNewArchiveName( const QString & newArchiveName )
{
    m_newArchiveName = cleanPath( newArchiveName );
}

00537 void KDarConfig::setDirectoryToBackup( const QString & directoryToBackup )
{
    m_directoryToBackup = cleanPath( directoryToBackup );
}

00542 void KDarConfig::setDifferentialBackup( const bool differentialBackup )
{
    m_differentialBackup = differentialBackup;
}

00547 void KDarConfig::setDifferentialBackupArchiveName( const QString & differentialBackupArchiveName )
{
    m_differentialBackupArchiveName = cleanPath( differentialBackupArchiveName );
}

00552 void KDarConfig::setInputPipe( const QString & inputPipe )
{
    m_inputPipe = cleanPath( inputPipe );
}

00557 void KDarConfig::setOutputPipe( const QString & outputPipe )
{
    m_outputPipe = cleanPath( outputPipe );
}

00562 void KDarConfig::setExecuteCommand( const QString & executeCommand )
{
    m_executeCommand = executeCommand;
}

00567 void KDarConfig::setCryptoAlgorithm( const int cryptoAlgorithm )
{
    m_cryptoAlgorithm = cryptoAlgorithm;
    //This ensures that the crypto_scrambling is disabled until
    //libdar supports automatic encryption detection.
    if ( cryptoAlgorithm == KDar::CRYPTO_SCRAMBLE ) m_cryptoAlgorithm = KDar::CRYPTO_BLOWFISH;
}

00575 void KDarConfig::setCryptoBlockSize( const int cryptoBlockSize )
{
    m_cryptoBlockSize = cryptoBlockSize;
}

00580 void KDarConfig::setStorePassword( bool storePassword )
{
    m_storePassword = storePassword;
    kdDebug() << "KDarConfig::setStorePassword(): m_storePassword is " << m_storePassword << endl;
}

00586 void KDarConfig::setPasswordString( const QString & passwordString )
{
    m_passwordString = passwordString;
}

00591 void KDarConfig::setExecuteRef( const QString & executeRef )
{
    m_executeRef = executeRef;
}

void KDarConfig::setPassRef( const QString & passRef )
{
    m_passRef = passRef;
}

00601 void KDarConfig::setVerbose( const bool verbose )
{
    m_verbose = verbose;
}

00606 void KDarConfig::setAllowOverwrite( const bool allowOverwrite )
{
    m_allowOverwrite = allowOverwrite;
}

00611 void KDarConfig::setWarnOnOverwrite( const bool warnOnOverwrite )
{
    m_warnOnOverwrite = warnOnOverwrite;
}

00616 void KDarConfig::setUserEA( const bool userEA )
{
    m_userEA = userEA;
}

00621 void KDarConfig::setSystemEA( const bool systemEA )
{
    m_systemEA = systemEA;
}

00626 void KDarConfig::setIgnoreID( const bool ignoreID )
{
    m_ignoreID = ignoreID;
}

00631 void KDarConfig::setNoDelete( const bool noDelete )
{
    m_noDelete = noDelete;
}

00636 void KDarConfig::setRestoreRecent( const bool restoreRecent )
{
    m_restoreRecent = restoreRecent;
}

00641 void KDarConfig::setFlatRestore( const bool flatRestore )
{
    m_flatRestore = flatRestore;
}

00646 void KDarConfig::setUseCreateArchiveWizard( const bool useCreateArchiveWizard )
{
    m_useCreateArchiveWizard = useCreateArchiveWizard;
}

00651 void KDarConfig::setSplitArchive( const bool splitArchive )
{
    m_splitArchive = splitArchive;
}

00656 void KDarConfig::setPauseBetweenSlices( const bool pauseBetweenSlices )
{
    m_pauseBetweenSlices = pauseBetweenSlices;
}

00661 void KDarConfig::setKeepPruned( const bool keepPruned )
{
    m_keepPruned = keepPruned;
}

00666 void KDarConfig::setIgnoreDump( const bool ignoreDump )
{
    m_ignoreDump = ignoreDump;
}

00671 void KDarConfig::setMedia( const int media )
{
    m_media = media;
}

00676 void KDarConfig::setSliceSizeString( const QString & sliceSizeString )
{
    //Make sure we have a valid slice size: whole numbers only.
    //i.e. suppose the config file is modified...
    QRegExpValidator *validator = ( QRegExpValidator * ) sliceSizeLineEdit->validator();
    if ( validator )
    {
        QString input = sliceSizeString;
        int pos = input.length() - 1;
        if ( validator->validate( input, pos ) == QValidator::Acceptable )
        {
            m_sliceSizeString = sliceSizeString;
            mediaSizes[ KDar::CUSTOM ] = sliceSizeString;
        }
    }
    else
    {
        kdDebug() << "KDarConfig::setSliceSizeString() error: QValidator is not set." << endl;
    }
}

00697 void KDarConfig::setSliceSizeSuffix( const int sliceSizeSuffix )
{
    m_sliceSizeSuffix = sliceSizeSuffix;
    mediaSuffices[ KDar::CUSTOM ] = sliceSizeSuffix;
}

00703 void KDarConfig::setFirstSliceSizeStrings( const QStringList & firstSliceSizeStrings)
{
    if ( !firstSliceSizeStrings.empty() )
    {
        mediaFirstSizes = firstSliceSizeStrings;
    }
}

00711 void KDarConfig::setFirstSliceSizeString( int medium, const QString & firstSliceSizeString )
{
    //Make sure we have a valid slice size: whole numbers only.
    //i.e. suppose the config file is modified...
    QRegExpValidator *validator = ( QRegExpValidator * ) firstSliceSizeLineEdit->validator();
    if ( validator )
    {
        QString input = firstSliceSizeString;
        int pos = input.length() - 1;
        if ( validator->validate( input, pos ) == QValidator::Acceptable )
        {
            mediaFirstSizes[ medium ] = firstSliceSizeString;
        }
    }
    else
    {
        kdDebug() << "KDarConfig::setFirstSliceSizeString() error: QValidator is not set." << endl;
    }
}

00731 void KDarConfig::setFirstSliceSizeSuffices( const QValueList<int> & firstSliceSizeSuffices )
{
    if ( !firstSliceSizeSuffices.empty() )
    {
        mediaFirstSuffices = firstSliceSizeSuffices;
    }
}

00739 void KDarConfig::setFirstSliceSizeSuffix( int medium, const int firstSliceSizeSuffix )
{
    mediaFirstSuffices[ medium ] = firstSliceSizeSuffix;
}

00744 void KDarConfig::setCompressionAlgorithm( const int compressionAlgorithm )
{
    m_compressionAlgorithm = compressionAlgorithm;
}

00749 void KDarConfig::setCompressionLevel( const int compressionLevel )
{
    m_compressionLevel = compressionLevel;
}

00754 void KDarConfig::setMinimumCompressionSizeInt( const int minimumCompressionSizeInt )
{
    m_minimumCompressionSizeInt = minimumCompressionSizeInt;
}

00759 void KDarConfig::setHourShiftInt( const int hourShiftInt )
{
    m_hourShiftInt = hourShiftInt;
}

00764 void KDarConfig::setCompressionMaskList( const QStringList & compressionMaskList )
{
    //Do we need to clean this path?
    //i.e. are these regexp filters? Does QDir::cleanDirPath affect them?
    m_compressionMaskList = cleanPath( compressionMaskList );
}

00771 void KDarConfig::setDirectoryMaskList( const QStringList & directoryMaskList )
{
    //Do we need to clean this path?
    m_directoryMaskList = cleanPath( directoryMaskList );
}

00777 void KDarConfig::setFileMaskList( const QStringList & fileMaskList )
{
    //Do we need to clean this path?
    //i.e. are these regexp filters? Does QDir::cleanDirPath affect them?
    m_fileMaskList = cleanPath( fileMaskList );
}

00784 void KDarConfig::setCompressionMaskType( const int compressionMaskType )
{
    m_compressionMaskType = compressionMaskType;
}

00789 void KDarConfig::setDirectoryMaskTypes( const QStringList & directoryMaskTypes )
{
    m_directoryMaskTypes = directoryMaskTypes;
}

00794 void KDarConfig::setFileMaskType( const int fileMaskType )
{
    m_fileMaskType = fileMaskType;
}

00799 void KDarConfig::setGeneralFont( const QFont & generalFont )
{
    m_generalFont = generalFont;
}

00804 void KDarConfig::setFileBrowserFont( const QFont & fileBrowserFont )
{
    m_fileBrowserFont = fileBrowserFont;
}

00809 void KDarConfig::setMessageWindowFont( const QFont & messageWindowFont )
{
    m_messageWindowFont = messageWindowFont;
}

00814 void KDarConfig::setStatusBarFont( const QFont & statusBarFont )
{
    m_statusBarFont = statusBarFont;
}

00819 void KDarConfig::setShowKDarSplashScreen( const bool showKDarSplashScreen )
{
    m_showKDarSplashScreen = showKDarSplashScreen;
}

00824 void KDarConfig::setDryRun( const bool dryRun )
{
    m_dryRun = dryRun;
}

00829 void KDarConfig::setIsolationArchiveName( const QString & isolationArchiveName )
{
    m_isolationArchiveName = cleanPath( isolationArchiveName );
}

00834 void KDarConfig::setDiffArchiveDirectory( const QString & diffArchiveDirectory )
{
    m_diffArchiveDirectory = cleanPath( diffArchiveDirectory );
}

00839 void KDarConfig::setExtractArchiveDirectory( const QString & extractArchiveDirectory )
{
    m_extractArchiveDirectory = cleanPath( extractArchiveDirectory );
}

void KDarConfig::setNewArchiveBasename( const QString & newArchiveBaseName )
{
    m_newArchiveBasename = cleanPath( newArchiveBaseName );
}

00849 void KDarConfig::setLogFile( const QString & logFile )
{
    m_logFile = cleanPath( logFile );
}

00854 void KDarConfig::setLogLevel( const int logLevel )
{
    m_logLevel = logLevel;
}

//member varible reading functions:

00861 KConfig * KDarConfig::globalConfig() const
{
    return m_kc;
}

00866 QString KDarConfig::archiveName() const
{
    return m_archiveName;
}

00871 QString KDarConfig::archiveStorageDirectory() const
{
    //If we have an empty string, leave it alone
    //This allows KDar to prompt the user for a default directory
    //when starting for the first time.
    if ( m_archiveStorageDirectory.isEmpty() ) return QString( "" );
    //Otherwise, make sure we have a trailing slash:
    if ( m_archiveStorageDirectory.endsWith( "/" ) )
    {
        return m_archiveStorageDirectory;
    }
    else
    {
        return m_archiveStorageDirectory + "/";
    }
}

00888 QString KDarConfig::newArchiveName( ) const
{
    return m_newArchiveName;
}

00893 QString KDarConfig::directoryToBackup() const
{
    return m_directoryToBackup;
}

00898 bool KDarConfig::differentialBackup() const
{
    return m_differentialBackup;
}

00903 QString KDarConfig::differentialBackupArchiveName() const
{
    return m_differentialBackupArchiveName;
}

00908 QString KDarConfig::inputPipe() const
{
    return m_inputPipe;
}

00913 QString KDarConfig::outputPipe() const
{
    return m_outputPipe;
}

00918 QString KDarConfig::executeCommand() const
{
    return m_executeCommand;
}

00923 int KDarConfig::cryptoAlgorithm() const
{
    return m_cryptoAlgorithm;
}

00928 int KDarConfig::cryptoBlockSize() const
{
    return m_cryptoBlockSize;
}

00933 bool KDarConfig::storePassword() const
{
    return m_storePassword;
}

00938 QString KDarConfig::passwordString() const
{
    return m_passwordString;
}

00943 QString KDarConfig::executeRef() const
{
    return m_executeRef;
}

00948 QString KDarConfig::passRef() const
{
    return m_passRef;
}

00953 bool KDarConfig::verbose() const
{
    return m_verbose;
}

00958 bool KDarConfig::allowOverwrite() const
{
    return m_allowOverwrite;
}

00963 bool KDarConfig::warnOnOverwrite() const
{
    return m_warnOnOverwrite;
}

00968 bool KDarConfig::userEA() const
{
    return m_userEA;
}

00973 bool KDarConfig::systemEA() const
{
    return m_systemEA;
}

00978 bool KDarConfig::ignoreID() const
{
    return m_ignoreID;
}

00983 bool KDarConfig::noDelete() const
{
    return m_noDelete;
}

00988 bool KDarConfig::restoreRecent() const
{
    return m_restoreRecent;
}

00993 bool KDarConfig::flatRestore() const
{
    return m_flatRestore;
}

00998 bool KDarConfig::useCreateArchiveWizard() const
{
    return m_useCreateArchiveWizard;
}

01003 bool KDarConfig::splitArchive() const
{
    return m_splitArchive;
}

01008 bool KDarConfig::pauseBetweenSlices() const
{
    return m_pauseBetweenSlices;
}

01013 bool KDarConfig::keepPruned() const
{
    return m_keepPruned;
}

01018 bool KDarConfig::ignoreDump() const
{
    return m_ignoreDump;
}

01023 int KDarConfig::media() const
{
    return m_media;
}

01028 QString KDarConfig::mediaText() const
{
    return statusBarMediaNames[ media() ];
}

01033 QString KDarConfig::sliceSizeString() const
{
    return m_sliceSizeString;
}

01038 int KDarConfig::sliceSizeSuffix() const
{
    return m_sliceSizeSuffix;
}

01043 QString KDarConfig::firstSliceSizeString() const
{
    return mediaFirstSizes[ media() ];
}

01048 int KDarConfig::firstSliceSizeSuffix() const
{
    return mediaFirstSuffices[ media() ];
}

01053 QStringList KDarConfig::firstSliceSizeStrings() const
{
    return mediaFirstSizes;
}

01058 QValueList<int> KDarConfig::firstSliceSizeSuffices() const
{
    return mediaFirstSuffices;
}

01063 int KDarConfig::compressionAlgorithm() const
{
    return m_compressionAlgorithm;
}

01068 int KDarConfig::compressionLevel() const
{
    return m_compressionLevel;
}

01073 int KDarConfig::minimumCompressionSizeInt() const
{
    return m_minimumCompressionSizeInt;
}

01078 int KDarConfig::hourShiftInt() const
{
    return m_hourShiftInt;
}

01083 QStringList KDarConfig::compressionMaskList() const
{
    return m_compressionMaskList;
}

01088 QStringList KDarConfig::directoryMaskList() const
{
    return m_directoryMaskList;
}

01093 QStringList KDarConfig::fileMaskList() const
{
    return m_fileMaskList;
}

01098 int KDarConfig::compressionMaskType() const
{
    return m_compressionMaskType;
}

01103 QStringList KDarConfig::directoryMaskTypes() const
{
    return m_directoryMaskTypes;
}

01108 int KDarConfig::fileMaskType() const
{
    return m_fileMaskType;
}

01113 QFont KDarConfig::generalFont() const
{
    return m_generalFont;
}

01118 QFont KDarConfig::fileBrowserFont() const
{
    return m_fileBrowserFont;
}

01123 QFont KDarConfig::messageWindowFont() const
{
    return m_messageWindowFont;
}

01128 QFont KDarConfig::statusBarFont() const
{
    return m_statusBarFont;
}

01133 bool KDarConfig::showKDarSplashScreen() const
{
    return m_showKDarSplashScreen;
}

01138 bool KDarConfig::dryRun() const
{
    return m_dryRun;
}

01143 QString KDarConfig::isolationArchiveName() const
{
    return m_isolationArchiveName;
}

01148 QString KDarConfig::diffArchiveDirectory() const
{
    return m_diffArchiveDirectory;
}

01153 QString KDarConfig::extractArchiveDirectory() const
{
    return m_extractArchiveDirectory;
}

01158 QString KDarConfig::newArchiveBasename() const
{
    return m_newArchiveBasename;
}

01163 QString KDarConfig::logFile() const
{
    return m_logFile;
}

01168 int KDarConfig::logLevel() const
{
    return m_logLevel;
}

01173 libdar::infinint KDarConfig::libdarSliceSize()
{
    //code for calculating the slice size from strings and suffices.
    //defaults to 0 when not splitting archives:
    libdar::infinint libdarSliceSize( (libdar::U_I) 0 );
    if ( m_splitArchive )
    {
        //Catch possible exception from libdar::infinint being too small (i.e. 32-bit or 64-bit)
        try
        {
            libdarSliceSize = libdar::deci( kdar::toStdString( mediaSizes[ media() ] ) ).computer()*libdar::infinint( (libdar::U_I) 1024 ).power( (libdar::U_I) mediaSuffices[ media() ] );
            kdDebug() << "The slice size is " << libdar::deci(libdarSliceSize).human().c_str() << endl;
        }
        catch(libdar::Egeneric &e)
        {
// TODO    What is the best way to display info to the user here?
//             KDarInteraction ki( ;
//             libdar::user_interaction_warning(e.get_message());
        }
    }
    return libdarSliceSize;
}

01196 libdar::infinint KDarConfig::libdarFirstSliceSize()
{
    //code for calculating the slice size from strings and suffices.
    libdar::infinint libdarFirstSliceSize( (libdar::U_I) 0 );
    if ( m_splitArchive )
    {
        //Catch possible exception from libdar::infinint being too small (i.e. 32-bit or 64-bit)
        try
        {
            libdarFirstSliceSize = libdar::deci( kdar::toStdString( mediaFirstSizes[ media() ] ) ).computer()*libdar::infinint( (libdar::U_I) 1024 ).power( (libdar::U_I) mediaFirstSuffices[ media() ] );
            kdDebug() << "The slice size is " << libdar::deci(libdarFirstSliceSize).human().c_str() << endl;
        }
        catch(libdar::Egeneric &e)
        {
// TODO What is the best way to display this info to the user?
//             libdar::user_interaction_warning(e.get_message());
        }
    }
    return libdarFirstSliceSize;
}

01217 void KDarConfig::activateHelp( void )
{
    slotHelp();
}

01222 void KDarConfig::slotHelp( void )
{
    kapp->invokeHelp( "configuration", "kdar" );
}

01227 void KDarConfig::operator=( const KDarConfig &_kdc )
{
    //set up an integer validator on the slicesize lineEdits
    kdDebug() << "kdarView::kdarView(): integer validator for lineEdits" << endl;
    QRegExp rx("[1-9][0-9]*");
    QRegExpValidator * restrictToWholeNumbers = new QRegExpValidator(rx, this);
    sliceSizeLineEdit->setValidator( restrictToWholeNumbers );
    firstSliceSizeLineEdit->setValidator( restrictToWholeNumbers );
    //Default media types:
    setArchiveName( _kdc.archiveName() );
    setArchiveStorageDirectory( _kdc.archiveStorageDirectory() );
    setExtractArchiveDirectory( _kdc.extractArchiveDirectory() );
    setInputPipe( _kdc.inputPipe() );
    setOutputPipe( _kdc.outputPipe() );
    setExecuteCommand( _kdc.executeCommand() );
    setCryptoAlgorithm( _kdc.cryptoAlgorithm() );
    setCryptoBlockSize( _kdc.cryptoBlockSize() );
    setStorePassword( _kdc.storePassword() );
    setExecuteRef( _kdc.executeRef() );
    setPassRef( _kdc.passRef() );

    setVerbose( _kdc.verbose() );
    setLogFile( _kdc.logFile() );
    setLogLevel( _kdc.logLevel() );
    setAllowOverwrite( _kdc.allowOverwrite() );
    setWarnOnOverwrite( _kdc.warnOnOverwrite() );
    setUserEA( _kdc.userEA() );
    setSystemEA( _kdc.systemEA() );
    setIgnoreID( _kdc.ignoreID() );
    setNoDelete( _kdc.noDelete() );
    setRestoreRecent( _kdc.restoreRecent() );
    setFlatRestore( _kdc.flatRestore() );

    setUseCreateArchiveWizard( _kdc.useCreateArchiveWizard() );
    setSplitArchive( _kdc.splitArchive() );
    setPauseBetweenSlices( _kdc.pauseBetweenSlices() );
    setKeepPruned( _kdc.keepPruned() );
    setIgnoreDump( _kdc.ignoreDump() );
    setMedia( _kdc.media() );
    setSliceSizeString( _kdc.sliceSizeString() );
    setSliceSizeSuffix( _kdc.sliceSizeSuffix() );
    setFirstSliceSizeStrings( _kdc.firstSliceSizeStrings() );
    setFirstSliceSizeSuffices( _kdc.firstSliceSizeSuffices() );
    setCompressionAlgorithm( _kdc.compressionAlgorithm() );
    setCompressionLevel( _kdc.compressionLevel() );
    setMinimumCompressionSizeInt( _kdc.minimumCompressionSizeInt() );
    setHourShiftInt( _kdc.hourShiftInt() );

    setCompressionMaskList(_kdc.compressionMaskList() );
    setDirectoryMaskList( _kdc.directoryMaskList() );
    setFileMaskList( _kdc.fileMaskList() );
    setCompressionMaskType( _kdc.compressionMaskType() );
    setDirectoryMaskTypes( _kdc.directoryMaskTypes() );
    setFileMaskType( _kdc.fileMaskType() );

    setGeneralFont( _kdc.generalFont() );
    setFileBrowserFont( _kdc.fileBrowserFont() );
    setMessageWindowFont( _kdc.messageWindowFont() );
    setStatusBarFont( _kdc.statusBarFont() );

    setShowKDarSplashScreen( _kdc.showKDarSplashScreen() );
    setDryRun( _kdc.dryRun() );

    fillInDialog();
}

01293 void KDarConfig::fillListView(QListView *listView, QStringList stringList)
{
    QStringList tmpList;
    //clear the listView, so that we can fill it from scratch.
    if ( listView ) listView->clear();
    if ( listView && !stringList.empty() )
    {
        for (QStringList::Iterator it = stringList.begin(); it != stringList.end(); ++it)
        {
            tmpList = makeQStringList( listView );
            if ( !tmpList.contains( *it ) )
            {
                (void) new QListViewItem(listView, *it);
            }
        }
    }
}

01311 void KDarConfig::loadDirectoryFilters()
{
    QStringList directoryList = directoryMaskList();
    QStringList maskTypes = directoryMaskTypes();
    //clear the listview, so we can fill it from scratch.
    directoryFiltersListView->clear();
    kdDebug() << "KDarConfig::loadDirectoryFilters(): maskTypes.count() = " << maskTypes.count() << endl;
    kdDebug() << "KDarConfig::loadDirectoryFilters(): directoryList.count() = " << directoryList.count() << endl;
    if ( !directoryList.empty() && !maskTypes.empty() && ( maskTypes.count() == directoryList.count() ) )
    {
        kdDebug() << "KDarConfig::loadDirectoryFilters(): Loading directory filters..." << endl;
        QStringList::Iterator typeIterator = maskTypes.begin();
        for ( QStringList::Iterator directoryIterator = directoryList.begin(); directoryIterator != directoryList.end(); ++directoryIterator )
        {
            QStringList tmpList = makeQStringList( directoryFiltersListView, 1 );
            if ( !tmpList.contains( *directoryIterator ) || ( *typeIterator == i18n( "automatic filter type", "Auto" ) ) )
            {
                QListViewItem* item = new QListViewItem( directoryFiltersListView, *typeIterator, *directoryIterator );
                if ( *typeIterator == i18n( "automatic filter type", "Auto" ) )
                {
                    item->setEnabled( false );
                }
            }
            ++typeIterator;
        }
    }
}

//Slots

01341 void KDarConfig::slotArchiveName( const QString & archiveName )
{
    setArchiveName( archiveName );
    emit configChanged();
}

01347 void KDarConfig::slotArchiveStorageDirectory( const QString & archiveStorageDirectory )
{
    if ( archiveStorageDirectory.isNull() )
    {
        kdDebug() << "KDarConfig::slotArchiveStorageDirectory(): archiveStorageDirectory is NULL!" << endl;
        return;
    }
    setArchiveStorageDirectory( archiveStorageDirectory );
    //update the auto directory filter
    QStringList directoryList = directoryMaskList();
    QStringList maskTypes = directoryMaskTypes();
    QStringList::Iterator directoryIterator = directoryList.begin();
    for ( QStringList::Iterator typeIterator = maskTypes.begin(); typeIterator != maskTypes.end(); ++typeIterator )
    {
        //Assumes we can only have 1 auto directory filter
        if ( *typeIterator == i18n( "automatic filter type", "Auto" ) )
        {
            *directoryIterator = archiveStorageDirectory;
        }
        ++directoryIterator;
    }
    setDirectoryMaskList( directoryList );
    loadDirectoryFilters();

    kdDebug() << "KDarConfig::slotArchiveStorageDirectory(): archiveStorageDirectory() is " << archiveStorageDirectory << endl;
    emit configChanged();
}

01375 void KDarConfig::slotInputPipe( const QString & inputPipe )
{
    setInputPipe( inputPipe );
    emit configChanged();
}

01381 void KDarConfig::slotOutputPipe( const QString & outputPipe )
{
    setOutputPipe( outputPipe );
    emit configChanged();

}

01388 void KDarConfig::slotExecuteCommand( const QString & executeCommand )
{
    setExecuteCommand( executeCommand );
    emit configChanged();
}

01394 void KDarConfig::slotCryptoAlgorithm( int algorithm )
{
    setCryptoAlgorithm( algorithm );
    emit configChanged();
}

01400 void KDarConfig::slotCryptoBlockSize( int blockSize )
{
    setCryptoBlockSize( blockSize );
    emit configChanged();
}

01406 void KDarConfig::slotExecuteRef( const QString & executeRef )
{
    setExecuteRef( executeRef );
    emit configChanged();
}

01412 void KDarConfig::slotStorePassword( bool storePassword )
{
    setStorePassword( storePassword );
    kdDebug() << "KDarConfig::slotStorePassword(): storePassword is " << storePassword << endl;
    emit configChanged();
}

01419 void KDarConfig::slotChangePassword()
{
    emit changeWalletPassword();
}

01424 void KDarConfig::slotPassRef( const QString & passRef )
{
    setPassRef( passRef );
    emit configChanged();
}

01430 void KDarConfig::slotVerbose( bool verbose )
{
    setVerbose( verbose );
    emit configChanged();
}

01436 void KDarConfig::slotAllowOverwrite( bool allowOverwrite )
{
    setAllowOverwrite( allowOverwrite );
    emit configChanged();
}

01442 void KDarConfig::slotWarnOnOverwrite( bool warnOnOverwrite )
{
    setWarnOnOverwrite( warnOnOverwrite );
    emit configChanged();
}

01448 void KDarConfig::slotUserEA( bool disableUserEA )
{
    setUserEA( !disableUserEA );
    emit configChanged();
}

01454 void KDarConfig::slotSystemEA( bool disableSystemEA )
{
    setSystemEA( !disableSystemEA );
    emit configChanged();
}

01460 void KDarConfig::slotIgnoreID( bool ignoreID )
{
    setIgnoreID( ignoreID );
    emit configChanged();
}

01466 void KDarConfig::slotNoDelete( bool noDelete )
{
    setNoDelete( noDelete );
    emit configChanged();
}

01472 void KDarConfig::slotRestoreRecent( bool restoreRecent )
{
    setRestoreRecent( restoreRecent );
    emit configChanged();
}

01478 void KDarConfig::slotFlatRestore( bool flatRestore )
{
    setFlatRestore( flatRestore );
    emit configChanged();
}

01484 void KDarConfig::slotUseCreateArchiveWizard( bool useCreateArchiveWizard )
{
    setUseCreateArchiveWizard( useCreateArchiveWizard );
    emit configChanged();
}

01490 void KDarConfig::slotSplitArchive( bool splitArchive )
{
    setSplitArchive( splitArchive );
    emit configChanged();
}

01496 void KDarConfig::slotPauseBetweenSlices( bool pauseBetweenSlices )
{
    setPauseBetweenSlices( pauseBetweenSlices );
    emit configChanged();
}

01502 void KDarConfig::slotKeepPruned( bool keepPruned )
{
    setKeepPruned( keepPruned );
    emit configChanged();
}

01508 void KDarConfig::slotIgnoreDump( bool ignoreDump )
{
    setIgnoreDump( ignoreDump );
    emit configChanged();
}

01514 void KDarConfig::slotMedia( int media )
{
    kdDebug() << "KDarConfig::slotMedia(): media is " << media << endl;
    setMedia( media );
    setMediaSize( media );
    emit configChanged();
}

01522 void KDarConfig::slotSliceSizeString( const QString & sliceSizeString )
{
    if ( media() != KDar::CUSTOM )
    {
        setMedia( KDar::CUSTOM );
        mediaTypeKComboBox->blockSignals( true );
        mediaTypeKComboBox->setCurrentItem( KDar::CUSTOM );
        mediaTypeKComboBox->blockSignals( false );
    }
    setSliceSizeString( sliceSizeString );
    emit configChanged();
}

01535 void KDarConfig::slotSliceSizeSuffix( int sliceSizeSuffix )
{
    if ( media() != KDar::CUSTOM )
    {
        setMedia( KDar::CUSTOM );
        mediaTypeKComboBox->blockSignals( true );
        mediaTypeKComboBox->setCurrentItem( KDar::CUSTOM );
        mediaTypeKComboBox->blockSignals( false );
    }
    setSliceSizeSuffix( sliceSizeSuffix );
    emit configChanged();
}

01548 void KDarConfig::slotFirstSliceSizeString( const QString & firstSliceSizeString )
{
    //All media can have a custom first slice size string
    setFirstSliceSizeString( media(), firstSliceSizeString );
    emit configChanged();
}

01555 void KDarConfig::slotFirstSliceSizeSuffix( int firstSliceSizeSuffix )
{
    //All media cna have a custom first slice size suffix
    setFirstSliceSizeSuffix( media(), firstSliceSizeSuffix );
    emit configChanged();
}

01562 void KDarConfig::slotCompressionAlgorithmBZip2( bool toggled )
{
    if (toggled)
    {
        setCompressionAlgorithm( libdar::bzip2 );
    }
    emit configChanged();
}

01571 void KDarConfig::slotCompressionAlgorithmGZip( bool toggled )
{
    if (toggled)
    {
        setCompressionAlgorithm( libdar::gzip );
    }
    emit configChanged();
}

01580 void KDarConfig::slotCompressionAlgorithmNone( bool toggled )
{
    if (toggled)
    {
        setCompressionAlgorithm( libdar::none );
    }
    emit configChanged();
}

01589 void KDarConfig::slotCompressionLevel( int compressionLevel )
{
    setCompressionLevel( compressionLevel );
    emit configChanged();
}

01595 void KDarConfig::slotMinimumCompressionSizeInt( int minimumCompressionSizeInt )
{
    setMinimumCompressionSizeInt( minimumCompressionSizeInt );
    emit configChanged();
}

01601 void KDarConfig::slotHourShiftInt( int hourShiftInt )
{
    setHourShiftInt( hourShiftInt );
    emit configChanged();
}

01607 void KDarConfig::slotRemoveAllFileFilter()
{
    fileFiltersListView->clear();
    emit fileMaskListChanged();
}

01613 void KDarConfig::slotRemoveFileFilter()
{
    QListViewItem * currItem = fileFiltersListView->selectedItem();
    if (!currItem) return;
    delete currItem;
    emit fileMaskListChanged();
}

01621 void KDarConfig::slotEditFileFilter()
{
    QListViewItem* filterItem = fileFiltersListView->selectedItem();
    if ( filterItem )
    {
        m_fileDlg->fileFilterValueComboBox->setEditText( filterItem->text( 0 ) );
        if ( m_fileDlg->exec() )
        {
            if ( filterItem ) delete filterItem;
            newFileFilter();
        }
    }
}

01635 void KDarConfig::slotNewFileFilter()
{
    if ( m_fileDlg->exec() )
    {
        newFileFilter();
    }
}

01643 void KDarConfig::newFileFilter()
{
    QString fileMask = m_fileDlg->fileFilterValueComboBox->currentText();
    if ( !fileMask.isEmpty() )
    {
        if (fileMask != QString( i18n( "select all filters from list", "All of the above" ) ) )
        {
            //Add the filter if it is not already in the list
            QStringList tmpList = makeQStringList( fileFiltersListView );
            if ( !tmpList.contains( fileMask ) )
            {
                (void) new QListViewItem( fileFiltersListView, fileMask);
            }
        }
        else
        {
            for (int i = 0; i<(m_fileDlg->fileFilterValueComboBox->count()-1);++i)
            {
                //Add the filter if it is not already in the list
                QStringList tmpList = makeQStringList( fileFiltersListView );
                fileMask = m_fileDlg->fileFilterValueComboBox->text(i);
                if ( !tmpList.contains( fileMask ) )
                {
                    (void) new QListViewItem(fileFiltersListView, fileMask );
                }
            }
        }
        emit fileMaskListChanged();
    }
}

01674 void KDarConfig::slotRemoveAllDirectoryFilter()
{
    directoryFiltersListView->clear();
    emit directoryMaskListChanged();
}

01680 void KDarConfig::slotRemoveDirectoryFilter()
{
    QListViewItem * currItem = directoryFiltersListView->selectedItem();
    if (!currItem) return;
    delete currItem;
    emit directoryMaskListChanged();
}

01688 void KDarConfig::slotEditDirectoryFilter()
{
    //Set the filesystem radiobutton, since if the user wants to edit the
    //filter, they can use the keyboard from the lineEdit --- you can't
    //edit the combobox anyway. Otherwise, we'd have to come up with a more
    //sophisticated filter system that keeps track of whether a given
    //filter came from the "list" or the "filesystem" part of the dialog.
    //The user can still select "list" and choose a combobox item.
    QListViewItem* filterItem = directoryFiltersListView->selectedItem();
    if ( filterItem )
    {
        m_directoryDlg->filesystemRadioButton->setChecked( true );
        QString type = filterItem->text( 0 );
        if ( type == i18n( "filter type for exclusion", "Exclude" ) )
        {
            m_directoryDlg->directoryFilesystemTypeComboBox->setCurrentItem( KDar::DO_NOT_INCLUDE );
        }
        else if ( type == i18n( "filter type for inclusion", "Include" ) )
        {
            m_directoryDlg->directoryFilesystemTypeComboBox->setCurrentItem( KDar::INCLUDE );
        }
        m_directoryDlg->directoryFilterValueKURLRequester->lineEdit()->setText( filterItem->text( 1 ) );
        if ( m_directoryDlg->exec() )
        {
            if ( filterItem ) delete filterItem;
            newDirectoryFilter();
        }
    }
}

01718 void KDarConfig::slotNewDirectoryFilter()
{
    if ( m_directoryDlg->exec() )
    {
        newDirectoryFilter();
    }
}

01726 void KDarConfig::newDirectoryFilter()
{
    if ( m_directoryDlg->listRadioButton->isChecked() )
    {
        QString subDir;
        subDir = m_directoryDlg->directoryListComboBox->currentText();
        if ( !subDir.isEmpty() )
        {
            if ( subDir != i18n( "select all filters from list", "All of the above" ) )
            {
                //Add the filter if it is not already in the list
                QStringList tmpList = makeQStringList( directoryFiltersListView, 1 );
                if ( !tmpList.contains( subDir ) )
                {
                    QString type = m_directoryDlg->directoryListTypeComboBox->currentText();
                    (void) new QListViewItem( directoryFiltersListView, type, subDir );
                }
            }
            else
            {
                QString type = m_directoryDlg->directoryListTypeComboBox->currentText();
                for (int i = 0; i<( m_directoryDlg->directoryListComboBox->count()-1 );++i)
                {
                    //Add the filter if it is not already in the list
                    QStringList tmpList = makeQStringList( directoryFiltersListView, 1 );
                    subDir = m_directoryDlg->directoryListComboBox->text(i);
                    if ( !tmpList.contains( subDir ) )
                    {
                        (void) new QListViewItem(directoryFiltersListView, type, subDir);
                    }
                }
            }
            emit directoryMaskListChanged();
        }
    }
    else
    {
        QString subDir = m_directoryDlg->directoryFilterValueKURLRequester->lineEdit()->text();
        if ( !subDir.isEmpty() )
        {
            //Add the filter if it is not already in the list
            QStringList tmpList = makeQStringList( directoryFiltersListView, 1 );
            if ( !tmpList.contains( subDir ) )
            {
                QString type = m_directoryDlg->directoryFilesystemTypeComboBox->currentText();
                (void) new QListViewItem(directoryFiltersListView, type, subDir);
            }
            emit directoryMaskListChanged();
        }
    }
}

01778 void KDarConfig::slotRemoveAllCompressionFilter()
{
    compressionFiltersListView->clear();
    emit compressionMaskListChanged();
}

01784 void KDarConfig::slotRemoveCompressionFilter()
{
    QListViewItem * currItem = compressionFiltersListView->selectedItem();
    if (!currItem) return;
    delete currItem;
    emit compressionMaskListChanged();
}

01792 void KDarConfig::slotEditCompressionFilter()
{
    //Turns out that this is pretty easy to set up:
    QListViewItem* filterItem = compressionFiltersListView->selectedItem();
    if ( filterItem )
    {
        m_compressionDlg->compressionFilterValueComboBox->setEditText( filterItem->text( 0 ) );
        if ( m_compressionDlg->exec() )
        {
            if ( filterItem ) delete filterItem;
            newCompressionFilter();
        }
    }
}

01807 void KDarConfig::slotNewCompressionFilter()
{
    if (m_compressionDlg->exec())
    {
        newCompressionFilter();
    }
}
01814 void KDarConfig::newCompressionFilter()
{
    QString compressionMask = m_compressionDlg->compressionFilterValueComboBox->currentText();
    if ( !compressionMask.isEmpty() )
    {
        if ( compressionMask != i18n("select all filters from list", "All of the above" ) )
        {
            //Add the filter if it is not already in the list
            QStringList tmpList = makeQStringList( compressionFiltersListView );
            if ( !tmpList.contains( compressionMask ) )
            {
                (void) new QListViewItem(compressionFiltersListView, compressionMask);
            }
        }
        else
        {
            for (int i = 0; i<(m_compressionDlg->compressionFilterValueComboBox->count()-1);++i)
            {
                //Add the filter if it is not already in the list
                QStringList tmpList = makeQStringList( compressionFiltersListView );
                compressionMask = m_compressionDlg->compressionFilterValueComboBox->text(i);
                if ( !tmpList.contains( compressionMask ) )
                {
                    (void) new QListViewItem(compressionFiltersListView, compressionMask );
                }
            }
        }
        emit compressionMaskListChanged();
    }
}

01845 void KDarConfig::slotUpdateCompressionMaskList()
{
    //Get a QStringList of compression filters and update the config object
    slotCompressionMaskList( makeQStringList( compressionFiltersListView ) );
}

01851 void KDarConfig::slotUpdateDirectoryMaskList()
{
    //Get a QStringList of directory filters and update the config object
    QStringList directories;
    QStringList types;
    makeDirectoryQStringLists( directoryFiltersListView, directories, types );
    slotDirectoryMaskList( directories );
    slotDirectoryMaskTypes( types );
}

01861 void KDarConfig::slotUpdateFileMaskList()
{
    //Get a QStringList of file filters and update the config object
    slotFileMaskList( makeQStringList( fileFiltersListView ) );
}

01867 void KDarConfig::slotKDarSplashScreen( bool showKDarSplashScreen )
{
    setShowKDarSplashScreen( showKDarSplashScreen );
    emit configChanged();
}

01873 void KDarConfig::slotRaiseWidgetStack( const QString & module )
{
    if ( module == i18n( "config module", "General" ) )
    {
        configureWidgetStack->raiseWidget( KDar::GENERAL );
    }
    else if ( module == i18n( "config module", "Fonts" ) )
    {
        configureWidgetStack->raiseWidget( KDar::FONTS );
    }
    else if ( module == i18n( "config module", "Slicing" ) )
    {
        configureWidgetStack->raiseWidget( KDar::SLICING );
    }
    else if ( module == i18n( "config module", "Compression" ) )
    {
        configureWidgetStack->raiseWidget( KDar::COMPRESSION );
    }
    else if ( module == i18n( "config module", "Directories" ) )
    {
        configureWidgetStack->raiseWidget( KDar::DIRECTORIES );
    }
    else if ( module == i18n( "config module", "Files" ) )
    {
        configureWidgetStack->raiseWidget( KDar::FILES );
    }
    else if ( module == i18n( "config module", "Filesystem" ) )
    {
        configureWidgetStack->raiseWidget( KDar::FILESYSTEM );
    }
    else if ( module == i18n( "config module", "Comparison" ) )
    {
        configureWidgetStack->raiseWidget( KDar::COMPARISON );
    }
    else if ( module == i18n( "config module", "Restore" ) )
    {
        configureWidgetStack->raiseWidget( KDar::RESTORE );
    }
    else if ( module == i18n( "config module", "Cryptography" ) )
    {
        configureWidgetStack->raiseWidget( KDar::CRYPTO );
    }
    else
    {
        kdDebug() << "KDarConfig::slotRaiseWidgetStack(): " << module << ": no such config module." << endl;
    }
}

01921 QStringList KDarConfig::makeQStringList( QListView * listView, const int column )
{
    QStringList list;
    QListViewItem * tmpItem = listView->firstChild();
    QString text;
    while( tmpItem )
    {
        text = tmpItem->text( column );
        if ( !list.contains( text ) )
        {
            list << text;
        }
        tmpItem = tmpItem->nextSibling();
    }
    return list;
}

01938 void KDarConfig::makeDirectoryQStringLists( QListView * listView, QStringList & directories, QStringList & types )
{
    QListViewItem * tmpItem = listView->firstChild();
    QString directoryText;
    QString typeText;
    QStringList dirList;
    QStringList typeList;

    while( tmpItem )
    {
        directoryText = tmpItem->text( 1 );
        if ( !dirList.contains( directoryText ) )
        {
            dirList << directoryText;
            typeList << tmpItem->text( 0 );
        }
        tmpItem = tmpItem->nextSibling();
    }
    directories = dirList;
    types = typeList;
}

01960 void KDarConfig::slotCompressionMaskList( const QStringList & compressionMaskList )
{
    setCompressionMaskList( compressionMaskList );
    emit configChanged();
}

01966 void KDarConfig::slotDirectoryMaskList( const QStringList & directoryMaskList )
{
    setDirectoryMaskList( directoryMaskList );
    emit configChanged();
}

01972 void KDarConfig::slotFileMaskList( const QStringList & fileMaskList )
{
    setFileMaskList( fileMaskList );
    emit configChanged();
}

01978 void KDarConfig::slotCompressionMaskType( int compressionMaskType )
{
    setCompressionMaskType( compressionMaskType );
    emit configChanged();
}

01984 void KDarConfig::slotDirectoryMaskTypes( const QStringList & maskTypes )
{
    setDirectoryMaskTypes( maskTypes );
    emit configChanged();
}

01990 void KDarConfig::slotFileMaskType( int fileMaskType )
{
    setFileMaskType( fileMaskType );
    emit configChanged();
}

01996 void KDarConfig::slotGeneralFont( const QFont & generalFont )
{
    setGeneralFont (generalFont );
    emit configChanged();
}

02002 void KDarConfig::slotFileBrowserFont( const QFont & fileBrowserFont )
{
    setFileBrowserFont( fileBrowserFont );
    emit configChanged();
}

02008 void KDarConfig::slotMessageWindowFont( const QFont & messageWindowFont )
{
    setMessageWindowFont( messageWindowFont );
    emit configChanged();
}

02014 void KDarConfig::slotStatusBarFont( const QFont & statusBarFont )
{
    setStatusBarFont( statusBarFont );
    emit configChanged();
}

02020 void KDarConfig::slotLogFile( const QString & logFile )
{
    setLogFile( logFile );
    emit configChanged();
}

02026 void KDarConfig::slotLogLevelNone( bool toggled )
{
    if ( toggled )
    {
        setLogLevel( KDar::LOG_NONE );
    }
    emit configChanged();
}

02035 void KDarConfig::slotLogLevelBasic( bool toggled )
{
    if ( toggled )
    {
        setLogLevel( KDar::LOG_BASIC );
    }
    emit configChanged();
}

02044 void KDarConfig::slotLogLevelFull( bool toggled )
{
    if ( toggled )
    {
        setLogLevel( KDar::LOG_FULL );
    }
    emit configChanged();
}

02053 void KDarConfig::setMediaSize( int currentItem )
{
    kdDebug() << "KDarConfig::setMediaSize() reached. CurrentItem is " << currentItem << endl;
    //Block the textChanged() and activated() signals for the lineEdit and Combobox
    sliceSizeLineEdit->blockSignals( true );
    sliceSizeComboBox->blockSignals( true );
    sliceSizeLineEdit->setText( mediaSizes[ currentItem ] );
    sliceSizeComboBox->setCurrentItem( mediaSuffices[ currentItem ] );
    firstSliceSizeLineEdit->setText( mediaFirstSizes[ currentItem ] );
    firstSliceSizeComboBox->setCurrentItem( mediaFirstSuffices[ currentItem ] );
    //unblock the signals
    sliceSizeLineEdit->blockSignals( false );
    sliceSizeComboBox->blockSignals( false );

    kdDebug() << "KDarConfig::setMediaSize() reached. sliceSize is " << libdar::deci(libdarSliceSize()).human().c_str() << endl;
}

02070 libdar::et_mask KDarConfig::libdarCreateCompressionMask()
{
    libdar::et_mask compr_mask;
    libdar::ou_mask compr_list;
    QStringList compressionList = compressionMaskList();
    //Iterate over the QStringList, adding the masks to the libdar::ou_mask
    for( QStringList::Iterator it = compressionList.begin(); it != compressionList.end(); ++it )
    {
// TODO store case sensitive filter info and give user option to toggle
        bool caseSensitive = false;
        compr_list.add_mask( libdar::simple_mask( kdar::toStdString( *it ), caseSensitive ) );
    }
    //If the compression list contains items, add them to the compression mask
    if ( !compressionList.empty() )
    {
        //compress
        if ( compressionMaskType() == KDar::INCLUDE )
        {
            compr_mask.add_mask( compr_list );
        }
        //do not compress
        else
        {
            compr_mask.add_mask( libdar::not_mask( compr_list ) );
        }
    }
    //otherwise, we compress everything
    else
    {
        compr_mask.add_mask( libdar::bool_mask( true ) );
    }

    return compr_mask;

}

02106 libdar::et_mask KDarConfig::libdarCreateDirectoryMask()
{
//    kdDebug() << "KDarConfig::libdarCreateDirectoryMask(): reached." << endl;
    //Directories to include ["list of paths"],
    //or exclude ["-P" option]
    libdar::et_mask subtree;
    libdar::ou_mask directoryIncludes;
    libdar::ou_mask directoryExcludes;

    QStringList directoryList = directoryMaskList();
    QStringList maskTypes = directoryMaskTypes();
//    kdDebug() << "KDarConfig::libdarCreateDirectoryMask(): mask type count is " << maskTypes.count() << endl;
    kdDebug() << "KDarConfig::libdarCreateDirectoryMask(): mask directory count is " << directoryList.count() << endl;

    //Iterate over the QStringList, adding the masks to the appropriate libdar::ou_mask
    if ( maskTypes.count() == directoryList.count() )
    {
        QStringList::Iterator typeIterator = maskTypes.begin();
        for( QStringList::Iterator directoryIterator = directoryList.begin(); directoryIterator != directoryList.end(); ++directoryIterator )
        {
// TODO handle caseSensitive:
            bool caseSensitive = false;
            //Add the directory to the appropriate include or exclude mask
            if ( *typeIterator == i18n( "filter type for inclusion", "Include" ) )
            {
                directoryIncludes.add_mask( libdar::simple_path_mask( libdar::path( kdar::toStdString( *directoryIterator ) ).display(), caseSensitive ) );
//                 kdDebug() << "KDarConfig::libdarCreateDirectoryMask(): added include mask " << endl;
            }
            else //exclude "Exclude" and "Auto" masks
            {
                directoryExcludes.add_mask( libdar::simple_mask( libdar::path( kdar::toStdString( *directoryIterator ) ).display(), caseSensitive ) );
//                 kdDebug() << "KDarConfig::libdarCreateDirectoryMask(): added exclude mask " << endl;
            }
            ++typeIterator;
        }
    }
    //If the include or exclude masks contain items, add them to the subtree mask
//     kdDebug() << "KDarConfig::libdarCreateDirectoryMask(): directoryIncludes.size() = "  << directoryIncludes.size() << endl;
//     kdDebug() << "KDarConfig::libdarCreateDirectoryMask(): directoryExcludes.size() = "  << directoryExcludes.size() << endl;

    if ( directoryIncludes.size() != 0 )
    {
        subtree.add_mask( directoryIncludes );
//         kdDebug() << "KDarConfig::libdarCreateDirectoryMask(): subtree got include mask" << endl;

    }
    else
    {
        subtree.add_mask( libdar::bool_mask( true ) );
    }
    if ( directoryExcludes.size() != 0 )
    {
        subtree.add_mask( libdar::not_mask( directoryExcludes ) );
//         kdDebug() << "KDarConfig::libdarCreateDirectoryMask(): subtree got exclude mask" << endl;
    }

    return subtree;
}

02165 libdar::et_mask KDarConfig::libdarCreateFileMask()
{
    libdar::et_mask file_mask;
    libdar::ou_mask file_list;
    QStringList fileList = fileMaskList();
    //Iterate over the QStringList, adding the masks to the libdar::ou_mask
    for( QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it )
    {
// TODO handle caseSensitive:
        bool caseSensitive = false;
        file_list.add_mask( libdar::simple_mask( kdar::toStdString(*it), caseSensitive ) );
    }
    //If the file list contains items, add them to the file mask
    if ( !fileList.empty() )
    {
        //include
        if ( fileMaskType() == KDar::INCLUDE )
        {
            file_mask.add_mask( file_list );
        }
        //ignore
        else
        {
            file_mask.add_mask( libdar::bool_mask( true ) );
            file_mask.add_mask( libdar::not_mask( file_list ) );
        }
    }
    //otherwise, we compress everything
    else
    {
        file_mask.add_mask( libdar::bool_mask( true ) );
    }

    return file_mask;

}

02202 void KDarConfig::disableZCompression()
{
    //remove the Z compression option
    if ( gzipRadioButton->isChecked() )
    {
        gzipRadioButton->setChecked( false );
        noneRadioButton->setChecked( true );
        setCompressionAlgorithm( libdar::none );
    }
    if ( gzipQHBox1 )
    {
        gzipQHBox1->remove( gzipRadioButton );
        delete gzipQHBox1;
        gzipQHBox1 = 0;
        gzipRadioButton->hide();
    }

    if ( gzipQHBox2 )
    {
        gzipQHBox2->remove( gzipTextLabel );
        gzipQHBox2->remove( compressionLevelSpinBox );
        delete gzipQHBox2;
        gzipQHBox2 = 0;
        gzipTextLabel->hide();
        compressionLevelSpinBox->hide();
    }
    m_ZCompression = false;
}

02231 void KDarConfig::disableBZ2Compression()
{
    bzip2RadioButton->setEnabled( false );
    if ( bzip2RadioButton->isChecked() )
    {
        bzip2RadioButton->setChecked( false );
        noneRadioButton->setChecked( true );
        setCompressionAlgorithm( libdar::none );
    }

    if ( bzip2QHBox )
    {
        bzip2QHBox->remove( bzip2RadioButton );
        delete bzip2QHBox;
        bzip2QHBox = 0;
        bzip2RadioButton->hide();
    }

    m_BZ2Compression = false;
}

02252 void KDarConfig::disableCompressionModule()
{
    disableZCompression();
    disableBZ2Compression();
    configModulesKListBox->takeItem( configModulesKListBox->findItem( i18n( "config module", "Compression" ), Qt::CaseSensitive ) );
}

02259 void KDarConfig::disableStrongCrypto()
{
    //remove the encryption item
    configModulesKListBox->takeItem( configModulesKListBox->findItem( i18n( "config module", "Cryptography" ), Qt::CaseSensitive ) );
    m_strongCrypto = false;
}

02266 void KDarConfig::setupCreateConfig()
{
    //remove the font item
    configModulesKListBox->takeItem( configModulesKListBox->findItem( i18n( "config module", "Fonts" ), Qt::CaseSensitive ) );
    //remove the comparison item
    configModulesKListBox->takeItem( configModulesKListBox->findItem( i18n( "config module", "Comparison" ), Qt::CaseSensitive ) );
    //remove the restore item
    configModulesKListBox->takeItem( configModulesKListBox->findItem( i18n( "config module", "Restore" ), Qt::CaseSensitive ) );

    //Hide the useCreateArchiveWizard checkbox in the General module
    hideCreateArchiveWizardCheckBox();
    //Hide the showKDarSplashCheckBox
    hideKDarSplashCheckBox();
    //Hide the storePassword checkbox, since this is set once and for
    //all in the main config dialog.
    //It is confusing if the create/restore configs can have a different
    //setting from the main config, because the "open" method looks to the
    //main config to determine whether to look in a wallet for the password.
    passwordGroupBox->hide();
}

02287 void KDarConfig::hideCreateArchiveWizardCheckBox()
{
    wizardQHBox->remove( useCreateArchiveWizardCheckBox );
    delete wizardQHBox;
    wizardQHBox = 0;
    useCreateArchiveWizardCheckBox->hide();
}

02295 void KDarConfig::hideKDarSplashCheckBox()
{
    splashQHBox->remove( showKDarSplashCheckBox );
    delete splashQHBox;
    splashQHBox = 0;
    showKDarSplashCheckBox->hide();
}

02303 void KDarConfig::setupRestoreConfig()
{
    //remove the font item
    configModulesKListBox->takeItem( configModulesKListBox->findItem( i18n( "config module", "Fonts" ), Qt::CaseSensitive ) );
    //remove the slicing item
    configModulesKListBox->takeItem( configModulesKListBox->findItem( i18n( "config module", "Slicing" ), Qt::CaseSensitive ) );
    //remove the compresion item
    configModulesKListBox->takeItem( configModulesKListBox->findItem( i18n( "config module", "Compression" ), Qt::CaseSensitive ) );
    //remove the comparison item
    configModulesKListBox->takeItem( configModulesKListBox->findItem( i18n( "config module", "Comparison" ), Qt::CaseSensitive ) );
    //remove the cryptography item, since KDar now probes the archive to
    //to determine the type of encryption algorithm that was used to create
    //the archive.
    configModulesKListBox->takeItem( configModulesKListBox->findItem( i18n( "config module", "Cryptography" ), Qt::CaseSensitive ) );
    //Hide the useCreateArchiveWizard checkbox in the General module
    hideCreateArchiveWizardCheckBox();
    //Hide the showKDarSplashCheckBox
    hideKDarSplashCheckBox();
}

02323 QString KDarConfig::buildDarCommandLine( KDar::libdarCommand command )
{
    QString darCommand( "dar" );
    QString newName = archiveHandle::parseStringSubstitutions( newArchiveName(), this );
    if ( newName[0] != '/' )
    {
        newName = cleanPath( archiveStorageDirectory() + "/" + newName );
    }
    QString archive = archiveName();
    if ( archive[0] != '/' )
    {
        archive = cleanPath( archiveStorageDirectory() + "/" + archive );
    }
    QString isolationName = isolationArchiveName();
    if ( isolationName[0] != '/' )
    {
        isolationName = cleanPath( archiveStorageDirectory() + "/" + isolationName );
    }
    QString refArchiveName = differentialBackupArchiveName();
    if ( refArchiveName[0] != '/' )
    {
        refArchiveName = cleanPath( archiveStorageDirectory() + "/" + refArchiveName );
    }

    //Other options...
    if ( dryRun() ) darCommand += " -e";
    if ( verbose() ) darCommand += " -v";

    //Compression masks
    QString compressionInclude( " -Y " );
    QString compressionExclude( " -Z " );
    QString compressionString( "" );
    QStringList compressionList( compressionMaskList() );
    for ( QStringList::Iterator it = compressionList.begin(); it != compressionList.end(); ++it )
    {
        if ( compressionMaskType() == KDar::INCLUDE )
        {
            compressionString += compressionInclude + "\"" + *it + "\"";
        }
        else
        {
            compressionString += compressionExclude + "\"" + *it + "\"";
        }
    }

    //File masks
    QString fileInclude( " -I " );
    QString fileExclude( " -X " );
    QString fileString( "" );
    QStringList fileList( fileMaskList() );
    for ( QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it )
    {
        if ( fileMaskType() == KDar::INCLUDE )
        {
            fileString += fileInclude + "\"" + *it + "\"";
        }
        else
        {
            fileString += fileExclude + "\"" + *it + "\"";
        }
    }

    //Directory filters
    QString directoryInclude( " " );
    QString directoryExclude( " -P " );
    QString directoryIncludeString( "" );
    QString directoryExcludeString( "" );
    QStringList directoryList( directoryMaskList() );
    QStringList maskTypes( directoryMaskTypes() );

    //Make sure the root directory has a trailing slash
    QString root( directoryToBackup() );
    if ( !root.endsWith( "/" ) ) root += "/";

    if ( maskTypes.count() == directoryList.count() )
    {
        QStringList::Iterator typeIterator = maskTypes.begin();
        for( QStringList::Iterator directoryIterator = directoryList.begin(); directoryIterator != directoryList.end(); ++directoryIterator )
        {
            QString filter( *directoryIterator );
            if ( filter.find( root ) == 0 )
            {
                filter.remove( 0, root.length() );
            }
            if ( *typeIterator == i18n( "filter type for inclusion", "Include" ) )
            {
                directoryIncludeString += directoryInclude + "\"" + filter + "\"";
            }
            else //exclude "Exclude" and "Auto" masks
            {
                directoryExcludeString += directoryExclude + "\"" + filter + "\"";
            }
            ++typeIterator;
        }
    }

    switch ( command )
    {
        case KDar::LIBDAR_CREATE:
            darCommand += " -c \"" + newName + "\"";
            darCommand += " -R \"" + root + "\"";
            if ( differentialBackup() ) darCommand += " -A \"" + refArchiveName + "\"";
            if ( !allowOverwrite() ) darCommand += " -n";
            if ( !warnOnOverwrite() ) darCommand += " -w";
            if ( libdarSliceSize() != 0 )
            {
                darCommand += " -s " + QString( libdar::deci( libdarSliceSize() ).human().c_str() );
                if ( libdarFirstSliceSize() != libdarSliceSize() && libdarFirstSliceSize() > 0 )
                {
                    darCommand += " -S " + QString( libdar::deci( libdarFirstSliceSize() ).human().c_str() );
                }
                if ( pauseBetweenSlices() ) darCommand += " -p";
            }
            if ( keepPruned() ) darCommand += " -D";
            if ( compressionAlgorithm() != libdar::none )
            {
                if ( compressionAlgorithm() == libdar::gzip ) darCommand += " -z" + QString::number( compressionLevel() );
                if ( compressionAlgorithm() == libdar::bzip2 ) darCommand += " -y";
                darCommand += " -m " + QString::number( minimumCompressionSizeInt() );
                //Add compression filters here.
                darCommand += compressionString;
            }
            if ( !userEA() ) darCommand += " -u";
            if ( !systemEA() ) darCommand += " -U";
            if ( !executeCommand().isEmpty() ) darCommand += " -E \"" + executeCommand() + "\"";
            if ( !passwordString().isEmpty() ) darCommand += " -K \"" + passwordString() + "\"";
            if ( ignoreDump() ) darCommand += " --nodump";
            if ( ignoreID() ) darCommand += " -O";
            if ( hourShiftInt() != 0 ) darCommand += " -H" + QString::number( hourShiftInt() );
            //File inclusion/exclusion filters:
            darCommand += fileString;
            //Directory filters
            darCommand += directoryExcludeString;
            darCommand += directoryIncludeString;
            break;
        case KDar::LIBDAR_DIFF:
            darCommand += " -d \"" + archive + "\"";
            darCommand += " -R \"" + diffArchiveDirectory() + "\"";
            if ( !userEA() ) darCommand += " -u";
            if ( !systemEA() ) darCommand += " -U";
            if ( ignoreID() ) darCommand += " -O";
            //File inclusion/exclusion filters:
            darCommand += fileString;
            //Directory filters
            darCommand += directoryExcludeString;
            darCommand += directoryIncludeString;
            break;
        case KDar::LIBDAR_ISOLATE:
            darCommand += " -C \"" + isolationName + "\"";
            darCommand += " -A \"" + archive + "\"";
            if ( !allowOverwrite() ) darCommand += " -n";
            if ( !warnOnOverwrite() ) darCommand += " -w";
            if ( libdarSliceSize() != 0 )
            {
                darCommand += " -s " + QString( libdar::deci( libdarSliceSize() ).human().c_str() );
                if ( libdarFirstSliceSize() != libdarSliceSize() && libdarFirstSliceSize() > 0 )
                {
                    darCommand += " -S " + QString( libdar::deci( libdarFirstSliceSize() ).human().c_str() );
                }
                if ( pauseBetweenSlices() ) darCommand += " -p";
            }
            if ( compressionAlgorithm() != libdar::none )
            {
                if ( compressionAlgorithm() == libdar::gzip ) darCommand += " -z" + QString::number( compressionLevel() );
                if ( compressionAlgorithm() == libdar::bzip2 ) darCommand += " -y";
                darCommand += " -m " + QString::number( minimumCompressionSizeInt() );
            }
            if ( !executeCommand().isEmpty() ) darCommand += " -E \"" + executeCommand() + "\"";
            if ( !passwordString().isEmpty() ) darCommand += " -K \"" + passwordString() + "\"";
            break;
        case KDar::LIBDAR_RESTORE:
            darCommand += " -x \"" + archive + "\"";
            darCommand += " -R \"" + extractArchiveDirectory()+ "\"";
            if ( !allowOverwrite() ) darCommand += " -n";
            if ( !warnOnOverwrite() ) darCommand += " -w";
            if ( noDelete() ) darCommand += " -k";
            if ( restoreRecent() ) darCommand += " -r";
            if ( flatRestore() ) darCommand += " -f";
            if ( hourShiftInt() != 0 ) darCommand += " -H" + QString::number( hourShiftInt() );
            if ( !userEA() ) darCommand += " -u";
            if ( !systemEA() ) darCommand += " -U";
            if ( ignoreID() ) darCommand += " -O";
             //File filters:
            darCommand += fileString;
            //directory filters
            darCommand += directoryExcludeString;
            darCommand += directoryIncludeString;
           break;
        case KDar::LIBDAR_TEST:
            darCommand += " -t \"" + archive + "\"";
            //File filters:
            darCommand += fileString;
            //directory filters
            break;
        default:
            ;
    }

    darCommand += "\n";
    return darCommand;
}

02525 bool KDarConfig::ZCompression() const
{
    return m_ZCompression;
}

02530 bool KDarConfig::BZ2Compression() const
{
    return m_BZ2Compression;
}

02535 bool KDarConfig::strongCrypto() const
{
    return m_strongCrypto;
}

#include "kdarConfig.moc"

Generated by  Doxygen 1.6.0   Back to index