Back to index

salome-gui  6.5.0
QtxShortcutEdit.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef QTXSHORTCUTEDIT_H
00021 #define QTXSHORTCUTEDIT_H
00022 
00023 #include "Qtx.h"
00024 
00025 #include <QFrame>
00026 #include <QTreeWidget>
00027 
00028 class QLineEdit;
00029 class QPushButton;
00030 class QTreeWidgetItem;
00031 
00032 typedef QMap< QString, QString > ShortcutMap;
00033 
00034 class QTX_EXPORT QtxShortcutEdit : public QFrame
00035 {
00036   Q_OBJECT
00037 
00038 public:
00039   QtxShortcutEdit( QWidget* = 0 );
00040   virtual ~QtxShortcutEdit();
00041   void           setShortcut( const QKeySequence& );
00042   QKeySequence   shortcut();
00043   static QString parseEvent( QKeyEvent* );
00044   static bool    isValidKey( int );
00045 
00046 
00047 private slots:
00048   void           onCliked();
00049   void           onEditingFinished();
00050 
00051 protected:
00052   virtual bool   eventFilter( QObject*, QEvent* );
00053 
00054 private:
00055   void           initialize();
00056 
00057 private:
00058   QLineEdit*     myShortcut;
00059   QString        myPrevShortcutText;
00060 };
00061 
00062 class QTX_EXPORT QtxShortcutTree : public QTreeWidget
00063 {
00064   Q_OBJECT
00065 
00066 public:
00067   QtxShortcutTree( QWidget * parent = 0 );
00068   virtual ~QtxShortcutTree();
00069   void                      setBindings( const QString&, const ShortcutMap& );
00070   ShortcutMap*              bindings( const QString& ) const;
00071   QStringList               sections() const;
00072   void                      setGeneralSections( const QStringList& );
00073 
00074 protected:
00075   virtual bool              eventFilter( QObject*, QEvent* );
00076   virtual void              focusOutEvent( QFocusEvent* );
00077   virtual bool              checkUniqueness( QTreeWidgetItem*, const QString& );
00078 
00079 private slots:
00080   void                      onCurrentItemChanged( QTreeWidgetItem*, QTreeWidgetItem* );
00081 
00082 private:
00083   QMap< QString, ShortcutMap > myPrevBindings;
00084   QStringList myGeneralSections;
00085 };
00086 
00087 #endif // QTXSHORTCUTEDIT_H