Diffstat (limited to 'noncore/settings/aqpkg/mainwin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index b00931e..5e03f11 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -1,107 +1,134 @@ /*************************************************************************** mainwin.cpp - description ------------------- begin : Mon Aug 26 13:32:30 BST 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <iostream> using namespace std; #include <qmenubar.h> -#include <qpopupmenu.h> #include <qmessagebox.h> +#include <qpopupmenu.h> +#include <qtimer.h> #include "mainwin.h" +#include "progresswidget.h" #include "datamgr.h" #include "networkpkgmgr.h" #include "settingsimpl.h" #include "helpwindow.h" #include "utils.h" #include "global.h" MainWindow :: MainWindow( QWidget *p, char *name ) : QMainWindow( p, name ) { #ifdef QWS showMaximized(); #endif setCaption( tr( "AQPkg - Package Manager" ) ); // Create our menu help = new QPopupMenu( this ); help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G ); help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); settings = new QPopupMenu( this ); settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); edit = new QPopupMenu( this ); edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I ); edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N ); filter = new QPopupMenu( this ); mnuShowUninstalledPkgsId = filter->insertItem( "Show &Non-Installed Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U ); mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S ); mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P ); filter->insertSeparator(); mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C ); mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A ); // Create the main menu menu = menuBar(); //new QMenuBar( this ); menu->insertItem( tr( "&Settings" ), settings ); menu->insertItem( tr( "&Edit" ), edit ); menu->insertItem( tr( "&Filter" ), filter ); menu->insertItem( tr( "&Help" ), help ); - mgr = new DataManager(); - mgr->loadServers(); - + // Create UI widgets stack = new QWidgetStack( this ); - networkPkgWindow = new NetworkPackageManager( mgr, stack ); + progressWindow = new ProgressWidget( stack ); + stack->addWidget( progressWindow, 2 ); + + networkPkgWindow = new NetworkPackageManager( stack ); + connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) ); + connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) ); + connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); + connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ), + progressWindow, SLOT( setMessage( const QString & ) ) ); + connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); stack->addWidget( networkPkgWindow, 1 ); setCentralWidget( stack ); - stack->raiseWidget( networkPkgWindow ); + stack->raiseWidget( progressWindow ); + + // Delayed call to finish initialization + QTimer::singleShot( 100, this, SLOT( init() ) ); + } MainWindow :: ~MainWindow() { - delete networkPkgWindow; + delete mgr; +} + +void MainWindow :: init() +{ + stack->raiseWidget( progressWindow ); + mgr = new DataManager(); + connect( mgr, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); + connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), + progressWindow, SLOT( setMessage( const QString & ) ) ); + connect( mgr, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); + mgr->loadServers(); + networkPkgWindow->setDataManager( mgr ); + networkPkgWindow->updateData(); + stack->raiseWidget( networkPkgWindow ); } void MainWindow :: setDocument( const QString &doc ) { // Remove path from package QString package = Utils::getPackageNameFromIpkFilename( doc ); std::cout << "Selecting package " << package << std::endl; networkPkgWindow->selectLocalPackage( package ); } void MainWindow :: displaySettings() { SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); if ( dlg->showDlg( 0 ) ) networkPkgWindow->updateData(); delete dlg; } void MainWindow :: displayHelp() { HelpWindow *dlg = new HelpWindow( this ); dlg->exec(); delete dlg; } @@ -187,24 +214,34 @@ void MainWindow :: filterUpgradedPackages() networkPkgWindow->showOnlyInstalledPackages( false ); networkPkgWindow->showUpgradedPackages( val ); } void MainWindow :: setFilterCategory() { if ( networkPkgWindow->setFilterCategory( ) ) filter->setItemChecked( mnuFilterByCategory, true ); } void MainWindow :: filterCategory() { if ( filter->isItemChecked( mnuFilterByCategory ) ) { networkPkgWindow->filterByCategory( false ); filter->setItemChecked( mnuFilterByCategory, false ); } else { if ( networkPkgWindow->filterByCategory( true ) ) filter->setItemChecked( mnuFilterByCategory, true ); } } + +void MainWindow :: raiseMainWidget() +{ + stack->raiseWidget( networkPkgWindow ); +} + +void MainWindow :: raiseProgressWidget() +{ + stack->raiseWidget( progressWindow ); +} |