kmail

messageactions.h

Go to the documentation of this file.
00001 /*
00002     Copyright (c) 2007 Volker Krause <vkrause@kde.org>
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef KMAIL_MESSAGEACTIONS_H
00020 #define KMAIL_MESSAGEACTIONS_H
00021 
00022 #include "kmcommands.h"
00023 #include "kmreaderwin.h"
00024 
00025 #include <qobject.h>
00026 #include <qvaluelist.h>
00027 
00028 class QWidget;
00029 class KAction;
00030 class KActionMenu;
00031 class KActionCollection;
00032 class KMMessage;
00033 
00034 namespace KMail {
00035 
00039 class MessageActions : public QObject
00040 {
00041   Q_OBJECT
00042   public:
00043     MessageActions( KActionCollection* ac, QWidget *parent );
00044     void setMessageView( KMReaderWin *msgView );
00045 
00046     void setCurrentMessage( KMMessage *msg );
00047     void setSelectedSernums( const QValueList<Q_UINT32> &sernums );
00048     void setSelectedVisibleSernums( const QValueList<Q_UINT32> &sernums );
00049 
00050     KActionMenu* replyMenu() const { return mReplyActionMenu; }
00051     KAction* replyListAction() const { return mReplyListAction; }
00052     KAction* createTodoAction() const { return mCreateTodoAction; }
00053 
00054     KActionMenu* messageStatusMenu() const { return mStatusMenu; }
00055 
00056     KAction* editAction() const { return mEditAction; }
00057 
00058   public slots:
00059     void editCurrentMessage();
00060 
00061   private:
00062     void updateActions();
00063     template<typename T> void replyCommand()
00064     {
00065       if ( !mCurrentMessage )
00066         return;
00067       const QString text = mMessageView ? mMessageView->copyText() : "";
00068       KMCommand *command = new T( mParent, mCurrentMessage, text );
00069       command->start();
00070     }
00071     void setMessageStatus( KMMsgStatus status, bool toggle = false );
00072 
00073   private slots:
00074     void slotReplyToMsg();
00075     void slotReplyAuthorToMsg();
00076     void slotReplyListToMsg();
00077     void slotReplyAllToMsg();
00078     void slotNoQuoteReplyToMsg();
00079     void slotCreateTodo();
00080     void slotSetMsgStatusNew();
00081     void slotSetMsgStatusUnread();
00082     void slotSetMsgStatusRead();
00083     void slotSetMsgStatusTodo();
00084     void slotSetMsgStatusFlag();
00085 
00086   private:
00087     QWidget *mParent;
00088     KActionCollection *mActionCollection;
00089     KMMessage* mCurrentMessage;
00090     QValueList<Q_UINT32> mSelectedSernums;
00091     QValueList<Q_UINT32> mVisibleSernums;
00092     KMReaderWin *mMessageView;
00093 
00094     KActionMenu *mReplyActionMenu;
00095     KAction *mReplyAction, *mReplyAllAction, *mReplyAuthorAction,
00096             *mReplyListAction, *mNoQuoteReplyAction;
00097     KAction *mCreateTodoAction;
00098     KActionMenu *mStatusMenu;
00099     KToggleAction *mToggleFlagAction, *mToggleTodoAction;
00100     KAction *mEditAction;
00101 };
00102 
00103 }
00104 
00105 #endif
00106