text: /*
     Copyright 2013 Research In Motion Limited
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  */
  #ifndef cascades_keylistener_h
  #define cascades_keylistener_h
  
  // begin mock includes
  #include <gmock/gmock.h>
  #include <QSharedPointer>
  // end mock includes
  
  #include <bb/cascades/UIObject>
  namespace bb {
      namespace cascades {
        class KeyEvent;
        class KeyListenerPrivate;
  
        class KeyListenerMock : public UIObjectMock {
        public:
            MOCK_METHOD1(ctor, void(UIObject* parent));
        };
  
        class KeyListener : public UIObject {
              Q_OBJECT
          public:
              explicit KeyListener(UIObject *parent=0) : UIObject(parent) {
                mock<KeyListenerMock>()->ctor(parent);
            };
              virtual ~KeyListener() {};
  Q_SIGNALS:
              void keyEvent(bb::cascades::KeyEvent *event);
              void keyPressed(bb::cascades::KeyEvent *event);
              void keyReleased(bb::cascades::KeyEvent *event);
        public:
            template <typename BuilderType, typename BuiltType>
            class TBuilder : public BaseObject::TBuilder<BuilderType, BuiltType>
            {
            protected:
                TBuilder(BuiltType* node) : BaseObject::TBuilder<BuilderType, BuiltType>(node)
                {
                }
            public:
                BuilderType& onKeyEvent(const QObject* receiver, const char *method) {
                    this->connect(SIGNAL(keyEvent(bb::cascades::KeyEvent*)), receiver, method);
                    return this->builder();
                }
                BuilderType& onKeyPressed(const QObject* receiver, const char *method) {
                    this->connect(SIGNAL(keyPressed(bb::cascades::KeyEvent*)), receiver, method);
                    return this->builder();
                }
                BuilderType& onKeyReleased(const QObject* receiver, const char *method) {
                    this->connect(SIGNAL(keyReleased(bb::cascades::KeyEvent*)), receiver, method);
                    return this->builder();
                }
            };
            class Builder : public TBuilder<Builder, KeyListener>
            {
            public:
                explicit Builder() : TBuilder<Builder, KeyListener>(new KeyListener()) {}
            };
            static Builder create() {
                return Builder();
            }
          private:
              Q_DECLARE_PRIVATE(KeyListener)
        };
      }
  }
  QML_DECLARE_TYPE(bb::cascades::KeyListener)
  #endif
  