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