1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/*
clientpropertymodel.cpp
This file is part of GammaRay, the Qt application inspection and manipulation tool.
SPDX-FileCopyrightText: 2018 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Volker Krause <volker.krause@kdab.com>
SPDX-License-Identifier: GPL-2.0-or-later
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "clientpropertymodel.h"
#include <common/propertymodel.h>
#include <QStringList>
using namespace GammaRay;
ClientPropertyModel::ClientPropertyModel(QObject *parent)
: QIdentityProxyModel(parent)
{
}
ClientPropertyModel::~ClientPropertyModel() = default;
QVariant ClientPropertyModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::ToolTipRole && index.isValid()) {
const auto idx0 = index.sibling(index.row(), 0);
const auto f = idx0.data(PropertyModel::PropertyFlagsRole).value<PropertyModel::PropertyFlags>();
const auto revision = idx0.data(PropertyModel::PropertyRevisionRole);
const auto notifySignal = idx0.data(PropertyModel::NotifySignalRole).toString();
QStringList tt;
if (f != PropertyModel::None) {
QStringList fs;
if (f & PropertyModel::Constant)
fs.push_back(tr("constant"));
if (f & PropertyModel::Designable)
fs.push_back(tr("designable"));
if (f & PropertyModel::Final)
fs.push_back(tr("final"));
if (f & PropertyModel::Resetable)
fs.push_back(tr("resetable"));
if (f & PropertyModel::Scriptable)
fs.push_back(tr("scriptable"));
if (f & PropertyModel::Stored)
fs.push_back(tr("stored"));
if (f & PropertyModel::User)
fs.push_back(tr("user"));
if (f & PropertyModel::Writable)
fs.push_back(tr("writable"));
tt.push_back(tr("Attributes: %1").arg(fs.join(QLatin1String(", "))));
}
if (!revision.isNull()) {
tt.push_back(tr("Revision: %1").arg(revision.toInt()));
}
if (!notifySignal.isEmpty()) {
tt.push_back(tr("Notify signal: %1").arg(notifySignal));
}
return tt.join(QLatin1String("\n"));
}
return QIdentityProxyModel::data(index, role);
}
QVariant ClientPropertyModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) {
case 0:
return tr("Property");
case 1:
return tr("Value");
case 2:
return tr("Type");
case 3:
return tr("Class");
}
}
return QAbstractItemModel::headerData(section, orientation, role);
}
|