kitchensync
remotekonnectorconfig.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "remotekonnectorconfig.h"
00023
00024 #include "remotekonnector.h"
00025
00026 #include <libkcal/resourcelocal.h>
00027
00028 #include <kconfig.h>
00029 #include <klocale.h>
00030 #include <kabc/resourcefile.h>
00031 #include <kmessagebox.h>
00032 #include <kinputdialog.h>
00033 #include <klineedit.h>
00034
00035 #include <qlabel.h>
00036 #include <qlayout.h>
00037 #include <qpushbutton.h>
00038
00039 using namespace KSync;
00040
00041 RemoteKonnectorConfig::RemoteKonnectorConfig( QWidget *parent )
00042 : KRES::ConfigWidget( parent, 0 )
00043 {
00044 QBoxLayout *topLayout = new QVBoxLayout( this );
00045
00046 QPushButton *button = new QPushButton( i18n("Standard Setup..."), this );
00047 topLayout->addWidget( button );
00048 connect( button, SIGNAL( clicked() ), SLOT( setupStandard() ) );
00049
00050 topLayout->addWidget( new QLabel( i18n("Calendar file:"), this ) );
00051
00052 mCalendarUrl = new KURLRequester( this );
00053 mCalendarUrl->setMode( KFile::File );
00054 topLayout->addWidget( mCalendarUrl );
00055
00056 topLayout->addSpacing( 4 );
00057
00058 topLayout->addWidget( new QLabel( i18n("Address book file:"), this ) );
00059
00060 mAddressBookUrl = new KURLRequester( this );
00061 mAddressBookUrl->setMode( KFile::File );
00062 topLayout->addWidget( mAddressBookUrl );
00063 }
00064
00065 RemoteKonnectorConfig::~RemoteKonnectorConfig()
00066 {
00067 }
00068
00069 void RemoteKonnectorConfig::loadSettings( KRES::Resource *r )
00070 {
00071 RemoteKonnector *konnector = dynamic_cast<RemoteKonnector *>( r );
00072 if ( konnector ) {
00073 mCalendarUrl->setURL( konnector->calendarUrl() );
00074 mAddressBookUrl->setURL( konnector->addressBookUrl() );
00075 }
00076 }
00077
00078 void RemoteKonnectorConfig::saveSettings( KRES::Resource *r )
00079 {
00080 RemoteKonnector *konnector = dynamic_cast<RemoteKonnector *>( r );
00081 if ( konnector ) {
00082 konnector->setCalendarUrl( mCalendarUrl->url() );
00083 konnector->setAddressBookUrl( mAddressBookUrl->url() );
00084 }
00085 }
00086
00087 void RemoteKonnectorConfig::setupStandard()
00088 {
00089 bool ok = false;
00090
00091 QString hostname = KInputDialog::getText( i18n( "Remote Host" ), i18n( "Enter remote host name:" ),
00092 QString::null, &ok, this );
00093
00094 if ( hostname.isEmpty() || !ok )
00095 return;
00096
00097 QString username = KInputDialog::getText( i18n( "Remote User" ), i18n( "Enter remote user name:" ),
00098 QString::null, &ok, this );
00099
00100 if ( username.isEmpty() || !ok )
00101 return;
00102
00103 QString urlBase = "fish://" + hostname + "/~" + username + "/";
00104 mCalendarUrl->setURL( urlBase + ".kde/share/apps/korganizer/std.ics" );
00105 mAddressBookUrl->setURL( urlBase + ".kde/share/apps/kabc/std.vcf" );
00106 }
00107
00108 #include "remotekonnectorconfig.moc"
|