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 | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <qpopupmenu.h> | 12 | #include <qpopupmenu.h> |
13 | #include <qaction.h> | 13 | #include <qaction.h> |
14 | 14 | ||
15 | #include "listviewitemoipkg.h" | ||
15 | #include "packagelistitem.h" | 16 | #include "packagelistitem.h" |
16 | #include "pksettings.h" | 17 | #include "pksettings.h" |
17 | 18 | ||
@@ -19,8 +20,6 @@ PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettin | |||
19 | : QListView(p,n) | 20 | : QListView(p,n) |
20 | { | 21 | { |
21 | settings = s; | 22 | settings = s; |
22 | popupMenu = new QPopupMenu( this ); | ||
23 | destsMenu = new QPopupMenu( popupMenu ); | ||
24 | popupTimer = new QTimer( this ); | 23 | popupTimer = new QTimer( this ); |
25 | setSelectionMode(QListView::NoSelection); | 24 | setSelectionMode(QListView::NoSelection); |
26 | addColumn( tr("Package") ); | 25 | addColumn( tr("Package") ); |
@@ -41,58 +40,38 @@ PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettin | |||
41 | 40 | ||
42 | void PackageListView::setCurrent( QListViewItem* p ) | 41 | void PackageListView::setCurrent( QListViewItem* p ) |
43 | { | 42 | { |
44 | if ( !p ) return; | 43 | qDebug("PackageListView::setCurrent "); |
45 | activePackageListItem = (PackageListItem*)p; | 44 | activeItem = (ListViewItemOipkg*)p; |
46 | activePackage = activePackageListItem->getPackage(); | 45 | |
47 | if (!activePackage) | 46 | if ( activeItem != 0 ) popupTimer->start( 750, true ); |
48 | { | 47 | |
49 | // QDictIterator<QCheckListItem> it( rootItems ); | 48 | // if ( activeItem->getType() != ListViewItemOipkg::Package ){ |
50 | // while ( it.current() ) | 49 | // qDebug("PackageListView::setCurrent !p "); |
50 | // activePackage = 0; | ||
51 | // activePackageListItem = 0; | ||
52 | // qDebug("PackageListView::setCurrent returning "); | ||
53 | // return; | ||
54 | // }; | ||
55 | // activePackageListItem = (PackageListItem*)p; | ||
56 | // activePackage = activePackageListItem->getPackage(); | ||
57 | // if (activePackage == 0 ) | ||
51 | // { | 58 | // { |
52 | // if ( it.current()==p ) | 59 | // qDebug("PackageListView::setCurrent if (!activePackage)"); |
53 | // pvDebug(2,"current item"); | 60 | // return; |
54 | // ++it; | ||
55 | // } | 61 | // } |
56 | 62 | ||
57 | return; | 63 | |
58 | } | 64 | qDebug("PackageListView::setCurrent popupTimer->start"); |
59 | popupTimer->start( 750, true ); | ||
60 | } | 65 | } |
61 | 66 | ||
62 | 67 | ||
63 | void PackageListView::showPopup() | 68 | void PackageListView::showPopup() |
64 | { | 69 | { |
65 | popupMenu->clear(); | 70 | qDebug("PackageListView::showPopup"); |
66 | destsMenu->clear(); | 71 | QPopupMenu *popup = activeItem->getPopupMenu(); |
67 | 72 | if (popup == 0) return; | |
68 | QAction *popupAction; | 73 | popup->popup( QCursor::pos() ); |
69 | if ( !activePackage->installed() ) | 74 | qDebug("PackageListView::showPopup"); |
70 | { | ||
71 | popupMenu->insertItem( tr("Install to"), destsMenu ); | ||
72 | QStringList dests = settings->getDestinationNames(); | ||
73 | QString ad = settings->getDestinationName(); | ||
74 | for (uint i = 0; i < dests.count(); i++ ) | ||
75 | { | ||
76 | popupAction = new QAction( dests[i], QString::null, 0, this, 0 ); | ||
77 | popupAction->addTo( destsMenu ); | ||
78 | if ( dests[i] == ad && activePackage->toInstall() ) | ||
79 | { | ||
80 | popupAction->setToggleAction( true ); | ||
81 | popupAction->setOn(true); | ||
82 | }; | ||
83 | } | ||
84 | connect( destsMenu, SIGNAL( activated( int ) ), | ||
85 | this, SLOT( changePackageDest( int ) ) ); | ||
86 | }else{ | ||
87 | popupAction = new QAction( tr("Remove"),QString::null, 0, this, 0 ); | ||
88 | popupAction->addTo( popupMenu ); | ||
89 | connect( popupAction, SIGNAL( activated() ), | ||
90 | this , SLOT( toggleProcess() ) ); | ||
91 | popupAction = new QAction( tr("Reinstall"),QString::null, 0, this, 0 ); | ||
92 | popupAction->addTo( popupMenu ); | ||
93 | popupAction->setEnabled( false ); | ||
94 | } | ||
95 | popupMenu->popup( QCursor::pos() ); | ||
96 | } | 75 | } |
97 | 76 | ||
98 | void PackageListView::stopTimer( QListViewItem* ) | 77 | void PackageListView::stopTimer( QListViewItem* ) |
@@ -101,27 +80,13 @@ void PackageListView::stopTimer( QListViewItem* ) | |||
101 | } | 80 | } |
102 | 81 | ||
103 | 82 | ||
104 | void PackageListView::changePackageDest( int i ) | ||
105 | { | ||
106 | activePackage->setDest( destsMenu->text(i) ); | ||
107 | activePackage->setOn(); | ||
108 | activePackage->setLink( settings->createLinks() ); | ||
109 | activePackageListItem->displayDetails(); | ||
110 | } | ||
111 | |||
112 | void PackageListView::toggleProcess() | ||
113 | { | ||
114 | activePackage->toggleProcess() ; | ||
115 | activePackageListItem->displayDetails(); | ||
116 | } | ||
117 | |||
118 | void PackageListView::display() | 83 | void PackageListView::display() |
119 | { | 84 | { |
120 | QDictIterator<PackageList> list( PackageLists ); | 85 | QDictIterator<PackageList> list( PackageLists ); |
121 | PackageList *packlist; | 86 | PackageList *packlist; |
122 | Package *pack; | 87 | OipkgPackage *pack; |
123 | PackageListItem *item; | 88 | PackageListItem *item; |
124 | QCheckListItem *rootItem; | 89 | ListViewItemOipkg *rootItem; |
125 | QListViewItem* it; | 90 | QListViewItem* it; |
126 | QListViewItem* itdel; | 91 | QListViewItem* itdel; |
127 | while ( list.current() ) { | 92 | while ( list.current() ) { |
@@ -148,6 +113,6 @@ void PackageListView::display() | |||
148 | void PackageListView::addList( QString n, PackageList* pl) | 113 | void PackageListView::addList( QString n, PackageList* pl) |
149 | { | 114 | { |
150 | PackageLists.insert(n, pl); | 115 | PackageLists.insert(n, pl); |
151 | QCheckListItem *item = new QCheckListItem(this,n); | 116 | ListViewItemOipkg *item = new ListViewItemOipkg(this,n,ListViewItemOipkg::Feed); |
152 | rootItems.insert(n, item); | 117 | rootItems.insert(n, item); |
153 | } | 118 | } |