Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

packagelistview.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  ***************************************************************************/
00009 // (c) 2002 Patrick S. Vogt <tille@handhelds.org>
00010 #include "packagelistview.h"
00011 
00012 #include <qpopupmenu.h>
00013 #include <qaction.h>
00014 
00015 #include "listviewitemoipkg.h"
00016 #include "packagelistitem.h"
00017 #include "pksettings.h"
00018 
00019 PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s)
00020   : QListView(p,n)
00021 {
00022   settings = s;
00023   popupTimer = new QTimer( this );
00024   setSelectionMode(QListView::NoSelection);
00025   addColumn( tr("Package") );
00026   setRootIsDecorated( true );
00027 
00028   connect( popupTimer, SIGNAL(timeout()),
00029            this, SLOT(showPopup()) );
00030   connect( this, SIGNAL( pressed(QListViewItem*) ),
00031            this, SLOT( setCurrent(QListViewItem*) ) );
00032   connect( this, SIGNAL( clicked(QListViewItem*) ),
00033            this, SLOT( stopTimer(QListViewItem*) ) );   
00034 
00035 }
00036 
00037 //PackageListView::~PackageListView()
00038 //{
00039 //}
00040 
00041 void PackageListView::setCurrent( QListViewItem* p )
00042 {
00043   qDebug("PackageListView::setCurrent ");
00044   activeItem = (ListViewItemOipkg*)p;
00045 
00046   if ( activeItem != 0 ) popupTimer->start( 750, true );
00047   
00048 //  if ( activeItem->getType() != ListViewItemOipkg::Package ){
00049 //    qDebug("PackageListView::setCurrent !p ");
00050 //    activePackage = 0;
00051 //        activePackageListItem = 0;
00052 //    qDebug("PackageListView::setCurrent returning ");
00053 //    return;
00054 //  };
00055 //  activePackageListItem = (PackageListItem*)p;
00056 //  activePackage = activePackageListItem->getPackage();
00057 //  if (activePackage == 0 )
00058 //    {
00059 //      qDebug("PackageListView::setCurrent  if (!activePackage)");
00060 //      return;
00061 //    }
00062   
00063 
00064   qDebug("PackageListView::setCurrent popupTimer->start");
00065 }
00066 
00067 
00068 void PackageListView::showPopup()
00069 {
00070   qDebug("PackageListView::showPopup");
00071   QPopupMenu *popup = activeItem->getPopupMenu();
00072   if (popup == 0) return;
00073   popup->popup( QCursor::pos() );
00074   qDebug("PackageListView::showPopup");
00075 }
00076 
00077 void PackageListView::stopTimer( QListViewItem* )
00078 {
00079   popupTimer->stop();
00080 }
00081 
00082 
00083 void PackageListView::display()
00084 {
00085   QDictIterator<PackageList> list( PackageLists );
00086   PackageList *packlist;
00087   OipkgPackage *pack;
00088   PackageListItem *item;
00089   ListViewItemOipkg *rootItem;
00090   QListViewItem* it;
00091   QListViewItem* itdel;
00092   while ( list.current() ) {
00093     packlist = list.current();
00094     rootItem = rootItems.find( list.currentKey() );
00095     //rootItem->clear();
00096     it=rootItem->firstChild();
00097     while ( it )
00098       {
00099         itdel = it;
00100         it    = it->nextSibling();
00101         delete itdel;
00102       }
00103     pack = packlist->first();
00104     while( pack )
00105       {
00106         item = new PackageListItem( rootItem, pack, settings );                         
00107         pack = packlist->next();
00108       } 
00109     ++list;
00110   }
00111 }
00112 
00113 void PackageListView::addList( QString n, PackageList* pl)
00114 {
00115   PackageLists.insert(n, pl);
00116   ListViewItemOipkg *item = new ListViewItemOipkg(this,n,ListViewItemOipkg::Feed);
00117   rootItems.insert(n, item);
00118 }

Generated on Sat Nov 5 16:18:10 2005 for OPIE by  doxygen 1.4.2