Diffstat (limited to 'noncore/unsupported/oipkg/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 165 |
1 files changed, 108 insertions, 57 deletions
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index c95f482..ca1e5e8 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp | |||
@@ -3,63 +3,60 @@ | |||
3 | 3 | ||
4 | #include "mainwindow.h" | 4 | #include "mainwindow.h" |
5 | 5 | ||
6 | #include <qpe/qpemenubar.h> | 6 | #include <qpe/qpemenubar.h> |
7 | #include <qpe/qpemessagebox.h> | 7 | #include <qpe/qpemessagebox.h> |
8 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | #include <qpe/config.h> | ||
9 | #include <qpe/qpetoolbar.h> | 10 | #include <qpe/qpetoolbar.h> |
10 | #include <qpe/qcopenvelope_qws.h> | 11 | #include <qpe/qcopenvelope_qws.h> |
11 | #include <qaction.h> | 12 | #include <qaction.h> |
12 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
13 | #include <qpopupmenu.h> | 14 | #include <qpopupmenu.h> |
14 | #include <qtoolbutton.h> | 15 | #include <qtoolbutton.h> |
15 | #include <qstring.h> | 16 | #include <qstring.h> |
16 | #include <qlabel.h> | 17 | #include <qlabel.h> |
17 | #include <qfile.h> | 18 | #include <qfile.h> |
18 | #include <qlistview.h> | 19 | #include <qlistview.h> |
19 | #include <qtextview.h> | 20 | #include <qtextview.h> |
21 | #include <qcheckbox.h> | ||
20 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
21 | #include <qtabwidget.h> | 23 | #include <qtabwidget.h> |
22 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
23 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
24 | #include <qlayout.h> | 26 | #include <qlayout.h> |
25 | 27 | ||
26 | #include "pksettingsbase.h" | 28 | #include "pksettingsbase.h" |
29 | #include "utils.h" | ||
27 | #include "packagelistitem.h" | 30 | #include "packagelistitem.h" |
28 | 31 | ||
29 | 32 | ||
30 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | 33 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : |
31 | QMainWindow( parent, name, f ) | 34 | QMainWindow( parent, name, f ) |
32 | { | 35 | { |
36 | setCaption( tr("Package Manager") ); | ||
33 | settings = new PackageManagerSettings(this,0,TRUE); | 37 | settings = new PackageManagerSettings(this,0,TRUE); |
34 | listViewPackages = new PackageListView( this,"listViewPackages",settings ); | 38 | listViewPackages = new PackageListView( this,"listViewPackages",settings ); |
35 | ipkg = new PmIpkg( settings, this ); | ||
36 | |||
37 | setCentralWidget( listViewPackages ); | 39 | setCentralWidget( listViewPackages ); |
38 | setCaption( tr("Package Manager") ); | ||
39 | 40 | ||
40 | //wait = new QMessageBox(tr("oipkg"),tr("Please wait")//,QMessageBox::Information,QMessageBox::NoButton,QMessageBox::NoButton,QMessageBox::NoButton); | 41 | //wait = new QMessageBox(tr("oipkg"),tr("Please wait")//,QMessageBox::Information,QMessageBox::NoButton,QMessageBox::NoButton,QMessageBox::NoButton); |
41 | wait = new QMessageBox(this); | 42 | //wait = new QMessageBox(this); |
42 | wait->setText(tr("Please wait")); | 43 | // wait->setText(tr("Please wait")); |
43 | |||
44 | channel = new QCopChannel( "QPE/Application/oipkg", this ); | ||
45 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
46 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | ||
47 | |||
48 | makeMenu(); | ||
49 | |||
50 | connect( section, SIGNAL( activated(int) ), | ||
51 | this, SLOT( sectionChanged() ) ); | ||
52 | connect( subsection, SIGNAL(activated(int) ), | ||
53 | this, SLOT( subSectionChanged() ) ); | ||
54 | |||
55 | ipkg = new PmIpkg( settings, this ); | 44 | ipkg = new PmIpkg( settings, this ); |
56 | packageList.setSettings( settings ); | 45 | packageList.setSettings( settings ); |
57 | getList(); | 46 | packageList.update(); |
58 | setSections(); | 47 | makeMenu(); |
59 | setSubSections(); | 48 | makeChannel(); |
49 | //opie is hardcoded default ;) | ||
50 | for (int i=0;i<section->count();i++) | ||
51 | if (section->text(i)=="opie") | ||
52 | section->setCurrentItem(i); | ||
53 | sectionChanged(); | ||
54 | |||
55 | connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); | ||
56 | connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); | ||
60 | displayList(); | 57 | displayList(); |
61 | } | 58 | } |
62 | 59 | ||
63 | void MainWindow::makeMenu() | 60 | void MainWindow::makeMenu() |
64 | { | 61 | { |
65 | 62 | ||
@@ -97,144 +94,166 @@ void MainWindow::makeMenu() | |||
97 | QString::null, 0, this, 0 ); | 94 | QString::null, 0, this, 0 ); |
98 | connect( updateAction, SIGNAL( activated() ), | 95 | connect( updateAction, SIGNAL( activated() ), |
99 | this , SLOT( updateList() ) ); | 96 | this , SLOT( updateList() ) ); |
100 | updateAction->addTo( toolBar ); | 97 | updateAction->addTo( toolBar ); |
101 | updateAction->addTo( srvMenu ); | 98 | updateAction->addTo( srvMenu ); |
102 | 99 | ||
103 | // would we use for find | 100 | // could we use for find |
104 | // detailsAction = new QAction( tr( "Details" ), | 101 | // detailsAction = new QAction( tr( "Find" ), |
105 | // Resource::loadIconSet( "find" ), | 102 | // Resource::loadIconSet( "find" ), |
106 | // QString::null, 0, this, 0 ); | 103 | // QString::null, 0, this, 0 ); |
107 | // connect( detailsAction, SIGNAL( activated() ), | 104 | // connect( detailsAction, SIGNAL( activated() ), |
108 | // this , SLOT( showDetails() ) ); | 105 | // this , SLOT( showFind() ) ); |
109 | // detailsAction->addTo( toolBar ); | 106 | // detailsAction->addTo( toolBar ); |
110 | // detailsAction->addTo( srvMenu ); | ||
111 | 107 | ||
112 | QAction *cfgact; | 108 | QAction *cfgact; |
113 | 109 | ||
114 | cfgact = new QAction( tr( "Setups" ), | 110 | cfgact = new QAction( tr( "Setups" ), |
115 | // Resource::loadIconSet( "" ), | ||
116 | QString::null, 0, this, 0 ); | 111 | QString::null, 0, this, 0 ); |
117 | connect( cfgact, SIGNAL( activated() ), | 112 | connect( cfgact, SIGNAL( activated() ), |
118 | SLOT( showSettings() ) ); | 113 | SLOT( showSettings() ) ); |
119 | cfgact->addTo( cfgMenu ); | 114 | cfgact->addTo( cfgMenu ); |
120 | 115 | ||
121 | cfgact = new QAction( tr( "Servers" ), | 116 | cfgact = new QAction( tr( "Servers" ), |
122 | // Resource::loadIconSet( "" ), | ||
123 | QString::null, 0, this, 0 ); | 117 | QString::null, 0, this, 0 ); |
124 | connect( cfgact, SIGNAL( activated() ), | 118 | connect( cfgact, SIGNAL( activated() ), |
125 | SLOT( showSettingsSrv() ) ); | 119 | SLOT( showSettingsSrv() ) ); |
126 | cfgact->addTo( cfgMenu ); | 120 | cfgact->addTo( cfgMenu ); |
127 | cfgact = new QAction( tr( "Destinations" ), | 121 | cfgact = new QAction( tr( "Destinations" ), |
128 | //Resource::loadIconSet( "" ), | ||
129 | QString::null, 0, this, 0 ); | 122 | QString::null, 0, this, 0 ); |
130 | connect( cfgact, SIGNAL( activated() ), | 123 | connect( cfgact, SIGNAL( activated() ), |
131 | SLOT( showSettingsDst() ) ); | 124 | SLOT( showSettingsDst() ) ); |
132 | cfgact->addTo( cfgMenu ); | 125 | cfgact->addTo( cfgMenu ); |
133 | 126 | ||
134 | QAction *a; | 127 | QAction *a; |
135 | 128 | ||
136 | sectionBar = new QPEToolBar( this ); | 129 | sectionBar = new QPEToolBar( this ); |
137 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); | 130 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); |
138 | sectionBar->setHorizontalStretchable( true ); | 131 | sectionBar->setHorizontalStretchable( true ); |
139 | QLabel *label = new QLabel( tr("Section: "), sectionBar ); | 132 | QLabel *label = new QLabel( tr("Section: "), sectionBar ); |
140 | label->setBackgroundColor( sectionBar->backgroundColor() ); | 133 | label->setBackgroundColor( sectionBar->backgroundColor() ); |
141 | sectionBar->setStretchableWidget( label ); | 134 | sectionBar->setStretchableWidget( label ); |
142 | section = new QComboBox( false, sectionBar ); | 135 | section = new QComboBox( false, sectionBar ); |
143 | // section->setBackgroundMode( PaletteBackground ); | ||
144 | label = new QLabel( " / ", sectionBar ); | 136 | label = new QLabel( " / ", sectionBar ); |
145 | label->setBackgroundColor( sectionBar->backgroundColor() ); | 137 | label->setBackgroundColor( sectionBar->backgroundColor() ); |
146 | subsection = new QComboBox( false, sectionBar ); | 138 | subsection = new QComboBox( false, sectionBar ); |
147 | |||
148 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 139 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
149 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); | 140 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); |
150 | a->addTo( sectionBar ); | 141 | a->addTo( sectionBar ); |
151 | 142 | ||
143 | setSections(); | ||
144 | setSubSections(); | ||
145 | |||
152 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); | 146 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); |
153 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); | 147 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); |
154 | sectionAction->setToggleAction( true ); | 148 | sectionAction->setToggleAction( true ); |
155 | sectionAction->setOn( true ); | ||
156 | sectionAction->addTo( viewMenu ); | 149 | sectionAction->addTo( viewMenu ); |
157 | 150 | ||
158 | findBar = new QPEToolBar(this); | 151 | findBar = new QPEToolBar(this); |
159 | addToolBar( findBar, "Search", QMainWindow::Top, TRUE ); | 152 | addToolBar( findBar, "Search", QMainWindow::Top, TRUE ); |
160 | label = new QLabel( tr("Filter: "), findBar ); | 153 | label = new QLabel( tr("Filter: "), findBar ); |
161 | label->setBackgroundColor( findBar->backgroundColor() ); | 154 | label->setBackgroundColor( findBar->backgroundColor() ); |
162 | findBar->setHorizontalStretchable( TRUE ); | 155 | findBar->setHorizontalStretchable( TRUE ); |
163 | findEdit = new QLineEdit( findBar, "findEdit" ); | 156 | findEdit = new QLineEdit( findBar, "findEdit" ); |
164 | findBar->setStretchableWidget( findEdit ); | 157 | findBar->setStretchableWidget( findEdit ); |
165 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), | 158 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), |
166 | this, SLOT( displayList() ) ); | 159 | this, SLOT( displayList() ) ); |
167 | 160 | ||
161 | a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | ||
162 | connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); | ||
163 | a->addTo( findBar ); | ||
168 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 164 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
169 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 165 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
170 | a->addTo( findBar ); | 166 | a->addTo( findBar ); |
171 | findAction = new QAction( tr( "Find" ), QString::null, 0, this, 0 ); | 167 | findAction = new QAction( tr( "Find" ), QString::null, 0, this, 0 ); |
172 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); | 168 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); |
173 | findAction->setToggleAction( true ); | 169 | findAction->setToggleAction( true ); |
174 | findAction->setOn( true ); | ||
175 | findAction->addTo( viewMenu ); | 170 | findAction->addTo( viewMenu ); |
176 | 171 | ||
177 | #ifdef NEW | 172 | destBar = new QPEToolBar(this); |
173 | addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); | ||
174 | label = new QLabel( tr("Destination: "), destBar ); | ||
175 | label->setBackgroundColor( destBar->backgroundColor() ); | ||
176 | destBar->setHorizontalStretchable( TRUE ); | ||
177 | destination = new QComboBox( false, destBar ); | ||
178 | destination->insertStringList( settings->getDestinationNames() ); | ||
179 | setComboName(destination,settings->getDestinationName()); | ||
180 | // connect( destination, SIGNAL(activated(int)), | ||
181 | // SLOT(activeDestinationChange(int)) ); | ||
182 | spacer = new QLabel( " ", destBar ); | ||
183 | spacer->setBackgroundColor( destBar->backgroundColor() ); | ||
184 | CheckBoxLink = new QCheckBox( tr("Link"), destBar); | ||
185 | CheckBoxLink->setBackgroundColor( destBar->backgroundColor() ); | ||
186 | CheckBoxLink->setChecked( settings->createLinks() ); | ||
187 | // connect( CheckBoxLink, SIGNAL(toggled(bool)), | ||
188 | // settings, SLOT(linkEnabled(bool)) ); | ||
189 | destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); | ||
190 | connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); | ||
191 | a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | ||
192 | connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); | ||
193 | a->addTo( destBar ); | ||
194 | destBar->setStretchableWidget( CheckBoxLink ); | ||
195 | destAction->setToggleAction( true ); | ||
196 | // destAction->addTo( viewMenu ); | ||
197 | |||
198 | // configure the menus | ||
178 | Config cfg( "oipkg", Config::User ); | 199 | Config cfg( "oipkg", Config::User ); |
179 | cfg.setGroup( "Setting_" + QString::number( setting ) ); | 200 | cfg.setGroup( "gui" ); |
180 | CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) ); | 201 | |
181 | findShow(bool b) | 202 | findShow( cfg.readBoolEntry( "findBar", true ) ); |
182 | sectionShow(bool b) | 203 | sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); |
183 | #endif | 204 | destShow( cfg.readBoolEntry( "destBar", false ) ); |
184 | } | 205 | } |
185 | 206 | ||
186 | MainWindow::~MainWindow() | 207 | MainWindow::~MainWindow() |
187 | { | 208 | { |
209 | Config cfg( "oipkg", Config::User ); | ||
210 | cfg.setGroup( "gui" ); | ||
211 | cfg.writeEntry( "findBar", !findBar->isHidden() ); | ||
212 | cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); | ||
213 | cfg.writeEntry( "destBar", !destBar->isHidden() ); | ||
214 | |||
188 | } | 215 | } |
189 | 216 | ||
190 | void MainWindow::runIpkg() | 217 | void MainWindow::runIpkg() |
191 | { | 218 | { |
219 | packageList.allPackages(); | ||
192 | ipkg->commit( packageList ); | 220 | ipkg->commit( packageList ); |
193 | // ##### If we looked in the list of files, we could send out accurate | 221 | // ##### If we looked in the list of files, we could send out accurate |
194 | // ##### messages. But we don't bother yet, and just do an "all". | 222 | // ##### messages. But we don't bother yet, and just do an "all". |
195 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 223 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
196 | QString lf = QString::null; | 224 | QString lf = QString::null; |
197 | e << lf; | 225 | e << lf; |
198 | displayList(); | 226 | displayList(); |
199 | } | 227 | } |
200 | 228 | ||
201 | void MainWindow::updateList() | 229 | void MainWindow::updateList() |
202 | { | 230 | { |
203 | wait->show(); | 231 | //wait->show(); |
204 | QTimer *t = new QTimer( this ); | 232 | QTimer *t = new QTimer( this ); |
205 | connect( t, SIGNAL(timeout()), SLOT( rotateUpdateIcon() ) ); | 233 | connect( t, SIGNAL(timeout()), SLOT( rotateUpdateIcon() ) ); |
206 | t->start( 0, false ); | 234 | t->start( 0, false ); |
207 | packageList.clear(); | 235 | packageList.clear(); |
208 | ipkg->update(); | 236 | ipkg->update(); |
209 | getList(); | ||
210 | t->stop(); | ||
211 | wait->hide(); | ||
212 | |||
213 | } | ||
214 | |||
215 | void MainWindow::getList() | ||
216 | { | ||
217 | wait->show(); | ||
218 | packageList.update(); | 237 | packageList.update(); |
219 | displayList(); | 238 | t->stop(); |
220 | wait->hide(); | 239 | // wait->hide(); |
221 | } | 240 | } |
222 | 241 | ||
223 | void MainWindow::filterList() | 242 | void MainWindow::filterList() |
224 | { | 243 | { |
225 | wait->show(); | 244 | //wait->show(); |
226 | QString f = ""; | 245 | QString f = ""; |
227 | if ( findAction->isOn() ) f = findEdit->text(); | 246 | if ( findAction->isOn() ) f = findEdit->text(); |
228 | packageList.filterPackages( f ); | 247 | packageList.filterPackages( f ); |
229 | wait->hide(); | 248 | //wait->hide(); |
230 | } | 249 | } |
231 | 250 | ||
232 | void MainWindow::displayList() | 251 | void MainWindow::displayList() |
233 | { | 252 | { |
234 | wait->hide(); | 253 | //wait->hide(); |
235 | filterList(); | 254 | filterList(); |
236 | listViewPackages->clear(); | 255 | listViewPackages->clear(); |
237 | Package *pack = packageList.first(); | 256 | Package *pack = packageList.first(); |
238 | while( pack ) | 257 | while( pack ) |
239 | { | 258 | { |
240 | if ( pack && (pack->name() != "") ) | 259 | if ( pack && (pack->name() != "") ) |
@@ -323,12 +342,24 @@ void MainWindow::findShow(bool b) | |||
323 | 342 | ||
324 | void MainWindow::findClose() | 343 | void MainWindow::findClose() |
325 | { | 344 | { |
326 | findAction->setOn( false ); | 345 | findAction->setOn( false ); |
327 | } | 346 | } |
328 | 347 | ||
348 | void MainWindow::destShow(bool b) | ||
349 | { | ||
350 | if (b) destBar->show(); | ||
351 | else destBar->hide(); | ||
352 | destAction->setOn( b ); | ||
353 | } | ||
354 | |||
355 | void MainWindow::destClose() | ||
356 | { | ||
357 | destAction->setOn( false ); | ||
358 | } | ||
359 | |||
329 | void MainWindow::rotateUpdateIcon() | 360 | void MainWindow::rotateUpdateIcon() |
330 | { | 361 | { |
331 | pvDebug(2, "MainWindow::rotateUpdateIcon"); | 362 | pvDebug(2, "MainWindow::rotateUpdateIcon"); |
332 | if ( updateIcon ) | 363 | if ( updateIcon ) |
333 | updateAction->setIconSet( Resource::loadIconSet( "oipkg/update" ) ); | 364 | updateAction->setIconSet( Resource::loadIconSet( "oipkg/update" ) ); |
334 | else | 365 | else |
@@ -358,14 +389,34 @@ void MainWindow::installFile(const QString &fileName) | |||
358 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 389 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
359 | QString lf = QString::null; | 390 | QString lf = QString::null; |
360 | e << lf; | 391 | e << lf; |
361 | displayList(); | 392 | displayList(); |
362 | } | 393 | } |
363 | 394 | ||
395 | void MainWindow::makeChannel() | ||
396 | { | ||
397 | channel = new QCopChannel( "QPE/Application/oipkg", this ); | ||
398 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
399 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | ||
400 | } | ||
401 | |||
402 | |||
403 | |||
364 | void MainWindow::receive(const QCString &msg, const QByteArray &arg) | 404 | void MainWindow::receive(const QCString &msg, const QByteArray &arg) |
365 | { | 405 | { |
366 | pvDebug(3, "QCop "+msg); | 406 | pvDebug(3, "QCop "+msg+" "+QCString(arg)); |
367 | if ( msg == "installFile(QString)" ) | 407 | if ( msg == "installFile(QString)" ) |
368 | { | 408 | { |
369 | installFile( QString(arg) ); | 409 | ipkg->installFile( QString(arg) ); |
370 | } | 410 | }else if( msg == "removeFile(QString)" ) |
371 | } \ No newline at end of file | 411 | { |
412 | ipkg->removeFile( QString(arg) ); | ||
413 | }else if( msg == "createLinks(QString)" ) | ||
414 | { | ||
415 | ipkg->createLinks( QString(arg) ); | ||
416 | }else if( msg == "removeLinks(QString)" ) | ||
417 | { | ||
418 | ipkg->removeLinks( QString(arg) ); | ||
419 | }else{ | ||
420 | pvDebug(2,"Huh what do ya want") | ||
421 | } | ||
422 | } | ||