Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 1f9eb832ba1e4b88d9a5c2b384813bb4 > files > 6497

kdelibs3-apidocs-3.5.10-31.fc15.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_US" xml:lang="en_US">

<head>
  <title>kresources: The KDE Resource library (kresources)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <meta http-equiv="Content-Style-Type" content="text/css" />

  <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org"  r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org"  r (n 0 s 0 v 0 l 0))' />

  <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" />

  <link rel="shortcut icon" href="../../favicon.ico" />

<link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" />



</head>

<body>

<div id="nav_header_top" align="right">
  <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a>

  <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a>
  <span class="doNotDisplay">::</span>

  <div id="nav_header_title" align="left">KDE API Reference</div>


</div>

<div id="nav_header_bottom" align="right">
  <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span>
  <div id="nav_header_bottom_right" style="text-align: left;">
/ <a href="../..">API Reference</a>
 / <a href=".">kresources</a>
  </div>
</div>


<table id="main" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
      <td valign="top" class="menuheader" height="0"></td>

  <td id="contentcolumn" valign="top" rowspan="2" >
    <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;">
    <a name="content"></a>


<!-- Generated by Doxygen 1.7.4 -->
</div>
<div class="header">
  <div class="headertitle">
<div class="title">The KDE <a class="el" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">Resource</a> library </div>  </div>
</div>
<div class="contents">
<div class="textblock"><p>The KDE <a class="el" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">Resource</a> framework can be used to manage resources of different types, organized in families. The <a class="el" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">Resource</a> 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 <a class="el" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">Resource</a> 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 <a class="el" href="classKRES_1_1Resource.html" title="This class provides a resource which is managed in a general way.">Resource</a> 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"><pre class="fragment"><span class="preprocessor">#include &lt;kconfig.h&gt;</span>
<span class="preprocessor">#include &lt;kresources/resource.h&gt;</span>

<span class="keyword">class </span>ResourceExample : <span class="keyword">public</span> KRES::Resource
{
  <span class="keyword">public</span>:
    ResourceExample( <span class="keyword">const</span> KConfig * );
    ~ResourceExample();
    <span class="keywordtype">void</span> writeConfig( KConfig *config );

  <span class="keyword">private</span>:
    <a class="codeRef" href="qstring.html">QString</a> mLocation;
    <a class="codeRef" href="qstring.html">QString</a> mPassword;
}
</pre></div><p><b>resourceexample.cpp</b>: </p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;kconfig.h&gt;</span>

<span class="preprocessor">#include &quot;resourceexample.h&quot;</span>

ResourceExample::ResourceExample( <span class="keyword">const</span> KConfig *config )
    : Resource( config )
{
  <span class="keywordflow">if</span> ( config ) {
    mLocation = config-&gt;readPathEntry( <span class="stringliteral">&quot;Location&quot;</span> );
    mPassword = KStringHandler::obscure( config-&gt;readEntry( <span class="stringliteral">&quot;Password&quot;</span> ) );
  } <span class="keywordflow">else</span> {
    mLocation = <span class="stringliteral">&quot;&quot;</span>; <span class="comment">// Or some sensible default</span>
    mPassword = <span class="stringliteral">&quot;&quot;</span>;
  }
}

<span class="keywordtype">void</span> ResourceExample::writeConfig( KConfig *config )
{
  <a class="code" href="classKRES_1_1Resource.html#a1dd01b89702931d060d87332001e77d4" title="Write configuration information for this resource to a configuration file.">KRES::Resource::writeConfig</a>( config );
  config-&gt;writePathEntry( <span class="stringliteral">&quot;Location&quot;</span>, mLocation );
  config-&gt;writeEntry( <span class="stringliteral">&quot;Password&quot;</span>, KStringHandler::obscure( mPassword ) );
}

<span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span>
{
  KRES::ResourceExample *config_widget( <a class="codeRef" href="qwidget.html">QWidget</a> *parent ) {
    <span class="keywordflow">return</span> <span class="keyword">new</span> ResourceExampleConfig( parent, <span class="stringliteral">&quot;Configure Example Resource&quot;</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> *resource( <span class="keyword">const</span> KConfig *config ) {
    <span class="keywordflow">return</span> <span class="keyword">new</span> ResourceExample( config );
  }
}
</pre></div><p><b>resourceexampleconfig.h</b>: </p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;klineedit.h&gt;</span>
<span class="preprocessor">#include &lt;kresources/resourceconfigwidget.h&gt;</span>

<span class="preprocessor">#include &quot;resourceexample.h&quot;</span>

<span class="keyword">class </span>ResourceExampleConfig : <span class="keyword">public</span> KRES::ResourceConfigWidget
{
    Q_OBJECT
  <span class="keyword">public</span>:
    ResourceExampleConfig( <a class="codeRef" href="qwidget.html">QWidget</a> *parent = 0, <span class="keyword">const</span> <span class="keywordtype">char</span> *name = 0 );

  <span class="keyword">public</span> slots:
    <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);
    <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 );

  <span class="keyword">private</span>:
    KLineEdit *mLocationEdit;
    KLineEdit *mPasswordEdit;
};
</pre></div><p><b>resourceexampleconfig.cpp</b>: </p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;qlayout.h&gt;</span>
<span class="preprocessor">#include &lt;qlabel.h&gt;</span>
<span class="preprocessor">#include &lt;kresources/resourceconfigwidget.h&gt;</span>
<span class="preprocessor">#include &quot;resourceexample.h&quot;</span>
<span class="preprocessor">#include &quot;resourceexampleconfig.h&quot;</span>

ResourceExampleConfig::ResourceExampleConfig( <a class="codeRef" href="qwidget.html">QWidget</a> *parent,  <span class="keyword">const</span> <span class="keywordtype">char</span> *name )
  : KRES::ResourceConfigWidget( parent, name )
{
  <a class="codeRef" href="qgridlayout.html">QGridLayout</a> *mainLayout = <span class="keyword">new</span> <a class="codeRef" href="qgridlayout.html">QGridLayout</a>( <span class="keyword">this</span>, 2, 2 );

  <a class="codeRef" href="qlabel.html">QLabel</a> *label = <span class="keyword">new</span> <a class="codeRef" href="qlabel.html">QLabel</a>( i18n( <span class="stringliteral">&quot;Location:&quot;</span> ), <span class="keyword">this</span> );
  mHostEdit = <span class="keyword">new</span> KLineEdit( <span class="keyword">this</span> );
  mainLayout-&gt;<a class="codeRef" href="qgridlayout.html#addWidget">addWidget</a>( label, 1, 0 );
  mainLayout-&gt;<a class="codeRef" href="qgridlayout.html#addWidget">addWidget</a>( mHostEdit, 1, 1 );

  label = <span class="keyword">new</span> <a class="codeRef" href="qlabel.html">QLabel</a>( i18n( <span class="stringliteral">&quot;Password:&quot;</span> ), <span class="keyword">this</span> );
  mPasswordEdit = <span class="keyword">new</span> KLineEdit( <span class="keyword">this</span> );
  mPasswordEdit-&gt;setEchoMode( QLineEdit::Password );
  mainLayout-&gt;<a class="codeRef" href="qgridlayout.html#addWidget">addWidget</a>( label, 2, 0 );
  mainLayout-&gt;<a class="codeRef" href="qgridlayout.html#addWidget">addWidget</a>( mPasswordEdit, 2, 1 );
}

<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 )
{
  ResourceExample *res = <span class="keyword">dynamic_cast&lt;</span>ResourceExample *<span class="keyword">&gt;</span>( resource );
  <span class="keywordflow">if</span> ( res ) {
    mHostEdit-&gt;setText( res-&gt;host() );
    mPasswordEdit-&gt;setText( res-&gt;password() );
  } <span class="keywordflow">else</span>
    kdDebug() &lt;&lt; <span class="stringliteral">&quot;ERROR: ResourceExampleConfig::loadSettings(): no ResourceExample, cast failed&quot;</span> &lt;&lt; endl;
}

<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 )
{
  ResourceExample *res = <span class="keyword">dynamic_cast&lt;</span>ResourceExample *<span class="keyword">&gt;</span>( resource );
  <span class="keywordflow">if</span> ( res ) {
    res-&gt;setHost( mHostEdit-&gt;text() );
    res-&gt;setPassword( mPasswordEdit-&gt;text() );
  } <span class="keywordflow">else</span>
    kdDebug() &lt;&lt; <span class="stringliteral">&quot;ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed&quot;</span> &lt;&lt; endl;
}
</pre></div><p><b>resourceexample.desktop</b>: </p>
<div class="fragment"><pre class="fragment">[Desktop Entry]
Type=Service

[Misc]
Encoding=UTF-8
Name=Example Resource

[Plugin]
Type=exchange
X-KDE-Library=resourceexample
</pre></div><p><b>Makefile.am</b> </p>
<div class="fragment"><pre class="fragment">kde_module_LTLIBRARIES = resourceexample.la

resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp
resourceexample_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
resourceexample_la_LIBADD = -lkresources

servicedir = $(kde_datadir)/resources/example
service_DATA = resourceexample.desktop
</pre></div> </div></div>
    </div></div>


      </td>
  </tr>
  <tr>
    <td valign="top" id="leftmenu" width="25%">
      <a name="navigation"></a>
      <div class="menu_box"><h2>kresources</h2>
<div class="nav_list">
<ul><li><a href="index.html">Main Page</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="functions.html">Class Members</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_1Factory.html">kres::factory</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_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></div>
<div class="menu_box"><h2>API Dox</h2>
<div class="nav_list">
<ul>
<li><a href="../../arts/html/index.html">arts</a></li><li><a href="../../dcop/html/index.html">dcop</a></li><li><a href="../../dnssd/html/index.html">dnssd</a></li><li><a href="../../interfaces/html/index.html">interfaces</a></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../interfaces/kimproxy/interface/html/index.html">interface</a></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../interfaces/kimproxy/library/html/index.html">library</a></li><li>&nbsp;&nbsp;<a href="../../interfaces/kspeech/html/index.html">kspeech</a></li><li>&nbsp;&nbsp;<a href="../../interfaces/ktexteditor/html/index.html">ktexteditor</a></li><li><a href="../../kabc/html/index.html">kabc</a></li><li><a href="../../kate/html/index.html">kate</a></li><li><a href="../../kcmshell/html/index.html">kcmshell</a></li><li><a href="../../kdecore/html/index.html">kdecore</a></li><li><a href="../../kded/html/index.html">kded</a></li><li><a href="../../kdefx/html/index.html">kdefx</a></li><li><a href="../../kdeprint/html/index.html">kdeprint</a></li><li><a href="../../kdesu/html/index.html">kdesu</a></li><li><a href="../../kdeui/html/index.html">kdeui</a></li><li><a href="../../kdoctools/html/index.html">kdoctools</a></li><li><a href="../../khtml/html/index.html">khtml</a></li><li><a href="../../kimgio/html/index.html">kimgio</a></li><li><a href="../../kinit/html/index.html">kinit</a></li><li><a href="../../kio/html/index.html">kio</a></li><li>&nbsp;&nbsp;<a href="../../kio/bookmarks/html/index.html">bookmarks</a></li><li>&nbsp;&nbsp;<a href="../../kio/httpfilter/html/index.html">httpfilter</a></li><li>&nbsp;&nbsp;<a href="../../kio/kfile/html/index.html">kfile</a></li><li>&nbsp;&nbsp;<a href="../../kio/kio/html/index.html">kio</a></li><li>&nbsp;&nbsp;<a href="../../kio/kioexec/html/index.html">kioexec</a></li><li>&nbsp;&nbsp;<a href="../../kio/kpasswdserver/html/index.html">kpasswdserver</a></li><li>&nbsp;&nbsp;<a href="../../kio/kssl/html/index.html">kssl</a></li><li><a href="../../kioslave/html/index.html">kioslave</a></li><li>&nbsp;&nbsp;<a href="../../kioslave/http/html/index.html">http</a></li><li><a href="../../kjs/html/index.html">kjs</a></li><li><a href="../../kmdi/html/index.html">kmdi</a></li><li>&nbsp;&nbsp;<a href="../../kmdi/kmdi/html/index.html">kmdi</a></li><li><a href="../../knewstuff/html/index.html">knewstuff</a></li><li><a href="../../kparts/html/index.html">kparts</a></li><li><a href="../../kresources/html/index.html">kresources</a></li><li><a href="../../kspell2/html/index.html">kspell2</a></li><li><a href="../../kunittest/html/index.html">kunittest</a></li><li><a href="../../kutils/html/index.html">kutils</a></li><li><a href="../../kwallet/html/index.html">kwallet</a></li><li><a href="../../libkmid/html/index.html">libkmid</a></li><li><a href="../../libkscreensaver/html/index.html">libkscreensaver</a></li>
</ul></div></div>


        </td>
</tr>
</table>

<span class="doNotDisplay">
  <a href="http://www.kde.org/" accesskey="8">KDE Home</a> |
  <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> |
  <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a>
</span>


<div style="height: 8px"></div>

<div id="footer">
  <div id="footer_left">
    Maintained by <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;groo&#116;&#64;kde&#46;or&#x67;">Adriaan de Groot</a>
and
<a href="&#109;a&#105;&#108;&#116;&#111;&#58;w&#105;nter&#64;kde&#46;or&#x67">Allen Winter</a>.
<br/>
    KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> |
    <a href="http://www.kde.org/contact/impressum.php">Legal</a>
  </div>
  <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div>
</div>

<!--
WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL
BE BLOCKED INSTANTLY AND PERMANENTLY!
<a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a>
WARNING END
-->

</body>
</html>