KeyActionListViewItem.h

Go to the documentation of this file.
00001 /*
00002  * This class contains code borrowed from 
00003  * keyboard_shortcuts.h (rev. 1.2) and
00004  * keyboard_shortcuts.cpp (rev. 1.3) of ZBEDic.
00005  * Copyright (C) 2004 Rafal Mantiuk <rafm@users.sourceforge.org>
00006  */
00007 #ifndef KEY_ACTION_LIST_VIEW_ITEM
00008 #define KEY_ACTION_LIST_VIEW_ITEM
00009 
00010 #include <qaction.h>
00011 #include <qlistview.h>
00012 #include "Util.h"
00013 
00014 class KeyActionListViewItem : public QListViewItem {
00015 
00016 public:
00017     KeyActionListViewItem( QListView *parent, QAction *action, Action actionIndex ) : QListViewItem( parent ), action( action ), actionIndex( actionIndex ) {
00018         keyCode = action->accel();
00019         updateText();
00020     }
00021 
00022     QAction *getAction() {
00023         return action;
00024     }
00025 
00026     Action getActionIndex() {
00027         return( actionIndex );
00028     }
00029 
00030     void setKey( int keyCode ) {
00031         this->keyCode = keyCode;
00032         updateText();
00033     }
00034 
00035     int getKey() {
00036         return keyCode;
00037     }
00038 
00039     void updateText() {
00040         setText( 1, keyCode ? Util::describeKey( keyCode ) : QString::null );
00041     }  
00042 
00043 private:
00044 
00045     QAction*    action;
00046     int         keyCode;
00047     Action      actionIndex;
00048 
00049 };
00050 
00051 #endif

Generated on Sun Mar 1 17:30:47 2009 for toMOTko by  doxygen 1.5.6