Skip to content

Commit 93249d4

Browse files
committed
Fix regression in Value Editor RedisInsight#3679
1 parent f559159 commit 93249d4

File tree

6 files changed

+104
-93
lines changed

6 files changed

+104
-93
lines changed

src/app/models/key-models/hashkey.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class HashKeyModel : public KeyModel<QPair<QByteArray, QByteArray>>
2020
void addLoadedRowsToCache(const QVariantList& list, int rowStart) override;
2121

2222
private:
23-
enum Roles { Value = Qt::UserRole + 1, RowNumber, Key};
23+
enum Roles { RowNumber = Qt::UserRole + 1, Key, Value};
2424

2525
void setHashRow(const QByteArray &hashKey, const QByteArray &hashValue, bool updateIfNotExist = true);
2626
void deleteHashRow(const QByteArray& hashKey);

src/app/models/key-models/listlikekey.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ListLikeKeyModel : public KeyModel<QByteArray>
1717
QVariant getData(int rowIndex, int dataRole) override;
1818

1919
protected:
20-
enum Roles { Value = Qt::UserRole + 1, RowNumber};
20+
enum Roles { RowNumber = Qt::UserRole + 1, Value};
2121

2222
protected:
2323
void addLoadedRowsToCache(const QVariantList& rows, int rowStart) override;

src/app/models/key-models/sortedsetkey.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SortedSetKeyModel : public KeyModel<QPair<QByteArray, QByteArray>>
2020
void addLoadedRowsToCache(const QVariantList& list, int rowStart) override;
2121

2222
private:
23-
enum Roles { Value = Qt::UserRole + 1, RowNumber, Score};
23+
enum Roles { RowNumber = Qt::UserRole + 1, Value, Score};
2424

2525
bool addSortedSetRow(const QByteArray &value, QByteArray score);
2626
void deleteSortedSetRow(const QByteArray& value);

src/modules/value-editor/viewmodel.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ QVariant ValueEditor::ViewModel::data(const QModelIndex &index, int role) const
8989
case keyNameRole: return model->getKeyName();
9090
case keyDisplayName: return model->getKeyTitle();
9191
case keyTTL: return model->getTTL();
92-
case keyType: return model->getType();
92+
case keyType: return model->getType();
9393
case showValueNavigation: return model->isMultiRow();
9494
case columnNames: return QVariant(model->getColumnNames()).toList();
9595
case count: return static_cast<qulonglong>(model->rowsCount());
@@ -108,8 +108,7 @@ QHash<int, QByteArray> ValueEditor::ViewModel::roleNames() const
108108
roles[keyType] = "keyType";
109109
roles[showValueNavigation] = "showValueNavigation";
110110
roles[columnNames] = "columnNames";
111-
roles[count] = "valuesCount";
112-
roles[keyValue] = "keyValue";
111+
roles[count] = "valuesCount";
113112
return roles;
114113
}
115114

@@ -206,7 +205,7 @@ void ValueEditor::ViewModel::setCurrentTab(int i)
206205
m_currentTabIndex = i;
207206
}
208207

209-
QObject* ValueEditor::ViewModel::getValue(int i)
208+
QObject* ValueEditor::ViewModel::getValue(int i) const
210209
{
211210
if (!isIndexValid(index(i, 0)))
212211
return nullptr;
@@ -215,7 +214,6 @@ QObject* ValueEditor::ViewModel::getValue(int i)
215214

216215
QList<QObject *> valueEditors = model->getConnector()->findChildren<QObject *>();
217216

218-
219217
if (valueEditors.isEmpty())
220218
return new ValueEditor::ValueViewModel(model);
221219
else
@@ -257,7 +255,7 @@ void ValueEditor::ViewModel::loadModel(QSharedPointer<ValueEditor::Model> model,
257255
m_valueModels.insert(m_currentTabIndex, model);
258256
m_valueModels.removeAt(m_currentTabIndex+1);
259257
emit dataChanged(index(m_currentTabIndex, 0), index(m_currentTabIndex, 0));
260-
emit replaceTab(m_currentTabIndex);
258+
emit replaceTab(m_currentTabIndex);
261259
}
262260
}
263261

src/modules/value-editor/viewmodel.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ namespace ValueEditor {
1818
class ViewModel : public QAbstractListModel
1919
{
2020
Q_OBJECT
21-
2221
public:
2322
enum Roles {
2423
keyNameRole = Qt::UserRole + 1,
@@ -28,8 +27,7 @@ class ViewModel : public QAbstractListModel
2827
keyType,
2928
showValueNavigation,
3029
columnNames,
31-
count,
32-
keyValue
30+
count
3331
};
3432

3533
public:
@@ -49,7 +47,7 @@ class ViewModel : public QAbstractListModel
4947
Q_INVOKABLE void setTTL(int i, const QString& newTTL);
5048
Q_INVOKABLE void closeTab(int i);
5149
Q_INVOKABLE void setCurrentTab(int i);
52-
Q_INVOKABLE QObject* getValue(int i);
50+
Q_INVOKABLE QObject* getValue(int i) const;
5351

5452
signals:
5553
void keyError(int index, const QString& error);

0 commit comments

Comments
 (0)