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 @@ -15,4 +15,5 @@ #include <qstring.h> #include <qlabel.h> +#include <qfile.h> #include <qlistview.h> #include <qtextview.h> @@ -28,9 +29,10 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : QMainWindow( parent, name, f ) { - setCaption( tr("Package Manager") ); + settings = new PackageManagerSettings(this,0,TRUE); + listViewPackages = new PackageListView( this,"listViewPackages",settings ); + ipkg = new PmIpkg( settings, this ); - listViewPackages = new QListView( this,0,0 ); - listViewPackages->setSelectionMode(QListView::NoSelection); setCentralWidget( listViewPackages ); + setCaption( tr("Package Manager") ); channel = new QCopChannel( "QPE/Application/oipkg", this ); @@ -39,35 +41,9 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : makeMenu(); -#ifdef NEWLAYOUT - listViewPackages->addColumn( tr("Package") ); - listViewPackages->setRootIsDecorated( true ); -#endif -#ifndef NEWLAYOUT - QFontMetrics fm = fontMetrics(); - int wlw = width()*2; - int w0 = fm.width(tr("Package"))+30; - // int w0 = fm.width(tr("Package"))+30; - int w2 = fm.width("00000")+4; - int w1 = wlw-w2-w0-24; - listViewPackages->addColumn( tr("Package"), w0 ); - listViewPackages->addColumn( tr("Description"), w1 ); - listViewPackages->addColumn( tr("Size"), w2 ); - listViewPackages->setColumnWidthMode(0,QListView::Manual); - listViewPackages->setColumnWidthMode(1,QListView::Manual); - listViewPackages->setColumnWidthMode(2,QListView::Manual); - listViewPackages->setSelectionMode( QListView::Multi ); -#endif + connect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); connect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); - connect( listViewPackages, SIGNAL( pressed( QListViewItem* ) ), - this, SLOT( setCurrent( QListViewItem* ) ) ); - connect( listViewPackages, SIGNAL( clicked( QListViewItem* ) ), - this, SLOT( stopTimer( QListViewItem* ) ) ); - - popupMenu = new QPopupMenu( this ); - - settings = new PackageManagerSettings(this,0,TRUE); ipkg = new PmIpkg( settings, this ); @@ -89,9 +65,4 @@ void MainWindow::makeMenu() // QPopupMenu *sectMenu = new QPopupMenu( menuBar ); - popupMenu = new QPopupMenu( this ); - destsMenu = new QPopupMenu( popupMenu ); - popupTimer = new QTimer( this ); - connect( popupTimer, SIGNAL(timeout()), this, SLOT(showPopup()) ); - setToolBarsMovable( false ); toolBar->setHorizontalStretchable( true ); @@ -124,11 +95,12 @@ void MainWindow::makeMenu() updateAction->addTo( srvMenu ); - detailsAction = new QAction( tr( "Details" ), - Resource::loadIconSet( "find" ), - QString::null, 0, this, 0 ); - connect( detailsAction, SIGNAL( activated() ), - this , SLOT( showDetails() ) ); - detailsAction->addTo( toolBar ); - detailsAction->addTo( srvMenu ); +// would we use for find +// detailsAction = new QAction( tr( "Details" ), +// Resource::loadIconSet( "find" ), +// QString::null, 0, this, 0 ); +// connect( detailsAction, SIGNAL( activated() ), +// this , SLOT( showDetails() ) ); +// detailsAction->addTo( toolBar ); +// detailsAction->addTo( srvMenu ); QAction *cfgact; @@ -317,43 +289,4 @@ void MainWindow::showSettingsDst() } - -void MainWindow::showDetails() -{ - if ( details ) - { - details = new PackageDetails( this ); - connect( details->install, SIGNAL(clicked()), SLOT( toggleActivePackage() ) ); - connect( details->remove, SIGNAL(clicked()), SLOT( toggleActivePackage() ) ); - connect( details->ignore, SIGNAL(clicked()), details, SLOT(close())); - details->description->setTextFormat(RichText); - } - if ( !activePackage ) - { - details->description->setText(tr("no package selected")); - details->description->setText(tr("errmm...<br>...not working?")); - }else{ - details->setCaption("Package: " + activePackage->name()); - details->description->setText(activePackage->details() ); - details->install->setEnabled(!activePackage->installed()); - details->remove->setEnabled(activePackage->installed()); - } - details->showMaximized(); -} - -void MainWindow::toggleActivePackage() -{ - activePackage->toggleProcess(); - if ( details ) details->close(); -} - -void MainWindow::setCurrent( QListViewItem* p ) -{ - if ( !p ) return; - activePackageListItem = (PackageListItem*)p; - activePackage = activePackageListItem->getPackage(); - pvDebug(5, "start timer"); - popupTimer->start( 750, true ); -} - void MainWindow::sectionShow(bool b) { @@ -390,39 +323,27 @@ void MainWindow::rotateUpdateIcon() } -void MainWindow::showPopup() -{ - popupMenu->clear(); - destsMenu->clear(); - - QAction *popupAction; - popupMenu->insertItem( tr("Install to"), destsMenu ); - QStringList dests = settings->getDestinationNames(); - for (uint i = 0; i < dests.count(); i++ ) - { - popupAction = new QAction( dests[i], QString::null, 0, this, 0 ); - popupAction->addTo( destsMenu ); - } - connect( destsMenu, SIGNAL( activated( int ) ), - this, SLOT( changePackageDest( int ) ) ); - popupMenu->popup( QCursor::pos() ); -} - -void MainWindow::changePackageDest( int i ) -{ - activePackage->setDest( destsMenu->text(i) ); - activePackage->setOn(); - activePackage->setLink( settings->createLinks() ); - activePackageListItem->displayDetails(); -} -void MainWindow::stopTimer( QListViewItem* ) +void MainWindow::setDocument(const QString &fileName) { - pvDebug( 5, "stop timer" ); - popupTimer->stop(); + installFile(fileName); + // ##### If we looked in the list of files, we could send out accurate + // ##### messages. But we don't bother yet, and just do an "all". + QCopEnvelope e("QPE/System", "linkChanged(QString)"); + QString lf = QString::null; + e << lf; + displayList(); } -void MainWindow::setDocument(const QString &fileName) +void MainWindow::installFile(const QString &fileName) { + pvDebug(3, "MainWindow::installFile "+fileName); + if ( !QFile::exists( fileName ) ) return; ipkg->installFile( fileName ); + // ##### If we looked in the list of files, we could send out accurate + // ##### messages. But we don't bother yet, and just do an "all". + QCopEnvelope e("QPE/System", "linkChanged(QString)"); + QString lf = QString::null; + e << lf; + displayList(); } @@ -430,7 +351,7 @@ void MainWindow::receive(const QCString &msg, const QByteArray &arg) { pvDebug(3, "QCop "+msg); - if ( msg == "setDocument(QString)" ) + if ( msg == "installFile(QString)" ) { - setDocument( QString(arg) ); + installFile( QString(arg) ); } }
\ No newline at end of file |