/****************************************************************************
**
** Copyright (C) 1992-2004 Trolltech AS. All rights reserved.
**
** This file is part of the compatibility classes of the Qt Toolkit.
**
** Licensees holding valid Qt Preview licenses may use this file in
** accordance with the Qt Preview License Agreement provided with the
** Software.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#ifndef QACCEL_H
#define QACCEL_H

#include "qobject.h"

#include "qkeysequence.h"

#ifndef QT_NO_ACCEL

class QAccelPrivate;
class QKeySequence;
class QWidget;

class Q_COMPAT_EXPORT QAccel : public QObject
{
    Q_OBJECT
    Q_DECLARE_PRIVATE(QAccel)
public:
    QAccel(QWidget *parent, const char *name=0);
    QAccel(QWidget* watch, QObject *parent, const char *name=0);
    ~QAccel();

    bool isEnabled() const;
    void setEnabled(bool);

    uint count() const;

    int insertItem(const QKeySequence& key, int id=-1);
    void removeItem(int id);
    void clear();

    QKeySequence key(int id);
    int findKey(const QKeySequence& key) const;

    bool isItemEnabled(int id) const;
    void setItemEnabled(int id, bool enable);

    bool connectItem(int id,  const QObject *receiver, const char* member);
    bool disconnectItem(int id,  const QObject *receiver, const char* member);

    void setWhatsThis(int id, const QString&);
    QString whatsThis(int id) const;
    void setIgnoreWhatsThis(bool);
    bool ignoreWhatsThis() const;

    static QKeySequence shortcutKey(const QString &);
    static QString keyToString(const QKeySequence &k);
    static QKeySequence stringToKey(const QString &);

signals:
    void activated(int id);
    void activatedAmbiguously(int id);

private:
    Q_DISABLE_COPY(QAccel)

    friend class QAccelManager;
};

class QKeyEvent;

inline QString QAccel::keyToString(const QKeySequence &k)
{
    return QString(k);
}

inline QKeySequence QAccel::stringToKey(const QString & s)
{
    return QKeySequence(s);
}

#endif // QT_NO_ACCEL
#endif // QACCEL_H
