adaptormodel.cpp
author insilmaril
Wed, 25 Nov 2009 15:28:05 +0000
changeset 809 0a1abd218f36
parent 807 f9f7922989d8
child 832 6a6018ba4cc7
permissions -rw-r--r--
Removing unneeded findwindow.*
     1 #include "adaptormodel.h"
     2 #include <QtCore/QMetaObject>
     3 #include <QtCore/QString>
     4 #include <QtCore/QVariant>
     5 
     6 #include "vymmodel.h"
     7 
     8 extern QString vymInstanceName;
     9 
    10 AdaptorModel::AdaptorModel(QObject *obj)
    11          : QDBusAbstractAdaptor(obj)
    12 {
    13 	model=static_cast <VymModel*> (obj);
    14 	setAutoRelaySignals (true);
    15 }
    16 
    17 AdaptorModel::~AdaptorModel()
    18 {
    19     // destructor
    20 }
    21 
    22 void AdaptorModel::setModel(VymModel *vm)
    23 {
    24 	model=vm;
    25 }
    26 
    27 QString AdaptorModel::caption()
    28 {
    29 	return m_caption;
    30 }
    31 
    32 void AdaptorModel::setCaption (const QString &newCaption)
    33 {
    34 	m_caption=newCaption;
    35 }
    36 
    37 QDBusVariant AdaptorModel::query(const QString &query)
    38 {
    39 	QString s;
    40 	if (model)
    41 		s=model->getHeading();
    42 	else
    43 		s="oops, no vymModel?";
    44 
    45 	return QDBusVariant (s);
    46 }
    47 
    48 QDBusVariant AdaptorModel::getHeading()
    49 {
    50 	QString s;
    51 	if (model)
    52 		s=model->getHeading();
    53 	else
    54 		s="oops, no vymModel?";
    55 
    56 	return QDBusVariant (s);
    57 }
    58 
    59 
    60 void AdaptorModel::setHeading (const QString &s)
    61 {
    62 	model->setHeading(s);
    63 }
    64 
    65 QDBusVariant AdaptorModel::getInstanceName()
    66 {
    67 	return QDBusVariant (vymInstanceName);
    68 }
    69 
    70 QDBusVariant AdaptorModel::execute (const QString &s)
    71 {
    72 	if (model)
    73 		return QDBusVariant (model->runScript (s));
    74 	else
    75 		return QDBusVariant ("No model.");
    76 }
    77