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

List:       kde-commits
Subject:    playground/pim/mailody
From:       Tom Albers <tomalbers () kde ! nl>
Date:       2007-02-01 21:44:15
Message-ID: 1170366255.921848.21466.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 629201 by toma:

-  add pulldowns to/forward with current addressess
-  allow new mail when no mailbox is selected. Just store it in Inbox.


 M  +0 -2      TODO  
 M  +1 -1      src/composer.cpp  
 M  +96 -28    src/mainwindow.cpp  
 M  +1 -0      src/mainwindow.h  


--- trunk/playground/pim/mailody/TODO #629200:629201
@@ -2,8 +2,6 @@
   draw error when opening a fresh mailbox - headers not parsed in time.
   check if newly addressess in the addressbook are directly usable in the composer.
   tooltip does not dissapear when app is no longer in focus
-  fill pulldowns to/forward with current addressess when there are no addresses yet.
-  allow new mail when no mailbox is selected. Just store it in Inbox.
 
 Future Soon
   Composer: send html-version of the plain message [spaze]
--- trunk/playground/pim/mailody/src/composer.cpp #629200:629201
@@ -734,7 +734,7 @@
     if (choice == del)
     {
         DB* conn = DB::dbinstance();
-        conn->deleteFromRecentList(lvi->text(1));
+        conn->deleteFromRecentList(lvi->text(0));
         delete lvi;
     }
 }
--- trunk/playground/pim/mailody/src/mainwindow.cpp #629200:629201
@@ -313,11 +313,15 @@
     m_msgNewAction = KStdAction::openNew( this, SLOT( slotNewMessage() ),
                          actionCollection(), "compose_new_message" );
     m_msgNewAction->setIcon("mail_new3");
+    m_msgNewAction->setEnabled( true );
+
     m_msgNewActionMenu = new KActionMenu( i18n( "New message to" ),
                                     "compose_new_message",
                                     actionCollection(),
                                     "compose_new_messageMenu" );
     m_msgNewActionMenu->setIcon("mail_new3");
+    m_msgNewActionMenu->setEnabled( true );
+
     connect(m_msgNewActionMenu, SIGNAL(activated()),
             SLOT(slotNewMessage()));
     connect(m_msgNewActionMenu->popupMenu(), SIGNAL(aboutToShow()),
@@ -1656,10 +1660,14 @@
 {
     MailBoxListViewItem* mbi =
             static_cast<MailBoxListViewItem*>(m_mailboxList->currentItem());
+
+    QString box;
     if (!mbi)
-        return;
+        box = "INBOX";
+    else
+        box = mbi->fullName();
 
-    Composer* composer = new Composer(this, mbi->fullName());
+    Composer* composer = new Composer(this, box);
     if (!to.isEmpty())
         composer->setRcpt(to, Composer::To);
 
@@ -1670,26 +1678,7 @@
 
 void MainWindow::slotNewMessageMenu()
 {
-    m_msgNewActionMenu->popupMenu()->clear();
-    m_recentList.clear();
-
-    QStringList values;
-    m_db->getTopTenRecentList(values);
-    QStringList::iterator it = values.begin();
-    while(it != values.end())
-    {
-        QString name = (*it);
-        ++it;
-        QString email = (*it);
-        ++it;
-
-        if (name.isEmpty())
-            name = email;
-
-        int i = m_msgNewActionMenu->popupMenu()->insertItem(name);
-        m_recentList[i] = email;
-
-    }
+    messageMenu(m_msgNewActionMenu);
 }
 
 void MainWindow::slotNewMessageMenuSelected(int i)
@@ -1795,12 +1784,81 @@
 
 void MainWindow::slotForwardMessageMenu()
 {
-    m_msgForwardActionMenu->popupMenu()->clear();
+    messageMenu(m_msgForwardActionMenu);
+}
+
+void MainWindow::messageMenu(KActionMenu* am)
+{
+    am->popupMenu()->clear();
     m_recentList.clear();
 
+    // add them from the current message.
+    TotalView* i = static_cast<TotalView*>(m_tabWidget->currentPage());
     QStringList values;
-    m_db->getTopTenRecentList(values);
-    QStringList::iterator it = values.begin();
+    bool sep = false;
+    if (i && i->msg() && i->headers()->isVisible())
+    {
+        MessageData *msg = i->msg();
+
+        if (!msg->replyTo().isEmpty())
+        {
+            values.append(msg->replyTo());
+            values.append(msg->replyTo());
+            sep = true;
+        }
+
+        if (!msg->sender())
+        {
+            values.append(msg->sender());
+            values.append(msg->sender_email());
+            sep = true;
+        }
+
+        QStringList* list = msg->to_list();
+        if (list->count())
+        {
+            QStringList::Iterator it=list->begin();
+            for(; it!=list->end(); ++it)
+            {
+                values.append(*it);
+                values.append(*it);
+                sep = true;
+            }
+        }
+
+        list  = msg->cc_list();
+        if (list->count())
+        {
+            QStringList::Iterator it=list->begin();
+            for(; it!=list->end(); ++it)
+            {
+                values.append(*it);
+                values.append(*it);
+                sep = true;
+            }
+        }
+    }
+
+    // add top 10
+    QStringList values2;
+    m_db->getTopTenRecentList(values2);
+
+    if (sep && values.count() > 0)
+    {
+        values.append("-");
+        values.append("-");
+    }
+
+    QStringList::iterator it = values2.begin();
+    while(it != values2.end())
+    {
+        if (values.findIndex(*it) == -1)
+            values.append(*it);
+        ++it;
+    }
+
+    // make the menu
+    it = values.begin();
     while(it != values.end())
     {
         QString name = (*it);
@@ -1811,9 +1869,21 @@
         if (name.isEmpty())
             name = email;
 
-        int i = m_msgForwardActionMenu->popupMenu()->insertItem(name);
+        int i;
+        if (name == "-")
+            i = am->popupMenu()->insertSeparator();
+        else
+            i = am->popupMenu()->insertItem(name);
+
         m_recentList[i] = email;
+    }
 
+    // still nothing???
+    if (!values.count())
+    {
+        // change after messagefreeze
+        int i = am->popupMenu()->insertItem(i18n("None"));
+        am->popupMenu()->setItemEnabled(i, false);
     }
 }
 
@@ -1996,8 +2066,6 @@
     m_childSortAction->setEnabled( mbi );
     m_hideDeletedAction->setEnabled( mbi );
     m_syncAction->setEnabled( mbi );
-    m_msgNewAction->setEnabled( mbi );
-    m_msgNewActionMenu->setEnabled( mbi );
 }
 
 void MainWindow::setStatusBarStates()
--- trunk/playground/pim/mailody/src/mainwindow.h #629200:629201
@@ -87,6 +87,7 @@
         void showMessage();
         void setActionStates();
         void setStatusBarStates();
+        void messageMenu(KActionMenu* am);
 
         QSplitter                           *m_first;
         QSplitter                           *m_second;
[prev in list] [next in list] [prev in thread] [next in thread] 

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