2
<one line to give the library's name and an idea of what it does.>
3
Copyright (C) 2012 Dan Vratil <dvratil@redhat.com>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
15
You should have received a copy of the GNU Lesser General Public
16
License along with this library; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
#include "qmloutput.h"
22
#include <kscreen/output.h>
25
#include <QStandardItem>
26
#include <QStandardItemModel>
27
#include <QStringBuilder>
29
Q_DECLARE_METATYPE(KScreen::Mode*);
31
QMLOutput::QMLOutput():
35
m_modesModel(new QStandardItemModel(this))
40
QMLOutput::~QMLOutput()
45
void QMLOutput::setOutput(KScreen::Output* output)
49
QList<KScreen::Mode*> modes = m_output->modes().values();
50
Q_FOREACH (KScreen::Mode *mode, modes) {
51
QList<QStandardItem*> items = m_modesModel->findItems(mode->name(), Qt::MatchExactly, 0);
52
if (items.isEmpty()) {
53
QStandardItem *item = new QStandardItem(mode->name());
54
item->setData(mode->size(), QMLOutput::SizeRole);
56
m_modesModel->appendRow(item);
60
QStandardItem *modeItem = new QStandardItem(QString::number(mode->refreshRate(), 'f', 1) % QLatin1String("Hz"));
61
modeItem->setData(mode->refreshRate(), QMLOutput::RefreshRateRole);
62
modeItem->setData(mode->id(), QMLOutput::ModeIdRole);
63
modeItem->setData(QVariant::fromValue(mode), QMLOutput::ModeRole);
65
QStandardItem *item = items.first();
66
item->appendRow(modeItem);
69
connect(output, SIGNAL(clonesChanged()), SIGNAL(changed()));
70
connect(output, SIGNAL(currentModeChanged()), SIGNAL(changed()));
71
connect(output, SIGNAL(isEnabledChanged()), SIGNAL(changed()));
72
connect(output, SIGNAL(isPrimaryChanged()), SIGNAL(changed()));
73
connect(output, SIGNAL(outputChanged()), SIGNAL(changed()));
74
connect(output, SIGNAL(posChanged()), SIGNAL(changed()));
75
connect(output, SIGNAL(rotationChanged()), SIGNAL(changed()));
77
Q_EMIT outputChanged();
80
KScreen::Output* QMLOutput::output() const
85
void QMLOutput::setCloneOf(QMLOutput* other)
89
Q_EMIT cloneOfChanged();
92
QMLOutput* QMLOutput::cloneOf() const
97
QAbstractItemModel* QMLOutput::modesModel()