/* ****************************************************************************
  This file is part of KBabel

  Copyright (C) 2000 by Matthias Kiefer
                            <matthias.kiefer@gmx.de>

  This program 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 program 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 program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

**************************************************************************** */
#ifndef DICTIONARYMENU_H
#define DICTIONARYMENU_H

#include <qintdict.h>
#include <qobject.h>
#include <qstringlist.h>
#include <qguardedptr.h>

class QPopupMenu;
class QAccel;

class DictionaryMenu : public QObject
{
   Q_OBJECT

public:
   DictionaryMenu(QPopupMenu *menu, QAccel *accel, QObject *parent=0);
   ~DictionaryMenu();
   
   void add(const QString& name,const QString& id);

   /**
    * Adds an item to this menu and to the keyboard accelerator.
    * If key contains %1 it is replaced with a number 1-9 
    */
   void add(const QString& name,const QString& id, const QString& key);

   void clear();
   
signals:
   void activated(const QString moduleId);
   
private slots:
   void activated(int);
   void accelActivated(int);
   
private:
   QGuardedPtr<QPopupMenu> popup;
   QGuardedPtr<QAccel> accel;
   QIntDict<QString> num2id;
   QIntDict<QString> accel2id;
};

#endif

