~ubuntu-branches/ubuntu/edgy/psi/edgy

« back to all changes in this revision

Viewing changes to src/discodlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2005-09-14 16:33:49 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050914163349-3zacov4afysz5cw5
Tags: 0.9.3-2ubuntu1
* Sync with debian
* Applied patch to psi.desktop to start psi without gpg-agent use (known
  issue)
* Updated README.Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <qcheckbox.h>
26
26
#include <qmessagebox.h>
27
27
#include <qaction.h>
28
 
#include <qtoolbar.h>
29
28
#include <qstatusbar.h>
30
29
#include <qpopupmenu.h>
31
30
#include <qsignalmapper.h>
37
36
#include "im.h"
38
37
#include "xmpp_tasks.h"
39
38
 
 
39
#include "psitoolbar.h"
40
40
#include "tasklist.h"
41
41
#include "psiaccount.h"
42
42
#include "psicon.h"
184
184
        void updateInfo(const DiscoItem &);
185
185
        void updateItemsFinished(const DiscoList &);
186
186
        void autoItemsChildren() const; // automatically call disco#items for children :-)
 
187
        QString hash() { return computeHash( item().jid().full(), item().node() ); }
 
188
        QString computeHash( QString jid, QString node );
187
189
 
188
190
        // helper functions
189
191
        void init(DiscoItem it, DiscoData *dd);
529
531
        alreadyItems = true;
530
532
}
531
533
 
 
534
QString DiscoListItem::computeHash( QString jid, QString node )
 
535
{
 
536
        QString ret = jid.replace( '@', "\\@" );
 
537
        ret += "@";
 
538
        ret += node.replace( '@', "\\@" );
 
539
        return ret;
 
540
}
 
541
 
532
542
void DiscoListItem::updateItemsFinished(const DiscoList &list)
533
543
{
 
544
        QDict<DiscoListItem> children;
 
545
        DiscoListItem *child = (DiscoListItem *)firstChild();
 
546
        while ( child ) {
 
547
                children.insert( child->hash(), child );
 
548
 
 
549
                child = (DiscoListItem *)child->nextSibling();
 
550
        }
 
551
 
534
552
        // add/update items
535
553
        for(DiscoList::ConstIterator it = list.begin(); it != list.end(); ++it) {
536
554
                const DiscoItem a = *it;
537
 
                bool found = false;
538
 
 
539
 
                DiscoListItem *child = (DiscoListItem *)firstChild();
540
 
                while ( child ) {
541
 
                        if ( child->item().jid().full() == a.jid().full() &&
542
 
                             child->item().node()       == a.node() )
543
 
                        {
544
 
                                child->copyItem ( a );
545
 
                                found = true;
546
 
                                break;
547
 
                        }
548
 
 
549
 
                        child = (DiscoListItem *)child->nextSibling();
 
555
 
 
556
                QString key = computeHash(a.jid().full(), a.node());
 
557
                DiscoListItem *child = children[ key ];
 
558
 
 
559
                if ( child ) {
 
560
                        child->copyItem ( a );
 
561
                        children.remove( key );
550
562
                }
551
 
 
552
 
                if ( !found )
 
563
                else {
553
564
                        new DiscoListItem (a, d, this);
554
 
        }
555
 
 
556
 
        // check for removed items
557
 
        QPtrList<DiscoListItem> removeList;
558
 
        removeList.setAutoDelete (true);
559
 
        DiscoListItem *child = (DiscoListItem *)firstChild();
560
 
        while ( child ) {
561
 
                bool found = false;
562
 
 
563
 
                for(DiscoList::ConstIterator it = list.begin(); it != list.end(); ++it) {
564
 
                        const DiscoItem a = *it;
565
 
 
566
 
                        if ( child->item().jid().full() == a.jid().full() &&
567
 
                             child->item().node()       == a.node() )
568
 
                        {
569
 
                                found = true;
570
 
                                break;
571
 
                        }
572
565
                }
573
 
 
574
 
                if ( !found )
575
 
                        removeList.append ( child ); // items will be deleted later
576
 
 
577
 
                child = (DiscoListItem *)child->nextSibling();
578
566
        }
579
 
        removeList.clear();
 
567
 
 
568
        // remove all items that are not on new DiscoList
 
569
        children.setAutoDelete( true );
 
570
        children.clear();
580
571
 
581
572
        if ( autoItems && isOpen() )
582
573
                autoItemsChildren();
795
786
 
796
787
        DiscoData data;
797
788
 
798
 
        QToolBar *toolBar;
 
789
        PsiToolBar *toolBar;
799
790
        IconAction *actBrowse, *actBack, *actForward, *actRefresh, *actStop;
800
791
 
801
792
        // custom actions, that will be added to toolbar and context menu
915
906
        sm->setMapping(actAdd, Features::FID_Add);
916
907
 
917
908
        // create toolbar
918
 
        toolBar = new QToolBar(dlg);
 
909
        toolBar = new PsiToolBar(dlg);
 
910
        toolBar->setCustomizeable( false );
919
911
 
920
912
        actBack->addTo(toolBar);
921
913
        actBrowse->addTo(toolBar);