Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_input_profile_model.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the KDE project
3 * SPDX-FileCopyrightText: 2013 Arjen Hiemstra <ahiemstra@heimr.nl>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
9
11
13 : QStringListModel(parent)
14{
15 setStringList(KisInputProfileManager::instance()->profileNames());
16 connect(KisInputProfileManager::instance(), SIGNAL(profilesChanged()), SLOT(profileNamesChanged()));
17}
18
23
25{
26 setStringList(KisInputProfileManager::instance()->profileNames());
27}
28
29bool KisInputProfileModel::setData(const QModelIndex &index, const QVariant &value, int /*role*/)
30{
31 QString oldName = profileName(index);
32 return KisInputProfileManager::instance()->renameProfile(oldName, value.toString());
33}
34
35QString KisInputProfileModel::profileName(const QModelIndex &index)
36{
37 return data(index, Qt::DisplayRole).toString();
38}
39
40QModelIndex KisInputProfileModel::find(const QString &name)
41{
42 for (int i = 0; i < rowCount(); ++i) {
43 QModelIndex ind = index(i, 0);
44
45 if (profileName(ind) == name) {
46 return ind;
47 }
48 }
49
50 return QModelIndex();
51}
52
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static KisInputProfileManager * instance()
bool renameProfile(const QString &oldName, const QString &newName)
QString profileName(const QModelIndex &index)
KisInputProfileModel(QObject *parent=0)
QModelIndex find(const QString &name)
bool setData(const QModelIndex &index, const QVariant &value, int=Qt::EditRole) override