summaryrefslogtreecommitdiff
authordrw <drw>2004-12-21 18:40:42 (UTC)
committer drw <drw>2004-12-21 18:40:42 (UTC)
commit570c8709d1d7622e2a57432f40a67213216d2606 (patch) (unidiff)
tree663a8fd177364ad6c2550eb8cee95f98ea664d87
parent23fa4508dabaf07a67e1e9bd9e66a7088a014ad0 (diff)
downloadopie-570c8709d1d7622e2a57432f40a67213216d2606.zip
opie-570c8709d1d7622e2a57432f40a67213216d2606.tar.gz
opie-570c8709d1d7622e2a57432f40a67213216d2606.tar.bz2
Reworked destination config tab UI
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp238
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.h41
2 files changed, 151 insertions, 128 deletions
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index 6805863..77ad220 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -51,9 +51,7 @@ OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *paren
51 , m_ipkg( ipkg ) 51 , m_ipkg( ipkg )
52 , m_configs( 0l ) 52 , m_configs( 0l )
53 , m_installOptions( installOptions ) 53 , m_installOptions( installOptions )
54 , m_serverNew( false )
55 , m_serverCurrent( -1 ) 54 , m_serverCurrent( -1 )
56 , m_destNew( false )
57 , m_destCurrent( -1 ) 55 , m_destCurrent( -1 )
58 , m_layout( this, 2, 4 ) 56 , m_layout( this, 2, 4 )
59 , m_tabWidget( this ) 57 , m_tabWidget( this )
@@ -173,7 +171,7 @@ void OIpkgConfigDlg::initServerWidget()
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." ) ); 171 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." ) );
174 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 172 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
175 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) ); 173 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) );
176 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); 174 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 );
177 175
178 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 176 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
179 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); 177 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
@@ -205,58 +203,30 @@ void OIpkgConfigDlg::initDestinationWidget()
205 sv->setFrameStyle( QFrame::NoFrame ); 203 sv->setFrameStyle( QFrame::NoFrame );
206 QWidget *container = new QWidget( sv->viewport() ); 204 QWidget *container = new QWidget( sv->viewport() );
207 sv->addChild( container ); 205 sv->addChild( container );
208 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 206 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 );
209 207
210 m_destList = new QListBox( container ); 208 m_destList = new QListBox( container );
211 QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) ); 209 QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) );
212 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 210 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
213 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) ); 211 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) );
214 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 ); 212 layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 );
215 213
216 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 214 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
217 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); 215 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
218 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); 216 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );
219 layout->addWidget( btn, 1, 0 ); 217 layout->addWidget( btn, 1, 0 );
220 218
221 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 219 m_destEditBtn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), container );
222 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); 220 m_destEditBtn->setEnabled( false );
223 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); 221 QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) );
224 layout->addWidget( btn, 1, 1 ); 222 connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) );
225 223 layout->addWidget( m_destEditBtn, 1, 1 );
226 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container );
227 grpbox->layout()->setSpacing( 2 );
228 grpbox->layout()->setMargin( 4 );
229 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
230
231 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
232
233 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
234 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
235 grplayout->addWidget( label, 0, 0 );
236 m_destName = new QLineEdit( grpbox );
237 QWhatsThis::add( m_destName, tr( "Enter the name of this entry here." ) );
238 grplayout->addMultiCellWidget( m_destName, 0, 0, 1, 2 );
239
240 label = new QLabel( tr( "Location:" ), grpbox );
241 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) );
242 grplayout->addWidget( label, 1, 0 );
243 m_destLocation = new QLineEdit( grpbox );
244 QWhatsThis::add( m_destLocation, tr( "Enter the absolute directory path of this entry here." ) );
245 grplayout->addWidget( m_destLocation, 1, 1 );
246 btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, grpbox );
247 btn->setMaximumWidth( btn->height() );
248 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) );
249 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestSelectPath()) );
250 grplayout->addWidget( btn, 1, 2 );
251 224
252 m_destActive = new QCheckBox( tr( "Active" ), grpbox ); 225 m_destDeleteBtn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
253 QWhatsThis::add( m_destActive, tr( "Tap here to indicate whether this entry is active or not." ) ); 226 m_destDeleteBtn->setEnabled( false );
254 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 2 ); 227 QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
255 228 connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) );
256 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 229 layout->addWidget( m_destDeleteBtn, 1, 2 );
257 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) );
258 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) );
259 grplayout->addMultiCellWidget( btn, 3, 3, 0, 2 );
260} 230}
261 231
262void OIpkgConfigDlg::initProxyWidget() 232void OIpkgConfigDlg::initProxyWidget()
@@ -474,7 +444,7 @@ void OIpkgConfigDlg::slotServerEdit()
474 // Find selected server in list 444 // Find selected server in list
475 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 445 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
476 446
477 // Delete server 447 // Edit server
478 if ( server ) 448 if ( server )
479 { 449 {
480 QString origName = server->name(); 450 QString origName = server->name();
@@ -501,96 +471,63 @@ void OIpkgConfigDlg::slotServerDelete()
501 } 471 }
502} 472}
503 473
504void OIpkgConfigDlg::slotDestEdit( int index ) 474void OIpkgConfigDlg::slotDestSelected( int index )
505{ 475{
506 m_destNew = false;
507 m_destCurrent = index; 476 m_destCurrent = index;
508 477
509 // Find selected destination in list 478 // Enable Edit and Delete buttons
510 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 479 m_destEditBtn->setEnabled( true );
511 480 m_destDeleteBtn->setEnabled( true );
512 // Display destination details
513 if ( destination )
514 {
515 m_destCurrName = destination->name();
516 m_destName->setText( destination->name() );
517 m_destLocation->setText( destination->value() );
518 m_destActive->setChecked( destination->active() );
519 m_destName->setFocus();
520 }
521} 481}
522 482
523void OIpkgConfigDlg::slotDestNew() 483void OIpkgConfigDlg::slotDestNew()
524{ 484{
525 m_destNew = true; 485 OConfItem *dest = new OConfItem( OConfItem::Destination );
526 486
527 m_destName->setText( QString::null ); 487 OIpkgDestDlg dlg( dest, this );
528 m_destLocation->setText( QString::null ); 488 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
529 m_destActive->setChecked( true );
530 m_destName->setFocus();
531}
532
533void OIpkgConfigDlg::slotDestDelete()
534{ 489{
535 // Find selected destination in list 490 // Add to configuration option list
536 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 491 m_configs->append( dest );
492 m_configs->sort();
537 493
538 // Delete destination 494 // Add to destination list
539 if ( destination ) 495 m_destList->insertItem( dest->name() );
540 { 496 m_destList->setCurrentItem( m_destList->count() );
541 m_configs->removeRef( destination );
542 m_destList->removeItem( m_destCurrent );
543 }
544} 497}
545 498 else
546void OIpkgConfigDlg::slotDestSelectPath() 499 delete dest;
547{
548 QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_destLocation->text() );
549 if ( path.at( path.length() - 1 ) == '/' )
550 path.truncate( path.length() - 1 );
551 m_destLocation->setText( path );
552} 500}
553 501
554void OIpkgConfigDlg::slotDestUpdate() 502void OIpkgConfigDlg::slotDestEdit()
555{
556 QString newName = m_destName->text();
557
558 // Convert any spaces to underscores
559 newName.replace( QRegExp( " " ), "_" );
560
561 if ( !m_destNew )
562 { 503 {
563 // Find selected destination in list 504 // Find selected destination in list
564 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName ); 505 OConfItem *dest = findConfItem( OConfItem::Destination, m_destList->currentText() );
565 506
566 // Display destination details 507 // Edit destination
567 if ( destination ) 508 if ( dest )
568 { 509 {
569 // Update url 510 QString origName = dest->name();
570 destination->setValue( m_destLocation->text() ); 511 OIpkgDestDlg dlg( dest, this );
571 destination->setActive( m_destActive->isChecked() ); 512 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
572
573 // Check if destination name has changed, if it has then we need to replace the key in the map
574 if ( m_destCurrName != newName )
575 { 513 {
576 // Update destination name 514 // Check to see if name has changed, if so update the dest list
577 destination->setName( newName ); 515 if ( dest->name() != origName )
578 516 m_destList->changeItem( dest->name(), m_destCurrent );
579 // Update list box
580 m_destList->changeItem( newName, m_destCurrent );
581 } 517 }
582 } 518 }
583 } 519 }
584 else 520
521void OIpkgConfigDlg::slotDestDelete()
585 { 522 {
586 // Add new destination to configuration list 523 // Find selected destination in list
587 m_configs->append( new OConfItem( OConfItem::Destination, newName, 524 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
588 m_destLocation->text(), QString::null, m_destActive->isChecked() ) );
589 m_configs->sort();
590 525
591 m_destList->insertItem( newName ); 526 // Delete destination
592 m_destList->setCurrentItem( m_destList->count() ); 527 if ( destination )
593 m_destNew = false; 528 {
529 m_configs->removeRef( destination );
530 m_destList->removeItem( m_destCurrent );
594 } 531 }
595} 532}
596 533
@@ -598,7 +535,7 @@ OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent )
598 : QDialog( parent, QString::null, true, WStyle_ContextHelp ) 535 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
599 , m_server( server ) 536 , m_server( server )
600{ 537{
601 setCaption( tr( "Edit server" ) ); 538 setCaption( tr( "Edit Server" ) );
602 539
603 // Initialize UI 540 // Initialize UI
604 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 ); 541 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );
@@ -644,7 +581,9 @@ OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent )
644void OIpkgServerDlg::accept() 581void OIpkgServerDlg::accept()
645{ 582{
646 // Save information entered 583 // Save information entered
647 m_server->setName( m_name->text() ); 584 QString name = m_name->text();
585 name.replace( QRegExp( " " ), "_" );
586 m_server->setName( name );
648 m_server->setValue( m_location->text() ); 587 m_server->setValue( m_location->text() );
649 m_compressed->isChecked() ? m_server->setFeatures( "Compressed" ) 588 m_compressed->isChecked() ? m_server->setFeatures( "Compressed" )
650 : m_server->setFeatures( QString::null ); 589 : m_server->setFeatures( QString::null );
@@ -652,3 +591,74 @@ void OIpkgServerDlg::accept()
652 591
653 QDialog::accept(); 592 QDialog::accept();
654} 593}
594
595OIpkgDestDlg::OIpkgDestDlg( OConfItem *dest, QWidget *parent )
596 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
597 , m_dest( dest )
598{
599 setCaption( tr( "Edit Destination" ) );
600
601 // Initialize UI
602 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );
603
604 m_active = new QCheckBox( tr( "Active" ), this );
605 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
606 layout->addWidget( m_active );
607
608 layout->addStretch();
609
610 QLabel *label = new QLabel( tr( "Name:" ), this );
611 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
612 layout->addWidget( label );
613 m_name = new QLineEdit( this );
614 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
615 layout->addWidget( m_name );
616
617 layout->addStretch();
618
619 label = new QLabel( tr( "Location:" ), this );
620 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) );
621 layout->addWidget( label );
622
623 QHBoxLayout *layout2 = new QHBoxLayout( this, 2, 4 );
624 layout->addLayout( layout2 );
625
626 m_location = new QLineEdit( this );
627 QWhatsThis::add( m_location, tr( "Enter the absolute directory path of this entry here." ) );
628 layout2->addWidget( m_location );
629 QPushButton *btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, this );
630 btn->setMaximumWidth( btn->height() );
631 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) );
632 connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) );
633 layout2->addWidget( btn );
634
635 // Populate initial information
636 if ( m_dest )
637 {
638 m_name->setText( m_dest->name() );
639 m_location->setText( m_dest->value() );
640 m_active->setChecked( m_dest->active() );
641 }
642}
643
644void OIpkgDestDlg::accept()
645{
646 // Save information entered
647 QString name = m_name->text();
648 name.replace( QRegExp( " " ), "_" );
649 m_dest->setName( name );
650 m_dest->setValue( m_location->text() );
651 m_dest->setActive( m_active->isChecked() );
652
653 QDialog::accept();
654}
655
656void OIpkgDestDlg::slotSelectPath()
657{
658 QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_location->text() );
659 if ( path.at( path.length() - 1 ) == '/' )
660 path.truncate( path.length() - 1 );
661 if ( !path.isNull() )
662 m_location->setText( path );
663}
664
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h
index 076a181..5b7e91d 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.h
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.h
@@ -63,15 +63,9 @@ private:
63 63
64 bool m_installOptions; // If true, will only display the Options tab 64 bool m_installOptions; // If true, will only display the Options tab
65 65
66 // Server cached information 66 // Server/Destination cached information
67 bool m_serverNew; // Indicates if server information is for a new server
68 int m_serverCurrent; // Index of currently selected server in m_serverList 67 int m_serverCurrent; // Index of currently selected server in m_serverList
69 QString m_serverCurrName; // Name of currently selected server in m_serverList
70
71 // Destination cached information
72 bool m_destNew; // Indicates if destination information is for a new destination
73 int m_destCurrent; // Index of currently selected destination in m_destList 68 int m_destCurrent; // Index of currently selected destination in m_destList
74 QString m_destCurrName; // Name of currently selected destination in m_destList
75 69
76 // UI controls 70 // UI controls
77 QVBoxLayout m_layout; // Main dialog layout control 71 QVBoxLayout m_layout; // Main dialog layout control
@@ -88,9 +82,8 @@ private:
88 82
89 // Destination configuration UI controls 83 // Destination configuration UI controls
90 QListBox *m_destList; // Destination list selection 84 QListBox *m_destList; // Destination list selection
91 QLineEdit *m_destName; // Destination name edit box 85 QPushButton *m_destEditBtn; // Destination edit button
92 QLineEdit *m_destLocation; // Destination location URL edit box 86 QPushButton *m_destDeleteBtn; // Destination edit button
93 QCheckBox *m_destActive; // Activate destination check box
94 87
95 // Proxy server configuration UI controls 88 // Proxy server configuration UI controls
96 QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box 89 QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box
@@ -122,13 +115,11 @@ private slots:
122 void slotServerNew(); 115 void slotServerNew();
123 void slotServerEdit(); 116 void slotServerEdit();
124 void slotServerDelete(); 117 void slotServerDelete();
125// void slotServerUpdate();
126 118
127 void slotDestEdit( int index ); 119 void slotDestSelected( int index );
128 void slotDestNew(); 120 void slotDestNew();
121 void slotDestEdit();
129 void slotDestDelete(); 122 void slotDestDelete();
130 void slotDestSelectPath();
131 void slotDestUpdate();
132}; 123};
133 124
134class OIpkgServerDlg : public QDialog 125class OIpkgServerDlg : public QDialog
@@ -151,4 +142,26 @@ private:
151 QCheckBox *m_active; // Indicates whether the server is activated 142 QCheckBox *m_active; // Indicates whether the server is activated
152}; 143};
153 144
145class OIpkgDestDlg : public QDialog
146{
147 Q_OBJECT
148
149public:
150 OIpkgDestDlg( OConfItem *dest = 0l, QWidget *parent = 0l );
151
152protected slots:
153 void accept();
154
155private:
156 OConfItem *m_dest;
157
158 // UI controls
159 QLineEdit *m_name; // Destination name edit box
160 QLineEdit *m_location; // Destination location URL edit box
161 QCheckBox *m_active; // Indicates whether the destination is activated
162
163private slots:
164 void slotSelectPath();
165};
166
154#endif 167#endif