author | tille <tille> | 2002-05-01 22:19:05 (UTC) |
---|---|---|
committer | tille <tille> | 2002-05-01 22:19:05 (UTC) |
commit | 89b16f3378b783be9058852528e066dcadea953d (patch) (unidiff) | |
tree | a66ab1808d96f326831bbf46e36a4fd7a214e215 | |
parent | 82ff405e40d4aa6cad8b5583f9d7e5b89a78f261 (diff) | |
download | opie-89b16f3378b783be9058852528e066dcadea953d.zip opie-89b16f3378b783be9058852528e066dcadea953d.tar.gz opie-89b16f3378b783be9058852528e066dcadea953d.tar.bz2 |
added popupmenu for installed packages
-rw-r--r-- | noncore/unsupported/oipkg/packagelistview.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/noncore/unsupported/oipkg/packagelistview.cpp b/noncore/unsupported/oipkg/packagelistview.cpp index 36d081b..26b1ce7 100644 --- a/noncore/unsupported/oipkg/packagelistview.cpp +++ b/noncore/unsupported/oipkg/packagelistview.cpp | |||
@@ -3,87 +3,94 @@ | |||
3 | #include <qpopupmenu.h> | 3 | #include <qpopupmenu.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | 5 | ||
6 | #include "packagelistitem.h" | 6 | #include "packagelistitem.h" |
7 | #include "pksettings.h" | 7 | #include "pksettings.h" |
8 | 8 | ||
9 | PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s) | 9 | PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s) |
10 | : QListView(p,n) | 10 | : QListView(p,n) |
11 | { | 11 | { |
12 | settings = s; | 12 | settings = s; |
13 | popupMenu = new QPopupMenu( this ); | 13 | popupMenu = new QPopupMenu( this ); |
14 | destsMenu = new QPopupMenu( popupMenu ); | 14 | destsMenu = new QPopupMenu( popupMenu ); |
15 | popupTimer = new QTimer( this ); | 15 | popupTimer = new QTimer( this ); |
16 | setSelectionMode(QListView::NoSelection); | 16 | setSelectionMode(QListView::NoSelection); |
17 | addColumn( tr("Package") ); | 17 | addColumn( tr("Package") ); |
18 | setRootIsDecorated( true ); | 18 | setRootIsDecorated( true ); |
19 | 19 | ||
20 | connect( popupTimer, SIGNAL(timeout()), | 20 | connect( popupTimer, SIGNAL(timeout()), |
21 | this, SLOT(showPopup()) ); | 21 | this, SLOT(showPopup()) ); |
22 | connect( this, SIGNAL( pressed( QListViewItem* ) ), | 22 | connect( this, SIGNAL( pressed( QListViewItem* ) ), |
23 | this, SLOT( setCurrent( QListViewItem* ) ) ); | 23 | this, SLOT( setCurrent( QListViewItem* ) ) ); |
24 | connect( this, SIGNAL( clicked( QListViewItem* ) ), | 24 | connect( this, SIGNAL( clicked( QListViewItem* ) ), |
25 | this, SLOT( stopTimer( QListViewItem* ) ) ); | 25 | this, SLOT( stopTimer( QListViewItem* ) ) ); |
26 | 26 | ||
27 | } | 27 | } |
28 | 28 | ||
29 | //PackageListView::~PackageListView() | 29 | //PackageListView::~PackageListView() |
30 | //{ | 30 | //{ |
31 | //} | 31 | //} |
32 | 32 | ||
33 | void PackageListView::setCurrent( QListViewItem* p ) | 33 | void PackageListView::setCurrent( QListViewItem* p ) |
34 | { | 34 | { |
35 | if ( !p ) return; | 35 | if ( !p ) return; |
36 | activePackageListItem = (PackageListItem*)p; | 36 | activePackageListItem = (PackageListItem*)p; |
37 | activePackage = activePackageListItem->getPackage(); | 37 | activePackage = activePackageListItem->getPackage(); |
38 | if (!activePackage) return; | 38 | if (!activePackage) return; |
39 | popupTimer->start( 750, true ); | 39 | popupTimer->start( 750, true ); |
40 | } | 40 | } |
41 | 41 | ||
42 | 42 | ||
43 | void PackageListView::showPopup() | 43 | void PackageListView::showPopup() |
44 | { | 44 | { |
45 | popupMenu->clear(); | 45 | popupMenu->clear(); |
46 | destsMenu->clear(); | 46 | destsMenu->clear(); |
47 | 47 | ||
48 | QAction *popupAction; | 48 | QAction *popupAction; |
49 | if ( !activePackage->installed() ) | 49 | if ( !activePackage->installed() ) |
50 | { | 50 | { |
51 | popupMenu->insertItem( QObject::tr("Install to"), destsMenu ); | 51 | popupMenu->insertItem( QObject::tr("Install to"), destsMenu ); |
52 | QStringList dests = settings->getDestinationNames(); | 52 | QStringList dests = settings->getDestinationNames(); |
53 | QString ad = settings->getDestinationName(); | 53 | QString ad = settings->getDestinationName(); |
54 | for (uint i = 0; i < dests.count(); i++ ) | 54 | for (uint i = 0; i < dests.count(); i++ ) |
55 | { | 55 | { |
56 | popupAction = new QAction( dests[i], QString::null, 0, this, 0 ); | 56 | popupAction = new QAction( dests[i], QString::null, 0, this, 0 ); |
57 | popupAction->addTo( destsMenu ); | 57 | popupAction->addTo( destsMenu ); |
58 | if ( dests[i] == ad && activePackage->toInstall() ) | 58 | if ( dests[i] == ad && activePackage->toInstall() ) |
59 | { | 59 | { |
60 | popupAction->setToggleAction( true ); | 60 | popupAction->setToggleAction( true ); |
61 | popupAction->setOn(true); | 61 | popupAction->setOn(true); |
62 | }; | 62 | }; |
63 | } | 63 | } |
64 | connect( destsMenu, SIGNAL( activated( int ) ), | 64 | connect( destsMenu, SIGNAL( activated( int ) ), |
65 | this, SLOT( changePackageDest( int ) ) ); | 65 | this, SLOT( changePackageDest( int ) ) ); |
66 | }else{ | 66 | }else{ |
67 | popupAction = new QAction( QObject::tr("Remove"),QString::null, 0, this, 0 ); | ||
68 | popupAction->addTo( popupMenu ); | ||
69 | connect( popupAction, SIGNAL( activated() ), | ||
70 | this , SLOT( toggleProcess() ) ); | ||
71 | popupAction = new QAction( QObject::tr("Reinstall"),QString::null, 0, this, 0 ); | ||
72 | popupAction->addTo( popupMenu ); | ||
73 | popupAction->setEnabled( false ); | ||
67 | } | 74 | } |
68 | popupMenu->popup( QCursor::pos() ); | 75 | popupMenu->popup( QCursor::pos() ); |
69 | } | 76 | } |
70 | 77 | ||
71 | void PackageListView::stopTimer( QListViewItem* ) | 78 | void PackageListView::stopTimer( QListViewItem* ) |
72 | { | 79 | { |
73 | popupTimer->stop(); | 80 | popupTimer->stop(); |
74 | } | 81 | } |
75 | 82 | ||
76 | 83 | ||
77 | void PackageListView::changePackageDest( int i ) | 84 | void PackageListView::changePackageDest( int i ) |
78 | { | 85 | { |
79 | activePackage->setDest( destsMenu->text(i) ); | 86 | activePackage->setDest( destsMenu->text(i) ); |
80 | activePackage->setOn(); | 87 | activePackage->setOn(); |
81 | activePackage->setLink( settings->createLinks() ); | 88 | activePackage->setLink( settings->createLinks() ); |
82 | activePackageListItem->displayDetails(); | 89 | activePackageListItem->displayDetails(); |
83 | } | 90 | } |
84 | 91 | ||
85 | void PackageListView::toggleProcess() | 92 | void PackageListView::toggleProcess() |
86 | { | 93 | { |
87 | activePackage->toggleProcess() ; | 94 | activePackage->toggleProcess() ; |
88 | activePackageListItem->displayDetails(); | 95 | activePackageListItem->displayDetails(); |
89 | } | 96 | } |