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

List:       kde-commits
Subject:    kdelibs/kabc
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2004-11-12 17:21:03
Message-ID: 20041112172103.5117916EA4 () office ! kde ! org
[Download RAW message or body]

CVS commit by tokoe: 

Add new class KABC::SortMode which is used by KABC::AddresseeList to allow
advanced sorting (e.g. multiple sorting rules).


  A            sortmode.cpp   1.1 [LGPL (v2+)]
  A            sortmode.h   1.1 [LGPL (v2+)]
  M +3 -2      Makefile.am   1.105
  M +18 -2     addresseelist.cpp   1.10
  M +7 -0      addresseelist.h   1.10
  M +6 -6      scripts/addressee.src.cpp   1.59
  M +8 -7      scripts/addressee.src.h   1.45


--- kdelibs/kabc/Makefile.am  #1.104:1.105
@@ -35,5 +35,6 @@
   vcardformatimpl.cpp vcardformatplugin.cpp ldifconverter.cpp addresslineedit.cpp \
   ldapclient.cpp addresseelist.cpp vcardtool.cpp addresseehelper.cpp \
-  addresseehelper.skel lock.cpp locknull.cpp ldif.cpp ldapurl.cpp ldapconfigwidget.cpp
+  addresseehelper.skel lock.cpp locknull.cpp ldif.cpp ldapurl.cpp ldapconfigwidget.cpp \
+  sortmode.cpp
 
 
@@ -46,5 +47,5 @@
   vcardconverter.h vcardformat.h vcardformatplugin.h ldifconverter.h \
   addresslineedit.h ldapclient.h addresseelist.h lock.h locknull.h ldif.h \
-  ldapurl.h ldapconfigwidget.h
+  ldapurl.h ldapconfigwidget.h sortmode.h
 
 METASOURCES = AUTO

--- kdelibs/kabc/addresseelist.cpp  #1.9:1.10
@@ -23,5 +23,7 @@
 
 #include "addresseelist.h"
+
 #include "field.h"
+#include "sortmode.h"
 
 using namespace KABC;
@@ -229,7 +231,21 @@ void AddresseeList::sortByField( Field *
     return;
 
-  KABC::Addressee::setSortKey( sActiveField );
+  KABC::FieldSortMode *mode = new KABC::FieldSortMode( sActiveField );
+
+  KABC::Addressee::setSortMode( mode );
   qHeapSort( *this );
-  KABC::Addressee::setSortKey( 0 );
+  KABC::Addressee::setSortMode( 0 );
+
+  delete mode;
+}
+
+void AddresseeList::sortByMode( SortMode *mode )
+{
+  if ( count() == 0 )
+    return;
+
+  KABC::Addressee::setSortMode( mode );
+  qHeapSort( *this );
+  KABC::Addressee::setSortMode( 0 );
 }
 

--- kdelibs/kabc/addresseelist.h  #1.9:1.10
@@ -30,4 +30,5 @@ namespace KABC {
 
 class Field;
+class SortField;
 
 /**
@@ -148,4 +149,10 @@ class KABC_EXPORT AddresseeList : public
 
     /**
+     * Sorts this list by a specific sorting mode.
+     * @param mode    pointer to the sorting mode object to be sorted by
+     */
+    void sortByMode( SortMode *mode = 0 );
+
+    /**
      * Sorts this list by its active sorting criterion. This normally is the
      * criterion of the last sortBy operation or <tt>FormattedName</tt> if up

--- kdelibs/kabc/scripts/addressee.src.cpp  #1.58:1.59
@@ -30,4 +30,5 @@
 #include "field.h"
 #include "resource.h"
+#include "sortmode.h"
 
 #include "addressee.h"
@@ -40,5 +41,5 @@ template <class L>
 static bool listEquals( const QValueList<L>&, const QValueList<L>& );
 
-KABC::Field *Addressee::mSortField = 0;
+KABC::SortMode *Addressee::mSortMode = 0;
 
 struct Addressee::AddresseeData : public KShared
@@ -895,16 +896,15 @@ bool Addressee::changed() const
 }
 
-void Addressee::setSortKey( KABC::Field *field )
+void Addressee::setSortMode( KABC::SortMode *mode )
 {
-  mSortField = field;
+  mSortMode = mode;
 }
 
 bool Addressee::operator< ( const Addressee &addr )
 {
-  if ( !mSortField )
+  if ( !mSortMode )
     return false;
   else
-    return ( QString::localeAwareCompare( mSortField->value( *this ).lower(),
-                                          mSortField->value( addr ).lower() ) < 0 );
+    return mSortMode->lesser( *this, addr );
 }
 

--- kdelibs/kabc/scripts/addressee.src.h  #1.44:1.45
@@ -44,4 +44,5 @@ namespace KABC {
 class Resource;
 class Field;
+class SortMode;
 
 /**
@@ -370,5 +371,5 @@ class KABC_EXPORT Addressee
     bool changed() const;
 
-    static void setSortKey( KABC::Field *field );
+    static void setSortMode( KABC::SortMode *mode );
 
     bool operator< ( const Addressee &addr );
@@ -383,5 +384,5 @@ class KABC_EXPORT Addressee
     static AddresseeData* shared_null;
     static AddresseeData* makeSharedNull();
-    static KABC::Field *mSortField;
+    static KABC::SortMode *mSortMode;
 };
 


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

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