@@ -32,12 +32,12 @@ QVariant SortedSetKeyModel::getData(int rowIndex, int dataRole)
3232 if (!isRowLoaded (rowIndex))
3333 return QVariant ();
3434
35- QPair<QByteArray, double > row = m_rowsCache[rowIndex];
35+ QPair<QByteArray, QByteArray > row = m_rowsCache[rowIndex];
3636
3737 if (dataRole == Roles::Value)
3838 return row.first ;
3939 else if (dataRole ==Roles::Score)
40- return QString::number ( row.second ) ;
40+ return row.second ;
4141 else if (dataRole == Roles::RowNumber)
4242 return QString::number (rowIndex+1 );
4343
@@ -49,14 +49,14 @@ void SortedSetKeyModel::updateRow(int rowIndex, const QVariantMap &row)
4949 if (!isRowLoaded (rowIndex) || !isRowValid (row))
5050 throw Exception (" Invalid row" );
5151
52- QPair<QByteArray, double > cachedRow = m_rowsCache[rowIndex];
52+ QPair<QByteArray, QByteArray > cachedRow = m_rowsCache[rowIndex];
5353
5454 bool valueChanged = cachedRow.first != row[" value" ].toString ();
55- bool scoreChanged = cachedRow.second != row[" score" ].toDouble ();
55+ bool scoreChanged = cachedRow.second != row[" score" ].toString ();
5656
57- QPair<QByteArray, double > newRow (
57+ QPair<QByteArray, QByteArray > newRow (
5858 (valueChanged) ? row[" value" ].toByteArray () : cachedRow.first ,
59- (scoreChanged) ? row[" score" ].toDouble () : cachedRow.second
59+ (scoreChanged) ? row[" score" ].toByteArray () : cachedRow.second
6060 );
6161
6262 // TODO (uglide): Update only score if value not changed
@@ -71,9 +71,9 @@ void SortedSetKeyModel::addRow(const QVariantMap &row)
7171 if (!isRowValid (row))
7272 throw Exception (" Invalid row" );
7373
74- QPair<QByteArray, double > cachedRow (
74+ QPair<QByteArray, QByteArray > cachedRow (
7575 row[" value" ].toByteArray (),
76- row[" score" ].toDouble ());
76+ row[" score" ].toByteArray ());
7777
7878 if (addSortedSetRow (cachedRow.first , cachedRow.second )) {
7979 m_rowsCache.push_back (cachedRow);
@@ -99,12 +99,12 @@ void SortedSetKeyModel::removeRow(int i)
9999 setRemovedIfEmpty ();
100100}
101101
102- bool SortedSetKeyModel::addSortedSetRow (const QByteArray &value, double score)
102+ bool SortedSetKeyModel::addSortedSetRow (const QByteArray &value, QByteArray score)
103103{
104104 RedisClient::Response result;
105105 try {
106106 result = m_connection->commandSync (
107- {" ZADD" , m_keyFullPath, QString::number ( score). toLatin1 () , value}, m_dbIndex);
107+ {" ZADD" , m_keyFullPath, score, value}, m_dbIndex);
108108 } catch (const RedisClient::Connection::Exception& e) {
109109 throw Exception (" Connection error: " + QString (e.what ()));
110110 }
@@ -123,19 +123,19 @@ void SortedSetKeyModel::deleteSortedSetRow(const QByteArray &value)
123123
124124void SortedSetKeyModel::addLoadedRowsToCache (const QVariantList &rows, int rowStart)
125125{
126- QList<QPair<QByteArray, double >> result;
126+ QList<QPair<QByteArray, QByteArray >> result;
127127
128128 for (QVariantList::const_iterator item = rows.begin ();
129129 item != rows.end (); ++item) {
130130
131- QPair<QByteArray, double > value;
131+ QPair<QByteArray, QByteArray > value;
132132 value.first = item->toByteArray ();
133133 ++item;
134134
135135 if (item == rows.end ())
136136 throw Exception (" Partial data loaded from server" );
137137
138- value.second = item->toDouble ();
138+ value.second = item->toByteArray ();
139139 result.push_back (value);
140140 }
141141
0 commit comments