summaryrefslogtreecommitdiff
authordrw <drw>2004-12-21 17:56:04 (UTC)
committer drw <drw>2004-12-21 17:56:04 (UTC)
commit23fa4508dabaf07a67e1e9bd9e66a7088a014ad0 (patch) (unidiff)
tree37c602b938dff7be3e2e76658497507fbf53d3eb
parent769f2a09ccfcc639a87600ecb046e9140fe2f691 (diff)
downloadopie-23fa4508dabaf07a67e1e9bd9e66a7088a014ad0.zip
opie-23fa4508dabaf07a67e1e9bd9e66a7088a014ad0.tar.gz
opie-23fa4508dabaf07a67e1e9bd9e66a7088a014ad0.tar.bz2
Reworked server config tab UI and included option to support src/gz feeds
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp211
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.h38
2 files changed, 141 insertions, 108 deletions
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index d9a67f3..6805863 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -33,6 +33,7 @@ _;:, .> :=|. This program is free software; you can
33 33
34#include <opie2/ofiledialog.h> 34#include <opie2/ofiledialog.h>
35 35
36#include <qpe/qpeapplication.h>
36#include <qpe/resource.h> 37#include <qpe/resource.h>
37 38
38#include <qcheckbox.h> 39#include <qcheckbox.h>
@@ -48,7 +49,7 @@ _;:, .> :=|. This program is free software; you can
48OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) 49OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
49 : QDialog( parent, QString::null, true, WStyle_ContextHelp ) 50 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
50 , m_ipkg( ipkg ) 51 , m_ipkg( ipkg )
51 , m_configs( 0x0 ) 52 , m_configs( 0l )
52 , m_installOptions( installOptions ) 53 , m_installOptions( installOptions )
53 , m_serverNew( false ) 54 , m_serverNew( false )
54 , m_serverCurrent( -1 ) 55 , m_serverCurrent( -1 )
@@ -166,12 +167,12 @@ void OIpkgConfigDlg::initServerWidget()
166 sv->setFrameStyle( QFrame::NoFrame ); 167 sv->setFrameStyle( QFrame::NoFrame );
167 QWidget *container = new QWidget( sv->viewport() ); 168 QWidget *container = new QWidget( sv->viewport() );
168 sv->addChild( container ); 169 sv->addChild( container );
169 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 170 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 );
170 171
171 m_serverList = new QListBox( container ); 172 m_serverList = new QListBox( container );
172 QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); 173 QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) );
173 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 174 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
174 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) ); 175 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) );
175 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); 176 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 );
176 177
177 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 178 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
@@ -179,40 +180,17 @@ void OIpkgConfigDlg::initServerWidget()
179 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); 180 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
180 layout->addWidget( btn, 1, 0 ); 181 layout->addWidget( btn, 1, 0 );
181 182
182 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 183 m_serverEditBtn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), container );
183 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); 184 m_serverEditBtn->setEnabled( false );
184 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); 185 QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) );
185 layout->addWidget( btn, 1, 1 ); 186 connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) );
186 187 layout->addWidget( m_serverEditBtn, 1, 1 );
187 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 188
188 grpbox->layout()->setSpacing( 2 ); 189 m_serverDeleteBtn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
189 grpbox->layout()->setMargin( 4 ); 190 m_serverDeleteBtn->setEnabled( false );
190 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 191 QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
191 192 connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
192 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 193 layout->addWidget( m_serverDeleteBtn, 1, 2 );
193
194 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
195 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
196 grplayout->addWidget( label, 0, 0 );
197 m_serverName = new QLineEdit( grpbox );
198 QWhatsThis::add( m_serverName, tr( "Enter the name of this entry here." ) );
199 grplayout->addWidget( m_serverName, 0, 1 );
200
201 label = new QLabel( tr( "Address:" ), grpbox );
202 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
203 grplayout->addWidget( label, 1, 0 );
204 m_serverLocation = new QLineEdit( grpbox );
205 QWhatsThis::add( m_serverLocation, tr( "Enter the URL address of this entry here." ) );
206 grplayout->addWidget( m_serverLocation, 1, 1 );
207
208 m_serverActive = new QCheckBox( tr( "Active" ), grpbox );
209 QWhatsThis::add( m_serverActive, tr( "Tap here to indicate whether this entry is active or not." ) );
210 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 );
211
212 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
213 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) );
214 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) );
215 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
216} 194}
217 195
218void OIpkgConfigDlg::initDestinationWidget() 196void OIpkgConfigDlg::initDestinationWidget()
@@ -449,7 +427,7 @@ OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &na
449{ 427{
450 // Find selected server in list 428 // Find selected server in list
451 OConfItemListIterator configIt( *m_configs ); 429 OConfItemListIterator configIt( *m_configs );
452 OConfItem *config = 0x0; 430 OConfItem *config = 0l;
453 for ( ; configIt.current(); ++configIt ) 431 for ( ; configIt.current(); ++configIt )
454 { 432 {
455 config = configIt.current(); 433 config = configIt.current();
@@ -460,39 +438,38 @@ OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &na
460 if ( config && config->type() == type && config->name() == name ) 438 if ( config && config->type() == type && config->name() == name )
461 return config; 439 return config;
462 440
463 return 0x0; 441 return 0l;
464} 442}
465 443
466void OIpkgConfigDlg::slotServerEdit( int index ) 444void OIpkgConfigDlg::slotServerSelected( int index )
467{ 445{
468 m_serverNew = false;
469 m_serverCurrent = index; 446 m_serverCurrent = index;
470 447
471 // Find selected server in list 448 // Enable Edit and Delete buttons
472 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 449 m_serverEditBtn->setEnabled( true );
473 450 m_serverDeleteBtn->setEnabled( true );
474 // Display server details
475 if ( server )
476 {
477 m_serverCurrName = server->name();
478 m_serverName->setText( server->name() );
479 m_serverLocation->setText( server->value() );
480 m_serverActive->setChecked( server->active() );
481 m_serverName->setFocus();
482 }
483} 451}
484 452
485void OIpkgConfigDlg::slotServerNew() 453void OIpkgConfigDlg::slotServerNew()
486{ 454{
487 m_serverNew = true; 455 OConfItem *server = new OConfItem( OConfItem::Source );
456
457 OIpkgServerDlg dlg( server, this );
458 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
459 {
460 // Add to configuration option list
461 m_configs->append( server );
462 m_configs->sort();
488 463
489 m_serverName->setText( QString::null ); 464 // Add to server list
490 m_serverLocation->setText( QString::null ); 465 m_serverList->insertItem( server->name() );
491 m_serverActive->setChecked( true ); 466 m_serverList->setCurrentItem( m_serverList->count() );
492 m_serverName->setFocus(); 467 }
468 else
469 delete server;
493} 470}
494 471
495void OIpkgConfigDlg::slotServerDelete() 472void OIpkgConfigDlg::slotServerEdit()
496{ 473{
497 // Find selected server in list 474 // Find selected server in list
498 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 475 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
@@ -500,52 +477,27 @@ void OIpkgConfigDlg::slotServerDelete()
500 // Delete server 477 // Delete server
501 if ( server ) 478 if ( server )
502 { 479 {
503 m_configs->removeRef( server ); 480 QString origName = server->name();
504 m_serverList->removeItem( m_serverCurrent ); 481 OIpkgServerDlg dlg( server, this );
482 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
483 {
484 // Check to see if name has changed, if so update the server list
485 if ( server->name() != origName )
486 m_serverList->changeItem( server->name(), m_serverCurrent );
487 }
505 } 488 }
506} 489}
507 490
508void OIpkgConfigDlg::slotServerUpdate() 491void OIpkgConfigDlg::slotServerDelete()
509{ 492{
510 QString newName = m_serverName->text(); 493 // Find selected server in list
511 494 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
512 // Convert any spaces to underscores
513 newName.replace( QRegExp( " " ), "_" );
514
515 if ( !m_serverNew )
516 {
517 // Find selected server in list
518 OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName );
519
520 // Delete server
521 if ( server )
522 {
523 // Update url
524 server->setValue( m_serverLocation->text() );
525 server->setActive( m_serverActive->isChecked() );
526
527 // Check if server name has changed, if it has then we need to replace the key in the map
528 if ( m_serverCurrName != newName )
529 {
530 // Update server name
531 server->setName( newName );
532 495
533 // Update list box 496 // Delete server
534 m_serverList->changeItem( newName, m_serverCurrent ); 497 if ( server )
535 }
536 }
537 }
538 else
539 { 498 {
540 // Add new server to configuration list 499 m_configs->removeRef( server );
541 // TODO - support src/gz 500 m_serverList->removeItem( m_serverCurrent );
542 m_configs->append( new OConfItem( OConfItem::Source, newName, m_serverLocation->text(),
543 QString::null, m_serverActive->isChecked() ) );
544 m_configs->sort();
545
546 m_serverList->insertItem( newName );
547 m_serverList->setCurrentItem( m_serverList->count() );
548 m_serverNew = false;
549 } 501 }
550} 502}
551 503
@@ -641,3 +593,62 @@ void OIpkgConfigDlg::slotDestUpdate()
641 m_destNew = false; 593 m_destNew = false;
642 } 594 }
643} 595}
596
597OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent )
598 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
599 , m_server( server )
600{
601 setCaption( tr( "Edit server" ) );
602
603 // Initialize UI
604 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );
605
606 m_active = new QCheckBox( tr( "Active" ), this );
607 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
608 layout->addWidget( m_active );
609
610 layout->addStretch();
611
612 QLabel *label = new QLabel( tr( "Name:" ), this );
613 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
614 layout->addWidget( label );
615 m_name = new QLineEdit( this );
616 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
617 layout->addWidget( m_name );
618
619 layout->addStretch();
620
621 label = new QLabel( tr( "Address:" ), this );
622 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
623 layout->addWidget( label );
624 m_location = new QLineEdit( this );
625 QWhatsThis::add( m_location, tr( "Enter the URL address of this entry here." ) );
626 layout->addWidget( m_location );
627
628 layout->addStretch();
629
630 m_compressed = new QCheckBox( tr( "Compressed server feed" ), this );
631 QWhatsThis::add( m_compressed, tr( "Tap here to indicate whether the server support compressed archives or not." ) );
632 layout->addWidget( m_compressed );
633
634 // Populate initial information
635 if ( m_server )
636 {
637 m_name->setText( m_server->name() );
638 m_location->setText( m_server->value() );
639 m_compressed->setChecked( m_server->features().contains( "Compressed" ) );
640 m_active->setChecked( m_server->active() );
641 }
642}
643
644void OIpkgServerDlg::accept()
645{
646 // Save information entered
647 m_server->setName( m_name->text() );
648 m_server->setValue( m_location->text() );
649 m_compressed->isChecked() ? m_server->setFeatures( "Compressed" )
650 : m_server->setFeatures( QString::null );
651 m_server->setActive( m_active->isChecked() );
652
653 QDialog::accept();
654}
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h
index a4e4f82..076a181 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.h
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.h
@@ -44,13 +44,14 @@ class QCheckBox;
44class QComboBox; 44class QComboBox;
45class QLineEdit; 45class QLineEdit;
46class QListBox; 46class QListBox;
47class QPushButton;
47 48
48class OIpkgConfigDlg : public QDialog 49class OIpkgConfigDlg : public QDialog
49{ 50{
50 Q_OBJECT 51 Q_OBJECT
51 52
52public: 53public:
53 OIpkgConfigDlg( OIpkg *ipkg = 0x0, bool installOptions = false, QWidget *parent = 0x0 ); 54 OIpkgConfigDlg( OIpkg *ipkg = 0l, bool installOptions = false, QWidget *parent = 0l );
54 55
55protected slots: 56protected slots:
56 void accept(); 57 void accept();
@@ -81,10 +82,9 @@ private:
81 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls 82 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls
82 83
83 // Server configuration UI controls 84 // Server configuration UI controls
84 QListBox *m_serverList; // Server list selection 85 QListBox *m_serverList; // Server list selection
85 QLineEdit *m_serverName; // Server name edit box 86 QPushButton *m_serverEditBtn; // Server edit button
86 QLineEdit *m_serverLocation; // Server location URL edit box 87 QPushButton *m_serverDeleteBtn; // Server edit button
87 QCheckBox *m_serverActive; // Activate server check box
88 88
89 // Destination configuration UI controls 89 // Destination configuration UI controls
90 QListBox *m_destList; // Destination list selection 90 QListBox *m_destList; // Destination list selection
@@ -114,13 +114,15 @@ private:
114 114
115 void initData(); 115 void initData();
116 116
117 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, const QString &name = 0x0 ); 117 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
118 const QString &name = QString::null );
118 119
119private slots: 120private slots:
120 void slotServerEdit( int index ); 121 void slotServerSelected( int index );
121 void slotServerNew(); 122 void slotServerNew();
123 void slotServerEdit();
122 void slotServerDelete(); 124 void slotServerDelete();
123 void slotServerUpdate(); 125// void slotServerUpdate();
124 126
125 void slotDestEdit( int index ); 127 void slotDestEdit( int index );
126 void slotDestNew(); 128 void slotDestNew();
@@ -129,4 +131,24 @@ private slots:
129 void slotDestUpdate(); 131 void slotDestUpdate();
130}; 132};
131 133
134class OIpkgServerDlg : public QDialog
135{
136 Q_OBJECT
137
138public:
139 OIpkgServerDlg( OConfItem *server = 0l, QWidget *parent = 0l );
140
141protected slots:
142 void accept();
143
144private:
145 OConfItem *m_server;
146
147 // UI controls
148 QLineEdit *m_name; // Server name edit box
149 QLineEdit *m_location; // Server location URL edit box
150 QCheckBox *m_compressed; // Indicates whether the server is a 'src/gz' feed
151 QCheckBox *m_active; // Indicates whether the server is activated
152};
153
132#endif 154#endif