summaryrefslogtreecommitdiff
authorandyq <andyq>2002-10-25 09:50:52 (UTC)
committer andyq <andyq>2002-10-25 09:50:52 (UTC)
commit2f2c23d398b6a47bd06aaf329a55bb455cf5ddd1 (patch) (unidiff)
tree4322eef1f6306763b3bc0332b6e57c05a24341d9
parent4a2f6dd634aa277bca3818f090d691844e219f64 (diff)
downloadopie-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp9
-rw-r--r--noncore/settings/aqpkg/mainwin.h1
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp31
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h1
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
@@ -1,86 +1,95 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.cpp - description 2 mainwin.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <qmenubar.h> 18#include <qmenubar.h>
19#include <qpopupmenu.h> 19#include <qpopupmenu.h>
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21 21
22#include "mainwin.h" 22#include "mainwin.h"
23#include "datamgr.h" 23#include "datamgr.h"
24#include "networkpkgmgr.h" 24#include "networkpkgmgr.h"
25#include "settingsimpl.h" 25#include "settingsimpl.h"
26#include "helpwindow.h" 26#include "helpwindow.h"
27#include "utils.h"
27#include "global.h" 28#include "global.h"
28 29
29MainWindow :: MainWindow( QWidget *p, char *name ) 30MainWindow :: MainWindow( QWidget *p, char *name )
30 :QMainWindow( p, name ) 31 :QMainWindow( p, name )
31{ 32{
32#ifdef QWS 33#ifdef QWS
33 showMaximized(); 34 showMaximized();
34#endif 35#endif
35 36
36 setCaption( "AQPkg - Package Manager" ); 37 setCaption( "AQPkg - Package Manager" );
37 38
38 // Create our menu 39 // Create our menu
39 QPopupMenu *help = new QPopupMenu( this ); 40 QPopupMenu *help = new QPopupMenu( this );
40 help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H ); 41 help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H );
41 help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); 42 help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A );
42 43
43 QPopupMenu *settings = new QPopupMenu( this ); 44 QPopupMenu *settings = new QPopupMenu( this );
44 settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); 45 settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S );
45 46
46 // Create the main menu 47 // Create the main menu
47 QMenuBar *menu = menuBar(); //new QMenuBar( this ); 48 QMenuBar *menu = menuBar(); //new QMenuBar( this );
48 menu->insertItem( "&Settings", settings ); 49 menu->insertItem( "&Settings", settings );
49 menu->insertItem( "&Help", help ); 50 menu->insertItem( "&Help", help );
50 51
51 mgr = new DataManager(); 52 mgr = new DataManager();
52 mgr->loadServers(); 53 mgr->loadServers();
53 54
54 stack = new QWidgetStack( this ); 55 stack = new QWidgetStack( this );
55 56
56 networkPkgWindow = new NetworkPackageManager( mgr, stack ); 57 networkPkgWindow = new NetworkPackageManager( mgr, stack );
57 stack->addWidget( networkPkgWindow, 1 ); 58 stack->addWidget( networkPkgWindow, 1 );
58 59
59 setCentralWidget( stack ); 60 setCentralWidget( stack );
60 stack->raiseWidget( networkPkgWindow ); 61 stack->raiseWidget( networkPkgWindow );
61} 62}
62 63
63MainWindow :: ~MainWindow() 64MainWindow :: ~MainWindow()
64{ 65{
65 delete networkPkgWindow; 66 delete networkPkgWindow;
66} 67}
67 68
69void MainWindow :: setDocument( const QString &doc )
70{
71 // Remove path from package
72 QString package = Utils::getPackageNameFromIpkFilename( doc );
73 cout << "Selecting package " << package << endl;
74 networkPkgWindow->selectLocalPackage( package );
75}
76
68void MainWindow :: displaySettings() 77void MainWindow :: displaySettings()
69{ 78{
70 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 79 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
71 if ( dlg->showDlg( 0 ) ) 80 if ( dlg->showDlg( 0 ) )
72 networkPkgWindow->updateData(); 81 networkPkgWindow->updateData();
73 delete dlg; 82 delete dlg;
74} 83}
75 84
76void MainWindow :: displayHelp() 85void MainWindow :: displayHelp()
77{ 86{
78 HelpWindow *dlg = new HelpWindow( this ); 87 HelpWindow *dlg = new HelpWindow( this );
79 dlg->exec(); 88 dlg->exec();
80 delete dlg; 89 delete dlg;
81} 90}
82 91
83void MainWindow :: displayAbout() 92void MainWindow :: displayAbout()
84{ 93{
85 QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); 94 QMessageBox::about( this, "About AQPkg", VERSION_TEXT );
86} 95}
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
@@ -1,47 +1,48 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.h - description 2 mainwin.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef MAINWIN_H 18#ifndef MAINWIN_H
19#define MAINWIN_H 19#define MAINWIN_H
20 20
21#include <qmainwindow.h> 21#include <qmainwindow.h>
22#include <qwidgetstack.h> 22#include <qwidgetstack.h>
23 23
24 24
25class NetworkPackageManager; 25class NetworkPackageManager;
26class DataManager; 26class DataManager;
27 27
28class MainWindow :public QMainWindow 28class MainWindow :public QMainWindow
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 32
33 MainWindow( QWidget *p = 0, char *name = 0 ); 33 MainWindow( QWidget *p = 0, char *name = 0 );
34 ~MainWindow(); 34 ~MainWindow();
35 35
36private: 36private:
37 DataManager *mgr; 37 DataManager *mgr;
38 38
39 QWidgetStack *stack; 39 QWidgetStack *stack;
40 NetworkPackageManager *networkPkgWindow; 40 NetworkPackageManager *networkPkgWindow;
41 41
42public slots: 42public slots:
43 void setDocument( const QString &doc );
43 void displayHelp(); 44 void displayHelp();
44 void displayAbout(); 45 void displayAbout();
45 void displaySettings(); 46 void displaySettings();
46}; 47};
47#endif 48#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
@@ -15,142 +15,169 @@
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <fstream> 18#include <fstream>
19#include <iostream> 19#include <iostream>
20using namespace std; 20using namespace std;
21 21
22#include <unistd.h> 22#include <unistd.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <linux/limits.h> 24#include <linux/limits.h>
25 25
26#ifdef QWS 26#ifdef QWS
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/qcopenvelope_qws.h> 28#include <qpe/qcopenvelope_qws.h>
29#include <qpe/config.h> 29#include <qpe/config.h>
30#else 30#else
31#include <qapplication.h> 31#include <qapplication.h>
32#endif 32#endif
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36 36
37#include "datamgr.h" 37#include "datamgr.h"
38#include "networkpkgmgr.h" 38#include "networkpkgmgr.h"
39#include "installdlgimpl.h" 39#include "installdlgimpl.h"
40#include "ipkg.h" 40#include "ipkg.h"
41#include "inputdlg.h" 41#include "inputdlg.h"
42#include "letterpushbutton.h" 42#include "letterpushbutton.h"
43 43
44#include "global.h" 44#include "global.h"
45 45
46NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 46NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
47 : QWidget(parent, name) 47 : QWidget(parent, name)
48{ 48{
49 dataMgr = dataManager; 49 dataMgr = dataManager;
50 50
51#ifdef QWS 51#ifdef QWS
52 // read download directory from config file 52 // read download directory from config file
53 Config cfg( "aqpkg" ); 53 Config cfg( "aqpkg" );
54 cfg.setGroup( "settings" ); 54 cfg.setGroup( "settings" );
55 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 55 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
56 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 56 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
57#endif 57#endif
58 58
59 59
60 initGui(); 60 initGui();
61 setupConnections(); 61 setupConnections();
62 62
63 progressDlg = 0; 63 updateData();
64 timerId = startTimer( 100 ); 64// progressDlg = 0;
65// timerId = startTimer( 100 );
65} 66}
66 67
67NetworkPackageManager::~NetworkPackageManager() 68NetworkPackageManager::~NetworkPackageManager()
68{ 69{
69} 70}
70 71
71void NetworkPackageManager :: timerEvent ( QTimerEvent * ) 72void NetworkPackageManager :: timerEvent ( QTimerEvent * )
72{ 73{
73 killTimer( timerId ); 74 killTimer( timerId );
74 75
75// showProgressDialog(); 76// showProgressDialog();
76 // Add server names to listbox 77 // Add server names to listbox
77 updateData(); 78 updateData();
78 79
79// progressDlg->hide(); 80// progressDlg->hide();
80} 81}
81 82
82void NetworkPackageManager :: updateData() 83void NetworkPackageManager :: updateData()
83{ 84{
84 serversList->clear(); 85 serversList->clear();
85 packagesList->clear(); 86 packagesList->clear();
86 87
87 88
88 vector<Server>::iterator it; 89 vector<Server>::iterator it;
89 int activeItem = -1; 90 int activeItem = -1;
90 int i; 91 int i;
91 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 92 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
92 { 93 {
93 if ( !it->isServerActive() ) 94 if ( !it->isServerActive() )
94 { 95 {
95 i--; 96 i--;
96 continue; 97 continue;
97 } 98 }
98 serversList->insertItem( it->getServerName() ); 99 serversList->insertItem( it->getServerName() );
99 if ( it->getServerName() == currentlySelectedServer ) 100 if ( it->getServerName() == currentlySelectedServer )
100 activeItem = i; 101 activeItem = i;
101 } 102 }
102 103
103 // set selected server to be active server 104 // set selected server to be active server
104 if ( activeItem != -1 ) 105 if ( activeItem != -1 )
105 serversList->setCurrentItem( activeItem ); 106 serversList->setCurrentItem( activeItem );
106 serverSelected( 0 ); 107 serverSelected( 0 );
107} 108}
108 109
110void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
111{
112 // First select local server
113 for ( int i = 0 ; i < serversList->count() ; ++i )
114 {
115 if ( serversList->text( i ) == LOCAL_IPKGS )
116 {
117 serversList->setCurrentItem( i );
118 break;
119 }
120 }
121 serverSelected( 0 );
122
123 // Now set the check box of the selected package
124 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
125 item != 0 ;
126 item = (QCheckListItem *)item->nextSibling() )
127 {
128 if ( item->text().startsWith( pkg ) )
129 {
130 item->setOn( true );
131 break;
132 }
133 }
134}
135
109 136
110void NetworkPackageManager :: initGui() 137void NetworkPackageManager :: initGui()
111{ 138{
112 QLabel *l = new QLabel( "Servers", this ); 139 QLabel *l = new QLabel( "Servers", this );
113 serversList = new QComboBox( this ); 140 serversList = new QComboBox( this );
114 packagesList = new QListView( this ); 141 packagesList = new QListView( this );
115 update = new QPushButton( "Refresh List", this ); 142 update = new QPushButton( "Refresh List", this );
116 download = new QPushButton( "Download", this ); 143 download = new QPushButton( "Download", this );
117 upgrade = new QPushButton( "Upgrade", this ); 144 upgrade = new QPushButton( "Upgrade", this );
118 apply = new QPushButton( "Apply", this ); 145 apply = new QPushButton( "Apply", this );
119 146
120 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 147 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
121 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 148 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
122 hbox1->addWidget( l ); 149 hbox1->addWidget( l );
123 hbox1->addWidget( serversList ); 150 hbox1->addWidget( serversList );
124 151
125 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); 152 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
126 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); 153 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
127 154
128 155
129 if ( showJumpTo ) 156 if ( showJumpTo )
130 { 157 {
131 char text[2]; 158 char text[2];
132 text[1] = '\0'; 159 text[1] = '\0';
133 for ( int i = 0 ; i < 26 ; ++i ) 160 for ( int i = 0 ; i < 26 ; ++i )
134 { 161 {
135 text[0] = 'A' + i; 162 text[0] = 'A' + i;
136 LetterPushButton *b = new LetterPushButton( text, this ); 163 LetterPushButton *b = new LetterPushButton( text, this );
137 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 164 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
138 if ( i < 13 ) 165 if ( i < 13 )
139 hbox3->addWidget( b ); 166 hbox3->addWidget( b );
140 else 167 else
141 hbox4->addWidget( b ); 168 hbox4->addWidget( b );
142 } 169 }
143 } 170 }
144 171
145 vbox->addWidget( packagesList ); 172 vbox->addWidget( packagesList );
146 packagesList->addColumn( "Packages" ); 173 packagesList->addColumn( "Packages" );
147 174
148 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 175 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
149 hbox2->addWidget( update ); 176 hbox2->addWidget( update );
150 hbox2->addWidget( download ); 177 hbox2->addWidget( download );
151 hbox2->addWidget( upgrade ); 178 hbox2->addWidget( upgrade );
152 hbox2->addWidget( apply ); 179 hbox2->addWidget( apply );
153} 180}
154 181
155void NetworkPackageManager :: setupConnections() 182void NetworkPackageManager :: setupConnections()
156{ 183{
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
@@ -1,77 +1,78 @@
1/*************************************************************************** 1/***************************************************************************
2 networkpkgmgr.h - description 2 networkpkgmgr.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef NETWORKPKGMGR_H 18#ifndef NETWORKPKGMGR_H
19#define NETWORKPKGMGR_H 19#define NETWORKPKGMGR_H
20 20
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qpushbutton.h> 22#include <qpushbutton.h>
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qlistview.h> 25#include <qlistview.h>
26 26
27#include "datamgr.h" 27#include "datamgr.h"
28#include "progressdlg.h" 28#include "progressdlg.h"
29class InstallData; 29class InstallData;
30 30
31/** NetworkPackageManager is the base class of the project */ 31/** NetworkPackageManager is the base class of the project */
32class NetworkPackageManager : public QWidget 32class NetworkPackageManager : public QWidget
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 /** construtor */ 36 /** construtor */
37 NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); 37 NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0);
38 /** destructor */ 38 /** destructor */
39 ~NetworkPackageManager(); 39 ~NetworkPackageManager();
40 40
41 void selectLocalPackage( const QString &pkg );
41 void updateData(); 42 void updateData();
42 43
43private: 44private:
44 DataManager *dataMgr; 45 DataManager *dataMgr;
45 46
46 QComboBox *serversList; 47 QComboBox *serversList;
47 QListView *packagesList; 48 QListView *packagesList;
48 QPushButton *update; 49 QPushButton *update;
49 QPushButton *upgrade; 50 QPushButton *upgrade;
50 QPushButton *download; 51 QPushButton *download;
51 QPushButton *apply; 52 QPushButton *apply;
52 53
53 ProgressDlg *progressDlg; 54 ProgressDlg *progressDlg;
54 QString currentlySelectedServer; 55 QString currentlySelectedServer;
55 56
56 bool showJumpTo; 57 bool showJumpTo;
57 int timerId; 58 int timerId;
58 59
59 void timerEvent ( QTimerEvent * ); 60 void timerEvent ( QTimerEvent * );
60 61
61 void initGui(); 62 void initGui();
62 void setupConnections(); 63 void setupConnections();
63 void showProgressDialog( char *initialText ); 64 void showProgressDialog( char *initialText );
64 InstallData dealWithItem( QCheckListItem *item ); 65 InstallData dealWithItem( QCheckListItem *item );
65 QString stickyOption; 66 QString stickyOption;
66 67
67public slots: 68public slots:
68 void serverSelected( int index ); 69 void serverSelected( int index );
69 void applyChanges(); 70 void applyChanges();
70 void upgradePackages(); 71 void upgradePackages();
71 void downloadPackage(); 72 void downloadPackage();
72 void updateServer(); 73 void updateServer();
73 void displayText( const QString &t ); 74 void displayText( const QString &t );
74 void letterPushed( QString t ); 75 void letterPushed( QString t );
75}; 76};
76 77
77#endif 78#endif