Qt: fix blank rows in library rendering
This commit is contained in:
parent
d79579d1ca
commit
44349b0a37
@ -336,6 +336,26 @@ QVariant LibraryModel::folderData(const QModelIndex& index, int role) const {
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LibraryModel::validateIndex(const QModelIndex& index) const
|
||||||
|
{
|
||||||
|
if (index.model() != this || index.row() < 0 || index.column() < 0 || index.column() > MAX_COLUMN) {
|
||||||
|
// Obviously invalid index
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index.parent().isValid() && !validateIndex(index.parent())) {
|
||||||
|
// Parent index is invalid
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index.row() >= rowCount(index.parent())) {
|
||||||
|
// Row is out of bounds for this level of hierarchy
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant LibraryModel::data(const QModelIndex& index, int role) const {
|
QVariant LibraryModel::data(const QModelIndex& index, int role) const {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
@ -357,7 +377,7 @@ QVariant LibraryModel::data(const QModelIndex& index, int role) const {
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index.model() != this || index.row() < 0 || index.row() > rowCount() || index.column() < 0 || index.column() > columnCount()) {
|
if (!validateIndex(index)) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,8 @@ private:
|
|||||||
|
|
||||||
QVariant folderData(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
QVariant folderData(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
|
bool validateIndex(const QModelIndex& index) const;
|
||||||
|
|
||||||
void addEntriesList(const QList<LibraryEntry>& items);
|
void addEntriesList(const QList<LibraryEntry>& items);
|
||||||
void addEntriesTree(const QList<LibraryEntry>& items);
|
void addEntriesTree(const QList<LibraryEntry>& items);
|
||||||
void addEntryInternal(const LibraryEntry& item);
|
void addEntryInternal(const LibraryEntry& item);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user