summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/odict/configdlg.cpp15
-rw-r--r--noncore/apps/odict/searchmethoddlg.cpp4
2 files changed, 11 insertions, 8 deletions
diff --git a/noncore/apps/odict/configdlg.cpp b/noncore/apps/odict/configdlg.cpp
index 7fa6008..3d98f63 100644
--- a/noncore/apps/odict/configdlg.cpp
+++ b/noncore/apps/odict/configdlg.cpp
@@ -8,97 +8,100 @@
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * ( at your option ) any later version. * 14 * ( at your option ) any later version. *
15 * * 15 * *
16 **************************************************************************/ 16 **************************************************************************/
17#include "configdlg.h" 17#include "configdlg.h"
18#include "searchmethoddlg.h" 18#include "searchmethoddlg.h"
19 19
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/config.h> 21#include <qpe/config.h>
22 22
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qvbox.h> 24#include <qvbox.h>
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28 28
29ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal) 29ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal)
30{ 30{
31 setCaption( tr( "Options" ) ); 31 setCaption( tr( "Options" ) );
32 QVBoxLayout *vbox_layout = new QVBoxLayout( this ); 32 QVBoxLayout *vbox_layout = new QVBoxLayout( this );
33 search_tab = new QWidget( this , "search_tab" ); 33 search_tab = new QWidget( this , "search_tab" );
34 QVBoxLayout *vbox_layout_searchtab = new QVBoxLayout( search_tab, 4 , 4 ,"blah" ); 34 QVBoxLayout *vbox_layout_searchtab = new QVBoxLayout( search_tab, 4 , 4 ,"blah" );
35 35
36 QHBox *hbox = new QHBox( search_tab ); 36 QHBox *hbox = new QHBox( search_tab );
37 list = new QListView( hbox ); 37 list = new QListView( hbox );
38 list->addColumn( tr( "Searchmethod" ) ); 38 list->addColumn( tr( "Searchmethod" ) );
39 loadSearchMethodNames(); 39 loadSearchMethodNames();
40 40
41 QVBox *vbox = new QVBox( hbox ); 41 QVBox *vbox = new QVBox( hbox );
42 new_button = new QPushButton( tr( "New" ) , vbox ); 42 new_button = new QPushButton( tr( "New" ) , vbox );
43 change_button = new QPushButton( tr( "Change" ) , vbox ); 43 change_button = new QPushButton( tr( "Change" ) , vbox );
44 delete_button = new QPushButton( tr( "Delete" ) , vbox ); 44 delete_button = new QPushButton( tr( "Delete" ) , vbox );
45 connect( new_button, SIGNAL( clicked() ), this, SLOT( slotNewMethod() ) ); 45 connect( new_button, SIGNAL( clicked() ), this, SLOT( slotNewMethod() ) );
46 connect( change_button, SIGNAL( clicked() ), this, SLOT( slotChangeMethod() )); 46 connect( change_button, SIGNAL( clicked() ), this, SLOT( slotChangeMethod() ));
47 connect( delete_button, SIGNAL( clicked() ), this, SLOT( slotDeleteMethod() )); 47 connect( delete_button, SIGNAL( clicked() ), this, SLOT( slotDeleteMethod() ));
48 48
49 vbox_layout_searchtab->addWidget( hbox ); 49 vbox_layout_searchtab->addWidget( hbox );
50 50
51 vbox_layout->addWidget( search_tab ); 51 vbox_layout->addWidget( search_tab );
52 52
53 QPEApplication::execDialog( this ); 53 QPEApplication::showDialog( this );
54} 54}
55 55
56void ConfigDlg::slotNewMethod() 56void ConfigDlg::slotNewMethod()
57{ 57{
58 SearchMethodDlg dlg( this, "SearchMethodDlg", true ); 58 SearchMethodDlg dlg( this, "SearchMethodDlg", true );
59 if ( dlg.exec() == QDialog::Accepted ) 59 if ( dlg.exec() == QDialog::Accepted )
60 { 60 {
61 dlg.saveItem(); 61 dlg.saveItem();
62 QListViewItem *item = new QListViewItem( list ); 62 QListViewItem *item = new QListViewItem( list );
63 item->setText( 0 , dlg.nameLE->text() ); 63 item->setText( 0 , dlg.nameLE->text() );
64 } 64 }
65} 65}
66 66
67void ConfigDlg::slotChangeMethod() 67void ConfigDlg::slotChangeMethod()
68{ 68{
69 if ( list->selectedItem() ) 69 if ( list->selectedItem() )
70 { 70 {
71 SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) ); 71 SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) );
72 if ( dlg.exec() == QDialog::Accepted ) 72 if ( dlg.exec() == QDialog::Accepted )
73 { 73 {
74 dlg.saveItem(); 74 dlg.saveItem();
75 QListViewItem *item = list->selectedItem(); 75 QListViewItem *item = list->selectedItem();
76 item->setText( 0 , dlg.nameLE->text() ); 76 item->setText( 0 , dlg.nameLE->text() );
77 } 77 }
78 } 78 }
79} 79}
80 80
81void ConfigDlg::slotDeleteMethod() 81void ConfigDlg::slotDeleteMethod()
82{ 82{
83 if ( list->selectedItem() ) 83 if ( list->selectedItem() )
84 { 84 {
85 Config cfg ( "odict" ); 85 Config cfg ( "odict" );
86 cfg.setGroup( "Method_"+list->selectedItem()->text(0) ); 86 cfg.setGroup( "Method_"+list->selectedItem()->text(0) );
87 cfg.clearGroup(); 87 cfg.clearGroup();
88 //FIXME: this only removes the entries but not the group itself 88 //FIXME: this only removes the entries but not the group itself
89 89
90 list->takeItem( list->selectedItem() ); 90 list->takeItem( list->selectedItem() );
91 } 91 }
92} 92}
93 93
94void ConfigDlg::loadSearchMethodNames() 94void ConfigDlg::loadSearchMethodNames()
95{ 95{
96 Config cfg( "odict" ); 96 Config cfg( "odict" );
97 QStringList groupListCfg = cfg.groupList().grep( "Method_" ); 97 QStringList groupListCfg = cfg.groupList().grep( "Method_" );
98 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) 98 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
99 { 99 {
100 QListViewItem *item = new QListViewItem( list );
101 cfg.setGroup( *it ); 100 cfg.setGroup( *it );
102 item->setText( 0 , cfg.readEntry( "Name" ) ); 101 QString name = cfg.readEntry( "Name" );
102 if ( name != QString::null ) {
103 QListViewItem *item = new QListViewItem( list );
104 item->setText( 0 , name );
105 }
103 } 106 }
104} 107}
diff --git a/noncore/apps/odict/searchmethoddlg.cpp b/noncore/apps/odict/searchmethoddlg.cpp
index 34e8b16..0425657 100644
--- a/noncore/apps/odict/searchmethoddlg.cpp
+++ b/noncore/apps/odict/searchmethoddlg.cpp
@@ -37,72 +37,72 @@ SearchMethodDlg::SearchMethodDlg(QWidget *parent, const char *name, bool modal,
37 QVBoxLayout *vbox_layout = new QVBoxLayout( this, 4,4,"vbox_layout" ); 37 QVBoxLayout *vbox_layout = new QVBoxLayout( this, 4,4,"vbox_layout" );
38 QVBox *vbox = new QVBox( this ); 38 QVBox *vbox = new QVBox( this );
39 39
40 QHBox *hbox1 = new QHBox( vbox ); 40 QHBox *hbox1 = new QHBox( vbox );
41 QLabel *nameLabel = new QLabel( tr( "Name:" ) , hbox1 ); 41 QLabel *nameLabel = new QLabel( tr( "Name:" ) , hbox1 );
42 nameLE = new QLineEdit( hbox1 ); 42 nameLE = new QLineEdit( hbox1 );
43 43
44 QLabel *dictLabel = new QLabel( tr( "Dictionary file" ), vbox ); 44 QLabel *dictLabel = new QLabel( tr( "Dictionary file" ), vbox );
45 QHBox *hbox2 = new QHBox( vbox ); 45 QHBox *hbox2 = new QHBox( vbox );
46 dictFileLE = new QLineEdit( hbox2 ); 46 dictFileLE = new QLineEdit( hbox2 );
47 QPushButton *browseButton = new QPushButton( tr( "Browse" ) , hbox2 ); 47 QPushButton *browseButton = new QPushButton( tr( "Browse" ) , hbox2 );
48 connect( browseButton, SIGNAL( clicked() ), this, SLOT( slotBrowse() ) ); 48 connect( browseButton, SIGNAL( clicked() ), this, SLOT( slotBrowse() ) );
49 49
50 QWidget *dummywidget = new QWidget( vbox ); 50 QWidget *dummywidget = new QWidget( vbox );
51 QLabel *lag1 = new QLabel( tr( "Language 1" ),dummywidget); 51 QLabel *lag1 = new QLabel( tr( "Language 1" ),dummywidget);
52 QLabel *devider = new QLabel( tr( "Decollator" ),dummywidget); 52 QLabel *devider = new QLabel( tr( "Decollator" ),dummywidget);
53 QLabel *lag2 = new QLabel( tr( "Language 2" ),dummywidget); 53 QLabel *lag2 = new QLabel( tr( "Language 2" ),dummywidget);
54 lang1 = new QLineEdit( dummywidget ); 54 lang1 = new QLineEdit( dummywidget );
55 lang2 = new QLineEdit( dummywidget ); 55 lang2 = new QLineEdit( dummywidget );
56 trenner = new QLineEdit( dummywidget ); 56 trenner = new QLineEdit( dummywidget );
57 trenner->setText( "::" ); 57 trenner->setText( "::" );
58 58
59 QGridLayout *grid = new QGridLayout( dummywidget, 2,3 ); 59 QGridLayout *grid = new QGridLayout( dummywidget, 2,3 );
60 grid->addWidget( lag1, 0,0 ); 60 grid->addWidget( lag1, 0,0 );
61 grid->addWidget( devider, 0,1 ); 61 grid->addWidget( devider, 0,1 );
62 grid->addWidget( lag2, 0,2 ); 62 grid->addWidget( lag2, 0,2 );
63 grid->addWidget( lang1, 1,0 ); 63 grid->addWidget( lang1, 1,0 );
64 grid->addWidget( trenner, 1,1 ); 64 grid->addWidget( trenner, 1,1 );
65 grid->addWidget( lang2, 1,2 ); 65 grid->addWidget( lang2, 1,2 );
66 66
67 vbox_layout->addWidget( vbox ); 67 vbox_layout->addWidget( vbox );
68 68
69 QPEApplication::execDialog ( this );
70
71 if( !itemname ) 69 if( !itemname )
72 setCaption( tr( "New Searchmethod" ) ); 70 setCaption( tr( "New Searchmethod" ) );
73 else 71 else
74 { 72 {
75 setCaption( tr( "Change Searchmethod" ) ); 73 setCaption( tr( "Change Searchmethod" ) );
76 itemName = itemname; 74 itemName = itemname;
77 setupEntries(itemname); 75 setupEntries(itemname);
78 } 76 }
77
78 QPEApplication::showDialog ( this );
79} 79}
80 80
81void SearchMethodDlg::setupEntries( QString item ) 81void SearchMethodDlg::setupEntries( QString item )
82{ 82{
83 Config cfg( "odict" ); 83 Config cfg( "odict" );
84 cfg.setGroup( "Method_"+itemName ); 84 cfg.setGroup( "Method_"+itemName );
85 trenner->setText( cfg.readEntry( "Seperator" ) ); 85 trenner->setText( cfg.readEntry( "Seperator" ) );
86 lang1->setText( cfg.readEntry( "Lang1" ) ); 86 lang1->setText( cfg.readEntry( "Lang1" ) );
87 lang2->setText( cfg.readEntry( "Lang2" ) ); 87 lang2->setText( cfg.readEntry( "Lang2" ) );
88 nameLE->setText( itemName ); 88 nameLE->setText( itemName );
89 dictFileLE->setText( cfg.readEntry( "file" ) ); 89 dictFileLE->setText( cfg.readEntry( "file" ) );
90} 90}
91 91
92void SearchMethodDlg::slotBrowse() 92void SearchMethodDlg::slotBrowse()
93{ 93{
94 itemName=OFileDialog::getOpenFileName( OFileSelector::EXTENDED,QDir::homeDirPath()); 94 itemName=OFileDialog::getOpenFileName( OFileSelector::EXTENDED,QDir::homeDirPath());
95 dictFileLE->setText( itemName ); 95 dictFileLE->setText( itemName );
96} 96}
97 97
98void SearchMethodDlg::saveItem() 98void SearchMethodDlg::saveItem()
99{ 99{
100 QString name = nameLE->text(); 100 QString name = nameLE->text();
101 Config cfg( "odict" ); 101 Config cfg( "odict" );
102 cfg.setGroup( "Method_"+name ); 102 cfg.setGroup( "Method_"+name );
103 cfg.writeEntry( "Name", name ); 103 cfg.writeEntry( "Name", name );
104 cfg.writeEntry( "Seperator", trenner->text() ); 104 cfg.writeEntry( "Seperator", trenner->text() );
105 cfg.writeEntry( "Lang1", lang1->text() ); 105 cfg.writeEntry( "Lang1", lang1->text() );
106 cfg.writeEntry( "Lang2", lang2->text() ); 106 cfg.writeEntry( "Lang2", lang2->text() );
107 cfg.writeEntry( "file", dictFileLE->text() ); 107 cfg.writeEntry( "file", dictFileLE->text() );
108} 108}