[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:       2008-03-15 23:42:44
Message-ID: 1205624564.670831.20961.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 786068 by toma:

Fix sending of attachments. For sending the filename() of the kurl was used, but when \
forwarding an existing message, the message uses temporary filenames and a visible \
name. the filename() of such a temp file name was ugly. Now change it to using the \
name as displayed.


 M  +0 -1      AKONADI  
 M  +8 -2      src/attachmentwidget.cpp  
 M  +1 -1      src/attachmentwidget.h  
 M  +1 -1      src/composer.cpp  
 M  +7 -8      src/sendmessage.cpp  
 M  +2 -2      src/sendmessage.h  


--- trunk/playground/pim/mailody/AKONADI #786067:786068
@@ -3,7 +3,6 @@
    flag changes are not stored on the server. see below.
    double clicking to see the messages
    implement purge
-   check if forwarding attachments will mangle the display of the filenames
    check mailtransports server test, some weird things are happening there
    all the handling of tabs is pretty much broken currently. disable for first \
release?  check keys for navigation for new mail loop, next/previous message, etc
--- trunk/playground/pim/mailody/src/attachmentwidget.cpp #786067:786068
@@ -49,9 +49,15 @@
     box->addWidget( list );
 }
 
-QList<KUrl> AttachmentWidget::attachments()
+QHash<KUrl, QString> AttachmentWidget::attachments()
 {
-    return allItems.values();
+    QHash<KUrl, QString> results;
+
+    QHash<QStandardItem*, KUrl>::Iterator ita;
+    for ( ita = allItems.begin(); ita != allItems.end(); ++ita )
+        results[ ita.value() ] = ita.key()->text();
+
+    return results;
 }
 
 void AttachmentWidget::dropEvent( QDropEvent *e )
--- trunk/playground/pim/mailody/src/attachmentwidget.h #786067:786068
@@ -48,7 +48,7 @@
      */
     explicit AttachmentWidget( QWidget *parent );
     void addAttachment( const KUrl &, const QString& name=QString() );
-    QList<KUrl> attachments();
+    QHash<KUrl, QString> attachments();
 
 protected:
     /**
--- trunk/playground/pim/mailody/src/composer.cpp #786067:786068
@@ -677,7 +677,7 @@
     kDebug() << "Adding: " << file.url() << endl;
 
     // find existing one
-    QList<KUrl> list = m_attachview->attachments();
+    QList<KUrl> list = m_attachview->attachments().keys();
     foreach( const KUrl& url, list )
     if ( url.path() == file.url().path() )
         return;
--- trunk/playground/pim/mailody/src/sendmessage.cpp #786067:786068
@@ -260,9 +260,10 @@
 
     // Hook in the attachments
     int totalSize = 0;
-    for ( int i=0 ; i < m_attachments.count(); ++i ) {
+    QHash<KUrl, QString>::Iterator ita;
+    for ( ita = m_attachments.begin(); ita != m_attachments.end(); ++ita ) {
         //TODO: network transparency....
-        QFile file( m_attachments.at( i ).path() );
+        QFile file( ita.key().path() );
         if ( file.open( QIODevice::ReadOnly ) ) {
             QByteArray data = file.readAll();
             file.close();
@@ -275,12 +276,10 @@
             c->setBody( final+"\n\n" );
 
             // Add a content type / find mime-type
-            KUrl url =  m_attachments.at( i ) ;
-            KMimeType::Ptr type = KMimeType::findByUrl( url );
-            KMime::Headers::ContentType *ctt= new
-            KMime::Headers::ContentType( c );
+            KMimeType::Ptr type = KMimeType::findByUrl( ita.key() );
+            KMime::Headers::ContentType *ctt= new KMime::Headers::ContentType( c );
             ctt->fromUnicodeString( type->name(),encoding( type->name() ) );
-            ctt->setName( url.fileName(),"" );
+            ctt->setName( ita.value(), "" );
             c->setHeader( ctt );
 
             // Set the encoding.
@@ -296,7 +295,7 @@
 
             newMessage->addContent( c );
         }
-    };
+    }
 
     if ( totalSize > 2000000 ) {
         int i = KMessageBox::warningContinueCancel( 0,
--- trunk/playground/pim/mailody/src/sendmessage.h #786067:786068
@@ -69,7 +69,7 @@
     void addBcc( const QString& Bcc ) {
         m_bccs.append( Bcc );
     };
-    void addAttachments( const QList<KUrl> &Attachment ) {
+    void addAttachments( const QHash<KUrl, QString> &Attachment ) {
         m_attachments = Attachment ;
     };
     void setSubject( const QString& Subject ) {
@@ -82,7 +82,7 @@
 private:
     const char * encoding( const QString& data );
     QStringList m_tos, m_ccs, m_bccs;
-    QList<KUrl> m_attachments;
+    QHash<KUrl, QString> m_attachments;
     QString m_subject, m_irt;
 
 private slots:


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

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