[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Patch: templates for kmail (Bug #1015)
From:       Florian Weber <Florian.Weber () pfaffenhofen ! de>
Date:       2001-08-13 0:34:02
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all!

Well, my guests left early, so here is the first (incomplete) draft for mail 
templates.

Summary:
- - new flag "isTemplateFolder" in KMFolder
- - new config-file option, same name
- - checkbox in the folder properties dialog
- - added special msgActivated handler for template folders:
   now open composer (with copy of original) instead of reader

Still to do:
- - disable showing the "isTemplateFolder" flag for system folders
   right now it is shown, but activating a msg will *always* open a
   composer
- - find a way to edit the templates instead of spawning new ones.
   Probably with entries in context menu and "Message" main menu
- - add menu option for instantiating the template
- - disable reply (also forward?) buttons when in template folder
- - make KMFolder emit a signal when template-status is changed (just for
   being thorough ...)
- - dcop binding (is a new one needed at all? I have not checked yet)
- - documentation: manual and announcement on "new version" splash

RFC:
Is it OK to copy all headers except Msg-ID from the template? Or should I 
remove/add other headers? (E.g. X-KMail-Template ... which, IMHO, would be a 
bad idea)

MfG,
Florian

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7dyB9IHY1JB8ZhlERAmjXAJ9qA3cWBV7qgecwzx1k2Z2mILYk7gCeN/LV
BH64/y8Zr6HxCdb67XFKIQ4=
=z59D
-----END PGP SIGNATURE-----

["templates.patch" (text/x-diff)]

Index: kmfolder.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolder.cpp,v
retrieving revision 1.184
diff -u -3 -p -r1.184 kmfolder.cpp
--- kmfolder.cpp	2001/08/09 00:03:41	1.184
+++ kmfolder.cpp	2001/08/12 23:50:57
@@ -946,6 +946,7 @@ void KMFolder::readConfig()
   if ( mIdentity.isEmpty() ) // backward compatiblity
       mIdentity = config->readEntry("MailingListIdentity");
   mCompactable = config->readBoolEntry("Compactable", TRUE);
+  mIsTemplateFolder = config->readBoolEntry("IsTemplateFolder", FALSE);
 }
 
 //-----------------------------------------------------------------------------
@@ -959,6 +960,7 @@ void KMFolder::writeConfig()
   config->writeEntry("MailingListAdminAddress", mMailingListAdminAddress);
   config->writeEntry("Identity", mIdentity);
   config->writeEntry("Compactable", mCompactable);
+  config->writeEntry("IsTemplateFolder", mIsTemplateFolder);
 }
 
 //-----------------------------------------------------------------------------
Index: kmfolder.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolder.h,v
retrieving revision 1.61
diff -u -3 -p -r1.61 kmfolder.h
--- kmfolder.h	2001/08/09 00:03:41	1.61
+++ kmfolder.h	2001/08/12 23:50:57
@@ -284,6 +284,12 @@ public:
 
     uchar *indexStreamBasePtr() { return mIndexStreamPtr; }
 
+  bool isTemplateFolder()
+  { return mIsTemplateFolder; }
+
+  void setIsTemplateFolder(bool newIsTemplate)
+  { mIsTemplateFolder=newIsTemplate; writeConfig(); }
+
 signals:
   /** Emitted when the status, name, or associated accounts of this
     folder changed. */
@@ -359,6 +365,7 @@ protected:
   /** name of the field that is used for "From" in listbox */
   QString mWhoField;
   bool mIsSystemFolder;
+  bool mIsTemplateFolder;
   KMAcctList* mAcctList;
 
   bool    mMailingListEnabled;
Index: kmfolderdia.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolderdia.cpp,v
retrieving revision 1.44
diff -u -3 -p -r1.44 kmfolderdia.cpp
--- kmfolderdia.cpp	2001/08/07 17:35:48	1.44
+++ kmfolderdia.cpp	2001/08/12 23:50:57
@@ -78,6 +78,11 @@ KMFolderDialog::KMFolderDialog(KMFolder*
 
   topLayout->addWidget( mtGroup );
 
+  QHBoxLayout *tb = new QHBoxLayout( mtGroup->layout() );
+  isTemplateFolder = new QCheckBox( i18n("Folder holds mail templates" ), mtGroup );
+  isTemplateFolder->setChecked(mFolder->isTemplateFolder());
+  tb->addWidget( isTemplateFolder );
+
   QHBoxLayout *ml = new QHBoxLayout( mtGroup->layout() );
   ml->setSpacing( 6 );
 
@@ -200,6 +205,11 @@ KMFolderDialog::KMFolderDialog(KMFolder*
 //-----------------------------------------------------------------------------
 void KMFolderDialog::slotOk()
 {
+  //fweber: is the checking neccessary? or can I rely on the existance of mFolder?
+  //fweber: please fix as needed and tell me
+  if (mFolder)
+    mFolder->setIsTemplateFolder( isTemplateFolder->isChecked() );
+
   if (!mFolder || (mFolder->protocol() != "imap"))
   {
     QString acctName;
Index: kmfolderdia.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolderdia.h,v
retrieving revision 1.14
diff -u -3 -p -r1.14 kmfolderdia.h
--- kmfolderdia.h	2001/08/07 17:35:48	1.14
+++ kmfolderdia.h	2001/08/12 23:50:57
@@ -36,6 +36,7 @@ protected:
   QValueList<QGuardedPtr<KMFolder> > mFolders;
 
   QCheckBox *holdsMailingList, *markAnyMessage;
+  QCheckBox *isTemplateFolder;
   QLineEdit *mailingListPostAddress;
   QComboBox *identity;
 //   QLineEdit *mailingListAdminAddress;
Index: kmheaders.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmheaders.cpp,v
retrieving revision 1.312
diff -u -3 -p -r1.312 kmheaders.cpp
--- kmheaders.cpp	2001/08/10 13:51:58	1.312
+++ kmheaders.cpp	2001/08/12 23:51:00
@@ -1177,6 +1177,29 @@ void KMHeaders::resendMsg ()
   kernel->kbp()->idle();
 }
 
+//-----------------------------------------------------------------------------
+//this is currently identical to resendMsg(),
+//but having a seperate function is better design, IMHO
+void KMHeaders::instantiateMsgTemplate ()
+{
+  KMComposeWin *win;
+  KMMessage *newMsg, *msg = currentMsg();
+  if (!msg) return;
+
+  kernel->kbp()->busy();
+  newMsg = new KMMessage;
+  newMsg->fromString(msg->asString());
+  newMsg->removeHeaderField("Message-Id");
+  newMsg->initHeader();
+  newMsg->setCharset(msg->codec()->name());
+  newMsg->setTo(msg->to());
+  newMsg->setSubject(msg->subject());
+
+  win = new KMComposeWin;
+  win->setMsg(newMsg, FALSE);
+  win->show();
+  kernel->kbp()->idle();
+}
 
 //-----------------------------------------------------------------------------
 void KMHeaders::bounceMsg ()
Index: kmheaders.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmheaders.h,v
retrieving revision 1.81
diff -u -3 -p -r1.81 kmheaders.h
--- kmheaders.h	2001/07/25 12:31:46	1.81
+++ kmheaders.h	2001/08/12 23:51:01
@@ -108,6 +108,9 @@ public:
   virtual void replyListToMsg(QString selection=QString::null);
   virtual void resendMsg();
 
+  /** Create a new message from a give template. */
+  virtual void instantiateMsgTemplate();
+
   /** If destination==NULL the messages are deleted, otherwise
     they are moved to this folder. */
   virtual void moveMsgToFolder(KMFolder* destination, int msgId=-1);
Index: kmmainwin.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmmainwin.cpp,v
retrieving revision 1.350
diff -u -3 -p -r1.350 kmmainwin.cpp
--- kmmainwin.cpp	2001/08/07 17:35:48	1.350
+++ kmmainwin.cpp	2001/08/12 23:51:04
@@ -982,6 +982,11 @@ void KMMainWin::slotBounceMsg()
   mHeaders->bounceMsg();
 }
 
+//-----------------------------------------------------------------------------
+void KMMainWin::slotInstantiateMsgTemplate()
+{
+  mHeaders->instantiateMsgTemplate();
+}
 
 //-----------------------------------------------------------------------------
 void KMMainWin::slotMessageQueuedOrDrafted()
@@ -1326,12 +1331,18 @@ void KMMainWin::slotPrevMessage()       
 void KMMainWin::slotPrevUnreadMessage() { mHeaders->prevUnreadMessage(); }
 
 //-----------------------------------------------------------------------------
-//called from heders. Message must not be deleted on close
+//called from headers. Message must not be deleted on close
 void KMMainWin::slotMsgActivated(KMMessage *msg)
 {
   if (mFolder == kernel->outboxFolder() || mFolder == kernel->draftsFolder())
   {
     slotEditMsg(); return;
+  }
+
+  if (mFolder->isTemplateFolder())
+  {
+    slotInstantiateMsgTemplate();
+    return;
   }
 
   assert(msg != NULL);
Index: kmmainwin.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmmainwin.h,v
retrieving revision 1.93
diff -u -3 -p -r1.93 kmmainwin.h
--- kmmainwin.h	2001/07/25 12:31:46	1.93
+++ kmmainwin.h	2001/08/12 23:51:04
@@ -143,6 +143,7 @@ protected slots:
   void slotForwardAttachedMsg();
   void slotRedirectMsg();
   void slotBounceMsg();
+  void slotInstantiateMsgTemplate();
   void slotMessageQueuedOrDrafted();
   void slotEditMsg();
   void slotDeleteMsg();

_______________________________________________
Kmail Developers mailing list
Kmail@master.kde.org
http://master.kde.org/mailman/listinfo/kmail


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic