You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pytde/sip/kdecore/ktimezones.sip

273 lines
6.6 KiB

//
// Copyright 2006 Jim Bublitz <jbublitz@nwinternet.com>
// Earlier copyrights 1998 - 2005 Jim Bublitz and/or Phil Thompson
// may also apply
// Generated by preSip
// module kdecore version KDE 3.5.3
// This software is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this library; see the file COPYING.
// If not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%If ( KDE_3_5_0 - )
class KTimezoneSource : KShared
{
%TypeHeaderCode
#include <ktimezones.h>
%End
public:
KTimezoneSource (const QString&);
virtual QString db ();
virtual bool parse (const QString&, KTimezoneDetails&) const;
}; // class KTimezoneSource
%End
%If ( KDE_3_5_0 - )
class KTimezone
{
%TypeHeaderCode
#include <ktimezones.h>
%End
public:
static const float UNKNOWN;
static bool isValidLatitude (float);
static bool isValidLongitude (float);
KTimezone (KSharedPtr<KTimezoneSource>, const QString&, const QString& = QString (), float = KTimezone ::UNKNOWN , float = KTimezone ::UNKNOWN , const QString& = QString ());
QString name () const;
QString countryCode () const;
float latitude () const;
float longitude () const;
int offset (Qt::TimeSpec = Qt ::UTC ) const;
int offset (const QDateTime&) const;
QDateTime convert (const KTimezone*, const QDateTime&) const;
QString comment () const;
bool parse (KTimezoneDetails&) const;
private:
KTimezone (const KTimezone&);
public:
//force
typedef KSharedPtr<KTimezoneSource> TZSourcePtr;
//end
}; // class KTimezone
%End
%If ( KDE_3_5_0 - )
class KTimezoneDetails
{
%TypeHeaderCode
#include <ktimezones.h>
%End
public:
KTimezoneDetails ();
virtual void parseEnded ();
virtual void parseStarted ();
virtual void gotHeader (uint, uint, uint, uint, uint, uint);
virtual void gotTransitionTime (int, uint);
virtual void gotLocalTimeIndex (int, uint);
virtual void gotLocalTime (int, int, bool, uint);
virtual void gotAbbreviation (int, const QString&);
virtual void gotLeapAdjustment (int, uint, uint);
virtual void gotIsStandard (int, bool);
virtual void gotIsUTC (int, bool);
}; // class KTimezoneDetails
%End
%If ( KDE_3_5_0 - )
class KTimezones
{
%TypeHeaderCode
#include <ktimezones.h>
%End
public:
KTimezones ();
const KTimezone* local ();
const KTimezone* zone (const QString&);
typedef QMap<QString,KTimezone*> ZoneMap;
const KTimezones::ZoneMap allZones ();
void add (KTimezone*);
private:
KTimezones (const KTimezones&);
}; // class KTimezones
%End
%If (KDE_3_5_0 - )
%MappedType KSharedPtr<KTimezoneSource>
//converts KSharedPtr<KTimezoneSource>
{
%TypeHeaderCode
#include <ksharedptr.h>
#include <ktimezones.h>
%End
%ConvertFromTypeCode
// Convert to a Python instance
if (!sipCpp)
return NULL;
KSharedPtr<KTimezoneSource> *cPtr = new KSharedPtr<KTimezoneSource> (*(KSharedPtr<KTimezoneSource> *)sipCpp);
KTimezoneSource *cpp = cPtr->data ();
PyObject *obj = sipConvertFromInstance (cpp, sipClass_KTimezoneSource, sipTransferObj);
return obj;
%End
%ConvertToTypeCode
// Convert a Python instance to a Ptr on the heap.
if (sipIsErr == NULL)
return PyInstance_Check(sipPy);
int iserr = 0;
KTimezoneSource *cpp = (KTimezoneSource *)sipForceConvertToType(sipPy, sipType_KTimezoneSource, sipTransferObj, SIP_NO_CONVERTORS, NULL, &iserr);
if (iserr)
{
*sipIsErr = 1;
return 0;
}
*sipCppPtr = new KSharedPtr<KTimezoneSource> (cpp);
return 1;
%End
};
%End
%If (KDE_3_5_0 - )
%MappedType KTimezones::ZoneMap
//converts a Python dict of QString:KTimezone
{
%TypeHeaderCode
#include <qmap.h>
#include <qstring.h>
#include <ktimezones.h>
%End
%ConvertFromTypeCode
// Convert to a Python dict
if (!sipCpp)
return PyDict_New();
PyObject *dict;
// Create the dictionary.
if ((dict = PyDict_New()) == NULL)
return NULL;
// Get it.
const QMap<QString, KTimezone*> cppmap = *sipCpp;
QMap<QString, KTimezone*>::ConstIterator it;
for (it = cppmap.begin (); it != cppmap.end (); ++it)
{
QString acpp = it.key ();
KTimezone *bcpp = it.data ();
PyObject *ainst;
PyObject *binst = NULL;
if (((ainst = sipConvertFromNewType(new QString(acpp), sipType_QString, sipTransferObj)) == NULL)
|| ((binst = sipConvertFromType(bcpp, sipType_KTimezone, sipTransferObj)) == NULL)
|| (PyDict_SetItem (dict, ainst, binst) < 0))
{
Py_XDECREF (ainst);
Py_XDECREF (binst);
Py_DECREF (dict);
return NULL;
}
}
return dict;
%End
%ConvertToTypeCode
// Convert a Python dictionary to a QMap on the heap.
if (sipIsErr == NULL)
return PyDict_Check(sipPy);
QMap<QString, KTimezone*> *cppmap = new QMap<QString, KTimezone*>;
PyObject *aelem, *belem;
SIP_SSIZE_T pos = 0;
QString *acpp;
KTimezone *bcpp;
while (PyDict_Next(sipPy, &pos, &aelem, &belem))
{
int iserr = 0, acpp_state;
acpp = (QString *)sipForceConvertToType(aelem, sipType_QString, sipTransferObj, SIP_NOT_NONE, &acpp_state, &iserr);
bcpp = (KTimezone *)sipForceConvertToType(belem, sipType_KTimezone, sipTransferObj, SIP_NO_CONVERTORS, NULL, &iserr);
if (iserr)
{
if (acpp)
sipReleaseType(acpp, sipType_QString, acpp_state);
*sipIsErr = 1;
delete cppmap;
return 0;
}
cppmap->insert (*acpp, bcpp);
sipReleaseType(acpp, sipType_QString, acpp_state);
}
*sipCppPtr = cppmap;
return 1;
%End
};
%End