author | tille <tille> | 2002-04-27 21:02:53 (UTC) |
---|---|---|
committer | tille <tille> | 2002-04-27 21:02:53 (UTC) |
commit | 69e271e44d23befc74a96a98708ddb6ec754a4b6 (patch) (unidiff) | |
tree | 6f8300d8858d2c7659eb90066b58b302a2863e43 /noncore/unsupported/oipkg/mainwindow.cpp | |
parent | acdc33336307e48ac7089b146006fe7b36e321a5 (diff) | |
download | opie-69e271e44d23befc74a96a98708ddb6ec754a4b6.zip opie-69e271e44d23befc74a96a98708ddb6ec754a4b6.tar.gz opie-69e271e44d23befc74a96a98708ddb6ec754a4b6.tar.bz2 |
setDocument working and some changes in install gui
Diffstat (limited to 'noncore/unsupported/oipkg/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 145 |
1 files changed, 33 insertions, 112 deletions
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index e3abf36..6bf9a7a 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp | |||
@@ -11,12 +11,13 @@ | |||
11 | #include <qaction.h> | 11 | #include <qaction.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qpopupmenu.h> | 13 | #include <qpopupmenu.h> |
14 | #include <qtoolbutton.h> | 14 | #include <qtoolbutton.h> |
15 | #include <qstring.h> | 15 | #include <qstring.h> |
16 | #include <qlabel.h> | 16 | #include <qlabel.h> |
17 | #include <qfile.h> | ||
17 | #include <qlistview.h> | 18 | #include <qlistview.h> |
18 | #include <qtextview.h> | 19 | #include <qtextview.h> |
19 | #include <qlineedit.h> | 20 | #include <qlineedit.h> |
20 | #include <qtabwidget.h> | 21 | #include <qtabwidget.h> |
21 | #include <qcombobox.h> | 22 | #include <qcombobox.h> |
22 | #include <qlayout.h> | 23 | #include <qlayout.h> |
@@ -24,54 +25,29 @@ | |||
24 | #include "pksettingsbase.h" | 25 | #include "pksettingsbase.h" |
25 | #include "packagelistitem.h" | 26 | #include "packagelistitem.h" |
26 | 27 | ||
27 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | 28 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : |
28 | QMainWindow( parent, name, f ) | 29 | QMainWindow( parent, name, f ) |
29 | { | 30 | { |
30 | setCaption( tr("Package Manager") ); | 31 | settings = new PackageManagerSettings(this,0,TRUE); |
32 | listViewPackages = new PackageListView( this,"listViewPackages",settings ); | ||
33 | ipkg = new PmIpkg( settings, this ); | ||
31 | 34 | ||
32 | listViewPackages = new QListView( this,0,0 ); | ||
33 | listViewPackages->setSelectionMode(QListView::NoSelection); | ||
34 | setCentralWidget( listViewPackages ); | 35 | setCentralWidget( listViewPackages ); |
36 | setCaption( tr("Package Manager") ); | ||
35 | 37 | ||
36 | channel = new QCopChannel( "QPE/Application/oipkg", this ); | 38 | channel = new QCopChannel( "QPE/Application/oipkg", this ); |
37 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 39 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
38 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 40 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
39 | 41 | ||
40 | makeMenu(); | 42 | makeMenu(); |
41 | #ifdef NEWLAYOUT | 43 | |
42 | listViewPackages->addColumn( tr("Package") ); | ||
43 | listViewPackages->setRootIsDecorated( true ); | ||
44 | #endif | ||
45 | #ifndef NEWLAYOUT | ||
46 | QFontMetrics fm = fontMetrics(); | ||
47 | int wlw = width()*2; | ||
48 | int w0 = fm.width(tr("Package"))+30; | ||
49 | // int w0 = fm.width(tr("Package"))+30; | ||
50 | int w2 = fm.width("00000")+4; | ||
51 | int w1 = wlw-w2-w0-24; | ||
52 | listViewPackages->addColumn( tr("Package"), w0 ); | ||
53 | listViewPackages->addColumn( tr("Description"), w1 ); | ||
54 | listViewPackages->addColumn( tr("Size"), w2 ); | ||
55 | listViewPackages->setColumnWidthMode(0,QListView::Manual); | ||
56 | listViewPackages->setColumnWidthMode(1,QListView::Manual); | ||
57 | listViewPackages->setColumnWidthMode(2,QListView::Manual); | ||
58 | listViewPackages->setSelectionMode( QListView::Multi ); | ||
59 | #endif | ||
60 | connect( section, SIGNAL( activated(int) ), | 44 | connect( section, SIGNAL( activated(int) ), |
61 | this, SLOT( sectionChanged() ) ); | 45 | this, SLOT( sectionChanged() ) ); |
62 | connect( subsection, SIGNAL(activated(int) ), | 46 | connect( subsection, SIGNAL(activated(int) ), |
63 | this, SLOT( subSectionChanged() ) ); | 47 | this, SLOT( subSectionChanged() ) ); |
64 | connect( listViewPackages, SIGNAL( pressed( QListViewItem* ) ), | ||
65 | this, SLOT( setCurrent( QListViewItem* ) ) ); | ||
66 | connect( listViewPackages, SIGNAL( clicked( QListViewItem* ) ), | ||
67 | this, SLOT( stopTimer( QListViewItem* ) ) ); | ||
68 | |||
69 | popupMenu = new QPopupMenu( this ); | ||
70 | |||
71 | settings = new PackageManagerSettings(this,0,TRUE); | ||
72 | 48 | ||
73 | ipkg = new PmIpkg( settings, this ); | 49 | ipkg = new PmIpkg( settings, this ); |
74 | packageList.setSettings( settings ); | 50 | packageList.setSettings( settings ); |
75 | getList(); | 51 | getList(); |
76 | setSections(); | 52 | setSections(); |
77 | setSubSections(); | 53 | setSubSections(); |
@@ -85,17 +61,12 @@ void MainWindow::makeMenu() | |||
85 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); | 61 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); |
86 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); | 62 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); |
87 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | 63 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); |
88 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | 64 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); |
89 | // QPopupMenu *sectMenu = new QPopupMenu( menuBar ); | 65 | // QPopupMenu *sectMenu = new QPopupMenu( menuBar ); |
90 | 66 | ||
91 | popupMenu = new QPopupMenu( this ); | ||
92 | destsMenu = new QPopupMenu( popupMenu ); | ||
93 | popupTimer = new QTimer( this ); | ||
94 | connect( popupTimer, SIGNAL(timeout()), this, SLOT(showPopup()) ); | ||
95 | |||
96 | setToolBarsMovable( false ); | 67 | setToolBarsMovable( false ); |
97 | toolBar->setHorizontalStretchable( true ); | 68 | toolBar->setHorizontalStretchable( true ); |
98 | menuBar->insertItem( tr( "Package" ), srvMenu ); | 69 | menuBar->insertItem( tr( "Package" ), srvMenu ); |
99 | menuBar->insertItem( tr( "View" ), viewMenu ); | 70 | menuBar->insertItem( tr( "View" ), viewMenu ); |
100 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 71 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
101 | // menuBar->insertItem( tr( "Sections" ), sectMenu ); | 72 | // menuBar->insertItem( tr( "Sections" ), sectMenu ); |
@@ -120,19 +91,20 @@ void MainWindow::makeMenu() | |||
120 | QString::null, 0, this, 0 ); | 91 | QString::null, 0, this, 0 ); |
121 | connect( updateAction, SIGNAL( activated() ), | 92 | connect( updateAction, SIGNAL( activated() ), |
122 | this , SLOT( updateList() ) ); | 93 | this , SLOT( updateList() ) ); |
123 | updateAction->addTo( toolBar ); | 94 | updateAction->addTo( toolBar ); |
124 | updateAction->addTo( srvMenu ); | 95 | updateAction->addTo( srvMenu ); |
125 | 96 | ||
126 | detailsAction = new QAction( tr( "Details" ), | 97 | // would we use for find |
127 | Resource::loadIconSet( "find" ), | 98 | // detailsAction = new QAction( tr( "Details" ), |
128 | QString::null, 0, this, 0 ); | 99 | // Resource::loadIconSet( "find" ), |
129 | connect( detailsAction, SIGNAL( activated() ), | 100 | // QString::null, 0, this, 0 ); |
130 | this , SLOT( showDetails() ) ); | 101 | // connect( detailsAction, SIGNAL( activated() ), |
131 | detailsAction->addTo( toolBar ); | 102 | // this , SLOT( showDetails() ) ); |
132 | detailsAction->addTo( srvMenu ); | 103 | // detailsAction->addTo( toolBar ); |
104 | // detailsAction->addTo( srvMenu ); | ||
133 | 105 | ||
134 | QAction *cfgact; | 106 | QAction *cfgact; |
135 | 107 | ||
136 | cfgact = new QAction( tr( "Setups" ), | 108 | cfgact = new QAction( tr( "Setups" ), |
137 | // Resource::loadIconSet( "" ), | 109 | // Resource::loadIconSet( "" ), |
138 | QString::null, 0, this, 0 ); | 110 | QString::null, 0, this, 0 ); |
@@ -313,51 +285,12 @@ void MainWindow::showSettingsSrv() | |||
313 | void MainWindow::showSettingsDst() | 285 | void MainWindow::showSettingsDst() |
314 | { | 286 | { |
315 | if ( settings->showDialog( 2 ) ) | 287 | if ( settings->showDialog( 2 ) ) |
316 | updateList(); | 288 | updateList(); |
317 | } | 289 | } |
318 | 290 | ||
319 | |||
320 | void MainWindow::showDetails() | ||
321 | { | ||
322 | if ( details ) | ||
323 | { | ||
324 | details = new PackageDetails( this ); | ||
325 | connect( details->install, SIGNAL(clicked()), SLOT( toggleActivePackage() ) ); | ||
326 | connect( details->remove, SIGNAL(clicked()), SLOT( toggleActivePackage() ) ); | ||
327 | connect( details->ignore, SIGNAL(clicked()), details, SLOT(close())); | ||
328 | details->description->setTextFormat(RichText); | ||
329 | } | ||
330 | if ( !activePackage ) | ||
331 | { | ||
332 | details->description->setText(tr("no package selected")); | ||
333 | details->description->setText(tr("errmm...<br>...not working?")); | ||
334 | }else{ | ||
335 | details->setCaption("Package: " + activePackage->name()); | ||
336 | details->description->setText(activePackage->details() ); | ||
337 | details->install->setEnabled(!activePackage->installed()); | ||
338 | details->remove->setEnabled(activePackage->installed()); | ||
339 | } | ||
340 | details->showMaximized(); | ||
341 | } | ||
342 | |||
343 | void MainWindow::toggleActivePackage() | ||
344 | { | ||
345 | activePackage->toggleProcess(); | ||
346 | if ( details ) details->close(); | ||
347 | } | ||
348 | |||
349 | void MainWindow::setCurrent( QListViewItem* p ) | ||
350 | { | ||
351 | if ( !p ) return; | ||
352 | activePackageListItem = (PackageListItem*)p; | ||
353 | activePackage = activePackageListItem->getPackage(); | ||
354 | pvDebug(5, "start timer"); | ||
355 | popupTimer->start( 750, true ); | ||
356 | } | ||
357 | |||
358 | void MainWindow::sectionShow(bool b) | 291 | void MainWindow::sectionShow(bool b) |
359 | { | 292 | { |
360 | if (b) sectionBar->show(); | 293 | if (b) sectionBar->show(); |
361 | else sectionBar->hide(); | 294 | else sectionBar->hide(); |
362 | sectionAction->setOn( b ); | 295 | sectionAction->setOn( b ); |
363 | } | 296 | } |
@@ -386,51 +319,39 @@ void MainWindow::rotateUpdateIcon() | |||
386 | updateAction->setIconSet( Resource::loadIconSet( "oipkg/update" ) ); | 319 | updateAction->setIconSet( Resource::loadIconSet( "oipkg/update" ) ); |
387 | else | 320 | else |
388 | updateAction->setIconSet( Resource::loadIconSet( "oipkg/update2" ) ); | 321 | updateAction->setIconSet( Resource::loadIconSet( "oipkg/update2" ) ); |
389 | updateIcon = !updateIcon; | 322 | updateIcon = !updateIcon; |
390 | } | 323 | } |
391 | 324 | ||
392 | void MainWindow::showPopup() | ||
393 | { | ||
394 | popupMenu->clear(); | ||
395 | destsMenu->clear(); | ||
396 | |||
397 | QAction *popupAction; | ||
398 | popupMenu->insertItem( tr("Install to"), destsMenu ); | ||
399 | QStringList dests = settings->getDestinationNames(); | ||
400 | for (uint i = 0; i < dests.count(); i++ ) | ||
401 | { | ||
402 | popupAction = new QAction( dests[i], QString::null, 0, this, 0 ); | ||
403 | popupAction->addTo( destsMenu ); | ||
404 | } | ||
405 | connect( destsMenu, SIGNAL( activated( int ) ), | ||
406 | this, SLOT( changePackageDest( int ) ) ); | ||
407 | popupMenu->popup( QCursor::pos() ); | ||
408 | } | ||
409 | |||
410 | void MainWindow::changePackageDest( int i ) | ||
411 | { | ||
412 | activePackage->setDest( destsMenu->text(i) ); | ||
413 | activePackage->setOn(); | ||
414 | activePackage->setLink( settings->createLinks() ); | ||
415 | activePackageListItem->displayDetails(); | ||
416 | } | ||
417 | 325 | ||
418 | void MainWindow::stopTimer( QListViewItem* ) | 326 | void MainWindow::setDocument(const QString &fileName) |
419 | { | 327 | { |
420 | pvDebug( 5, "stop timer" ); | 328 | installFile(fileName); |
421 | popupTimer->stop(); | 329 | // ##### If we looked in the list of files, we could send out accurate |
330 | // ##### messages. But we don't bother yet, and just do an "all". | ||
331 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | ||
332 | QString lf = QString::null; | ||
333 | e << lf; | ||
334 | displayList(); | ||
422 | } | 335 | } |
423 | 336 | ||
424 | void MainWindow::setDocument(const QString &fileName) | 337 | void MainWindow::installFile(const QString &fileName) |
425 | { | 338 | { |
339 | pvDebug(3, "MainWindow::installFile "+fileName); | ||
340 | if ( !QFile::exists( fileName ) ) return; | ||
426 | ipkg->installFile( fileName ); | 341 | ipkg->installFile( fileName ); |
342 | // ##### If we looked in the list of files, we could send out accurate | ||
343 | // ##### messages. But we don't bother yet, and just do an "all". | ||
344 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | ||
345 | QString lf = QString::null; | ||
346 | e << lf; | ||
347 | displayList(); | ||
427 | } | 348 | } |
428 | 349 | ||
429 | void MainWindow::receive(const QCString &msg, const QByteArray &arg) | 350 | void MainWindow::receive(const QCString &msg, const QByteArray &arg) |
430 | { | 351 | { |
431 | pvDebug(3, "QCop "+msg); | 352 | pvDebug(3, "QCop "+msg); |
432 | if ( msg == "setDocument(QString)" ) | 353 | if ( msg == "installFile(QString)" ) |
433 | { | 354 | { |
434 | setDocument( QString(arg) ); | 355 | installFile( QString(arg) ); |
435 | } | 356 | } |
436 | } \ No newline at end of file | 357 | } \ No newline at end of file |