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

kabc

  • sources
  • kde-4.12
  • kdepimlibs
  • kabc
  • plugins
  • dir
resourcedirconfig.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2002 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 "resourcedirconfig.h"
22 #include "resourcedir.h"
23 
24 #include "kabc/formatfactory.h"
25 #include "kabc/stdaddressbook.h"
26 
27 #include <kdebug.h>
28 #include <klocalizedstring.h>
29 #include <kstandarddirs.h>
30 #include <kdialog.h>
31 
32 #include <QFormLayout>
33 
34 using namespace KABC;
35 
36 ResourceDirConfig::ResourceDirConfig( QWidget *parent )
37  : KRES::ConfigWidget( parent )
38 {
39  QFormLayout *mainLayout = new QFormLayout( this );
40  mainLayout->setMargin( 0 );
41 
42  mFormatBox = new KComboBox( this );
43 
44  mainLayout->addRow( i18n( "Format:" ), mFormatBox );
45 
46  mFileNameEdit = new KUrlRequester( this );
47  mFileNameEdit->setMode( KFile::Directory );
48 
49  mainLayout->addRow( i18n( "Location:" ), mFileNameEdit );
50 
51  FormatFactory *factory = FormatFactory::self();
52  QStringList formats = factory->formats();
53  QStringList::Iterator it;
54  for ( it = formats.begin(); it != formats.end(); ++it ) {
55  FormatInfo info = factory->info( *it );
56  if ( !info.isNull() ) {
57  mFormatTypes << ( *it );
58  mFormatBox->addItem( info.nameLabel );
59  }
60  }
61 
62  mInEditMode = false;
63 }
64 
65 void ResourceDirConfig::setEditMode( bool value )
66 {
67  mFormatBox->setEnabled( !value );
68  mInEditMode = value;
69 }
70 
71 void ResourceDirConfig::loadSettings( KRES::Resource *res )
72 {
73  ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
74 
75  if ( !resource ) {
76  kDebug() << "cast failed";
77  return;
78  }
79 
80  mFormatBox->setCurrentIndex( mFormatTypes.indexOf( resource->format() ) );
81 
82  mFileNameEdit->setUrl( resource->path() );
83  if ( mFileNameEdit->url().isEmpty() ) {
84  mFileNameEdit->setUrl( KABC::StdAddressBook::directoryName() );
85  }
86 }
87 
88 void ResourceDirConfig::saveSettings( KRES::Resource *res )
89 {
90  ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
91 
92  if ( !resource ) {
93  kDebug() << "cast failed";
94  return;
95  }
96 
97  if ( mInEditMode ) {
98  resource->setFormat( mFormatTypes[ mFormatBox->currentIndex() ] );
99  }
100 
101  resource->setPath( mFileNameEdit->url().path() );
102 }
103 
KABC::FormatFactory
Class for loading format plugins.
Definition: formatfactory.h:94
KABC::FormatFactory::self
static FormatFactory * self()
Returns the global format factory.
Definition: formatfactory.cpp:68
KABC::ResourceDir::setPath
void setPath(const QString &)
Set path to be used for saving.
Definition: resourcedir.cpp:295
KABC::FormatFactory::info
FormatInfo info(const QString &type) const
Returns the info structure for a special type.
Definition: formatfactory.cpp:136
KABC::FormatInfo::isNull
bool isNull() const
Returns whether this info object is null.
Definition: formatfactory.h:45
KABC::ResourceDir::format
QString format() const
Returns the format name.
Definition: resourcedir.cpp:322
KABC::FormatInfo
Dataype to hold information on format plugins.
Definition: formatfactory.h:38
KABC::FormatFactory::formats
QStringList formats()
Returns a list of all available format types.
Definition: formatfactory.cpp:118
KABC::StdAddressBook::directoryName
static QString directoryName()
Returns the default directory name for vcard-based addressbook.
Definition: stdaddressbook.cpp:69
KRES::Resource
KABC::ResourceDir
Definition: resourcedir.h:37
KABC::FormatInfo::nameLabel
QString nameLabel
Localized string used as format's name, e.g.
Definition: formatfactory.h:65
KABC::ResourceDir::setFormat
void setFormat(const QString &format)
Set the format by name.
Definition: resourcedir.cpp:312
KABC::ResourceDir::path
QString path() const
Return path used for loading and saving the address book.
Definition: resourcedir.cpp:307
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:05 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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