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

searchmethoddlg.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 "searchmethoddlg.h"
00018 
00019 #include <opie2/ofileselector.h>
00020 #include <opie2/ofiledialog.h>
00021 
00022 #include <qpe/config.h>
00023 #include <qpe/qpeapplication.h>
00024 
00025 #include <qlayout.h>
00026 #include <qvbox.h>
00027 #include <qlabel.h>
00028 #include <qpushbutton.h>
00029 #include <qlineedit.h>
00030 #include <qdir.h>
00031 
00032 using namespace Opie::Ui;
00033 
00034 SearchMethodDlg::SearchMethodDlg(QWidget *parent, const char *name, bool modal, QString itemname) : QDialog(parent, name, modal)
00035 {
00036 
00037         QVBoxLayout *vbox_layout = new QVBoxLayout( this, 4,4,"vbox_layout" );
00038         QVBox *vbox = new QVBox( this );
00039 
00040         QHBox *hbox1 = new QHBox( vbox );
00041         QLabel *nameLabel = new QLabel( tr( "Name:" ) , hbox1 );
00042         nameLE = new QLineEdit( hbox1 );
00043 
00044         QLabel *dictLabel = new QLabel( tr( "Dictionary file" ), vbox );
00045         QHBox *hbox2 = new QHBox( vbox );
00046         dictFileLE = new QLineEdit( hbox2 );
00047         QPushButton *browseButton = new QPushButton( tr( "Browse" ) , hbox2 );
00048         connect( browseButton, SIGNAL( clicked() ), this, SLOT( slotBrowse() ) );
00049 
00050         QWidget *dummywidget = new QWidget( vbox );
00051         QLabel *lag1 = new QLabel( tr( "Language 1" ),dummywidget);
00052         QLabel *devider = new QLabel( tr( "Decollator" ),dummywidget);
00053         QLabel *lag2 = new QLabel( tr( "Language 2" ),dummywidget);
00054         lang1 = new QLineEdit( dummywidget );
00055         lang2 = new QLineEdit( dummywidget );
00056         trenner = new QLineEdit( dummywidget );
00057                 trenner->setText( "::" );
00058 
00059         QGridLayout *grid = new QGridLayout( dummywidget, 2,3 );
00060         grid->addWidget( lag1, 0,0 );
00061         grid->addWidget( devider, 0,1 );
00062         grid->addWidget( lag2, 0,2 );
00063         grid->addWidget( lang1, 1,0 );
00064         grid->addWidget( trenner, 1,1 );
00065         grid->addWidget( lang2, 1,2 );
00066 
00067         vbox_layout->addWidget( vbox );
00068 
00069         if( !itemname )
00070                 setCaption( tr( "New Searchmethod" ) );
00071         else
00072         {
00073                 setCaption( tr( "Change Searchmethod" ) );
00074                 itemName = itemname;
00075                 setupEntries(itemname);
00076         }
00077 
00078         QPEApplication::showDialog ( this );
00079 }
00080 
00081 void SearchMethodDlg::setupEntries( QString item )
00082 {
00083         Config cfg(  "odict" );
00084         cfg.setGroup( "Method_"+itemName );
00085         trenner->setText( cfg.readEntry( "Seperator" ) );
00086         lang1->setText( cfg.readEntry( "Lang1" ) );
00087         lang2->setText( cfg.readEntry( "Lang2" ) );
00088         nameLE->setText( itemName );
00089         dictFileLE->setText( cfg.readEntry( "file" ) );
00090 }
00091 
00092 void SearchMethodDlg::slotBrowse()
00093 {
00094         itemName=OFileDialog::getOpenFileName( OFileSelector::EXTENDED,QDir::homeDirPath());
00095         dictFileLE->setText( itemName );
00096 }
00097 
00098 void SearchMethodDlg::saveItem()
00099 {
00100         QString name = nameLE->text();
00101         Config cfg(  "odict" );
00102         cfg.setGroup( "Method_"+name );
00103         cfg.writeEntry( "Name", name );
00104         cfg.writeEntry( "Seperator", trenner->text() );
00105         cfg.writeEntry( "Lang1", lang1->text() );
00106         cfg.writeEntry( "Lang2", lang2->text() );
00107         cfg.writeEntry( "file", dictFileLE->text() );
00108 }

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