Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > 110492f5122731329f0db69a1df590c3 > files > 5057

kdepimlibs-apidocs-4.10.5-1.fc18.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
  <title>The KDE Resource library</title>
<style type="text/css">
  .cp-doNotDisplay { display: none; }
  @media aural, braille, handheld, tty { .cp-doNotDisplay { display: inline; speak: normal; }}
  .cp-edit { text-align: right; }
  @media print, embossed { .cp-edit { display: none; }}
</style>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <link rel="meta" href="http://www.kde.org/labels.rdf" type="application/rdf+xml" title="ICRA labels" />
  <meta name="trademark" content="KDE e.V." />
  <meta name="description" content="K Desktop Environment Homepage, KDE.org" />
  <meta name="MSSmartTagsPreventParsing" content="true" />
  <meta name="robots" content="all" />
  <meta name="no-email-collection" content="http://www.unspam.com/noemailcollection" />
  <script type="text/javascript" src="jquery.js"></script>
  <script type="text/javascript" src="dynsections.js"></script>
  <link rel="shortcut icon" href="../../favicon.ico" /><link rel="icon" href="../../favicon.ico" />
  <link rel="stylesheet" media="screen" type="text/css" title="KDE Colors" href="../../kde.css" />
  <link rel="stylesheet" media="print, embossed" type="text/css" href="../../print.css" />
  <link rel="stylesheet" media="screen, aural, handheld, tty, braille" type="text/css" title="Flat" href="../../flat.css" />
  <link rel="stylesheet" type="text/css" href="../../doxygen.css" />
  <link rel="stylesheet" type="text/css" href="../../tabs.css" />
</head>
<body>
<ul class="cp-doNotDisplay">
  <li><a href="#cp-content" accesskey="2">Skip to content</a></li>
  <li><a href="#cp-menu" accesskey="5">Skip to link menu</a></li>
</ul>
<div id="container">
<div id="header">
  <div id="header_top"><div><div>
    <img alt ="" src="../../top-kde.jpg"/>
    </div></div></div>
  <div id="header_bottom">
    <div id="location">
      <ul>
        <li><a href="http://api.kde.org">KDE API Reference</a></li>
        <li><a href="../../index.html">kdepimlibs-4.10.5 API Reference</a></li>
      </ul>
    </div>
    <div id="menu">
<ul>
<li><a href="http://www.kde.org/">KDE Home</a></li>
<li><a href="http://kde.org/contact/">Contact Us</a></li>
</ul>
</div>
</div>
</div>
<!-- End page header -->
    <div id="body_wrapper">
      <div id="body">
        <!-- begin main content -->
        <div id="right">
          <div class="content">
          <div id="main">
            <div class="clearer">&nbsp;</div>
<h2><a name="content"></a>kresources</h2>
<!-- BC -->
<div id="top">
<!-- Generated by Doxygen 1.8.3.1 -->
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">The KDE Resource library </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The KDE Resource framework can be used to manage resources of different types, organized in families. The Resource framework is for example used for addressbook resources in libkabc and for calendar resources in libkcal.</p>
<p>When you want to use the framework for a new family, you need to </p>
<ul>
<li>
Define a name for your resource family </li>
<li>
subclass Resource and add the fields and method that are needed in your application </li>
<li>
If needed, override the doOpen() and doClose() methods. </li>
<li>
In your application, you can use ResourceManager to keep track of the resources in your family, and you can use ResourceSelectDialog to let the user select a single resource. </li>
</ul>
<p>When you want to add a new resource type to an existing resource family, you need to </p>
<ul>
<li>
Further subclass the family-specific Resource to implement resource type-specific operation </li>
<li>
Subclass ResourceConfigWidget to provide a configuration widget for your new resource type </li>
<li>
Provide a .desktop file so that the new resource type can be found automatically by the ResourceManager </li>
</ul>
<p>Example:</p>
<p><b>resourceexample.h</b>: </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;kconfig.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;kresources/resource.h&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="keyword">class </span>ResourceExample : <span class="keyword">public</span> <a class="code" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">KRES::Resource</a></div>
<div class="line">{</div>
<div class="line">  <span class="keyword">public</span>:</div>
<div class="line">    ResourceExample( <span class="keyword">const</span> KConfig * );</div>
<div class="line">    ~ResourceExample();</div>
<div class="line">    <span class="keywordtype">void</span> <a class="code" href="classKRES_1_1Resource.html#ab3baaac13e2733723b143ea82851aca9" title="Write configuration information for this resource to a configuration file.">writeConfig</a>( KConfig *config );</div>
<div class="line"></div>
<div class="line">  <span class="keyword">private</span>:</div>
<div class="line">    QString mLocation;</div>
<div class="line">    QString mPassword;</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>resourceexample.cpp</b>: </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;kconfig.h&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &quot;resourceexample.h&quot;</span></div>
<div class="line"></div>
<div class="line">ResourceExample::ResourceExample( <span class="keyword">const</span> KConfig *config )</div>
<div class="line">    : Resource( config )</div>
<div class="line">{</div>
<div class="line">  <span class="keywordflow">if</span> ( config ) {</div>
<div class="line">    mLocation = config-&gt;readPathEntry( <span class="stringliteral">&quot;Location&quot;</span>, QString() );</div>
<div class="line">    mPassword = KStringHandler::obscure( config-&gt;readEntry( <span class="stringliteral">&quot;Password&quot;</span> ) );</div>
<div class="line">  } <span class="keywordflow">else</span> {</div>
<div class="line">    mLocation = <span class="stringliteral">&quot;&quot;</span>; <span class="comment">// Or some sensible default</span></div>
<div class="line">    mPassword = <span class="stringliteral">&quot;&quot;</span>;</div>
<div class="line">  }</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> ResourceExample::writeConfig( KConfig *config )</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classKRES_1_1Resource.html#ab3baaac13e2733723b143ea82851aca9" title="Write configuration information for this resource to a configuration file.">KRES::Resource::writeConfig</a>( config );</div>
<div class="line">  config-&gt;writePathEntry( <span class="stringliteral">&quot;Location&quot;</span>, mLocation );</div>
<div class="line">  config-&gt;writeEntry( <span class="stringliteral">&quot;Password&quot;</span>, KStringHandler::obscure( mPassword ) );</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span></div>
<div class="line">{</div>
<div class="line">  KRES::ResourceExample *config_widget( QWidget *parent ) {</div>
<div class="line">    <span class="keywordflow">return</span> <span class="keyword">new</span> ResourceExampleConfig( parent, <span class="stringliteral">&quot;Configure Example Resource&quot;</span> );</div>
<div class="line">  }</div>
<div class="line"></div>
<div class="line">  <a class="code" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">KRES::Resource</a> *resource( <span class="keyword">const</span> KConfig *config ) {</div>
<div class="line">    <span class="keywordflow">return</span> <span class="keyword">new</span> ResourceExample( config );</div>
<div class="line">  }</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>resourceexampleconfig.h</b>: </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;klineedit.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;kresources/resourceconfigwidget.h&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &quot;resourceexample.h&quot;</span></div>
<div class="line"></div>
<div class="line"><span class="keyword">class </span>ResourceExampleConfig : <span class="keyword">public</span> KRES::ResourceConfigWidget</div>
<div class="line">{</div>
<div class="line">    Q_OBJECT</div>
<div class="line">  <span class="keyword">public</span>:</div>
<div class="line">    ResourceExampleConfig( QWidget *parent = 0, <span class="keyword">const</span> <span class="keywordtype">char</span> *name = 0 );</div>
<div class="line"></div>
<div class="line">  <span class="keyword">public</span> Q_SLOTS:</div>
<div class="line">    <span class="keyword">virtual</span> <span class="keywordtype">void</span> loadSettings( <a class="code" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">KRES::Resource</a> *resource);</div>
<div class="line">    <span class="keyword">virtual</span> <span class="keywordtype">void</span> saveSettings( <a class="code" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">KRES::Resource</a> *resource );</div>
<div class="line"></div>
<div class="line">  <span class="keyword">private</span>:</div>
<div class="line">    KLineEdit *mLocationEdit;</div>
<div class="line">    KLineEdit *mPasswordEdit;</div>
<div class="line">};</div>
</div><!-- fragment --><p><b>resourceexampleconfig.cpp</b>: </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;qlayout.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;qlabel.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include &lt;kresources/resourceconfigwidget.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;QtCore/QList&gt;</span></div>
<div class="line"><span class="preprocessor">#include &quot;resourceexample.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;resourceexampleconfig.h&quot;</span></div>
<div class="line"></div>
<div class="line">ResourceExampleConfig::ResourceExampleConfig( QWidget *parent,  <span class="keyword">const</span> <span class="keywordtype">char</span> *name )</div>
<div class="line">  : KRES::ResourceConfigWidget( parent, name )</div>
<div class="line">{</div>
<div class="line">  QGridLayout *mainLayout = <span class="keyword">new</span> QGridLayout( <span class="keyword">this</span>, 2, 2 );</div>
<div class="line"></div>
<div class="line">  QLabel *label = <span class="keyword">new</span> QLabel( i18n( <span class="stringliteral">&quot;Location:&quot;</span> ), <span class="keyword">this</span> );</div>
<div class="line">  mHostEdit = <span class="keyword">new</span> KLineEdit( <span class="keyword">this</span> );</div>
<div class="line">  mainLayout-&gt;addWidget( label, 1, 0 );</div>
<div class="line">  mainLayout-&gt;addWidget( mHostEdit, 1, 1 );</div>
<div class="line"></div>
<div class="line">  label = <span class="keyword">new</span> QLabel( i18n( <span class="stringliteral">&quot;Password:&quot;</span> ), <span class="keyword">this</span> );</div>
<div class="line">  mPasswordEdit = <span class="keyword">new</span> KLineEdit( <span class="keyword">this</span> );</div>
<div class="line">  mPasswordEdit-&gt;setEchoMode( QLineEdit::Password );</div>
<div class="line">  mainLayout-&gt;addWidget( label, 2, 0 );</div>
<div class="line">  mainLayout-&gt;addWidget( mPasswordEdit, 2, 1 );</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> ResourceExampleConfig::loadSettings( <a class="code" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">KRES::Resource</a> *resource )</div>
<div class="line">{</div>
<div class="line">  ResourceExample *res = <span class="keyword">dynamic_cast&lt;</span>ResourceExample *<span class="keyword">&gt;</span>( resource );</div>
<div class="line">  <span class="keywordflow">if</span> ( res ) {</div>
<div class="line">    mHostEdit-&gt;setText( res-&gt;host() );</div>
<div class="line">    mPasswordEdit-&gt;setText( res-&gt;password() );</div>
<div class="line">  } <span class="keywordflow">else</span></div>
<div class="line">    kDebug() &lt;&lt; <span class="stringliteral">&quot;ERROR: ResourceExampleConfig::loadSettings(): no ResourceExample, cast failed&quot;</span>;</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> ResourceExampleConfig::saveSettings( <a class="code" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">KRES::Resource</a> *resource )</div>
<div class="line">{</div>
<div class="line">  ResourceExample *res = <span class="keyword">dynamic_cast&lt;</span>ResourceExample *<span class="keyword">&gt;</span>( resource );</div>
<div class="line">  <span class="keywordflow">if</span> ( res ) {</div>
<div class="line">    res-&gt;setHost( mHostEdit-&gt;text() );</div>
<div class="line">    res-&gt;setPassword( mPasswordEdit-&gt;text() );</div>
<div class="line">  } <span class="keywordflow">else</span></div>
<div class="line">    kDebug() &lt;&lt; <span class="stringliteral">&quot;ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed&quot;</span>;</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>resourceexample.desktop</b>: </p>
<div class="fragment"><div class="line">[Desktop Entry]</div>
<div class="line">Type=Service</div>
<div class="line"></div>
<div class="line">[Misc]</div>
<div class="line">Encoding=UTF-8</div>
<div class="line">Name=Example Resource</div>
<div class="line"></div>
<div class="line">[Plugin]</div>
<div class="line">Type=exchange</div>
<div class="line">X-KDE-Library=resourceexample</div>
</div><!-- fragment --><p><b>Makefile.am</b> </p>
<div class="fragment"><div class="line">kde_module_LTLIBRARIES = resourceexample.la</div>
<div class="line"></div>
<div class="line">resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp</div>
<div class="line">resourceexample_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)</div>
<div class="line">resourceexample_la_LIBADD = -lkresources</div>
<div class="line"></div>
<div class="line">servicedir = $(kde_datadir)/resources/example</div>
<div class="line">service_DATA = resourceexample.desktop</div>
</div><!-- fragment --> </div></div><!-- contents -->
<div class="copyrights">
This file is part of the KDE documentation.<br/>
Documentation copyright &copy; 1996-2013 The KDE developers.<br/>
Generated on Fri Jul 12 2013 16:48:47 by
<a href="http://www.doxygen.org/index.html">doxygen</a> 1.8.3.1 written
by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, &copy;&nbsp;1997-2006
<p>
KDE's <a href="http://techbase.kde.org/Policies/Library_Documentation_Policy">Doxygen guidelines</a> are available online.
</p>
</div>
            </div>
          </div>
        </div>
        <div id="left">
          <div class="menu_box">
<a name="cp-menu" /><div class="menutitle"><div>
<h2 id="cp-menu-project">kresources</h2>
<a href="#cp-skip-project" class="cp-doNotDisplay">Skip menu "kresources"</a>
</div></div>
<ul><li><a href="index.html">Main Page</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="functions.html">Class Members</a></li><li><a href="files.html">File List</a></li><li><a href="pages.html">Related Pages</a></li></ul>
<!--
<h2>Class Picker</h2>
<div style="text-align: center;">
<form name="guideform">
<select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value">
<option value="annotated.html">-- Choose --</option>
  <option value="classKRES_1_1ConfigDialog.html">kres::configdialog</option>,  <option value="classKRES_1_1ConfigPage.html">kres::configpage</option>,  <option value="classKRES_1_1ConfigWidget.html">kres::configwidget</option>,  <option value="classKRES_1_1Factory.html">kres::factory</option>,  <option value="classKRES_1_1IdMapper.html">kres::idmapper</option>,  <option value="classKRES_1_1Manager.html">kres::manager</option>,  <option value="classKRES_1_1Manager_1_1ActiveIterator.html">kres::manager::activeiterator</option>,  <option value="classKRES_1_1Manager_1_1Iterator.html">kres::manager::iterator</option>,  <option value="classKRES_1_1ManagerImpl.html">kres::managerimpl</option>,  <option value="classKRES_1_1ManagerNotifier.html">kres::managernotifier</option>,  <option value="classKRES_1_1ManagerObserver.html">kres::managerobserver</option>,  <option value="classKRES_1_1Resource.html">kres::resource</option>,  <option value="classKRES_1_1SelectDialog.html">kres::selectdialog</option>,
</select>
</form>
</div>
-->
<div class="menu_box">
<a name="cp-menu" /><div class="menutitle"><div>
<h2 id="cp-menu-project">kdepimlibs-4.10.5 API Reference</h2>
<a href="#cp-skip-project" class="cp-doNotDisplay">Skip menu "kdepimlibs-4.10.5 API Reference"</a>
</div></div>
<div class="nav_list">
<ul>
<li><a href="../../akonadi/html/index.html">akonadi</a></li><li>&nbsp;&nbsp;<a href="../../akonadi/contact/html/index.html">contact</a></li><li>&nbsp;&nbsp;<a href="../../akonadi/kmime/html/index.html">kmime</a></li><li>&nbsp;&nbsp;<a href="../../akonadi/socialutils/html/index.html">socialutils</a></li><li><a href="../../kabc/html/index.html">kabc</a></li><li><a href="../../kalarmcal/html/index.html">kalarmcal</a></li><li><a href="../../kblog/html/index.html">kblog</a></li><li><a href="../../kcal/html/index.html">kcal</a></li><li><a href="../../kcalcore/html/index.html">kcalcore</a></li><li><a href="../../kcalutils/html/index.html">kcalutils</a></li><li><a href="../../kholidays/html/index.html">kholidays</a></li><li><a href="../../kimap/html/index.html">kimap</a></li><li><a href="../../kioslave/html/index.html">kioslave</a></li><li>&nbsp;&nbsp;<a href="../../kioslave/imap4/html/index.html">imap4</a></li><li>&nbsp;&nbsp;<a href="../../kioslave/mbox/html/index.html">mbox</a></li><li>&nbsp;&nbsp;<a href="../../kioslave/nntp/html/index.html">nntp</a></li><li><a href="../../kldap/html/index.html">kldap</a></li><li><a href="../../kmbox/html/index.html">kmbox</a></li><li><a href="../../kmime/html/index.html">kmime</a></li><li><a href="../../kontactinterface/html/index.html">kontactinterface</a></li><li><a href="../../kpimidentities/html/index.html">kpimidentities</a></li><li><a href="../../kpimtextedit/html/index.html">kpimtextedit</a></li><li><a href="../../kpimutils/html/index.html">kpimutils</a></li><li><a href="../../kresources/html/index.html">kresources</a></li><li><a href="../../ktnef/html/index.html">ktnef</a></li><li><a href="../../kxmlrpcclient/html/index.html">kxmlrpcclient</a></li><li><a href="../../mailtransport/html/index.html">mailtransport</a></li><li><a href="../../microblog/html/index.html">microblog</a></li><li><a href="../../qgpgme/html/index.html">qgpgme</a></li><li><a href="../../syndication/html/index.html">syndication</a></li><li>&nbsp;&nbsp;<a href="../../syndication/atom/html/index.html">atom</a></li><li>&nbsp;&nbsp;<a href="../../syndication/rdf/html/index.html">rdf</a></li><li>&nbsp;&nbsp;<a href="../../syndication/rss2/html/index.html">rss2</a></li>
</ul></div></div>
<!-- api_searchbox -->
          </div>
        </div>
        <div class="clearer"></div>
      </div>
      <div class="clearer"></div>
    </div>
    <div id="end_body"></div>
    <div id="footer"><div id="footer_text">
    Report problems with this website to <a href="https://bugs.kde.org/enter_sysadmin_request.cgi?component=api.kde.org">our bug tracking system</a>.<br>
    Contact the specific authors with questions and comments about the page contents.<p>
    KDE<sup>&#174;</sup> and <a href="/media/images/kde_gear_black.png">the K Desktop Environment<sup>&#174;</sup> logo</a> are registered trademarks of <a href="http://ev.kde.org/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> |
        <a href="http://www.kde.org/contact/impressum.php">Legal</a></p>
    </div></div>
  </div>
<!--
WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL
BE BLOCKED INSTANTLY AND PERMANENTLY!
<a href="mailto:aaaatrap-45abe0e0c3bebc77@kde.org">Block me</a>
WARNING END
-->
</body>
</html>