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

List:       kde-commits
Subject:    branches/work/akonadi-ports
From:       Volker Krause <vkrause () kde ! org>
Date:       2009-09-15 8:55:26
Message-ID: 1253004926.951149.30355.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1023684 by vkrause:

Move stripOffPrefixes() back from KMime into messagelist internals. It's
not ready to be public API yet, KMail has a much better version of this 
function which is locale-aware and configurable.


 M  +1 -0      kdepim/messagelist/CMakeLists.txt  
 M  +3 -2      kdepim/messagelist/core/item_p.h  
 A             kdepim/messagelist/core/subjectutils.cpp   [License: GPL (v2+)]
 A             kdepim/messagelist/core/subjectutils_p.h   [License: GPL (v2+)]
 M  +3 -2      kdepim/messagelist/storagemodel.cpp  
 M  +0 -32     kdepimlibs/kmime/kmime_headers.cpp  
 M  +0 -3      kdepimlibs/kmime/kmime_headers.h  


--- branches/work/akonadi-ports/kdepim/messagelist/CMakeLists.txt #1023683:1023684
@@ -24,6 +24,7 @@
     core/themedelegate.cpp
     core/storagemodelbase.cpp
     core/sortorder.cpp
+    core/subjectutils.cpp
     core/view.cpp
     core/widgetbase.cpp
 
--- branches/work/akonadi-ports/kdepim/messagelist/core/item_p.h #1023683:1023684
@@ -22,6 +22,7 @@
 #define __MESSAGELIST_CORE_ITEM_P_H__
 
 #include "core/item.h"
+#include "core/subjectutils_p.h"
 
 // See the MessageList::ItemPrivate::insertChildItem() function below for an \
explaination of this macro.  #if __GNUC__ >= 3
@@ -309,8 +310,8 @@
 public:
   static inline bool firstGreaterOrEqual( Item * first, Item * second )
   {
-    int ret = KMime::Headers::Subject::stripOffPrefixes( first->subject() ).
-                compare( KMime::Headers::Subject::stripOffPrefixes( \
second->subject() ), Qt::CaseInsensitive ); +    int ret = \
SubjectUtils::stripOffPrefixes( first->subject() ). +                compare( \
SubjectUtils::stripOffPrefixes( second->subject() ), Qt::CaseInsensitive );  if ( ret \
< 0 )  return false;
     // compare by date when subjects are equal
--- branches/work/akonadi-ports/kdepim/messagelist/storagemodel.cpp #1023683:1023684
@@ -33,6 +33,7 @@
 
 #include "core/messageitem.h"
 #include "core/settings.h"
+#include "core/subjectutils_p.h"
 
 #include <QtCore/QAbstractItemModel>
 #include <QtCore/QAtomicInt>
@@ -253,8 +254,8 @@
 
   switch ( subset ) {
   case PerfectThreadingReferencesAndSubject:
-    mi->setStrippedSubjectMD5( md5Encode( mail->subject()->stripOffPrefixes() ) );
-    mi->setSubjectIsPrefixed( \
mail->subject()->asUnicodeString()!=mail->subject()->stripOffPrefixes() ); +    \
mi->setStrippedSubjectMD5( md5Encode( Core::SubjectUtils::stripOffPrefixes( \
mail->subject()->asUnicodeString() ) ) ); +    mi->setSubjectIsPrefixed( \
mail->subject()->asUnicodeString() != Core::SubjectUtils::stripOffPrefixes( \
mail->subject()->asUnicodeString() ) );  // fall through
   case PerfectThreadingPlusReferences:
     if ( !mail->references()->identifiers().isEmpty() ) {
--- branches/work/akonadi-ports/kdepimlibs/kmime/kmime_headers.cpp #1023683:1023684
@@ -2126,39 +2126,7 @@
   return asUnicodeString().indexOf( QLatin1String( "Re:" ), 0, Qt::CaseInsensitive ) \
== 0;  }
 
-QString Subject::stripOffPrefixes() const
-{
-  return stripOffPrefixes( asUnicodeString() );
-}
 
-QString Subject::stripOffPrefixes( const QString &subject )
-{
-  QString str = subject;
-  QStringList prefixRegExps;
-  prefixRegExps << "Re\\s*:" << "Re\\[\\d+\\]:" << "Re\\d+:"
-                << "Fwd:" << "FW:";
-
-  // construct a big regexp that
-  // 1. is anchored to the beginning of str (sans whitespace)
-  // 2. matches at least one of the part regexps in prefixRegExps
-  QString bigRegExp = QString::fromLatin1("^(?:\\s+|(?:%1))+\\s*")
-                      .arg( prefixRegExps.join(")|(?:") );
-  QRegExp rx( bigRegExp, Qt::CaseInsensitive );
-  if ( !rx.isValid() ) {
-    kWarning() << "bigRegExp = \""
-               << bigRegExp << "\"\n"
-               << "prefix regexp is invalid!";
-  } else { // valid rx
-    QString tmp = str;
-    if ( rx.indexIn( tmp ) == 0 ) {
-      return tmp.replace( 0, rx.matchedLength(), QString() );
-    }
-  }
-
-  return str;
-}
-
-
 //@cond PRIVATE
 kmime_mk_trivial_ctor_with_name( ContentDescription,
                                  Generics::Unstructured, Content-Description )
--- branches/work/akonadi-ports/kdepimlibs/kmime/kmime_headers.h #1023683:1023684
@@ -1255,9 +1255,6 @@
   //@endcond
   public:
     bool isReply() const;
-    QString stripOffPrefixes() const;
-
-    static QString stripOffPrefixes( const QString &subject );
 };
 
 /**


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

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