summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/configdlg.cpp
blob: afba6883b92d10b720bfe0c4e9dc7fcbcda169f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "configdlg.h"
#include "ocontactfields.h"
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qlistbox.h>
#include <qpushbutton.h>

#include <opie/ocontact.h>

ConfigDlg::ConfigDlg( QWidget *parent, const char *name):
	ConfigDlg_Base(parent, name, true )
{
	contFields = OContactFields::trfields();

	// We add all Fields into the Listbox
	for (uint i=0; i < contFields.count(); i++) {
		allFieldListBox->insertItem( contFields[i] );
	}

	// Get the translation maps between Field ID and translated strings
	m_mapStrToID = OContactFields::trFieldsToId();
	m_mapIDToStr = OContactFields::idToTrFields();

	connect ( m_addButton, SIGNAL( clicked() ), this, SLOT( slotItemAdd() ) );
	connect ( m_removeButton, SIGNAL( clicked() ), this, SLOT( slotItemRemove() ) );
	connect ( m_upButton, SIGNAL( clicked() ), this, SLOT( slotItemUp() ) );
	connect ( m_downButton, SIGNAL( clicked() ), this, SLOT( slotItemDown() ) );
}

void ConfigDlg::slotItemUp()
{
	qWarning( "void ConfigDlg::slotItemUp()" );

	int i = fieldListBox->currentItem();
	if ( i > 0 ) {
		QString item = fieldListBox->currentText();
		fieldListBox->removeItem( i );
		fieldListBox->insertItem( item, i-1 );
		fieldListBox->setCurrentItem( i-1 );
	}

}

void ConfigDlg::slotItemDown()
{
	qWarning( "void ConfigDlg::slotItemDown()" );

	int i = fieldListBox->currentItem();
	if ( i < (int)fieldListBox->count() - 1 ) {
		QString item = fieldListBox->currentText();
		fieldListBox->removeItem( i );
		fieldListBox->insertItem( item, i+1 );
		fieldListBox->setCurrentItem( i+1 );
	}
}

void ConfigDlg::slotItemAdd()
{
	qWarning( "void ConfigDlg::slotItemAdd()" );

	int i = allFieldListBox->currentItem();
	if ( i > 0 ) {
		QString item = allFieldListBox->currentText();
		qWarning("ADding %s", item.latin1());
		fieldListBox->insertItem( item );
	}	
}

void ConfigDlg::slotItemRemove()
{
	qWarning( "void ConfigDlg::slotItemRemove()" );

	int i = fieldListBox->currentItem();
	if ( i > 0 ) {
		fieldListBox->removeItem( i );
	}	
}
    
void ConfigDlg::setConfig( const AbConfig& cnf )
{ 
	m_config = cnf; 

	m_useRegExp->setChecked( m_config.useRegExp() );
	m_useWildCard->setChecked( m_config.useWildCards() );
	m_useQtMail->setChecked( m_config.useQtMail() );
	m_useOpieMail->setChecked( m_config.useOpieMail() );
	m_useCaseSensitive->setChecked( m_config.beCaseSensitive() );

	switch( m_config.fontSize() ){
	case 0:
		m_smallFont->setChecked( true );
		m_normalFont->setChecked( false );
		m_largeFont->setChecked( false );
		break;
	case 1: 
		m_smallFont->setChecked( false );
		m_normalFont->setChecked( true );
		m_largeFont->setChecked( false );
		break;
	case 2: 
		m_smallFont->setChecked( false );
		m_normalFont->setChecked( false );
		m_largeFont->setChecked( true );
		break;
	}

	for( uint i = 0; i < m_config.orderList().count(); i++ ) {
	        fieldListBox -> insertItem ( m_mapIDToStr[ m_config.orderList()[i] ] );
	}

	
}
    
AbConfig ConfigDlg::getConfig()
{ 
	m_config.setUseRegExp( m_useRegExp->isOn() );
	m_config.setUseWildCards( m_useWildCard->isOn() );
	m_config.setUseQtMail( m_useQtMail->isOn() );
	m_config.setUseOpieMail( m_useOpieMail->isOn() );
	m_config.setBeCaseSensitive( m_useCaseSensitive->isChecked() );

	if ( m_smallFont->isChecked() )
		m_config.setFontSize( 0 );
	if ( m_normalFont->isChecked() )
		m_config.setFontSize( 1 );
	if ( m_largeFont->isChecked() )
		m_config.setFontSize( 2 );

	QValueList<int> orderlist;
	for( int i = 0; i < (int)fieldListBox->count(); i++ ) {
	        orderlist.append( m_mapStrToID[ fieldListBox->text(i) ] );
	}
	m_config.setOrderList( orderlist );

	return m_config;
}