author | tille <tille> | 2002-11-10 22:50:50 (UTC) |
---|---|---|
committer | tille <tille> | 2002-11-10 22:50:50 (UTC) |
commit | 9337c912158da3ad2fcda7ee1120c9357faddf8b (patch) (side-by-side diff) | |
tree | c5800efad3f90cfc9901db0337039eb883c0cf28 /noncore/unsupported/oipkg/packagelistview.cpp | |
parent | f6cabaaa364ee6d894462c0902734e434715fc58 (diff) | |
download | opie-9337c912158da3ad2fcda7ee1120c9357faddf8b.zip opie-9337c912158da3ad2fcda7ee1120c9357faddf8b.tar.gz opie-9337c912158da3ad2fcda7ee1120c9357faddf8b.tar.bz2 |
here it's...
Diffstat (limited to 'noncore/unsupported/oipkg/packagelistview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/packagelistview.cpp | 91 |
1 files changed, 28 insertions, 63 deletions
diff --git a/noncore/unsupported/oipkg/packagelistview.cpp b/noncore/unsupported/oipkg/packagelistview.cpp index 0d6fa80..3c7435d 100644 --- a/noncore/unsupported/oipkg/packagelistview.cpp +++ b/noncore/unsupported/oipkg/packagelistview.cpp @@ -3,134 +3,99 @@ * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "packagelistview.h" #include <qpopupmenu.h> #include <qaction.h> +#include "listviewitemoipkg.h" #include "packagelistitem.h" #include "pksettings.h" PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s) : QListView(p,n) { settings = s; - popupMenu = new QPopupMenu( this ); - destsMenu = new QPopupMenu( popupMenu ); popupTimer = new QTimer( this ); setSelectionMode(QListView::NoSelection); addColumn( tr("Package") ); setRootIsDecorated( true ); connect( popupTimer, SIGNAL(timeout()), this, SLOT(showPopup()) ); connect( this, SIGNAL( pressed( QListViewItem* ) ), this, SLOT( setCurrent( QListViewItem* ) ) ); connect( this, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( stopTimer( QListViewItem* ) ) ); } //PackageListView::~PackageListView() //{ //} void PackageListView::setCurrent( QListViewItem* p ) { - if ( !p ) return; - activePackageListItem = (PackageListItem*)p; - activePackage = activePackageListItem->getPackage(); - if (!activePackage) - { -// QDictIterator<QCheckListItem> it( rootItems ); -// while ( it.current() ) + qDebug("PackageListView::setCurrent "); + activeItem = (ListViewItemOipkg*)p; + + if ( activeItem != 0 ) popupTimer->start( 750, true ); + +// if ( activeItem->getType() != ListViewItemOipkg::Package ){ +// qDebug("PackageListView::setCurrent !p "); +// activePackage = 0; +// activePackageListItem = 0; +// qDebug("PackageListView::setCurrent returning "); +// return; +// }; +// activePackageListItem = (PackageListItem*)p; +// activePackage = activePackageListItem->getPackage(); +// if (activePackage == 0 ) // { -// if ( it.current()==p ) -// pvDebug(2,"current item"); -// ++it; +// qDebug("PackageListView::setCurrent if (!activePackage)"); +// return; // } - return; - } - popupTimer->start( 750, true ); + + qDebug("PackageListView::setCurrent popupTimer->start"); } void PackageListView::showPopup() { - popupMenu->clear(); - destsMenu->clear(); - - QAction *popupAction; - if ( !activePackage->installed() ) - { - popupMenu->insertItem( tr("Install to"), destsMenu ); - QStringList dests = settings->getDestinationNames(); - QString ad = settings->getDestinationName(); - for (uint i = 0; i < dests.count(); i++ ) - { - popupAction = new QAction( dests[i], QString::null, 0, this, 0 ); - popupAction->addTo( destsMenu ); - if ( dests[i] == ad && activePackage->toInstall() ) - { - popupAction->setToggleAction( true ); - popupAction->setOn(true); - }; - } - connect( destsMenu, SIGNAL( activated( int ) ), - this, SLOT( changePackageDest( int ) ) ); - }else{ - popupAction = new QAction( tr("Remove"),QString::null, 0, this, 0 ); - popupAction->addTo( popupMenu ); - connect( popupAction, SIGNAL( activated() ), - this , SLOT( toggleProcess() ) ); - popupAction = new QAction( tr("Reinstall"),QString::null, 0, this, 0 ); - popupAction->addTo( popupMenu ); - popupAction->setEnabled( false ); - } - popupMenu->popup( QCursor::pos() ); + qDebug("PackageListView::showPopup"); + QPopupMenu *popup = activeItem->getPopupMenu(); + if (popup == 0) return; + popup->popup( QCursor::pos() ); + qDebug("PackageListView::showPopup"); } void PackageListView::stopTimer( QListViewItem* ) { popupTimer->stop(); } -void PackageListView::changePackageDest( int i ) -{ - activePackage->setDest( destsMenu->text(i) ); - activePackage->setOn(); - activePackage->setLink( settings->createLinks() ); - activePackageListItem->displayDetails(); -} - -void PackageListView::toggleProcess() -{ - activePackage->toggleProcess() ; - activePackageListItem->displayDetails(); -} - void PackageListView::display() { QDictIterator<PackageList> list( PackageLists ); PackageList *packlist; - Package *pack; + OipkgPackage *pack; PackageListItem *item; - QCheckListItem *rootItem; + ListViewItemOipkg *rootItem; QListViewItem* it; QListViewItem* itdel; while ( list.current() ) { packlist = list.current(); rootItem = rootItems.find( list.currentKey() ); //rootItem->clear(); it=rootItem->firstChild(); while ( it ) { itdel = it; it = it->nextSibling(); delete itdel; @@ -139,15 +104,15 @@ void PackageListView::display() while( pack ) { item = new PackageListItem( rootItem, pack, settings ); pack = packlist->next(); } ++list; } } void PackageListView::addList( QString n, PackageList* pl) { PackageLists.insert(n, pl); - QCheckListItem *item = new QCheckListItem(this,n); + ListViewItemOipkg *item = new ListViewItemOipkg(this,n,ListViewItemOipkg::Feed); rootItems.insert(n, item); } |