summaryrefslogtreecommitdiffstats
path: root/conduits/vcalconduit/vcal-setupbase.cpp
blob: 51a188c5bf19e39533ceacece48d7650d1b3671f (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
/* vcal-setup.cpp                        KPilot
**
** Copyright (C) 2002-2003 Reinhold Kainhofer
** Copyright (C) 2001 by Dan Pilone
**
** This file defines the setup dialog for the vcal-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 [email protected]
*/

#include "options.h"

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

#include <kurlrequester.h>

#include "korganizerConduit.h"
#include "vcalconduitSettings.h"
#include "vcal-setupbase.h"

VCalWidgetSetupBase::VCalWidgetSetupBase(TQWidget *w, const char *n) :
	ConduitConfigBase(w,n),
	fConfigWidget(new VCalWidget(w))
{
	FUNCTIONSETUP;
	fWidget=fConfigWidget;

	fConfigWidget->fCalendarFile->setMode(KFile::File);
	fConfigWidget->fCalendarFile->setFilter(CSL1("*.vcs *.ics|ICalendars\n*.*|All Files (*.*)"));

#define CM(a,b) connect(fConfigWidget->a,b,this,TQT_SLOT(modified()));
	CM(fSyncDestination,TQT_SIGNAL(clicked(int)));
	CM(fCalendarFile,TQT_SIGNAL(textChanged(const TQString &)));
	CM(fArchive,TQT_SIGNAL(toggled(bool)));
	CM(fConflictResolution,TQT_SIGNAL(activated(int)));
#undef CM
}

VCalWidgetSetupBase::~VCalWidgetSetupBase()
{
	FUNCTIONSETUP;
}

/* virtual */ void VCalWidgetSetupBase::commit()
{
	FUNCTIONSETUP;
	config()->readConfig();

	// General page
#ifdef DEBUG
	DEBUGKPILOT << fname << ": Selected type="
		<< fConfigWidget->fSyncDestination->selected()
		<< " with id="
		<< fConfigWidget->fSyncDestination->id(fConfigWidget->fSyncDestination->selected())
		<< endl;
#endif
	config()->setCalendarType( fConfigWidget->fSyncDestination->id(
			fConfigWidget->fSyncDestination->selected()));
	config()->setCalendarFile( fConfigWidget->fCalendarFile->url());

	config()->setSyncArchived( fConfigWidget->fArchive->isChecked() );

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

	config()->writeConfig();
	unmodified();
}

/* virtual */ void VCalWidgetSetupBase::load()
{
	FUNCTIONSETUP;
	config()->readConfig();

	// General page
	fConfigWidget->fSyncDestination->setButton( config()->calendarType());
	fConfigWidget->fCalendarFile->setURL( config()->calendarFile() );

	fConfigWidget->fArchive->setChecked( config()->syncArchived() );

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

	config()->writeConfig();
	unmodified();
}