Diffstat (limited to 'core/pim/addressbook/configdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/configdlg.cpp | 156 |
1 files changed, 116 insertions, 40 deletions
diff --git a/core/pim/addressbook/configdlg.cpp b/core/pim/addressbook/configdlg.cpp index d1c2ef8..afba688 100644 --- a/core/pim/addressbook/configdlg.cpp +++ b/core/pim/addressbook/configdlg.cpp | |||
@@ -1,61 +1,137 @@ | |||
1 | #include "configdlg.h" | 1 | #include "configdlg.h" |
2 | #include "ocontactfields.h" | ||
2 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
3 | #include <qradiobutton.h> | 4 | #include <qradiobutton.h> |
5 | #include <qlistbox.h> | ||
6 | #include <qpushbutton.h> | ||
7 | |||
8 | #include <opie/ocontact.h> | ||
4 | 9 | ||
5 | ConfigDlg::ConfigDlg( QWidget *parent, const char *name): | 10 | ConfigDlg::ConfigDlg( QWidget *parent, const char *name): |
6 | ConfigDlg_Base(parent, name, true ) | 11 | ConfigDlg_Base(parent, name, true ) |
7 | {} | ||
8 | |||
9 | |||
10 | bool ConfigDlg::useRegExp() const | ||
11 | { | ||
12 | return m_useRegExp->isOn(); | ||
13 | } | ||
14 | bool ConfigDlg::useWildCards() const | ||
15 | { | ||
16 | return m_useWildCard->isOn(); | ||
17 | } | ||
18 | bool ConfigDlg::useQtMail() const | ||
19 | { | ||
20 | return m_useQtMail->isOn(); | ||
21 | } | ||
22 | bool ConfigDlg::useOpieMail() const | ||
23 | { | 12 | { |
24 | return m_useOpieMail->isOn(); | 13 | contFields = OContactFields::trfields(); |
25 | } | 14 | |
26 | bool ConfigDlg::beCaseSensitive() const | 15 | // We add all Fields into the Listbox |
27 | { | 16 | for (uint i=0; i < contFields.count(); i++) { |
28 | return m_useCaseSensitive->isChecked(); | 17 | allFieldListBox->insertItem( contFields[i] ); |
29 | } | 18 | } |
30 | bool ConfigDlg::signalWrapAround() const | 19 | |
31 | { | 20 | // Get the translation maps between Field ID and translated strings |
32 | return m_signalWrapAround->isChecked(); | 21 | m_mapStrToID = OContactFields::trFieldsToId(); |
33 | } | 22 | m_mapIDToStr = OContactFields::idToTrFields(); |
34 | void ConfigDlg::setUseRegExp( bool v ) | 23 | |
35 | { | 24 | connect ( m_addButton, SIGNAL( clicked() ), this, SLOT( slotItemAdd() ) ); |
36 | m_useRegExp->setChecked( v ); | 25 | connect ( m_removeButton, SIGNAL( clicked() ), this, SLOT( slotItemRemove() ) ); |
26 | connect ( m_upButton, SIGNAL( clicked() ), this, SLOT( slotItemUp() ) ); | ||
27 | connect ( m_downButton, SIGNAL( clicked() ), this, SLOT( slotItemDown() ) ); | ||
37 | } | 28 | } |
38 | void ConfigDlg::setUseWildCards( bool v ) | 29 | |
30 | void ConfigDlg::slotItemUp() | ||
39 | { | 31 | { |
40 | m_useWildCard->setChecked( v ); | 32 | qWarning( "void ConfigDlg::slotItemUp()" ); |
33 | |||
34 | int i = fieldListBox->currentItem(); | ||
35 | if ( i > 0 ) { | ||
36 | QString item = fieldListBox->currentText(); | ||
37 | fieldListBox->removeItem( i ); | ||
38 | fieldListBox->insertItem( item, i-1 ); | ||
39 | fieldListBox->setCurrentItem( i-1 ); | ||
40 | } | ||
41 | |||
41 | } | 42 | } |
42 | void ConfigDlg::setBeCaseSensitive( bool v ) | 43 | |
44 | void ConfigDlg::slotItemDown() | ||
43 | { | 45 | { |
44 | m_useCaseSensitive->setChecked( v ); | 46 | qWarning( "void ConfigDlg::slotItemDown()" ); |
47 | |||
48 | int i = fieldListBox->currentItem(); | ||
49 | if ( i < (int)fieldListBox->count() - 1 ) { | ||
50 | QString item = fieldListBox->currentText(); | ||
51 | fieldListBox->removeItem( i ); | ||
52 | fieldListBox->insertItem( item, i+1 ); | ||
53 | fieldListBox->setCurrentItem( i+1 ); | ||
54 | } | ||
45 | } | 55 | } |
46 | void ConfigDlg::setSignalWrapAround( bool v ) | 56 | |
57 | void ConfigDlg::slotItemAdd() | ||
47 | { | 58 | { |
48 | m_signalWrapAround->setChecked( v ); | 59 | qWarning( "void ConfigDlg::slotItemAdd()" ); |
60 | |||
61 | int i = allFieldListBox->currentItem(); | ||
62 | if ( i > 0 ) { | ||
63 | QString item = allFieldListBox->currentText(); | ||
64 | qWarning("ADding %s", item.latin1()); | ||
65 | fieldListBox->insertItem( item ); | ||
66 | } | ||
49 | } | 67 | } |
50 | void ConfigDlg::setQtMail( bool v ) | 68 | |
69 | void ConfigDlg::slotItemRemove() | ||
51 | { | 70 | { |
52 | m_useQtMail->setChecked( v ); | 71 | qWarning( "void ConfigDlg::slotItemRemove()" ); |
72 | |||
73 | int i = fieldListBox->currentItem(); | ||
74 | if ( i > 0 ) { | ||
75 | fieldListBox->removeItem( i ); | ||
76 | } | ||
53 | } | 77 | } |
54 | void ConfigDlg::setOpieMail( bool v ) | 78 | |
55 | { | 79 | void ConfigDlg::setConfig( const AbConfig& cnf ) |
56 | m_useOpieMail->setChecked( v ); | 80 | { |
81 | m_config = cnf; | ||
82 | |||
83 | m_useRegExp->setChecked( m_config.useRegExp() ); | ||
84 | m_useWildCard->setChecked( m_config.useWildCards() ); | ||
85 | m_useQtMail->setChecked( m_config.useQtMail() ); | ||
86 | m_useOpieMail->setChecked( m_config.useOpieMail() ); | ||
87 | m_useCaseSensitive->setChecked( m_config.beCaseSensitive() ); | ||
88 | |||
89 | switch( m_config.fontSize() ){ | ||
90 | case 0: | ||
91 | m_smallFont->setChecked( true ); | ||
92 | m_normalFont->setChecked( false ); | ||
93 | m_largeFont->setChecked( false ); | ||
94 | break; | ||
95 | case 1: | ||
96 | m_smallFont->setChecked( false ); | ||
97 | m_normalFont->setChecked( true ); | ||
98 | m_largeFont->setChecked( false ); | ||
99 | break; | ||
100 | case 2: | ||
101 | m_smallFont->setChecked( false ); | ||
102 | m_normalFont->setChecked( false ); | ||
103 | m_largeFont->setChecked( true ); | ||
104 | break; | ||
105 | } | ||
106 | |||
107 | for( uint i = 0; i < m_config.orderList().count(); i++ ) { | ||
108 | fieldListBox -> insertItem ( m_mapIDToStr[ m_config.orderList()[i] ] ); | ||
109 | } | ||
110 | |||
111 | |||
57 | } | 112 | } |
113 | |||
114 | AbConfig ConfigDlg::getConfig() | ||
115 | { | ||
116 | m_config.setUseRegExp( m_useRegExp->isOn() ); | ||
117 | m_config.setUseWildCards( m_useWildCard->isOn() ); | ||
118 | m_config.setUseQtMail( m_useQtMail->isOn() ); | ||
119 | m_config.setUseOpieMail( m_useOpieMail->isOn() ); | ||
120 | m_config.setBeCaseSensitive( m_useCaseSensitive->isChecked() ); | ||
58 | 121 | ||
122 | if ( m_smallFont->isChecked() ) | ||
123 | m_config.setFontSize( 0 ); | ||
124 | if ( m_normalFont->isChecked() ) | ||
125 | m_config.setFontSize( 1 ); | ||
126 | if ( m_largeFont->isChecked() ) | ||
127 | m_config.setFontSize( 2 ); | ||
59 | 128 | ||
129 | QValueList<int> orderlist; | ||
130 | for( int i = 0; i < (int)fieldListBox->count(); i++ ) { | ||
131 | orderlist.append( m_mapStrToID[ fieldListBox->text(i) ] ); | ||
132 | } | ||
133 | m_config.setOrderList( orderlist ); | ||
60 | 134 | ||
135 | return m_config; | ||
136 | } | ||
61 | 137 | ||