//
//     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.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


class KAccel : QAccel
{
%TypeHeaderCode
#include <kaccel.h>
%End


public:
                         KAccel (QWidget* /TransferThis/, const char* = 0);
                         KAccel (QWidget*, QObject* /TransferThis/, const char* = 0);
    KAccelActions&       actions ();
    bool                 isEnabled () const;
    void                 setEnabled (bool);
    bool                 setAutoUpdate (bool);

%If ( KDE_3_1_4 -  )
    KAccelAction*        insert (const QString&, const QString&, const QString&, const KShortcut&, SIP_RXOBJ_CON, SIP_SLOT_CON (), bool = 1, bool = 1);
    KAccelAction*        insert (const QString&, const QString&, const QString&, const KShortcut&, const KShortcut&, SIP_RXOBJ_CON, SIP_SLOT_CON (), bool = 1, bool = 1);
    KAccelAction*        insert (const char*, const KShortcut&, SIP_RXOBJ_CON, SIP_SLOT_CON (), bool = 1, bool = 1);
    KAccelAction*        insert (KStdAccel::StdAccel, SIP_RXOBJ_CON, SIP_SLOT_CON (), bool = 1, bool = 1);
%End

    bool                 remove (const QString&);
    bool                 updateConnections ();
    const KShortcut&     shortcut (const QString&) const;
    bool                 setShortcut (const QString&, const KShortcut&);

%If ( KDE_3_1_4 -  )
    bool                 setSlot (const QString&, SIP_RXOBJ_CON, SIP_SLOT_CON ());
%End

    bool                 setEnabled (const QString&, bool);
    const QString&       configGroup () const;
    void                 setConfigGroup (const QString&);
    bool                 readSettings (KConfigBase* = 0);
    bool                 writeSettings (KConfigBase* = 0) const;
    void                 emitKeycodeChanged ();

signals:
    void                 keycodeChanged ();

public:
    bool                 insertItem (const QString&, const QString&, const char*, int = 0, QPopupMenu* = 0, bool = 1);
    bool                 insertItem (const QString&, const QString&, int, int, QPopupMenu*, bool = 1);
    bool                 insertStdItem (KStdAccel::StdAccel, const QString& = QString ::null );

%If ( KDE_3_1_4 -  )
    bool                 connectItem (const QString&, SIP_RXOBJ_CON, SIP_SLOT_CON (), bool = 1);
    bool                 connectItem (KStdAccel::StdAccel, SIP_RXOBJ_CON, SIP_SLOT_CON ());
%End

    bool                 removeItem (const QString&);
    bool                 setItemEnabled (const QString&, bool);
    void                 changeMenuAccel (QPopupMenu*, int, const QString&);
    void                 changeMenuAccel (QPopupMenu*, int, KStdAccel::StdAccel);
    static int           stringToKey (const QString&);
    int                  currentKey (const QString&) const;
    QString              findKey (int) const;

protected:
//igx     virtual void         virtual_hook (int, void*);

public:

%If (  - KDE_3_2_0 )
//ig     bool                 getAutoUpdate ();
//ig     KAccelAction*        insert (const QString&, const QString&);
%End


public:

%If (  - KDE_3_1_4 )
    KAccelAction*        insert (const QString&, const QString&, const QString&, const KShortcut&, const QObject*, const char*, bool = 1, bool = 1);
    KAccelAction*        insert (const QString&, const QString&, const QString&, const KShortcut&, const KShortcut&, const QObject*, const char*, bool = 1, bool = 1);
    KAccelAction*        insert (const char*, const KShortcut&, const QObject*, const char*, bool = 1, bool = 1);
    KAccelAction*        insert (KStdAccel::StdAccel, const QObject*, const char*, bool = 1, bool = 1);
    bool                 setSlot (const QString&, const QObject*, const char*);
%End


public:

%If (  - KDE_3_1_4 )
    bool                 connectItem (const QString&, const QObject*, const char*, bool = 1);
    bool                 connectItem (KStdAccel::StdAccel, const QObject*, const char*);

//force
%ConvertToSubClassCode
    // The table of Python class objects indexed by their names.  The table
    // must be sorted by name.

    static sipStringTypeClassMap map[] = {
        {sipName_KAccel,                  &sipClass_KAccel},
        {sipName_KApplication,            &sipClass_KApplication},
        {sipName_KAsyncIO,                &sipClass_KAsyncIO},
        {sipName_KAudioPlayer,            &sipClass_KAudioPlayer},
        {sipName_KBufferedIO,             &sipClass_KBufferedIO},
#if KDE_VERSION >= 0x030100
        {sipName_KClipboardSynchronizer,  &sipClass_KClipboardSynchronizer},
#endif
        {sipName_KCompletion,             &sipClass_KCompletion},
        {sipName_KConfig,                 &sipClass_KConfig},
        {sipName_KConfigBase,             &sipClass_KConfigBase},
        {sipName_KConfigGroup,            &sipClass_KConfigGroup},
        {sipName_KDesktopFile,            &sipClass_KDesktopFile},
        {sipName_KGlobalAccel,            &sipClass_KGlobalAccel},
        {sipName_KLibFactory,             &sipClass_KLibFactory},
        {sipName_KLibLoader,              &sipClass_KLibLoader},
        {sipName_KLibrary,                &sipClass_KLibrary},
        {sipName_KMultipleDrag,           &sipClass_KMultipleDrag},
        {sipName_KProcIO,                 &sipClass_KProcIO},
        {sipName_KProcess,                &sipClass_KProcess},
        {sipName_KProcessController,      &sipClass_KProcessController},
        {sipName_KServerSocket,           &sipClass_KServerSocket},
        {sipName_KShellProcess,           &sipClass_KShellProcess},
        {sipName_KSimpleConfig,           &sipClass_KSimpleConfig},
        {sipName_KSocket,                 &sipClass_KSocket},
        {sipName_KStartupInfo,            &sipClass_KStartupInfo},
        {sipName_KUniqueApplication,      &sipClass_KUniqueApplication},
        {sipName_KWinModule,              &sipClass_KWinModule},
    };

    sipClass = sipMapStringToClass(sipCpp -> className(),map,sizeof (map)/sizeof (map[0]));
%End
//end
%End


};  // class KAccel



%MappedType QMap<int,QString>
//converts a Python dict of int:QString
{
%TypeHeaderCode
#include <kaccel.h>
%End

%ConvertFromTypeCode

    if (!sipCpp)
        return PyDict_New();

        PyObject *dict;

    // Create the dictionary.

    if ((dict = PyDict_New()) == NULL)
        return NULL;

    // Get it.

        const QMap<int,QString> map = *sipCpp;
        QMap<int,QString>::ConstIterator it;

    for (it = map.begin (); it != map.end (); ++it)
        {
                PyObject *iKey  = PyInt_FromLong (((long) it.key ()));
                PyObject *sData = PyString_FromString ((char *)((QString *)&it.data ()));

                if ((iKey == NULL) || (sData == NULL) || (PyDict_SetItem (dict, iKey, sData) < 0))
                {
                        Py_XDECREF (iKey);
                        Py_XDECREF (sData);
                        Py_DECREF (dict);
                        return NULL;
                }
        }

    return dict;
%End


%ConvertToTypeCode
    // Convert a Python dictionary to a KKeyMapOrder on the heap.

    if (sipIsErr == NULL)
        return PyDict_Check(sipPy);

    QMap<int,QString> *map = new QMap<int,QString>;

    PyObject *key, *value;
    SIP_SSIZE_T pos = 0;
    int iKey;
    QString *sData;

    while (PyDict_Next(sipPy, &pos, &key, &value))
    {
        int iserr = 0, sData_state;

        iKey = PyInt_AS_LONG (key);
        sData = (QString *)sipForceConvertToType(value, sipType_QString, sipTransferObj, SIP_NOT_NONE, &sData_state, &iserr);

        if (iserr)
        {
            *sipIsErr = 1;
            delete map;
            return 0;
        }

        map->insert (iKey, *sData);

        sipReleaseType(sData, sipType_QString, sData_state);
    }

    *sipCppPtr = map;

    return 1;
%End
};


