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

List:       kde-commits
Subject:    kroupware_branch: kdepim/korganizer
From:       Bo Thorsen <bo () sonofthor ! dk>
Date:       2003-06-12 9:54:46
[Download RAW message or body]

CVS commit by thorsen: 

Conflict resolution of notes


  M +25 -5     kogroupware.cpp   1.1.2.19
  M +3 -2      kogroupware.h   1.1.2.12


--- kdepim/korganizer/kogroupware.cpp  #1.1.2.18:1.1.2.19
@@ -36,4 +36,5 @@
 #include <libkcal/journal.h>
 #include <libkcal/calendarimap.h>
+#include <libkcal/calformat.h>
 
 #include <kdebug.h>
@@ -86,4 +87,6 @@ KOGroupware::KOGroupware( QObject* kmail
   }
 
+  connect( this, SIGNAL( conflict( const QString& ) ),
+           kmailTarget, SLOT( slotConflictResolved( const QString& ) ) );
   connect( this, SIGNAL( newOrUpdatedNote( const QString&, const QString&, const \
                QColor&, const QString& ) ),
            kmailTarget, SLOT( slotNewOrUpdatedNote( const QString&, const QString&, \
const QColor&, const QString& ) ) ); @@ -91,6 +94,6 @@ KOGroupware::KOGroupware( \
QObject* kmail  kmailTarget, SLOT( slotDeleteNote( const QString& ) ) );
 
-  connect( kmailTarget, SIGNAL( signalNoteAdded( const QString& ) ),
-           this, SLOT( slotNoteAdded( const QString& ) ) );
+  connect( kmailTarget, SIGNAL( signalNoteAdded( const QString&, bool& ) ),
+           this, SLOT( slotNoteAdded( const QString&, bool& ) ) );
   connect( kmailTarget, SIGNAL( signalNoteDeleted( const QString& ) ),
            this, SLOT( slotNoteRemoved( const QString& ) ) );
@@ -439,5 +442,5 @@ void KOGroupware::noteDeleted( const QSt
   Add a note
 */
-void KOGroupware::noteAdded( const QString& noteString )
+bool KOGroupware::noteAdded( const QString& noteString )
 {
   // TODO: proper parsing of note
@@ -460,11 +463,28 @@ void KOGroupware::noteAdded( const QStri
   if( pos > -1 )
     note.text = noteString.mid(pos+2);
+
+  // Figure out if the note ID already exists
+  bool rc = true;
+  QValueList<Note>::Iterator it = mNotes.begin();
+  for( ; rc && it != mNotes.end(); ++it ) {
+    if( (*it).id == note.id ) {
+      // We have a match. And that means a conflict
+      // Give the new note a new ID, add it to the list and make KMail
+      // delete the one it tried to add
+      rc = false;
+      note.id = CalFormat::createUniqueId();
+      emit conflict( "Note" );
+    }
+  }
+  
   mNotes << note;
+
+  return rc;
 }
 
 /* Called by KMail when a note is added to the folder */
-void KOGroupware::slotNoteAdded( const QString& msg )
+void KOGroupware::slotNoteAdded( const QString& msg, bool& accepted )
 {
-  noteAdded( msg );
+  accepted = noteAdded( msg );
   emit notesUpdated();
 }

--- kdepim/korganizer/kogroupware.h  #1.1.2.11:1.1.2.12
@@ -131,5 +131,5 @@ class KOGroupware : public QObject
 
     // A note is added from the outside
-    void noteAdded( const QString& note );
+    bool noteAdded( const QString& note );
 
 
@@ -149,5 +149,5 @@ class KOGroupware : public QObject
 
     // A note is added from the outside
-    void slotNoteAdded( const QString& note );
+    void slotNoteAdded( const QString& note, bool& accepted );
     void slotNoteRemoved( const QString& uid );
 
@@ -167,4 +167,5 @@ class KOGroupware : public QObject
 
     void dialogsUp( const QString& type, bool up );
+    void conflict( const QString& );
 
   protected:


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

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