summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp109
1 files changed, 90 insertions, 19 deletions
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp
index ca1e5e8..06828e0 100644
--- a/noncore/unsupported/oipkg/mainwindow.cpp
+++ b/noncore/unsupported/oipkg/mainwindow.cpp
@@ -20,12 +20,13 @@
20#include <qtextview.h> 20#include <qtextview.h>
21#include <qcheckbox.h> 21#include <qcheckbox.h>
22#include <qlineedit.h> 22#include <qlineedit.h>
23#include <qtabwidget.h> 23#include <qtabwidget.h>
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qpushbutton.h>
26#include <qlayout.h> 27#include <qlayout.h>
27 28
28#include "pksettingsbase.h" 29#include "pksettingsbase.h"
29#include "utils.h" 30#include "utils.h"
30#include "packagelistitem.h" 31#include "packagelistitem.h"
31 32
@@ -39,24 +40,34 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
39 setCentralWidget( listViewPackages ); 40 setCentralWidget( listViewPackages );
40 41
41 //wait = new QMessageBox(tr("oipkg"),tr("Please wait")//,QMessageBox::Information,QMessageBox::NoButton,QMessageBox::NoButton,QMessageBox::NoButton); 42 //wait = new QMessageBox(tr("oipkg"),tr("Please wait")//,QMessageBox::Information,QMessageBox::NoButton,QMessageBox::NoButton,QMessageBox::NoButton);
42 //wait = new QMessageBox(this); 43 //wait = new QMessageBox(this);
43 // wait->setText(tr("Please wait")); 44 // wait->setText(tr("Please wait"));
44 ipkg = new PmIpkg( settings, this ); 45 ipkg = new PmIpkg( settings, this );
46// settings->setIpkg( ipkg );
45 packageList.setSettings( settings ); 47 packageList.setSettings( settings );
48 packageListSearch.setSettings( settings );
46 packageList.update(); 49 packageList.update();
47 makeMenu(); 50 makeMenu();
48 makeChannel(); 51 makeChannel();
49 //opie is hardcoded default ;) 52 //opie is hardcoded default ;)
50 for (int i=0;i<section->count();i++) 53 for (int i=0;i<section->count();i++)
51 if (section->text(i)=="opie") 54 if (section->text(i)=="opie")
52 section->setCurrentItem(i); 55 section->setCurrentItem(i);
53 sectionChanged(); 56 sectionChanged();
54 57
55 connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); 58 connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) );
56 connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); 59 connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) );
60
61 connect( settings->removeLinksButton, SIGNAL( clicked()),
62 SLOT(removeLinks()) );
63 connect( settings->createLinksButton, SIGNAL( clicked()),
64 SLOT(createLinks()) );
65
66 //rootLocal = new QCheckListItem(listViewPackages,tr("local"));
67 //rootSearch = new QCheckListItem(listViewPackages,tr("ipkgfind"));
57 displayList(); 68 displayList();
58} 69}
59 70
60void MainWindow::makeMenu() 71void MainWindow::makeMenu()
61{ 72{
62 73
@@ -94,20 +105,12 @@ void MainWindow::makeMenu()
94 QString::null, 0, this, 0 ); 105 QString::null, 0, this, 0 );
95 connect( updateAction, SIGNAL( activated() ), 106 connect( updateAction, SIGNAL( activated() ),
96 this , SLOT( updateList() ) ); 107 this , SLOT( updateList() ) );
97 updateAction->addTo( toolBar ); 108 updateAction->addTo( toolBar );
98 updateAction->addTo( srvMenu ); 109 updateAction->addTo( srvMenu );
99 110
100// could we use for find
101// detailsAction = new QAction( tr( "Find" ),
102 // Resource::loadIconSet( "find" ),
103 // QString::null, 0, this, 0 );
104// connect( detailsAction, SIGNAL( activated() ),
105// this , SLOT( showFind() ) );
106// detailsAction->addTo( toolBar );
107
108 QAction *cfgact; 111 QAction *cfgact;
109 112
110 cfgact = new QAction( tr( "Setups" ), 113 cfgact = new QAction( tr( "Setups" ),
111 QString::null, 0, this, 0 ); 114 QString::null, 0, this, 0 );
112 connect( cfgact, SIGNAL( activated() ), 115 connect( cfgact, SIGNAL( activated() ),
113 SLOT( showSettings() ) ); 116 SLOT( showSettings() ) );
@@ -123,12 +126,13 @@ void MainWindow::makeMenu()
123 connect( cfgact, SIGNAL( activated() ), 126 connect( cfgact, SIGNAL( activated() ),
124 SLOT( showSettingsDst() ) ); 127 SLOT( showSettingsDst() ) );
125 cfgact->addTo( cfgMenu ); 128 cfgact->addTo( cfgMenu );
126 129
127 QAction *a; 130 QAction *a;
128 131
132 // SECTIONS
129 sectionBar = new QPEToolBar( this ); 133 sectionBar = new QPEToolBar( this );
130 addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); 134 addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE );
131 sectionBar->setHorizontalStretchable( true ); 135 sectionBar->setHorizontalStretchable( true );
132 QLabel *label = new QLabel( tr("Section: "), sectionBar ); 136 QLabel *label = new QLabel( tr("Section: "), sectionBar );
133 label->setBackgroundColor( sectionBar->backgroundColor() ); 137 label->setBackgroundColor( sectionBar->backgroundColor() );
134 sectionBar->setStretchableWidget( label ); 138 sectionBar->setStretchableWidget( label );
@@ -136,59 +140,82 @@ void MainWindow::makeMenu()
136 label = new QLabel( " / ", sectionBar ); 140 label = new QLabel( " / ", sectionBar );
137 label->setBackgroundColor( sectionBar->backgroundColor() ); 141 label->setBackgroundColor( sectionBar->backgroundColor() );
138 subsection = new QComboBox( false, sectionBar ); 142 subsection = new QComboBox( false, sectionBar );
139 a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 143 a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
140 connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); 144 connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) );
141 a->addTo( sectionBar ); 145 a->addTo( sectionBar );
142
143 setSections(); 146 setSections();
144 setSubSections(); 147 setSubSections();
145
146 sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); 148 sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 );
147 connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); 149 connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) );
148 sectionAction->setToggleAction( true ); 150 sectionAction->setToggleAction( true );
149 sectionAction->addTo( viewMenu ); 151 sectionAction->addTo( viewMenu );
150 152
153 //FIND
151 findBar = new QPEToolBar(this); 154 findBar = new QPEToolBar(this);
152 addToolBar( findBar, "Search", QMainWindow::Top, TRUE ); 155 addToolBar( findBar, "Filter", QMainWindow::Top, TRUE );
153 label = new QLabel( tr("Filter: "), findBar ); 156 label = new QLabel( tr("Filter: "), findBar );
154 label->setBackgroundColor( findBar->backgroundColor() ); 157 label->setBackgroundColor( findBar->backgroundColor() );
155 findBar->setHorizontalStretchable( TRUE ); 158 findBar->setHorizontalStretchable( TRUE );
156 findEdit = new QLineEdit( findBar, "findEdit" ); 159 findEdit = new QLineEdit( findBar, "findEdit" );
157 findBar->setStretchableWidget( findEdit ); 160 findBar->setStretchableWidget( findEdit );
158 connect( findEdit, SIGNAL( textChanged( const QString & ) ), 161 connect( findEdit, SIGNAL( textChanged( const QString & ) ),
159 this, SLOT( displayList() ) ); 162 this, SLOT( displayList() ) );
160
161 a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); 163 a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 );
162 connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); 164 connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) );
163 a->addTo( findBar ); 165 a->addTo( findBar );
164 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 166 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
165 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 167 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
166 a->addTo( findBar ); 168 a->addTo( findBar );
167 findAction = new QAction( tr( "Find" ), QString::null, 0, this, 0 ); 169 findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 );
168 connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); 170 connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) );
169 findAction->setToggleAction( true ); 171 findAction->setToggleAction( true );
170 findAction->addTo( viewMenu ); 172 findAction->addTo( viewMenu );
171 173
174 //SEARCH
175 searchBar = new QPEToolBar(this);
176 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
177 label = new QLabel( tr("ipkgfind: "), searchBar );
178 label->setBackgroundColor( searchBar->backgroundColor() );
179 searchBar->setHorizontalStretchable( TRUE );
180 searchEdit = new QLineEdit( searchBar, "seachEdit" );
181 searchBar->setStretchableWidget( searchEdit );
182// connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
183// this, SLOT( displayList() ) );
184 a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 );
185 connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) );
186 a->addTo( searchBar );
187 searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
188 connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) );
189 searchCommit->addTo( searchBar );
190 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
191 connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) );
192 a->addTo( searchBar );
193 searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 );
194 connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) );
195 searchAction->setToggleAction( true );
196 searchAction->addTo( viewMenu );
197
198 //DEST
172 destBar = new QPEToolBar(this); 199 destBar = new QPEToolBar(this);
173 addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); 200 addToolBar( destBar, "Destination", QMainWindow::Top, TRUE );
174 label = new QLabel( tr("Destination: "), destBar ); 201 label = new QLabel( tr("Destination: "), destBar );
175 label->setBackgroundColor( destBar->backgroundColor() ); 202 label->setBackgroundColor( destBar->backgroundColor() );
176 destBar->setHorizontalStretchable( TRUE ); 203 destBar->setHorizontalStretchable( TRUE );
177 destination = new QComboBox( false, destBar ); 204 destination = new QComboBox( false, destBar );
178 destination->insertStringList( settings->getDestinationNames() ); 205 destination->insertStringList( settings->getDestinationNames() );
179 setComboName(destination,settings->getDestinationName()); 206 setComboName(destination,settings->getDestinationName());
180// connect( destination, SIGNAL(activated(int)), 207 connect( destination, SIGNAL(activated(int)),
181 // SLOT(activeDestinationChange(int)) ); 208 settings, SLOT(activeDestinationChange(int)) );
182 spacer = new QLabel( " ", destBar ); 209 spacer = new QLabel( " ", destBar );
183 spacer->setBackgroundColor( destBar->backgroundColor() ); 210 spacer->setBackgroundColor( destBar->backgroundColor() );
184 CheckBoxLink = new QCheckBox( tr("Link"), destBar); 211 CheckBoxLink = new QCheckBox( tr("Link"), destBar);
185 CheckBoxLink->setBackgroundColor( destBar->backgroundColor() ); 212 CheckBoxLink->setBackgroundColor( destBar->backgroundColor() );
186 CheckBoxLink->setChecked( settings->createLinks() ); 213 CheckBoxLink->setChecked( settings->createLinks() );
187// connect( CheckBoxLink, SIGNAL(toggled(bool)), 214 connect( CheckBoxLink, SIGNAL(toggled(bool)),
188 // settings, SLOT(linkEnabled(bool)) ); 215 settings, SLOT(linkEnabled(bool)) );
189 destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); 216 destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 );
190 connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); 217 connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) );
191 a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 218 a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
192 connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); 219 connect( a, SIGNAL( activated() ), SLOT( destClose() ) );
193 a->addTo( destBar ); 220 a->addTo( destBar );
194 destBar->setStretchableWidget( CheckBoxLink ); 221 destBar->setStretchableWidget( CheckBoxLink );
@@ -197,29 +224,32 @@ void MainWindow::makeMenu()
197 224
198 // configure the menus 225 // configure the menus
199 Config cfg( "oipkg", Config::User ); 226 Config cfg( "oipkg", Config::User );
200 cfg.setGroup( "gui" ); 227 cfg.setGroup( "gui" );
201 228
202 findShow( cfg.readBoolEntry( "findBar", true ) ); 229 findShow( cfg.readBoolEntry( "findBar", true ) );
230 searchShow( cfg.readBoolEntry( "searchBar", true ) );
203 sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); 231 sectionShow( cfg.readBoolEntry( "sectionBar", true ) );
204 destShow( cfg.readBoolEntry( "destBar", false ) ); 232 destShow( cfg.readBoolEntry( "destBar", false ) );
205} 233}
206 234
207MainWindow::~MainWindow() 235MainWindow::~MainWindow()
208{ 236{
209 Config cfg( "oipkg", Config::User ); 237 Config cfg( "oipkg", Config::User );
210 cfg.setGroup( "gui" ); 238 cfg.setGroup( "gui" );
211 cfg.writeEntry( "findBar", !findBar->isHidden() ); 239 cfg.writeEntry( "findBar", !findBar->isHidden() );
240 cfg.writeEntry( "searchBar", !searchBar->isHidden() );
212 cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); 241 cfg.writeEntry( "sectionBar", !sectionBar->isHidden() );
213 cfg.writeEntry( "destBar", !destBar->isHidden() ); 242 cfg.writeEntry( "destBar", !destBar->isHidden() );
214 243
215} 244}
216 245
217void MainWindow::runIpkg() 246void MainWindow::runIpkg()
218{ 247{
219 packageList.allPackages(); 248 packageList.allPackages();
249 ipkg->loadList( packageListSearch );
220 ipkg->commit( packageList ); 250 ipkg->commit( packageList );
221 // ##### If we looked in the list of files, we could send out accurate 251 // ##### If we looked in the list of files, we could send out accurate
222 // ##### messages. But we don't bother yet, and just do an "all". 252 // ##### messages. But we don't bother yet, and just do an "all".
223 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 253 QCopEnvelope e("QPE/System", "linkChanged(QString)");
224 QString lf = QString::null; 254 QString lf = QString::null;
225 e << lf; 255 e << lf;
@@ -251,18 +281,27 @@ void MainWindow::filterList()
251void MainWindow::displayList() 281void MainWindow::displayList()
252{ 282{
253 //wait->hide(); 283 //wait->hide();
254 filterList(); 284 filterList();
255 listViewPackages->clear(); 285 listViewPackages->clear();
256 Package *pack = packageList.first(); 286 Package *pack = packageList.first();
287 PackageListItem *item;
288
289 QCheckListItem *rootLocal = new QCheckListItem(listViewPackages,tr("local"));
290 QCheckListItem *rootSearch = new QCheckListItem(listViewPackages,tr("ipkgfind"));
257 while( pack ) 291 while( pack )
258 { 292 {
259 if ( pack && (pack->name() != "") ) 293 item = new PackageListItem( rootLocal, pack, settings );
260 listViewPackages->insertItem( new PackageListItem( listViewPackages, pack, settings ) );
261 pack = packageList.next(); 294 pack = packageList.next();
262 } 295 }
296 pack = packageListSearch.first();
297 while( pack )
298 {
299 item = new PackageListItem( rootSearch, pack, settings );
300 pack = packageListSearch.next();
301 }
263} 302}
264 303
265void MainWindow::sectionChanged() 304void MainWindow::sectionChanged()
266{ 305{
267 disconnect( section, SIGNAL( activated(int) ), 306 disconnect( section, SIGNAL( activated(int) ),
268 this, SLOT( sectionChanged() ) ); 307 this, SLOT( sectionChanged() ) );
@@ -342,12 +381,25 @@ void MainWindow::findShow(bool b)
342 381
343void MainWindow::findClose() 382void MainWindow::findClose()
344{ 383{
345 findAction->setOn( false ); 384 findAction->setOn( false );
346} 385}
347 386
387void MainWindow::searchShow(bool b)
388{
389 if (b) searchBar->show();
390 else searchBar->hide();
391 searchAction->setOn( b );
392}
393
394void MainWindow::searchClose()
395{
396 searchAction->setOn( false );
397}
398
399
348void MainWindow::destShow(bool b) 400void MainWindow::destShow(bool b)
349{ 401{
350 if (b) destBar->show(); 402 if (b) destBar->show();
351 else destBar->hide(); 403 else destBar->hide();
352 destAction->setOn( b ); 404 destAction->setOn( b );
353} 405}
@@ -417,6 +469,25 @@ void MainWindow::receive(const QCString &msg, const QByteArray &arg)
417 { 469 {
418 ipkg->removeLinks( QString(arg) ); 470 ipkg->removeLinks( QString(arg) );
419 }else{ 471 }else{
420 pvDebug(2,"Huh what do ya want") 472 pvDebug(2,"Huh what do ya want")
421 } 473 }
422} 474}
475
476
477void MainWindow::createLinks()
478{
479 pvDebug(2,"creating links...");
480 ipkg->createLinks( settings->destinationurl->text() );
481}
482
483void MainWindow::removeLinks()
484{
485 pvDebug(2,"removing links...");
486 ipkg->removeLinks( settings->destinationurl->text() );
487}
488
489void MainWindow::remotePackageQuery()
490{
491 packageListSearch.query( searchEdit->text() );
492 displayList();
493}