Make sure irrelevant context menu items are not shown based on the folder

an email is in.
This means for example, no 'move to trash' for mail in the trash folder, and
no 'reply' on an email in your sent-mail folder.

BUG: 76395

svn path=/trunk/KDE/kdepim/; revision=424437
wilder-work
Thomas Zander 21 years ago
parent eea0a888d1
commit cf8712d2f0
  1. 24
      kmfolder.h
  2. 16
      kmheaders.cpp
  3. 10
      kmkernel.cpp
  4. 1
      kmkernel.h
  5. 16
      kmmainwidget.cpp
  6. 9
      kmreadermainwin.cpp

@ -79,6 +79,30 @@ public:
KMFolderType aFolderType );
~KMFolder();
/** Returns true if this folder is the inbox on the local disk */
bool isMainInbox() {
return this == KMKernel::self()->inboxFolder();
}
/** Returns true only if this is the outbox for outgoing mail */
bool isOutbox() {
return this == KMKernel::self()->outboxFolder();
}
/** Retuns true if this folder is the sent-mail box of the local account,
or is configured to be the sent mail box of any of the users identities */
bool isSent() {
return KMKernel::self()->folderIsSentMailFolder( this );
}
/** Retuns true if this folder is configured as a trash folder, localy or
for one of the accounts. */
bool isTrash() {
return KMKernel::self()->folderIsTrash( this );
}
/** Retuns true if this folder is the drafts box of the local account,
or is configured to be the drafts box of any of the users identities */
bool isDrafts() {
return KMKernel::self()->folderIsDrafts( this );
}
/** This is used by the storage to read the folder specific configuration */
void readConfig( KConfig* config );

@ -2248,7 +2248,8 @@ void KMHeaders::slotRMB()
mOwner->editAction()->plug(menu);
else {
// show most used actions
mOwner->replyMenu()->plug(menu);
if( !mFolder->isSent() )
mOwner->replyMenu()->plug(menu);
mOwner->forwardMenu()->plug(menu);
if(mOwner->sendAgainAction()->isEnabled()) {
mOwner->sendAgainAction()->plug(menu);
@ -2292,11 +2293,14 @@ void KMHeaders::slotRMB()
mOwner->saveAttachmentsAction()->plug(menu);
mOwner->printAction()->plug(menu);
menu->insertSeparator();
mOwner->trashAction()->plug(menu);
mOwner->deleteAction()->plug(menu);
if ( mOwner->trashThreadAction()->isEnabled() ) {
mOwner->trashThreadAction()->plug(menu);
mOwner->deleteThreadAction()->plug(menu);
if ( mFolder->isTrash() ) {
mOwner->deleteAction()->plug(menu);
if ( mOwner->trashThreadAction()->isEnabled() )
mOwner->deleteThreadAction()->plug(menu);
} else {
mOwner->trashAction()->plug(menu);
if ( mOwner->trashThreadAction()->isEnabled() )
mOwner->trashThreadAction()->plug(menu);
}
KAcceleratorManager::manage(menu);
kmkernel->setContextMenuShown( true );

@ -1834,7 +1834,15 @@ void KMKernel::emergencyExit( const QString& reason )
bool KMKernel::folderIsDraftOrOutbox(const KMFolder * folder)
{
assert( folder );
if ( folder == the_outboxFolder || folder == the_draftsFolder )
if ( folder == the_outboxFolder )
return true;
return folderIsDrafts( folder );
}
bool KMKernel::folderIsDrafts(const KMFolder * folder)
{
assert( folder );
if ( folder == the_draftsFolder )
return true;
QString idString = folder->idString();

@ -190,6 +190,7 @@ public:
void byteArrayToRemoteFile(const QByteArray&, const KURL&,
bool overwrite = FALSE);
bool folderIsDraftOrOutbox(const KMFolder *);
bool folderIsDrafts(const KMFolder *);
bool folderIsTrash(KMFolder *);
/**
* Returns true if the folder is one of the sent-mail folders.

@ -2129,6 +2129,7 @@ void KMMainWidget::slotMsgPopup(KMMessage&, const KURL &aUrl, const QPoint& aPoi
mMsgView->mailToComposeAction()->plug( menu );
mMsgView->mailToReplyAction()->plug( menu );
mMsgView->mailToForwardAction()->plug( menu );
menu->insertSeparator();
mMsgView->addAddrBookAction()->plug( menu );
mMsgView->openAddrBookAction()->plug( menu );
@ -2160,6 +2161,9 @@ void KMMainWidget::slotMsgPopup(KMMessage&, const KURL &aUrl, const QPoint& aPoi
if(mMsgView && !mMsgView->copyText().isEmpty()) {
if ( urlMenuAdded )
menu->insertSeparator();
mReplyActionMenu->plug(menu);
menu->insertSeparator();
mMsgView->copyAction()->plug( menu );
mMsgView->selectAllAction()->plug( menu );
} else if ( !urlMenuAdded )
@ -2172,12 +2176,12 @@ void KMMainWidget::slotMsgPopup(KMMessage&, const KURL &aUrl, const QPoint& aPoi
return;
}
bool out_folder = kmkernel->folderIsDraftOrOutbox(mFolder);
if ( out_folder ) {
if ( mFolder->isDrafts() || mFolder->isOutbox() ) {
mEditAction->plug(menu);
}
else {
mReplyActionMenu->plug(menu);
if( !mFolder->isSent() )
mReplyActionMenu->plug(menu);
mForwardActionMenu->plug(menu);
}
menu->insertSeparator();
@ -2200,8 +2204,10 @@ void KMMainWidget::slotMsgPopup(KMMessage&, const KURL &aUrl, const QPoint& aPoi
mSaveAttachmentsAction->plug( menu );
menu->insertSeparator();
mTrashAction->plug( menu );
mDeleteAction->plug( menu );
if( mFolder->isTrash() )
mDeleteAction->plug( menu );
else
mTrashAction->plug( menu );
}
KAcceleratorManager::manage(menu);
menu->exec(aPoint, 0);

@ -350,10 +350,11 @@ void KMReaderMainWin::slotMsgPopup(KMMessage &aMsg, const KURL &aUrl, const QPoi
return;
}
mReplyActionMenu->plug( menu );
mForwardActionMenu->plug( menu );
menu->insertSeparator();
if( !aMsg.parent()->isSent() && !aMsg.parent()->isDrafts() ) {
mReplyActionMenu->plug( menu );
mForwardActionMenu->plug( menu );
menu->insertSeparator();
}
QPopupMenu* copyMenu = new QPopupMenu(menu);
KMMainWidget* mainwin = kmkernel->getKMMainWidget();

Loading…
Cancel
Save