Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/models/payeeidentifiercontainermodel.cpp
Show All 10 Lines | |||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | 12 | * GNU General Public License for more details. | ||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #include "payeeidentifiercontainermodel.h" | 18 | #include "payeeidentifiercontainermodel.h" | ||
19 | #include "payeeidentifier/payeeidentifierloader.h" | | |||
20 | #include "payeeidentifier/payeeidentifier.h" | 19 | #include "payeeidentifier/payeeidentifier.h" | ||
20 | #include "payeeidentifier/ibanbic/ibanbic.h" | ||||
21 | #include "payeeidentifier/nationalaccount/nationalaccount.h" | ||||
21 | 22 | | |||
22 | #include <KLocalizedString> | 23 | #include <KLocalizedString> | ||
23 | 24 | | |||
24 | payeeIdentifierContainerModel::payeeIdentifierContainerModel(QObject* parent) | 25 | payeeIdentifierContainerModel::payeeIdentifierContainerModel(QObject* parent) | ||
25 | : QAbstractListModel(parent), | 26 | : QAbstractListModel(parent), | ||
26 | m_data(QSharedPointer<MyMoneyPayeeIdentifierContainer>()) | 27 | m_data(QSharedPointer<MyMoneyPayeeIdentifierContainer>()) | ||
27 | { | 28 | { | ||
28 | } | 29 | } | ||
Show All 34 Lines | 54 | if (!m_data.isNull() && role == payeeIdentifier) { | |||
63 | } | 64 | } | ||
64 | return true; | 65 | return true; | ||
65 | } | 66 | } | ||
66 | return QAbstractItemModel::setData(index, value, role); | 67 | return QAbstractItemModel::setData(index, value, role); | ||
67 | } | 68 | } | ||
68 | 69 | | |||
69 | Qt::ItemFlags payeeIdentifierContainerModel::flags(const QModelIndex& index) const | 70 | Qt::ItemFlags payeeIdentifierContainerModel::flags(const QModelIndex& index) const | ||
70 | { | 71 | { | ||
71 | Qt::ItemFlags flags = QAbstractItemModel::flags(index) | Qt::ItemIsDragEnabled; | 72 | static const QVector<QString> editableDelegates { | ||
72 | const QString type = data(index, payeeIdentifierType).toString(); | 73 | payeeIdentifiers::ibanBic::staticPayeeIdentifierIid(), | ||
74 | payeeIdentifiers::nationalAccount::staticPayeeIdentifierIid() | ||||
75 | }; | ||||
76 | auto flags = QAbstractItemModel::flags(index) | Qt::ItemIsDragEnabled; | ||||
77 | const auto type = data(index, payeeIdentifierType).toString(); | ||||
78 | | ||||
73 | // type.isEmpty() means the type selection can be shown | 79 | // type.isEmpty() means the type selection can be shown | ||
74 | if (!type.isEmpty() && payeeIdentifierLoader::instance()->hasItemEditDelegate(type)) | 80 | if (!type.isEmpty() && editableDelegates.contains(type)) | ||
75 | flags |= Qt::ItemIsEditable; | 81 | flags |= Qt::ItemIsEditable; | ||
76 | return flags; | 82 | return flags; | ||
77 | } | 83 | } | ||
78 | 84 | | |||
79 | int payeeIdentifierContainerModel::rowCount(const QModelIndex& parent) const | 85 | int payeeIdentifierContainerModel::rowCount(const QModelIndex& parent) const | ||
80 | { | 86 | { | ||
81 | Q_UNUSED(parent); | 87 | Q_UNUSED(parent); | ||
82 | if (m_data.isNull()) | 88 | if (m_data.isNull()) | ||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |