diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
commit | cc29364f06178f8f6b457384f2ec37a042bd9d43 (patch) | |
tree | 7c77a3184c698bbf9d98cef09fb1ba8124daceba /kmail/filterimporterexporter.cpp | |
parent | 4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff) | |
download | tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip |
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed
* Added journal read support to the CalDAV resource
* Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail/filterimporterexporter.cpp')
-rw-r--r-- | kmail/filterimporterexporter.cpp | 166 |
1 files changed, 99 insertions, 67 deletions
diff --git a/kmail/filterimporterexporter.cpp b/kmail/filterimporterexporter.cpp index bfe40170c..c5780431d 100644 --- a/kmail/filterimporterexporter.cpp +++ b/kmail/filterimporterexporter.cpp @@ -38,74 +38,105 @@ #include <kfiledialog.h> #include <kdialogbase.h> #include <klistview.h> +#include <kpushbutton.h> #include <tqregexp.h> +#include <tqlayout.h> using namespace KMail; -class FilterSelectionDialog : public KDialogBase +FilterSelectionDialog::FilterSelectionDialog( TQWidget * parent ) + :KDialogBase( parent, "filterselection", true, i18n("Select Filters"), Ok|Cancel, Ok, true ), + wasCancelled( false ) { -public: - FilterSelectionDialog( TQWidget * parent = 0 ) - :KDialogBase( parent, "filterselection", true, i18n("Select Filters"), Ok|Cancel, Ok, true ), - wasCancelled( false ) - { - filtersListView = new KListView( this ); - setMainWidget(filtersListView); - filtersListView->setSorting( -1 ); - filtersListView->setSelectionMode( TQListView::NoSelection ); - filtersListView->addColumn( i18n("Filters"), 300 ); - filtersListView->setFullWidth( true ); - resize( 300, 350 ); - } + TQWidget *w = new TQWidget( this ); + TQVBoxLayout *top = new TQVBoxLayout( w ); + + filtersListView = new KListView( w ); + top->addWidget( filtersListView ); + setMainWidget(w); + filtersListView->setSorting( -1 ); + filtersListView->setSelectionMode( TQListView::NoSelection ); + filtersListView->addColumn( i18n("Filters"), 300 ); + filtersListView->setFullWidth( true ); + TQHBoxLayout *buttonLayout = new TQHBoxLayout( this ); + top->addLayout( buttonLayout ); + selectAllButton = new KPushButton( i18n( "Select All" ), w ); + buttonLayout->addWidget( selectAllButton ); + unselectAllButton = new KPushButton( i18n( "Unselect All" ), w ); + buttonLayout->addWidget( unselectAllButton ); + connect( selectAllButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotSelectAllButton() ) ); + connect( unselectAllButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotUnselectAllButton() ) ); + resize( 300, 350 ); +} - virtual ~FilterSelectionDialog() - { - } - - virtual void slotCancel() - { - wasCancelled = true; - KDialogBase::slotCancel(); - } - - bool cancelled() - { - return wasCancelled; - } +FilterSelectionDialog::~FilterSelectionDialog() +{ +} - void setFilters( const TQValueList<KMFilter*>& filters ) - { - originalFilters = filters; - filtersListView->clear(); - TQValueListConstIterator<KMFilter*> it = filters.constEnd(); - while ( it != filters.constBegin() ) { - --it; - KMFilter* filter = *it; - TQCheckListItem* item = new TQCheckListItem( filtersListView, filter->name(), TQCheckListItem::CheckBox ); - item->setOn( true ); - } - } - - TQValueList<KMFilter*> selectedFilters() const - { - TQValueList<KMFilter*> filters; - TQListViewItemIterator it( filtersListView ); - int i = 0; - while( it.current() ) { - TQCheckListItem* item = static_cast<TQCheckListItem*>( it.current() ); - if ( item->isOn() ) - filters << originalFilters[i]; - ++i; ++it; - } - return filters; - } -private: - KListView *filtersListView; - TQValueList<KMFilter*> originalFilters; - bool wasCancelled; -}; +void FilterSelectionDialog::slotCancel() +{ + wasCancelled = true; + KDialogBase::slotCancel(); +} + +bool FilterSelectionDialog::cancelled() +{ + return wasCancelled; +} + +void FilterSelectionDialog::setFilters( const TQValueList<KMFilter*>& filters ) +{ + if ( filters.isEmpty() ) + { + enableButtonOK( false ); + return; + } + originalFilters = filters; + filtersListView->clear(); + TQValueListConstIterator<KMFilter*> it = filters.constEnd(); + while ( it != filters.constBegin() ) { + --it; + KMFilter* filter = *it; + TQCheckListItem* item = new TQCheckListItem( filtersListView, filter->name(), TQCheckListItem::CheckBox ); + item->setOn( true ); + } +} + +TQValueList<KMFilter*> FilterSelectionDialog::selectedFilters() const +{ + TQValueList<KMFilter*> filters; + TQListViewItemIterator it( filtersListView ); + int i = 0; + while( it.current() ) { + TQCheckListItem* item = static_cast<TQCheckListItem*>( it.current() ); + if ( item->isOn() ) + filters << originalFilters[i]; + ++i; ++it; + } + return filters; +} + +void FilterSelectionDialog::slotUnselectAllButton() +{ + TQListViewItemIterator it( filtersListView ); + while( it.current() ) { + TQCheckListItem* item = static_cast<TQCheckListItem*>( it.current() ); + item->setOn( false ); + ++it; + } +} + +void FilterSelectionDialog::slotSelectAllButton() +{ + TQListViewItemIterator it( filtersListView ); + while( it.current() ) { + TQCheckListItem* item = static_cast<TQCheckListItem*>( it.current() ); + item->setOn( true ); + ++it; + } +} /* static */ TQValueList<KMFilter*> FilterImporterExporter::readFiltersFromConfig( KConfig* config, bool bPopFilter ) @@ -116,7 +147,7 @@ TQValueList<KMFilter*> FilterImporterExporter::readFiltersFromConfig( KConfig* c numFilters = config->readNumEntry("popfilters",0); else numFilters = config->readNumEntry("filters",0); - + TQValueList<KMFilter*> filters; for ( int i=0 ; i < numFilters ; ++i ) { TQString grpName; @@ -136,7 +167,7 @@ TQValueList<KMFilter*> FilterImporterExporter::readFiltersFromConfig( KConfig* c return filters; } -/* static */ +/* static */ void FilterImporterExporter::writeFiltersToConfig( const TQValueList<KMFilter*>& filters, KConfig* config, bool bPopFilter ) { // first, delete all groups: @@ -145,7 +176,7 @@ void FilterImporterExporter::writeFiltersToConfig( const TQValueList<KMFilter*>& for ( TQStringList::Iterator it = filterGroups.begin() ; it != filterGroups.end() ; ++it ) config->deleteGroup( *it ); - + int i = 0; for ( TQValueListConstIterator<KMFilter*> it = filters.constBegin() ; it != filters.constEnd() ; ++it ) { @@ -180,9 +211,9 @@ FilterImporterExporter::~FilterImporterExporter() TQValueList<KMFilter*> FilterImporterExporter::importFilters() { TQString fileName = KFileDialog::getOpenFileName( TQDir::homeDirPath(), TQString::null, mParent, i18n("Import Filters") ); - if ( fileName.isEmpty() ) + if ( fileName.isEmpty() ) return TQValueList<KMFilter*>(); // cancel - + { // scoping TQFile f( fileName ); if ( !f.open( IO_ReadOnly ) ) { @@ -190,7 +221,7 @@ TQValueList<KMFilter*> FilterImporterExporter::importFilters() return TQValueList<KMFilter*>(); } } - + KConfig config( fileName ); TQValueList<KMFilter*> imported = readFiltersFromConfig( &config, mPopFilter ); FilterSelectionDialog dlg( mParent ); @@ -202,10 +233,10 @@ TQValueList<KMFilter*> FilterImporterExporter::importFilters() void FilterImporterExporter::exportFilters(const TQValueList<KMFilter*> & filters ) { KURL saveUrl = KFileDialog::getSaveURL( TQDir::homeDirPath(), TQString::null, mParent, i18n("Export Filters") ); - + if ( saveUrl.isEmpty() || !Util::checkOverwrite( saveUrl, mParent ) ) return; - + KConfig config( saveUrl.path() ); FilterSelectionDialog dlg( mParent ); dlg.setFilters( filters ); @@ -214,3 +245,4 @@ void FilterImporterExporter::exportFilters(const TQValueList<KMFilter*> & filter writeFiltersToConfig( dlg.selectedFilters(), &config, mPopFilter ); } +#include "filterimporterexporter.moc" |