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

List:       kde-commits
Subject:    kdenonbeta/kmobiletools/kmobiletools
From:       Marco Gulino <marco () kmobiletools ! org>
Date:       2005-07-31 23:19:22
Message-ID: 1122851962.130020.28309.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 441798 by gulino:

Allows to delete more than one contact

 M  +20 -14    deviceparts/kmobiletools_devicepart.cpp  
 M  +7 -1      deviceparts/mainWidget.ui  
 M  +2 -2      engines/at_engine/kmobiletoolsat_engine.cpp  
 M  +1 -1      engines/at_engine/kmobiletoolsat_engine.h  
 M  +6 -4      engines/at_engine/phonebook_jobs.cpp  
 M  +2 -2      engines/at_engine/phonebook_jobs.h  
 M  +1 -1      engines/gammu_engine/kmobiletoolsgammu_engine.cpp  
 M  +1 -1      engines/gammu_engine/kmobiletoolsgammu_engine.h  
 M  +1 -1      libkmobiletoolsprivate/kmobiletoolsengine.h  


--- trunk/kdenonbeta/kmobiletools/kmobiletools/deviceparts/kmobiletools_devicepart.cpp #441797:441798
@@ -52,8 +52,8 @@
 #include <knuminput.h>
 #include <klineedit.h>
 #include <qvbox.h>
+#include <qlistview.h>
 
-
 #include "kmobiletools_cfg.h"
 #include "kmobiletools_devices.h"
 #include "mainWidget.h"
@@ -415,21 +415,27 @@
  */
 void kmobiletoolsDevicePart::slotDeleteContact()
 {
-    if( ! (m_widget->phonebookListView->selectedItem() ) ) return;
-    KABC::Addressee \
                *d_addr=engine->getAddresseeList()->at(m_widget->phonebookListView->selectedItem()->text(1).toInt() \
                );
-    QStringList indexes = QStringList::split(",",d_addr->custom("KMobileTools","index") );
-    if( KMessageBox::warningYesNo(NULL,i18n("This will permanently delete this contact from the phone \
                addressbook.\nContinue?"), "Warning") == KMessageBox::Yes) 
-    {
-        for ( QStringList::Iterator it = indexes.begin(); it != indexes.end(); ++it ) {
-            int index=(*it).toInt();
-            if (! index) break;
-            engine->slotDelAddressee( index);
+    QPtrList<QListViewItem> lst;
+
+    QListViewItemIterator l_it( m_widget->phonebookListView, QListViewItemIterator::Selected );
+    if( (! l_it.current() ) || ( KMessageBox::warningYesNo(NULL,i18n("This will permanently delete this \
contact from the phone addressbook.\nContinue?"), i18n("Warning") ) != KMessageBox::Yes) ) return;  +    \
QValueList<int> toDelete; +    while ( l_it.current() ) {
+        kdDebug() << (*l_it)->text(0) << endl;
+        KABC::Addressee *d_addr=engine->getAddresseeList()->at( (*l_it)->text(1).toInt() );
+        QStringList indexes = QStringList::split(",",d_addr->custom("KMobileTools","index") );
+        {
+            for ( QStringList::Iterator it = indexes.begin(); it != indexes.end(); ++it ) {
+                int index=(*it).toInt();
+                if (! index) break;
+                kdDebug() << index << endl;
+                toDelete.append(index);
+            }
         }
-        // It seems that having a retrieveAddressBook too early it's confusing.. so let's start it after \
                some secs
-        QTimer *timer = new QTimer( this );
-        connect( timer, SIGNAL(timeout()), this, SLOT(slotFetchPhonebook()) );
-        timer->start( 2000, TRUE ); // 3 seconds single-shot timer
+        ++l_it;
     }
+    kdDebug() << toDelete << endl;
+    engine->slotDelAddressee( toDelete);
 }
 
 void kmobiletoolsDevicePart::slotFetchPhonebook()
--- trunk/kdenonbeta/kmobiletools/kmobiletools/deviceparts/mainWidget.ui #441797:441798
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
 <class>mainWidget</class>
 <widget class="QWidget">
     <property name="name">
@@ -12,6 +12,9 @@
             <height>482</height>
         </rect>
     </property>
+    <property name="caption">
+        <string>mainWidget</string>
+    </property>
     <vbox>
         <property name="name">
             <cstring>unnamed</cstring>
@@ -323,6 +326,9 @@
                             <property name="name">
                                 <cstring>phonebookListView</cstring>
                             </property>
+                            <property name="selectionMode" stdset="0">
+                                <enum>Extended</enum>
+                            </property>
                             <property name="fullWidth">
                                 <bool>true</bool>
                             </property>
--- trunk/kdenonbeta/kmobiletools/kmobiletools/engines/at_engine/kmobiletoolsat_engine.cpp #441797:441798
@@ -92,7 +92,7 @@
             emit addressBookToUpdate();
             break;
         case kmobiletoolsEngine::delAddressee:
-//             emit addressBookToUpdate();
+            emit addressBookToUpdate();
             break;
     }
 }
@@ -174,7 +174,7 @@
 /*!
     \fn kmobiletoolsAT_engine::delAddressee(int index)
  */
-void kmobiletoolsAT_engine::slotDelAddressee(int index)
+void kmobiletoolsAT_engine::slotDelAddressee(QValueList<int> index)
 {
     enqueueJob( new DelAddressee(index, device, this, this->name() )) ;
 }
--- trunk/kdenonbeta/kmobiletools/kmobiletools/engines/at_engine/kmobiletoolsat_engine.h #441797:441798
@@ -50,7 +50,7 @@
     void retrieveSMSList();
     void slotAddAddressee(KABC::Addressee *addressee);
     void slotAddAddressee(KABC::AddressBook *addressbook);
-    void slotDelAddressee(int index);
+    void slotDelAddressee(QValueList<int> index);
 private slots:
     void devConnected();
 
--- trunk/kdenonbeta/kmobiletools/kmobiletools/engines/at_engine/phonebook_jobs.cpp #441797:441798
@@ -280,13 +280,15 @@
     return 0;
 }
 
-DelAddressee::DelAddressee(int index, Device *device, kmobiletoolsAT_engine* parent, const char* name) : \
kmobiletoolsATJob(device, parent, name) +DelAddressee::DelAddressee(QValueList<int> indexes, Device \
*device, kmobiletoolsAT_engine* parent, const char* name) : kmobiletoolsATJob(device, parent, name)  {
-    i_index=index;
+    l_indexes=indexes;
 }
 
 void DelAddressee::run()
 {
-    if (! i_index) return;
-    p_device->sendCommand( QString("AT+CPBW=%1\r").arg(i_index) );
+    if (! l_indexes.count() ) return;
+    QValueListIterator<int> it;
+    for ( it = l_indexes.begin(); it != l_indexes.end(); ++it )
+        p_device->sendCommand( QString("AT+CPBW=%1\r").arg(*it) );
 }
--- trunk/kdenonbeta/kmobiletools/kmobiletools/engines/at_engine/phonebook_jobs.h #441797:441798
@@ -58,12 +58,12 @@
 class DelAddressee :  public kmobiletoolsATJob
 {
     public:
-        DelAddressee( int index, Device *device, kmobiletoolsAT_engine *parent=0, const char *name = 0);
+        DelAddressee( QValueList<int> indexes, Device *device, kmobiletoolsAT_engine *parent=0, const \
char *name = 0);  int type() { return kmobiletoolsEngine::delAddressee; }
     protected:
         void run();
     private:
-        int i_index;;
+        QValueList<int> l_indexes;
 };
 
 
--- trunk/kdenonbeta/kmobiletools/kmobiletools/engines/gammu_engine/kmobiletoolsgammu_engine.cpp \
#441797:441798 @@ -110,7 +110,7 @@
     /// @todo implement me
 }
 
-void kmobiletoolsGammu_engine::slotDelAddressee(int index)
+void kmobiletoolsGammu_engine::slotDelAddressee(QValueList<int> index)
 {
     /// @todo implement me
 }
--- trunk/kdenonbeta/kmobiletools/kmobiletools/engines/gammu_engine/kmobiletoolsgammu_engine.h \
#441797:441798 @@ -53,7 +53,7 @@
     QStringList encodings() { return QStringList(QString::null); }
     void slotAddAddressee(KABC::Addressee*);
     void slotAddAddressee(KABC::AddressBook*);
-    void slotDelAddressee(int index);
+    void slotDelAddressee(QValueList<int> index);
 
 
 private slots:
--- trunk/kdenonbeta/kmobiletools/kmobiletools/libkmobiletoolsprivate/kmobiletoolsengine.h #441797:441798
@@ -98,7 +98,7 @@
     virtual void initPhone()=0;
     virtual void slotAddAddressee(KABC::Addressee*)=0;
     virtual void slotAddAddressee(KABC::AddressBook*)=0;
-    virtual void slotDelAddressee(int)=0;
+    virtual void slotDelAddressee(QValueList<int>)=0;
     virtual QStringList encodings()=0;
 
 signals:


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

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