• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

kabc

  • kabc
  • plugins
  • net
resourcenetconfig.cpp
1/*
2 This file is part of libkabc.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "resourcenetconfig.h"
22#include "resourcenet.h"
23
24#include "kabc/formatfactory.h"
25#include "kabc/stdaddressbook.h"
26
27#include <kdebug.h>
28#include <klocalizedstring.h>
29#include <kdialog.h>
30
31#include <QFormLayout>
32
33using namespace KABC;
34
35ResourceNetConfig::ResourceNetConfig( QWidget *parent )
36 : ConfigWidget( parent ), mInEditMode( false )
37{
38 QFormLayout *mainLayout = new QFormLayout( this );
39 mainLayout->setMargin( 0 );
40
41 mFormatBox = new KComboBox( this );
42
43 mainLayout->addRow( i18n( "Format:" ), mFormatBox );
44
45 mUrlEdit = new KUrlRequester( this );
46 mUrlEdit->setMode( KFile::File );
47
48 mainLayout->addRow( i18n( "Location:" ), mUrlEdit );
49
50 FormatFactory *factory = FormatFactory::self();
51 QStringList formats = factory->formats();
52 QStringList::Iterator it;
53 for ( it = formats.begin(); it != formats.end(); ++it ) {
54 FormatInfo info = factory->info( *it );
55 if ( !info.isNull() ) {
56 mFormatTypes << ( *it );
57 mFormatBox->addItem( info.nameLabel );
58 }
59 }
60}
61
62void ResourceNetConfig::setEditMode( bool value )
63{
64 mFormatBox->setEnabled( !value );
65 mInEditMode = value;
66}
67
68void ResourceNetConfig::loadSettings( KRES::Resource *res )
69{
70 ResourceNet *resource = dynamic_cast<ResourceNet*>( res );
71
72 if ( !resource ) {
73 kDebug() << "cast failed";
74 return;
75 }
76
77 mFormatBox->setCurrentIndex( mFormatTypes.indexOf( resource->format() ) );
78
79 mUrlEdit->setUrl( resource->url() );
80}
81
82void ResourceNetConfig::saveSettings( KRES::Resource *res )
83{
84 ResourceNet *resource = dynamic_cast<ResourceNet*>( res );
85
86 if ( !resource ) {
87 kDebug() << "cast failed";
88 return;
89 }
90
91 if ( !mInEditMode ) {
92 resource->setFormat( mFormatTypes[ mFormatBox->currentIndex() ] );
93 }
94
95 resource->setUrl( KUrl( mUrlEdit->url() ) );
96}
97
KABC::FormatFactory
Class for loading format plugins.
Definition formatfactory.h:95
KABC::FormatFactory::info
FormatInfo info(const QString &type) const
Returns the info structure for a special type.
Definition formatfactory.cpp:136
KABC::FormatFactory::self
static FormatFactory * self()
Returns the global format factory.
Definition formatfactory.cpp:68
KABC::FormatFactory::formats
QStringList formats()
Returns a list of all available format types.
Definition formatfactory.cpp:118
KABC::ResourceNet
Definition resourcenet.h:42
KABC::ResourceNet::setFormat
void setFormat(const QString &name)
Sets a new format by name.
Definition resourcenet.cpp:334
KABC::ResourceNet::url
KUrl url() const
Return url of directory used for loading and saving the address book.
Definition resourcenet.cpp:329
KABC::ResourceNet::format
QString format() const
Returns the format name.
Definition resourcenet.cpp:343
KABC::ResourceNet::setUrl
void setUrl(const KUrl &url)
Set url of directory to be used for saving.
Definition resourcenet.cpp:324
KRES::Resource
KABC
Class that holds a Calendar Url (FBURL/CALADRURI/CALURI)
Definition address.h:29
KABC::FormatInfo
Dataype to hold information on format plugins.
Definition formatfactory.h:39
KABC::FormatInfo::isNull
bool isNull() const
Returns whether this info object is null.
Definition formatfactory.h:45
KABC::FormatInfo::nameLabel
QString nameLabel
Localized string used as format's name, e.g.
Definition formatfactory.h:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal