From cc29364f06178f8f6b457384f2ec37a042bd9d43 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 1 Sep 2010 00:37:02 +0000 Subject: * 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 --- kmail/customtemplates.cpp | 120 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 97 insertions(+), 23 deletions(-) (limited to 'kmail/customtemplates.cpp') diff --git a/kmail/customtemplates.cpp b/kmail/customtemplates.cpp index 93b24e8f..6a0a7f4c 100644 --- a/kmail/customtemplates.cpp +++ b/kmail/customtemplates.cpp @@ -20,15 +20,19 @@ #include -#include -#include #include #include #include +#include #include #include -#include +#include +#include #include + +#include +#include +#include #include #include #include @@ -44,11 +48,14 @@ #include "globalsettings.h" #include "kmkernel.h" #include "kmmainwidget.h" +#include "kmfawidgets.h" #include "customtemplates.h" CustomTemplates::CustomTemplates( TQWidget *parent, const char *name ) - :CustomTemplatesBase( parent, name ), mCurrentItem( 0 ) + :CustomTemplatesBase( parent, name ), + mCurrentItem( 0 ), + mBlockChangeSignal( false ) { TQFont f = KGlobalSettings::fixedFont(); mEdit->setFont( f ); @@ -61,8 +68,14 @@ CustomTemplates::CustomTemplates( TQWidget *parent, const char *name ) mEditFrame->setEnabled( false ); + connect( mName, TQT_SIGNAL( textChanged ( const TQString &) ), + this, TQT_SLOT( slotNameChanged( const TQString & ) ) ); connect( mEdit, TQT_SIGNAL( textChanged() ), this, TQT_SLOT( slotTextChanged( void ) ) ); + connect( mToEdit, TQT_SIGNAL( textChanged(const TQString&) ), + this, TQT_SLOT( slotTextChanged( void ) ) ); + connect( mCCEdit, TQT_SIGNAL( textChanged(const TQString&) ), + this, TQT_SLOT( slotTextChanged( void ) ) ); connect( mInsertCommand, TQT_SIGNAL( insertCommand(TQString, int) ), this, TQT_SLOT( slotInsertCommand(TQString, int) ) ); @@ -105,6 +118,29 @@ CustomTemplates::CustomTemplates( TQWidget *parent, const char *name ) "You cannot bind keyboard shortcut to Universal templates.

" "" ); mHelp->setText( i18n( "How does this work?" ).arg( help ) ); + + const TQString toToolTip = i18n( "Additional recipients of the message when forwarding" ); + const TQString ccToolTip = i18n( "Additional recipients who get a copy of the message when forwarding" ); + const TQString toWhatsThis = i18n( "When using this template for forwarding, the default recipients are those you enter here. This is a comma-separated list of mail addresses." ); + const TQString ccWhatsThis = i18n( "When using this template for forwarding, the recipients you enter here will by default get a copy of this message. This is a comma-separated list of mail addresses." ); + + // We only want to set the tooltip/whatsthis to the lineedit, not the complete widget, + // so we use the name here to find the lineedit. This is similar to what KMFilterActionForward + // does. + KLineEdit *ccLineEdit = dynamic_cast( mCCEdit->child( "addressEdit" ) ); + KLineEdit *toLineEdit = dynamic_cast( mToEdit->child( "addressEdit" ) ); + Q_ASSERT( ccLineEdit && toLineEdit ); + + TQToolTip::add( mCCLabel, ccToolTip ); + TQToolTip::add( ccLineEdit, ccToolTip ); + TQToolTip::add( mToLabel, toToolTip ); + TQToolTip::add( toLineEdit, toToolTip ); + TQWhatsThis::add( mCCLabel, ccWhatsThis ); + TQWhatsThis::add( ccLineEdit, ccWhatsThis ); + TQWhatsThis::add( mToLabel, toWhatsThis ); + TQWhatsThis::add( toLineEdit, toWhatsThis ); + + slotNameChanged( mName->text() ); } CustomTemplates::~CustomTemplates() @@ -118,6 +154,19 @@ CustomTemplates::~CustomTemplates() } } +void CustomTemplates::setRecipientsEditsEnabled( bool enabled ) +{ + mToEdit->setHidden( !enabled ); + mCCEdit->setHidden( !enabled ); + mToLabel->setHidden( !enabled ); + mCCLabel->setHidden( !enabled ); +} + +void CustomTemplates::slotNameChanged( const TQString& text ) +{ + mAdd->setEnabled( !text.isEmpty() ); +} + TQString CustomTemplates::indexToType( int index ) { TQString typeStr; @@ -141,7 +190,8 @@ TQString CustomTemplates::indexToType( int index ) void CustomTemplates::slotTextChanged() { - emit changed(); + if ( !mBlockChangeSignal ) + emit changed(); } void CustomTemplates::load() @@ -155,7 +205,7 @@ void CustomTemplates::load() CustomTemplateItem *vitem = new CustomTemplateItem( *it, t.content(), shortcut, - static_cast( t.type() ) ); + static_cast( t.type() ), t.to(), t.cC() ); mItemList.insert( *it, vitem ); TQListViewItem *item = new TQListViewItem( mList, typeStr, *it, t.content() ); switch ( t.type() ) { @@ -178,11 +228,22 @@ void CustomTemplates::load() void CustomTemplates::save() { + // Before saving the new templates, delete the old ones. That needs to be done before + // saving, since otherwise a new template with the new name wouldn't get saved. + for ( TQStringList::const_iterator it = mItemsToDelete.constBegin(); + it != mItemsToDelete.constEnd(); ++it ) { + CTemplates t( (*it) ); + const TQString configGroup = t.currentGroup(); + kmkernel->config()->deleteGroup( configGroup ); + } + if ( mCurrentItem ) { CustomTemplateItem *vitem = mItemList[ mCurrentItem->text( 1 ) ]; if ( vitem ) { vitem->mContent = mEdit->text(); vitem->mShortcut = mKeyButton->shortcut(); + vitem->mTo = mToEdit->text(); + vitem->mCC = mCCEdit->text(); } } TQStringList list; @@ -191,8 +252,7 @@ void CustomTemplates::save() list.append( (*lit)->text( 1 ) ); ++lit; } - TQDictIterator it( mItemList ); - for ( ; it.current() ; ++it ) { + for ( TQDictIterator it( mItemList ); it.current() ; ++it ) { // list.append( (*it)->mName ); CTemplates t( (*it)->mName ); TQString &content = (*it)->mContent; @@ -202,6 +262,8 @@ void CustomTemplates::save() t.setContent( content ); t.setShortcut( (*it)->mShortcut.toString() ); t.setType( (*it)->mType ); + t.setTo( (*it)->mTo ); + t.setCC( (*it)->mCC ); t.writeConfig(); } GlobalSettings::self()->setCustomTemplates( list ); @@ -229,13 +291,15 @@ void CustomTemplates::slotAddClicked() if ( !str.isEmpty() ) { CustomTemplateItem *vitem = mItemList[ str ]; if ( !vitem ) { - vitem = new CustomTemplateItem( str, "", KShortcut::null(), TUniversal ); + vitem = new CustomTemplateItem( str, "", KShortcut::null(), TUniversal, + TQString(), TQString() ); mItemList.insert( str, vitem ); TQListViewItem *item = new TQListViewItem( mList, indexToType( TUniversal ), str, "" ); mList->setSelected( item, true ); mKeyButton->setEnabled( false ); - emit changed(); + if ( !mBlockChangeSignal ) + emit changed(); } } } @@ -243,13 +307,14 @@ void CustomTemplates::slotAddClicked() void CustomTemplates::slotRemoveClicked() { if ( mCurrentItem ) { - CustomTemplateItem *vitem = mItemList.take( mCurrentItem->text( 1 ) ); - if ( vitem ) { - delete vitem; - } + const TQString templateName = mCurrentItem->text( 1 ); + mItemsToDelete.append( templateName ); + CustomTemplateItem *vitem = mItemList.take( templateName ); + delete vitem; delete mCurrentItem; mCurrentItem = 0; - emit changed(); + if ( !mBlockChangeSignal ) + emit changed(); } } @@ -268,16 +333,14 @@ void CustomTemplates::slotListSelectionChanged() mCurrentItem = item; CustomTemplateItem *vitem = mItemList[ mCurrentItem->text( 1 ) ]; if ( vitem ) { - // avoid emit changed() - disconnect( mEdit, TQT_SIGNAL( textChanged() ), - this, TQT_SLOT( slotTextChanged( void ) ) ); + mBlockChangeSignal = true; mEdit->setText( vitem->mContent ); mKeyButton->setShortcut( vitem->mShortcut, false ); mType->setCurrentItem( vitem->mType ); - - connect( mEdit, TQT_SIGNAL( textChanged() ), - this, TQT_SLOT( slotTextChanged( void ) ) ); + mToEdit->setText( vitem->mTo ); + mCCEdit->setText( vitem->mCC ); + mBlockChangeSignal = false; if ( vitem->mType == TUniversal ) { @@ -285,11 +348,15 @@ void CustomTemplates::slotListSelectionChanged() } else { mKeyButton->setEnabled( true ); } + setRecipientsEditsEnabled( vitem->mType == TForward || + vitem->mType == TUniversal ); } } else { mEditFrame->setEnabled( false ); mCurrentItem = 0; mEdit->clear(); + mToEdit->clear(); + mCCEdit->clear(); mKeyButton->setShortcut( KShortcut::null(), false ); mType->setCurrentItem( 0 ); } @@ -324,8 +391,14 @@ void CustomTemplates::slotTypeActivated( int index ) } else { mKeyButton->setEnabled( true ); } - emit changed(); + + setRecipientsEditsEnabled( vitem->mType == TForward || + vitem->mType == TUniversal ); + if ( !mBlockChangeSignal ) + emit changed(); } + else + setRecipientsEditsEnabled( false ); } void CustomTemplates::slotShortcutCaptured( const KShortcut &shortcut ) @@ -369,7 +442,8 @@ void CustomTemplates::slotShortcutCaptured( const KShortcut &shortcut ) } if ( assign ) { mKeyButton->setShortcut( sc, false ); - emit changed(); + if ( !mBlockChangeSignal ) + emit changed(); } } -- cgit v1.2.3