diff options
Diffstat (limited to 'src/downloadlistsortproxy.cpp')
| -rw-r--r-- | src/downloadlistsortproxy.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/downloadlistsortproxy.cpp b/src/downloadlistsortproxy.cpp index fc743574..7abe8579 100644 --- a/src/downloadlistsortproxy.cpp +++ b/src/downloadlistsortproxy.cpp @@ -37,13 +37,16 @@ bool DownloadListSortProxy::lessThan(const QModelIndex &left, { int leftIndex = sourceModel()->data(left).toInt(); int rightIndex = sourceModel()->data(right).toInt(); - - if (left.column() == DownloadList::COL_NAME) { - return m_Manager->getFileName(leftIndex).compare(m_Manager->getFileName(rightIndex), Qt::CaseInsensitive) < 0; - } else if (left.column() == DownloadList::COL_FILETIME) { - return m_Manager->getFileTime(leftIndex) < m_Manager->getFileTime(rightIndex); - } else if (left.column() == DownloadList::COL_STATUS) { - return m_Manager->getState(leftIndex) < m_Manager->getState(rightIndex); + if (leftIndex < m_Manager->numTotalDownloads()) { + if (left.column() == DownloadList::COL_NAME) { + return m_Manager->getFileName(leftIndex).compare(m_Manager->getFileName(rightIndex), Qt::CaseInsensitive) < 0; + } else if (left.column() == DownloadList::COL_FILETIME) { + return m_Manager->getFileTime(leftIndex) < m_Manager->getFileTime(rightIndex); + } else if (left.column() == DownloadList::COL_STATUS) { + return m_Manager->getState(leftIndex) < m_Manager->getState(rightIndex); + } else { + return leftIndex < rightIndex; + } } else { return leftIndex < rightIndex; } @@ -54,6 +57,9 @@ bool DownloadListSortProxy::filterAcceptsRow(int source_row, const QModelIndex&) { if (m_CurrentFilter.length() == 0) { return true; + } else if (source_row < m_Manager->numTotalDownloads()) { + return m_Manager->getFileName(source_row).contains(m_CurrentFilter, Qt::CaseInsensitive); + } else { + return false; } - return m_Manager->getFileName(source_row).contains(m_CurrentFilter, Qt::CaseInsensitive); } |
