Diffstat (limited to 'noncore/unsupported/oipkg/mainwindow.cpp') (more/less context) (ignore 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 | |||
@@ -14,6 +14,7 @@ | |||
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> |
@@ -27,48 +28,23 @@ | |||
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 ); |
@@ -88,11 +64,6 @@ void MainWindow::makeMenu() | |||
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 ); |
@@ -123,13 +94,14 @@ void MainWindow::makeMenu() | |||
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 | ||
@@ -316,45 +288,6 @@ void MainWindow::showSettingsDst() | |||
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(); |
@@ -389,48 +322,36 @@ void MainWindow::rotateUpdateIcon() | |||
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 |