summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp145
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
@@ -16,2 +16,3 @@
16#include <qlabel.h> 16#include <qlabel.h>
17#include <qfile.h>
17#include <qlistview.h> 18#include <qlistview.h>
@@ -29,7 +30,8 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
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
@@ -40,21 +42,3 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
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) ),
@@ -63,10 +47,2 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
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
@@ -90,7 +66,2 @@ void MainWindow::makeMenu()
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 );
@@ -125,9 +96,10 @@ void MainWindow::makeMenu()
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
@@ -318,41 +290,2 @@ void MainWindow::showSettingsDst()
318 290
319
320void 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
343void MainWindow::toggleActivePackage()
344{
345 activePackage->toggleProcess();
346 if ( details ) details->close();
347}
348
349void 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
358void MainWindow::sectionShow(bool b) 291void MainWindow::sectionShow(bool b)
@@ -391,37 +324,25 @@ void MainWindow::rotateUpdateIcon()
391 324
392void 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
410void 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
418void MainWindow::stopTimer( QListViewItem* ) 326void 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
424void MainWindow::setDocument(const QString &fileName) 337void 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}
@@ -431,5 +352,5 @@ void MainWindow::receive(const QCString &msg, const QByteArray &arg)
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 }