Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ExtensionsHandler.cpp

Go to the documentation of this file.
00001 #include "ExtensionsHandler.h"
00002 
00003 void ExtensionsHandler::dispose(QXmlReader* parser, QXmlContentHandler* parent)
00004 {
00005         m_parser = parser;
00006         m_parent = parent;
00007         m_parser->setContentHandler(this);
00008 }
00009 
00010 bool ExtensionsHandler::startElement(const QString& /* namespaceURI */,
00011         const QString& localName,
00012         const QString& /* qName */,
00013         const QXmlAttributes& attr)
00014 {
00015         if(localName == "define"){
00016                 /* 変数初期化 */
00017                 m_kind = QString::null;
00018                 m_code = -1;
00019                 //m_mask = 0;
00020                 m_modlist.clear();
00021                 for(int i=0; i<attr.length(); i++){
00022                         if(attr.localName(i).lower() == "key"){
00023                                 /* keyname */
00024                                 if(attr.value(i) == "All"){
00025                                         m_code = 0;
00026                                 } else {
00027                                         m_code = KeyNames::getCode(attr.value(i));
00028                                 }
00029                         } else if(attr.localName(i).lower() == "code"){
00030                                 /* keycode */
00031                                 m_code = KHUtil::hex2int(attr.value(i).lower());
00032                         } else if(attr.localName(i).lower() == "kind"){
00033                                 /* extension kind */
00034                                 m_kind = attr.value(i);
00035                         }
00036                 }
00037         } else if(localName == "modifier"){
00038                 /* modifier keys */
00039                 for(int i=0; i<attr.length(); i++){
00040                         if(attr.value(i).lower() == "on"){
00041                                 m_modlist.append(attr.localName(i));
00042                                 //m_mask |= m_pModifiers->getMask(attr.localName(i));
00043                         }
00044                 }
00045         }
00046         return(true);
00047 }
00048 
00049 bool ExtensionsHandler::endElement(const QString& /* namespaceURI */,
00050         const QString& localName,
00051         const QString& /* qName */)
00052 {
00053         if(localName == "define"){
00054 #if 0
00055                 if(m_kind != QString::null
00056                         && (m_code > 0 || m_modlist.isEmpty() == false)){
00057 #else
00058                 if(m_kind != QString::null && m_code >= 0){
00059 #endif
00060                         /* assign extension */
00061                         int keymask = 0;
00062                         QValueList<int> modcodes;
00063                         for(QStringList::Iterator it=m_modlist.begin();
00064                                         it!=m_modlist.end(); ++it){
00065                                 keymask |= m_pModifiers->getMask(*it);
00066                                 qDebug("mask[%s][%x][%s]", m_kind.latin1(), keymask, (*it).latin1());
00067                                 int code = KeyNames::getCode(*it);
00068                                 if(code > 0){
00069                                         modcodes.append(code);
00070                                 }
00071                         }
00072                         m_pExtensions->assign(m_kind, m_code, keymask, modcodes);
00073                 }
00074         } else if(localName == "extensions"){
00075                 m_pExtensions->init();
00076                 /* return parent */
00077                 m_parser->setContentHandler(m_parent);
00078         }
00079         return(true);
00080 }

Generated on Sat Nov 5 16:16:42 2005 for OPIE by  doxygen 1.4.2