adaptormodel.cpp
author convert-repo
Fri, 23 Jul 2010 16:43:49 +0000
changeset 849 988f1908a7c4
parent 847 43268373032d
permissions -rw-r--r--
update tags
     1 #include "adaptormodel.h"
     2 #include <QtCore/QMetaObject>
     3 #include <QtCore/QString>
     4 #include <QtCore/QVariant>
     5 
     6 #include "mainwindow.h"
     7 #include "vymmodel.h"
     8 
     9 extern QString vymInstanceName;
    10 extern Main *mainWindow;
    11 
    12 AdaptorModel::AdaptorModel(QObject *obj)
    13          : QDBusAbstractAdaptor(obj)
    14 {
    15 	model=static_cast <VymModel*> (obj);
    16 	setAutoRelaySignals (true);
    17 }
    18 
    19 AdaptorModel::~AdaptorModel()
    20 {
    21     // destructor
    22 }
    23 
    24 void AdaptorModel::setModel(VymModel *vm)
    25 {
    26 	model=vm;
    27 }
    28 
    29 QString AdaptorModel::caption()
    30 {
    31 	return m_caption;
    32 }
    33 
    34 void AdaptorModel::setCaption (const QString &newCaption)
    35 {
    36 	m_caption=newCaption;
    37 }
    38 
    39 QDBusVariant AdaptorModel::query(const QString &)
    40 {
    41 	QString s;
    42 	if (model)
    43 		s=model->getHeading();
    44 	else
    45 		s="oops, no vymModel?";
    46 
    47 	return QDBusVariant (s);
    48 }
    49 
    50 QDBusVariant AdaptorModel::getCurrentModelID()
    51 {
    52 	return QDBusVariant (mainWindow->currentModelID());
    53 }
    54 
    55 QDBusVariant AdaptorModel::getHeading()
    56 {
    57 	QString s;
    58 	if (model)
    59 		s=model->getHeading();
    60 	else
    61 		s="oops, no vymModel?";
    62 
    63 	return QDBusVariant (s);
    64 }
    65 
    66 
    67 void AdaptorModel::setHeading (const QString &s)
    68 {
    69 	model->setHeading(s);
    70 }
    71 
    72 QDBusVariant AdaptorModel::getInstanceName()
    73 {
    74 	return QDBusVariant (vymInstanceName);
    75 }
    76 
    77 QDBusVariant AdaptorModel::execute (const QString &s)
    78 {
    79 	if (model)
    80 		return QDBusVariant (model->runScript (s));
    81 	else
    82 		return QDBusVariant ("No model.");
    83 }
    84