Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

configdlg.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002    application:             : ODict
00003 
00004    begin                    : December 2002
00005    copyright                : ( C ) 2002, 2003 by Carsten Niehaus
00006    email                    : cniehaus@handhelds.org
00007  **************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  * This program is free software; you can redistribute it and/or modify    *
00012  * it under the terms of the GNU General Public License as published by    *
00013  * the Free Software Foundation; either version 2 of the License, or       *
00014  * ( at your option ) any later version.                                   *
00015  *                                                                         *
00016  **************************************************************************/
00017 #include "configdlg.h"
00018 #include "searchmethoddlg.h"
00019 
00020 #include <qpe/qpeapplication.h>
00021 #include <qpe/config.h>
00022 
00023 #include <qlayout.h>
00024 #include <qvbox.h>
00025 #include <qlistview.h>
00026 #include <qpushbutton.h>
00027 #include <qlineedit.h>
00028 
00029 ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal)
00030 {
00031         setCaption( tr( "Options" ) );
00032         QVBoxLayout *vbox_layout = new QVBoxLayout( this );
00033         search_tab = new QWidget( this , "search_tab" );
00034         QVBoxLayout *vbox_layout_searchtab = new QVBoxLayout( search_tab, 4 , 4 ,"blah" );
00035 
00036         QHBox *hbox = new QHBox( search_tab );
00037         list = new QListView( hbox );
00038         list->addColumn( tr( "Searchmethod" ) );
00039         loadSearchMethodNames();
00040 
00041         QVBox *vbox = new QVBox( hbox );
00042         new_button = new QPushButton( tr( "New" ) , vbox );
00043         change_button = new QPushButton( tr( "Change" ) , vbox );
00044         delete_button = new QPushButton( tr( "Delete" ) , vbox );
00045         connect( new_button, SIGNAL( clicked() ), this, SLOT( slotNewMethod() ) );
00046         connect( change_button, SIGNAL( clicked() ), this, SLOT( slotChangeMethod() ));
00047         connect( delete_button, SIGNAL( clicked() ), this, SLOT( slotDeleteMethod() ));
00048 
00049         vbox_layout_searchtab->addWidget( hbox );
00050 
00051         vbox_layout->addWidget( search_tab );
00052 
00053         QPEApplication::showDialog( this );
00054 }
00055 
00056 void ConfigDlg::slotNewMethod()
00057 {
00058         SearchMethodDlg dlg( this, "SearchMethodDlg", true );
00059         if ( dlg.exec() == QDialog::Accepted )
00060         {
00061                 dlg.saveItem();
00062                 QListViewItem *item = new QListViewItem( list );
00063                 item->setText( 0 , dlg.nameLE->text() );
00064         }
00065 }
00066 
00067 void ConfigDlg::slotChangeMethod()
00068 {
00069         if ( list->selectedItem() )
00070         {
00071                 SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) );
00072                 if ( dlg.exec() == QDialog::Accepted )
00073                 {
00074                         dlg.saveItem();
00075                         QListViewItem *item = list->selectedItem();
00076                         item->setText( 0 , dlg.nameLE->text() );
00077                 }
00078         }
00079 }
00080 
00081 void ConfigDlg::slotDeleteMethod()
00082 {
00083         if ( list->selectedItem() )
00084         {
00085                 Config cfg ( "odict" );
00086                 cfg.setGroup( "Method_"+list->selectedItem()->text(0) );
00087                 cfg.clearGroup();
00088                 //FIXME: this only removes the entries but not the group itself
00089 
00090                 list->takeItem( list->selectedItem() );
00091         }
00092 }
00093 
00094 void ConfigDlg::loadSearchMethodNames()
00095 {
00096         Config cfg(  "odict" );
00097         QStringList groupListCfg = cfg.groupList().grep( "Method_" );
00098         for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
00099         {
00100                 cfg.setGroup( *it );
00101                 QString name = cfg.readEntry( "Name" );
00102                 if ( name != QString::null ) {
00103                         QListViewItem *item = new QListViewItem( list );
00104                         item->setText( 0 , name );
00105                 }
00106         }
00107 }

Generated on Sat Nov 5 16:15:46 2005 for OPIE by  doxygen 1.4.2