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

List:       kde-commits
Subject:    branches/work/nokia-pim-suite/trunk/contact
From:       Audrey Speronel <audenel () gmail ! com>
Date:       2009-01-22 11:14:35
Message-ID: 1232622875.467965.17730.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 915015 by asperonel:

Correction of a problem in the initialisation of the editor.

 M  +16 -3     kabcitemeditor.cpp  
 M  +1 -0      kabcitemeditor.h  
 M  +25 -5     stackedmanager.cpp  
 M  +3 -1      stackedmanager.h  


--- branches/work/nokia-pim-suite/trunk/contact/kabcitemeditor.cpp #915014:915015
@@ -262,8 +262,7 @@
   mMonitor = new Monitor;
   mMonitor->ignoreSession( Session::defaultSession() );
 
-  connect( mMonitor, SIGNAL( itemChanged( const Item&, const QSet<QByteArray>& ) ),
-           mParent, SLOT( itemChanged( const Item&, const QSet<QByteArray>& ) ) );
+  connect( mMonitor, SIGNAL( itemChanged( const Item&, const QSet<QByteArray>& ) ), \
mParent, SLOT( itemChanged( const Item&, const QSet<QByteArray>& ) ) );  }
 
 
@@ -277,6 +276,9 @@
   //add signal to button
   connect( d->gui.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, \
SLOT(slot_saveContact()) );  connect( \
d->gui.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL( clicked() ), this, \
SLOT(slot_cancelAddContact()) ); +
+  //ask to close the window in the stackedManager
+    connect( d->gui.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), \
this, SLOT(slot_exitWindow()) );  }
 
 
@@ -285,7 +287,7 @@
 }
 
 /**
-*Slot used when the user wants to add a new contact
+* Slot used when the user wants to add a new contact
 */
 void KABCItemEditor::slot_saveContact()
 {
@@ -302,6 +304,17 @@
   ((StackedManager *)parent())->open_window(StackedManager::mainWindow);
 }
 
+/**
+ * Slot used to remove and delete the editor from the stacked manager
+ */
+void KABCItemEditor::slot_exitWindow()
+{
+  if(d->mMode == CreateMode)
+    ((StackedManager *)parent())->deleteWindow(StackedManager::addContactWindow);
+  else
+    ((StackedManager *)parent())->deleteWindow(StackedManager::editContactWindow);
+}
+
 void KABCItemEditor::loadContact( const Item &item )
 {
   if ( d->mMode == CreateMode )
--- branches/work/nokia-pim-suite/trunk/contact/kabcitemeditor.h #915014:915015
@@ -71,6 +71,7 @@
 
     void slot_saveContact();
     void slot_cancelAddContact();
+    void slot_exitWindow();
 
   Q_SIGNALS:
     /**
--- branches/work/nokia-pim-suite/trunk/contact/stackedmanager.cpp #915014:915015
@@ -69,8 +69,6 @@
   kDebug() << "initialise the stacked windows";
 
   insertWidget(mainWindow, new VC_Contacts(contacts, this));
-  insertWidget(addContactWindow, new \
                Akonadi::KABCItemEditor(Akonadi::KABCItemEditor::CreateMode, this));
-  insertWidget(editContactWindow, new \
Akonadi::KABCItemEditor(Akonadi::KABCItemEditor::EditMode, this));  
   ConfigWindow * configWindow = new ConfigWindow(this, "configWindow");
   insertWidget(configContactWindow, configWindow);
@@ -93,12 +91,14 @@
       setVisible(false);
       break;
     case addContactWindow : /*to addContact window*/
-      kDebug() << "get addContactWindow in stack";
+      kDebug() << "create addContactWindow";
+      insertWidget(addContactWindow, new \
Akonadi::KABCItemEditor(Akonadi::KABCItemEditor::CreateMode, this));  \
setCurrentIndex(addContactWindow);  setVisible(true);
       break;
     case editContactWindow : /* to editContact window */
-      kDebug() << "get editContactWindow in stack";
+      kDebug() << "create editContactWindow";
+      insertWidget(editContactWindow, new \
Akonadi::KABCItemEditor(Akonadi::KABCItemEditor::EditMode, this));  \
                setCurrentIndex(editContactWindow);
       ((Akonadi::KABCItemEditor *) \
widget(editContactWindow))->loadContact(parameter);  setVisible(true);
@@ -106,12 +106,32 @@
     case configContactWindow : /* to config window */
       kDebug() << "get configContactWindow in stack";
       setCurrentIndex(configContactWindow);
-      setVisible(false);
+      //setVisible(false);
       break;
   }
 }
 
 /**
+ * Remove from the stackedWidget the current window and delete it
+ * Mainly implemented to reinitialize the editor
+ * @param idWindow identifier of the window to delete
+ */
+void StackedManager::deleteWindow(int idWindow)
+{
+  kDebug() << "delete the window :" << idWindow ;
+
+  //If the window is an item editor
+  if(idWindow == editContactWindow || idWindow == editContactWindow)
+  {
+    kDebug() << "delete editor";
+
+    Akonadi::KABCItemEditor * editor = ((Akonadi::KABCItemEditor *) \
widget(idWindow)); +    removeWidget(editor);
+    editor->deleteLater();
+  }
+}
+
+/**
  * Gets the common contacts model
  * @return the contacts model
  */
--- branches/work/nokia-pim-suite/trunk/contact/stackedmanager.h #915014:915015
@@ -32,7 +32,8 @@
 class StackedManager : public QStackedWidget
 {
   public:
-    enum Window {
+    enum Window
+    {
       mainWindow,
       addContactWindow,
       editContactWindow,
@@ -46,6 +47,7 @@
     ~StackedManager();
     void initWindows();
     void open_window(int idWindow=mainWindow, Akonadi::Item \
parameter=Akonadi::Item()); /*function opening one of the contact windows */ +    \
void deleteWindow(int idWindow); /*remove the given window and delete it*/  Contacts* \
getContacts();  };
 #endif //STACKEDMANAGER_H


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

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