]> git.sven.stormbind.net Git - sven/vym.git/blob - src/dbus/adaptormodel.cpp
New upstream version 2.9.22
[sven/vym.git] / src / dbus / adaptormodel.cpp
1 #include "adaptormodel.h"
2 #include <QtCore/QMetaObject>
3 #include <QtCore/QString>
4 #include <QtCore/QVariant>
5
6 #include "branchitem.h"
7 #include "command.h"
8 #include "mainwindow.h"
9 #include "vymmodel.h"
10
11 extern QString vymInstanceName;
12 extern Main *mainWindow;
13
14 extern QList<Command *> modelCommands;
15
16 AdaptorModel::AdaptorModel(QObject *obj) : QDBusAbstractAdaptor(obj)
17 {
18     model = static_cast<VymModel *>(obj);
19     setAutoRelaySignals(true);
20 }
21
22 void AdaptorModel::setModel(VymModel *vm) { model = vm; }
23
24 QString AdaptorModel::caption() { return m_caption; }
25
26 void AdaptorModel::setCaption(const QString &newCaption)
27 {
28     m_caption = newCaption;
29 }
30
31 QDBusVariant AdaptorModel::branchCount()
32 {
33     BranchItem *selbi = model->getSelectedBranch();
34     if (selbi)
35         return QDBusVariant(selbi->branchCount());
36     else
37         return QDBusVariant(-1);
38 }
39
40 QDBusVariant AdaptorModel::execute(const QString &s)
41 {
42     return QDBusVariant(model->execute(s));
43 }
44
45 QDBusVariant AdaptorModel::errorLevel()
46 {
47     return QDBusVariant(); // model->parser.errorLevel() );     // FIXME-4
48                            // really still needed? parser no longer used.
49 }
50
51 QDBusVariant AdaptorModel::errorDescription()
52 {
53     return QDBusVariant(); // model->parser.errorDescription() );// FIXME-4
54                            // really still needed? parser no longer used.
55 }
56
57 QDBusVariant AdaptorModel::listCommands()
58 {
59     QStringList list;
60
61     foreach (Command *command, modelCommands)
62         list << command->getName();
63
64     return QDBusVariant(list.join(","));
65 }