summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-10 11:04:16 (UTC)
committer zecke <zecke>2004-09-10 11:04:16 (UTC)
commit2ec724fc789cd34f6b3743896516f2fef2731456 (patch) (side-by-side diff)
tree67830cb237efa4201ff530bb0c66e496222a5fd3
parent29ed6115bd14aa95d29cf922fd179a6e470b5d53 (diff)
downloadopie-2ec724fc789cd34f6b3743896516f2fef2731456.zip
opie-2ec724fc789cd34f6b3743896516f2fef2731456.tar.gz
opie-2ec724fc789cd34f6b3743896516f2fef2731456.tar.bz2
Move handleWidget of OKeyConfigManager to a slot
Add some @see statements to the OKeyConfigManager
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/okeyconfigmanager.cpp10
-rw-r--r--libopie2/opiecore/okeyconfigmanager.h7
2 files changed, 14 insertions, 3 deletions
diff --git a/libopie2/opiecore/okeyconfigmanager.cpp b/libopie2/opiecore/okeyconfigmanager.cpp
index ccb96cc..891cda7 100644
--- a/libopie2/opiecore/okeyconfigmanager.cpp
+++ b/libopie2/opiecore/okeyconfigmanager.cpp
@@ -593,124 +593,134 @@ OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) {
return item;
}
/**
* Return the associated id of the item or -1 if no item
* matched the key
*
* @see handleKeyEvent
*/
int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) {
return handleKeyEvent( ev ).id();
}
/**
* Add Key Config to the List of items
*/
void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) {
m_keys.append( item );
delete m_map; m_map = 0;
}
/**
* Remove the Key from the Config. Internal lists will be destroyed
* and rebuild on demand later
*/
void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) {
m_keys.remove( item );
delete m_map; m_map = 0;
}
/**
* Clears the complete list
*/
void OKeyConfigManager::clearKeyConfig() {
m_keys.clear();
delete m_map; m_map = 0;
}
/**
*
*/
Opie::Core::OKeyConfigItem::List OKeyConfigManager::keyConfigList()const{
return m_keys;
}
/**
* Add this OKeyPair to the blackList.
* Internal lists will be destroyed
+ *
+ * @see clearBlackList
+ * @see removeFromBlackList
*/
void OKeyConfigManager::addToBlackList( const OKeyPair& key) {
m_blackKeys.append( key );
delete m_map; m_map = 0;
}
/**
* Remove this OKeyPair from the black List
* Internal lists will be destroyed
+ *
+ * @see addToBlackList
+ * @see clearBlackList
*/
void OKeyConfigManager::removeFromBlackList( const OKeyPair& key ) {
m_blackKeys.remove( key );
delete m_map; m_map = 0;
}
/**
* Clear the blackList
*/
void OKeyConfigManager::clearBlackList() {
m_blackKeys.clear();
delete m_map; m_map = 0;
}
/**
* Return a copy of the blackList
+ *
+ * @see addToBlackList
+ * @see clearBlackList
+ * @see removeFromBlackList
*/
OKeyPair::List OKeyConfigManager::blackList()const {
return m_blackKeys;
}
/**
* Ask the Manager to handle KeyEvents for you.
* All handled keys will emit a QSignal and return true
* that it handled the keyevent
*/
void OKeyConfigManager::handleWidget( QWidget* wid ) {
wid->installEventFilter( this );
}
/**
* @internal
*/
bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) {
if ( !obj->isWidgetType() )
return false;
/*
* check if we care for the event
*/
if ( (ev->type() != QEvent::KeyPress||!testEventMask(MaskPressed)) &&
(ev->type() != QEvent::KeyRelease||!testEventMask(MaskReleased)) )
return false;
QKeyEvent *key = static_cast<QKeyEvent*>( ev );
OKeyConfigItem item = handleKeyEvent( key );
if ( item.isEmpty() )
return false;
QWidget *wid = static_cast<QWidget*>( obj );
if ( item.object() && !item.slot().isEmpty() ) {
connect( this, SIGNAL( actionActivated(QWidget*, QKeyEvent*)),
item.object(), item.slot().data() );
emit actionActivated(wid, key);
disconnect( this, SIGNAL(actionActivated(QWidget*,QKeyEvent*)),
item.object(), item.slot().data() );
}
emit actionActivated( wid, key, item );
return true;
}
diff --git a/libopie2/opiecore/okeyconfigmanager.h b/libopie2/opiecore/okeyconfigmanager.h
index d0a6247..12804ee 100644
--- a/libopie2/opiecore/okeyconfigmanager.h
+++ b/libopie2/opiecore/okeyconfigmanager.h
@@ -21,203 +21,204 @@ namespace Core {
/**
* \brief small class representing a Key with possible modifiers
* This class holds information about key code and possible
* modifier state. That is the lowest level of the key input
* functions.
* There are also static methods to get special keys.
* OKeyPair will be used with \see OKeyConfigItem
*
* @since 1.2
*/
class OKeyPair {
public:
typedef QValueList<OKeyPair> List;
OKeyPair( int key = -1, int modifier = -1);
~OKeyPair();
bool operator==( const OKeyPair& )const;
bool operator!=( const OKeyPair& )const;
bool isEmpty()const;
int keycode()const;
int modifier()const;
void setKeycode( int );
void setModifier( int );
static OKeyPair returnKey();
static OKeyPair leftArrowKey();
static OKeyPair rightArrowKey();
static OKeyPair upArrowKey();
static OKeyPair downArrowKey();
static OKeyPair emptyKey();
static OKeyPair::List hardwareKeys();
private:
int m_key;
int m_mod;
class Private;
Private* d;
};
/**
* A class to represent an OKeyPair.
* It consists out of a Text exposed to the user, Config Key Item,
* Pixmap, A default OKeyPair and the set OKeyPair.
* You can also pass an id to it
*
- * @since 1.1.2
+ * @since 1.2
*/
class OKeyConfigItem {
friend class OKeyConfigManager;
public:
typedef QValueList<OKeyConfigItem> List;
OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(),
const QPixmap& symbol = QPixmap(),
int id = -1,
const OKeyPair& def = OKeyPair::emptyKey(),
QObject *caller = 0, const char* slot = 0);
OKeyConfigItem( const Opie::Core::ODeviceButton& );
~OKeyConfigItem();
bool operator==( const OKeyConfigItem& )const;
bool operator!=( const OKeyConfigItem& )const;
QString text()const;
QPixmap pixmap()const;
int id()const;
OKeyPair keyPair()const;
OKeyPair defaultKeyPair()const;
QCString configKey()const;
void setText( const QString& text );
void setPixmap( const QPixmap& );
void setKeyPair( const OKeyPair& );
void setDefaultKeyPair( const OKeyPair& );
bool isEmpty()const;
protected:
QObject *object()const;
QCString slot()const;
void setId( int id );
void setConfigKey( const QCString& );
private:
QString m_text;
QCString m_config;
QPixmap m_pix;
int m_id;
OKeyPair m_key;
OKeyPair m_def;
QObject *m_obj;
QCString m_str;
class Private;
Private *d;
};
/**
* \brief A manager to load and save Key Actions and get notified
* This is the Manager for KeyActions.
* You can say from which config and group to read data, to grab the
* keyboard to handle hardware keys, you can supply a blacklist of
* keys which should not be used by allowed to be used.
* You can even pass this manager to a Widget to do the configuration for you.
* You need to add OKeyConfigItem for your keys and then issue a load() to
* read the Key information.
* You can either handle the QKeyEvent yourself and ask this class if it is
* handled by your action and let give you the action. Or you can install
* the event filter and get a signal.
* You need to load and save yourself!
*
* Again if you want to extend it and I missed a virtual, tell me so I can improve (zecke@handhelds.org)
*
* @since 1.1.2
*/
class OKeyConfigManager : public QObject {
Q_OBJECT
typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate;
public:
enum EventMask {
MaskPressed = 0x1,
MaskReleased = 0x2,
};
OKeyConfigManager(Opie::Core::OConfig *conf = 0,
const QString& group = QString::null,
const OKeyPair::List &block = OKeyPair::List(),
bool grabkeyboard = false, QObject * par = 0,
const char* name = 0 );
virtual ~OKeyConfigManager();
+public slots:
virtual void load();
virtual void save();
+ void handleWidget( QWidget* );
+public:
virtual OKeyConfigItem handleKeyEvent( QKeyEvent* );
int handleKeyEventId( QKeyEvent* );
void addKeyConfig( const OKeyConfigItem& );
void removeKeyConfig( const OKeyConfigItem& );
void clearKeyConfig();
void addToBlackList( const OKeyPair& );
void removeFromBlackList( const OKeyPair& );
void clearBlackList();
OKeyPair::List blackList()const;
- void handleWidget( QWidget* );
-
bool eventFilter( QObject*, QEvent* );
/**
* Sets the event mask flags aMask.
*
* aMask is a combination of OKeyConfigManager::EventMask
*
* @see eventMask(), testEventMask(), addEventMask(), clearEventMask()
*/
void setEventMask(uint aMask);
/**
* Returns the event mask flags set.
*
* aMask is a combination of OKeyConfigManager::EventMask
*
* @see setEventMask(), testEventMask(), addEventMask(), clearEventMask()
*/
uint eventMask()const;
/**
* Test if the event mask flag aMask is set.
*
* @param aMask one of OKeyConfigManager::EventMask
*
* @see eventMask(), setEventMask(), addEventMask(), clearEventMask()
*/
bool testEventMask(uint aMask);
/**
* Add the event mask flag aMask.
*
* @param aMask one of OKeyConfigManager::EventMask
*
* @see eventMask(), setEventMask(), addEventMask(), clearEventMask()
*/
void addEventMask(uint aMask);
/**
* Clears the event mask flag aMask.
*
* @param aMask is one of OKeyConfigManager::EventMask
*
* @see eventMask(), testEventMask(), addEventMask(), setEventMask()
*/
void clearEventMask(uint aMask);
OKeyConfigItem::List keyConfigList()const;
signals:
/**
* The Signals are triggered on KeyPress and KeyRelease!