Changeset View
Changeset View
Standalone View
Standalone View
src/statsyncing/models/MatchedTracksModel.cpp
Show All 20 Lines | |||||
21 | #include "core/support/Debug.h" | 21 | #include "core/support/Debug.h" | ||
22 | #include "statsyncing/TrackTuple.h" | 22 | #include "statsyncing/TrackTuple.h" | ||
23 | 23 | | |||
24 | #include <KColorScheme> | 24 | #include <KColorScheme> | ||
25 | #include <KLocalizedString> | 25 | #include <KLocalizedString> | ||
26 | 26 | | |||
27 | using namespace StatSyncing; | 27 | using namespace StatSyncing; | ||
28 | 28 | | |||
29 | static const int tupleIndexIndernalId = -1; | 29 | static const quintptr tupleIndexIndernalId = 0; | ||
30 | 30 | | |||
31 | MatchedTracksModel::MatchedTracksModel( const QList<TrackTuple> &matchedTuples, | 31 | MatchedTracksModel::MatchedTracksModel( const QList<TrackTuple> &matchedTuples, | ||
32 | const QList<qint64> &columns, const Options &options, QObject *parent ) | 32 | const QList<qint64> &columns, const Options &options, QObject *parent ) | ||
33 | : QAbstractItemModel( parent ) | 33 | : QAbstractItemModel( parent ) | ||
34 | , CommonModel( columns, options ) | 34 | , CommonModel( columns, options ) | ||
35 | , m_matchedTuples( matchedTuples ) | 35 | , m_matchedTuples( matchedTuples ) | ||
36 | { | 36 | { | ||
37 | m_titleColumn = m_columns.indexOf( Meta::valTitle ); | 37 | m_titleColumn = m_columns.indexOf( Meta::valTitle ); | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 108 | { | |||
112 | qint64 field = m_columns.at( index.column() ); | 112 | qint64 field = m_columns.at( index.column() ); | ||
113 | if( index.internalId() == tupleIndexIndernalId ) | 113 | if( index.internalId() == tupleIndexIndernalId ) | ||
114 | { | 114 | { | ||
115 | TrackTuple tuple = m_matchedTuples.value( index.row() ); | 115 | TrackTuple tuple = m_matchedTuples.value( index.row() ); | ||
116 | if( tuple.isEmpty() ) | 116 | if( tuple.isEmpty() ) | ||
117 | return QVariant(); | 117 | return QVariant(); | ||
118 | return tupleData( tuple, field, role ); | 118 | return tupleData( tuple, field, role ); | ||
119 | } | 119 | } | ||
120 | else if( index.internalId() < m_matchedTuples.count() ) | 120 | else if( index.internalId() < (quintptr)m_matchedTuples.count() ) | ||
121 | { | 121 | { | ||
122 | TrackTuple tuple = m_matchedTuples.value( index.internalId() ); | 122 | TrackTuple tuple = m_matchedTuples.value( index.internalId() ); | ||
123 | ProviderPtr provider = tuple.provider( index.row() ); | 123 | ProviderPtr provider = tuple.provider( index.row() ); | ||
124 | if( !provider ) | 124 | if( !provider ) | ||
125 | return QVariant(); | 125 | return QVariant(); | ||
126 | return trackData( provider, tuple, field, role ); | 126 | return trackData( provider, tuple, field, role ); | ||
127 | } | 127 | } | ||
128 | return QVariant(); | 128 | return QVariant(); | ||
129 | } | 129 | } | ||
130 | 130 | | |||
131 | bool | 131 | bool | ||
132 | MatchedTracksModel::setData( const QModelIndex &idx, const QVariant &value, int role ) | 132 | MatchedTracksModel::setData( const QModelIndex &idx, const QVariant &value, int role ) | ||
133 | { | 133 | { | ||
134 | if( !idx.isValid() || | 134 | if( !idx.isValid() || | ||
135 | idx.internalId() >= m_matchedTuples.count() || | 135 | idx.internalId() >= (quintptr)m_matchedTuples.count() || | ||
136 | role != Qt::CheckStateRole ) | 136 | role != Qt::CheckStateRole ) | ||
137 | { | 137 | { | ||
138 | return false; | 138 | return false; | ||
139 | } | 139 | } | ||
140 | qint64 field = m_columns.value( idx.column() ); | 140 | qint64 field = m_columns.value( idx.column() ); | ||
141 | TrackTuple &tuple = m_matchedTuples[ idx.internalId() ]; // we need reference | 141 | TrackTuple &tuple = m_matchedTuples[ idx.internalId() ]; // we need reference | ||
142 | ProviderPtr provider = tuple.provider( idx.row() ); | 142 | ProviderPtr provider = tuple.provider( idx.row() ); | ||
143 | if( !provider ) | 143 | if( !provider ) | ||
▲ Show 20 Lines • Show All 266 Lines • Show Last 20 Lines |