author | tille <tille> | 2002-11-10 22:50:50 (UTC) |
---|---|---|
committer | tille <tille> | 2002-11-10 22:50:50 (UTC) |
commit | 9337c912158da3ad2fcda7ee1120c9357faddf8b (patch) (unidiff) | |
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) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/packagelistview.cpp | 141 |
1 files changed, 53 insertions, 88 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 | |||
@@ -13,23 +13,22 @@ | |||
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 | ||
18 | PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s) | 19 | PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s) |
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") ); |
27 | setRootIsDecorated( true ); | 26 | setRootIsDecorated( true ); |
28 | 27 | ||
29 | connect( popupTimer, SIGNAL(timeout()), | 28 | connect( popupTimer, SIGNAL(timeout()), |
30 | this, SLOT(showPopup()) ); | 29 | this, SLOT(showPopup()) ); |
31 | connect( this, SIGNAL( pressed( QListViewItem* ) ), | 30 | connect( this, SIGNAL( pressed( QListViewItem* ) ), |
32 | this, SLOT( setCurrent( QListViewItem* ) ) ); | 31 | this, SLOT( setCurrent( QListViewItem* ) ) ); |
33 | connect( this, SIGNAL( clicked( QListViewItem* ) ), | 32 | connect( this, SIGNAL( clicked( QListViewItem* ) ), |
34 | this, SLOT( stopTimer( QListViewItem* ) ) ); | 33 | this, SLOT( stopTimer( QListViewItem* ) ) ); |
35 | 34 | ||
@@ -42,20 +41,26 @@ PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettin | |||
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; | 61 | // } |
55 | // } | 62 | |
56 | 63 | ||
57 | return; | 64 | qDebug("PackageListView::setCurrent popupTimer->start"); |
58 | } | ||
59 | popupTimer->start( 750, true ); | ||
60 | } | 65 | } |
61 | 66 | ||
@@ -63,84 +68,44 @@ void PackageListView::setCurrent( QListViewItem* p ) | |||
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* ) |
99 | { | 78 | { |
100 | popupTimer->stop(); | 79 | popupTimer->stop(); |
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() ) { |
128 | packlist = list.current(); | 93 | packlist = list.current(); |
129 | rootItem = rootItems.find( list.currentKey() ); | 94 | rootItem = rootItems.find( list.currentKey() ); |
130 | //rootItem->clear(); | 95 | //rootItem->clear(); |
131 | it=rootItem->firstChild(); | 96 | it=rootItem->firstChild(); |
132 | while ( it ) | 97 | while ( it ) |
133 | { | 98 | { |
134 | itdel = it; | 99 | itdel = it; |
135 | it = it->nextSibling(); | 100 | it = it->nextSibling(); |
136 | delete itdel; | 101 | delete itdel; |
137 | } | 102 | } |
138 | pack = packlist->first(); | 103 | pack = packlist->first(); |
139 | while( pack ) | 104 | while( pack ) |
140 | { | 105 | { |
141 | item = new PackageListItem( rootItem, pack, settings ); | 106 | item = new PackageListItem( rootItem, pack, settings ); |
142 | pack = packlist->next(); | 107 | pack = packlist->next(); |
143 | } | 108 | } |
144 | ++list; | 109 | ++list; |
145 | } | 110 | } |
146 | } | 111 | } |
@@ -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 | } |