summaryrefslogtreecommitdiffstats
path: root/kpilot/conduits/abbrowserconduit/abbrowser-setup.cc
blob: f4d80d2ce00ac454486c64859eeea6238411fb58 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/* KPilot
**
** Copyright (C) 2001 by Dan Pilone
** Copyright (C) 2002-2003 Reinhold Kainhofer
**
** This file defines the setup dialog for the abbrowser-conduit plugin.
*/

/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/

/*
** Bug reports and questions can be sent to kde-pim@kde.org
*/

#include "options.h"

#include <tqcheckbox.h>
#include <tqcombobox.h>
#include <tqbuttongroup.h>

#include <kurlrequester.h>
#include <kaboutdata.h>

#include "kaddressbookConduit.h"
#include "abbrowser-setup.h"
#include "abbrowserSettings.h"



static KAboutData *createAbout()
{
	KAboutData *fAbout = new KAboutData("abbrowserconduit",
		I18N_NOOP("Abbrowser Conduit for KPilot"),
		KPILOT_VERSION,
		I18N_NOOP("Configures the Abbrowser Conduit for KPilot"),
		KAboutData::License_GPL,
		"(C) 2001, Dan Pilone\n(C) 2002-2003, Reinhold Kainhofer");
	fAbout->addAuthor("Greg Stern",
		I18N_NOOP("Primary Author"));
	fAbout->addAuthor("Adriaan de Groot",
		I18N_NOOP("Maintainer"),
		"groot@kde.org",
		"http://www.cs.kun.nl/~adridg/kpilot");
	fAbout->addAuthor("Reinhold Kainhofer", I18N_NOOP("Maintainer"),
		"reinhold@kainhofer.com", "http://reinhold.kainhofer.com");
	fAbout->addCredit("David Bishop", I18N_NOOP("UI"));
	return fAbout;
}

AbbrowserWidgetSetup::AbbrowserWidgetSetup(TQWidget *w, const char *n) :
	ConduitConfigBase(w,n),
	fConfigWidget(new AbbrowserWidget(w))
{
	FUNCTIONSETUP;

	fConduitName=i18n("Addressbook");
	fAbout = createAbout();
	ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget,fAbout);
	fWidget=fConfigWidget;
	fConfigWidget->fAbookFile->setMode(KFile::File);
#define CM(a,b) connect(fConfigWidget->a,b,this,TQT_SLOT(modified()));
	CM(fSyncDestination,TQT_SIGNAL(clicked(int)));
	CM(fAbookFile,TQT_SIGNAL(textChanged(const TQString &)));
	CM(fArchive,TQT_SIGNAL(toggled(bool)));
	CM(fConflictResolution,TQT_SIGNAL(activated(int)));
	CM(fOtherPhone,TQT_SIGNAL(activated(int)));
	CM(fAddress,TQT_SIGNAL(activated(int)));
	CM(fFax,TQT_SIGNAL(activated(int)));
	CM(fCustom0,TQT_SIGNAL(activated(int)));
	CM(fCustom1,TQT_SIGNAL(activated(int)));
	CM(fCustom2,TQT_SIGNAL(activated(int)));
	CM(fCustom3,TQT_SIGNAL(activated(int)));
	CM(fCustomDate, TQT_SIGNAL(activated(int)));
	CM(fCustomDate, TQT_SIGNAL(textChanged(const TQString&)));
#undef CM
}

AbbrowserWidgetSetup::~AbbrowserWidgetSetup()
{
	FUNCTIONSETUP;
}

/* virtual */ void AbbrowserWidgetSetup::commit()
{
	FUNCTIONSETUP;

	TQButtonGroup*grp=fConfigWidget->fSyncDestination;
	AbbrowserSettings::setAddressbookType(grp->id(grp->selected()));
	AbbrowserSettings::setFileName(fConfigWidget->fAbookFile->url());
	AbbrowserSettings::setArchiveDeleted(fConfigWidget->fArchive->isChecked());

	// Conflicts page
	AbbrowserSettings::setConflictResolution(
		fConfigWidget->fConflictResolution->currentItem()+SyncAction::eCROffset);

	// Fields page
	AbbrowserSettings::setPilotOther(fConfigWidget->fOtherPhone->currentItem());
	AbbrowserSettings::setPilotStreet(fConfigWidget->fAddress->currentItem());
	AbbrowserSettings::setPilotFax(fConfigWidget->fFax->currentItem());

	// Custom fields page
	AbbrowserSettings::setCustom0(fConfigWidget->fCustom0->currentItem());
	AbbrowserSettings::setCustom1(fConfigWidget->fCustom1->currentItem());
	AbbrowserSettings::setCustom2(fConfigWidget->fCustom2->currentItem());
	AbbrowserSettings::setCustom3(fConfigWidget->fCustom3->currentItem());
#ifdef DEBUG
	DEBUGKPILOT <<fname<<
	  "Custom0: "<<fConfigWidget->fCustom0->currentItem()<<"   "<<
	  "Custom1: "<<fConfigWidget->fCustom1->currentItem()<<"   "<<
	  "Custom2: "<<fConfigWidget->fCustom2->currentItem()<<"   "<<
	  "Custom3: "<<fConfigWidget->fCustom3->currentItem()<<"   "
		<< " eCustom[0]=" << AbbrowserSettings::custom0()<<"    "
		<< " eCustom[1]=" << AbbrowserSettings::custom1()<<"    "
		<< " eCustom[2]=" << AbbrowserSettings::custom2()<<"    "
		<< " eCustom[3]=" << AbbrowserSettings::custom3()<<"    "<<
		endl;
#endif
	int fmtindex=fConfigWidget->fCustomDate->currentItem();
	AbbrowserSettings::setCustomDateFormat(
	  (fmtindex==0)?(TQString::null):fConfigWidget->fCustomDate->currentText() );

	AbbrowserSettings::self()->writeConfig();
	unmodified();
}

/* virtual */ void AbbrowserWidgetSetup::load()
{
	FUNCTIONSETUP;
	AbbrowserSettings::self()->readConfig();

#ifdef DEBUG
	DEBUGKPILOT << fname
		<< ": Settings "
		<< " fPilotStreetHome=" << AbbrowserSettings::pilotStreet()
		<< " fPilotFaxHome=" << AbbrowserSettings::pilotFax()
		<< " fArchive=" << AbbrowserSettings::archiveDeleted()
		<< " eCustom[0]=" << AbbrowserSettings::custom0()
		<< " eCustom[1]=" << AbbrowserSettings::custom1()
		<< " eCustom[2]=" << AbbrowserSettings::custom2()
		<< " eCustom[3]=" << AbbrowserSettings::custom3()
		<< endl;
#endif

	// General page
	fConfigWidget->fSyncDestination->setButton(AbbrowserSettings::addressbookType());
	fConfigWidget->fAbookFile->setURL(AbbrowserSettings::fileName());
	fConfigWidget->fArchive->setChecked(AbbrowserSettings::archiveDeleted());

	// Conflicts page
	fConfigWidget->fConflictResolution->setCurrentItem(
	  AbbrowserSettings::conflictResolution() - SyncAction::eCROffset );

	// Fields page
	fConfigWidget->fOtherPhone->setCurrentItem(AbbrowserSettings::pilotOther());
	fConfigWidget->fAddress->setCurrentItem(AbbrowserSettings::pilotStreet());
	fConfigWidget->fFax->setCurrentItem(AbbrowserSettings::pilotFax());

	// Custom fields page
	fConfigWidget->fCustom0->setCurrentItem(AbbrowserSettings::custom0());
	fConfigWidget->fCustom1->setCurrentItem(AbbrowserSettings::custom1());
	fConfigWidget->fCustom2->setCurrentItem(AbbrowserSettings::custom2());
	fConfigWidget->fCustom3->setCurrentItem(AbbrowserSettings::custom3());
	TQString datefmt=AbbrowserSettings::customDateFormat();
	if (datefmt.isEmpty())
	{
		fConfigWidget->fCustomDate->setCurrentItem(0);
	}
	else
	{
		fConfigWidget->fCustomDate->setCurrentText(datefmt);
	}

	unmodified();
}

/* static */ ConduitConfigBase *AbbrowserWidgetSetup::create(TQWidget *w, const char *n)
{
	return new AbbrowserWidgetSetup(w,n);
}