author | andyq <andyq> | 2002-10-25 09:50:52 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-10-25 09:50:52 (UTC) |
commit | 2f2c23d398b6a47bd06aaf329a55bb455cf5ddd1 (patch) (side-by-side diff) | |
tree | 4322eef1f6306763b3bc0332b6e57c05a24341d9 | |
parent | 4a2f6dd634aa277bca3818f090d691844e219f64 (diff) | |
download | opie-2f2c23d398b6a47bd06aaf329a55bb455cf5ddd1.zip opie-2f2c23d398b6a47bd06aaf329a55bb455cf5ddd1.tar.gz opie-2f2c23d398b6a47bd06aaf329a55bb455cf5ddd1.tar.bz2 |
Modified so that you can click on a package in the documents view and
the Local IPKGS view is shown and the selected package checked
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.h | 1 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 31 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 1 |
4 files changed, 40 insertions, 2 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 206d11c..9f19dfa 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -3,84 +3,93 @@ -------------------
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 <qmenubar.h>
#include <qpopupmenu.h>
#include <qmessagebox.h>
#include "mainwin.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( "AQPkg - Package Manager" );
// Create our menu
QPopupMenu *help = new QPopupMenu( this );
help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H );
help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A );
QPopupMenu *settings = new QPopupMenu( this );
settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S );
// Create the main menu
QMenuBar *menu = menuBar(); //new QMenuBar( this );
menu->insertItem( "&Settings", settings );
menu->insertItem( "&Help", help );
mgr = new DataManager();
mgr->loadServers();
stack = new QWidgetStack( this );
networkPkgWindow = new NetworkPackageManager( mgr, stack );
stack->addWidget( networkPkgWindow, 1 );
setCentralWidget( stack );
stack->raiseWidget( networkPkgWindow );
}
MainWindow :: ~MainWindow()
{
delete networkPkgWindow;
}
+void MainWindow :: setDocument( const QString &doc )
+{
+ // Remove path from package
+ QString package = Utils::getPackageNameFromIpkFilename( doc );
+ cout << "Selecting package " << package << 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;
}
void MainWindow :: displayAbout()
{
QMessageBox::about( this, "About AQPkg", VERSION_TEXT );
}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index 2a182fc..a9e290c 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h @@ -19,29 +19,30 @@ #define MAINWIN_H
#include <qmainwindow.h>
#include <qwidgetstack.h>
class NetworkPackageManager;
class DataManager;
class MainWindow :public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *p = 0, char *name = 0 );
~MainWindow();
private:
DataManager *mgr;
QWidgetStack *stack;
NetworkPackageManager *networkPkgWindow;
public slots:
+ void setDocument( const QString &doc );
void displayHelp();
void displayAbout();
void displaySettings();
};
#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 6874ded..a374266 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -39,94 +39,121 @@ using namespace std; #include "installdlgimpl.h" #include "ipkg.h" #include "inputdlg.h" #include "letterpushbutton.h" #include "global.h" NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) : QWidget(parent, name) { dataMgr = dataManager; #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); #endif initGui(); setupConnections(); - progressDlg = 0; - timerId = startTimer( 100 ); + updateData(); +// progressDlg = 0; +// timerId = startTimer( 100 ); } NetworkPackageManager::~NetworkPackageManager() { } void NetworkPackageManager :: timerEvent ( QTimerEvent * ) { killTimer( timerId ); // showProgressDialog(); // Add server names to listbox updateData(); // progressDlg->hide(); } void NetworkPackageManager :: updateData() { serversList->clear(); packagesList->clear(); vector<Server>::iterator it; int activeItem = -1; int i; for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) { if ( !it->isServerActive() ) { i--; continue; } serversList->insertItem( it->getServerName() ); if ( it->getServerName() == currentlySelectedServer ) activeItem = i; } // set selected server to be active server if ( activeItem != -1 ) serversList->setCurrentItem( activeItem ); serverSelected( 0 ); } +void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) +{ + // First select local server + for ( int i = 0 ; i < serversList->count() ; ++i ) + { + if ( serversList->text( i ) == LOCAL_IPKGS ) + { + serversList->setCurrentItem( i ); + break; + } + } + serverSelected( 0 ); + + // Now set the check box of the selected package + for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); + item != 0 ; + item = (QCheckListItem *)item->nextSibling() ) + { + if ( item->text().startsWith( pkg ) ) + { + item->setOn( true ); + break; + } + } +} + void NetworkPackageManager :: initGui() { QLabel *l = new QLabel( "Servers", this ); serversList = new QComboBox( this ); packagesList = new QListView( this ); update = new QPushButton( "Refresh List", this ); download = new QPushButton( "Download", this ); upgrade = new QPushButton( "Upgrade", this ); apply = new QPushButton( "Apply", this ); QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); hbox1->addWidget( l ); hbox1->addWidget( serversList ); QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); if ( showJumpTo ) { char text[2]; text[1] = '\0'; diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h index fba8155..3c437b4 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.h +++ b/noncore/settings/aqpkg/networkpkgmgr.h @@ -17,48 +17,49 @@ #ifndef NETWORKPKGMGR_H #define NETWORKPKGMGR_H #include <qlayout.h> #include <qpushbutton.h> #include <qwidget.h> #include <qcombobox.h> #include <qlistview.h> #include "datamgr.h" #include "progressdlg.h" class InstallData; /** NetworkPackageManager is the base class of the project */ class NetworkPackageManager : public QWidget { Q_OBJECT public: /** construtor */ NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); /** destructor */ ~NetworkPackageManager(); + void selectLocalPackage( const QString &pkg ); void updateData(); private: DataManager *dataMgr; QComboBox *serversList; QListView *packagesList; QPushButton *update; QPushButton *upgrade; QPushButton *download; QPushButton *apply; ProgressDlg *progressDlg; QString currentlySelectedServer; bool showJumpTo; int timerId; void timerEvent ( QTimerEvent * ); void initGui(); void setupConnections(); void showProgressDialog( char *initialText ); InstallData dealWithItem( QCheckListItem *item ); |