This commit is contained in:
Martin Rotter 2014-11-11 18:49:55 +01:00
parent 585f59d57b
commit 615538200d
4 changed files with 21 additions and 30 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -3,7 +3,7 @@
Fixed: Fixed:
<ul> <ul>
<li>Fixed bug #105.</li> <li>Fixed bug #105, #103.</li>
</ul> </ul>
Added: Added:

View file

@ -86,23 +86,19 @@ void MessagesView::reloadSelections(int mark_current_index_read) {
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true); selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true);
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), mapped_current_index.column()));
mapped_current_index.column()));
if (current_index.isValid()) { if (current_index.isValid()) {
if (mark_current_index_read == 0) { if (mark_current_index_read == 0) {
// User selected to mark some messages as unread, if one // User selected to mark some messages as unread, if one
// of them will be marked as current, then it will be read again. // of them will be marked as current, then it will be read again.
m_batchUnreadSwitch = true; m_batchUnreadSwitch = true;
setCurrentIndex(current_index);
m_batchUnreadSwitch = false;
}
else {
setCurrentIndex(current_index);
} }
setCurrentIndex(current_index);
scrollTo(current_index); scrollTo(current_index);
reselectIndexes(selected_indexes); reselectIndexes(selected_indexes);
m_batchUnreadSwitch = false;
} }
else { else {
// Messages were probably removed from the model, nothing can // Messages were probably removed from the model, nothing can
@ -199,33 +195,32 @@ void MessagesView::mousePressEvent(QMouseEvent *event) {
} }
} }
void MessagesView::currentChanged(const QModelIndex &current, void MessagesView::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
const QModelIndex &previous) { QTreeView::currentChanged(current, previous);
QModelIndex mapped_current_index = m_proxyModel->mapToSource(current); }
void MessagesView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) {
QModelIndexList selected_rows = selectionModel()->selectedRows();
QModelIndex current_index = currentIndex();
QModelIndex mapped_current_index = m_proxyModel->mapToSource(current_index);
qDebug("Current row changed - row [%d,%d] source [%d, %d].", qDebug("Current row changed - row [%d,%d] source [%d, %d].",
current.row(), current.column(), current_index.row(), current_index.column(),
mapped_current_index.row(), mapped_current_index.column()); mapped_current_index.row(), mapped_current_index.column());
if (mapped_current_index.isValid()) { if (mapped_current_index.isValid() && !selected_rows.isEmpty()) {
if (!m_batchUnreadSwitch) { if (!m_batchUnreadSwitch) {
// Set this message as read only if current item // Set this message as read only if current item
// wasn't changed by "mark selected messages unread" action. // wasn't changed by "mark selected messages unread" action.
m_sourceModel->setMessageRead(mapped_current_index.row(), 1); m_sourceModel->setMessageRead(mapped_current_index.row(), 1);
} }
emit currentMessagesChanged(QList<Message>() << emit currentMessagesChanged(QList<Message>() << m_sourceModel->messageAt(m_proxyModel->mapToSource(selected_rows.first()).row()));
m_sourceModel->messageAt(mapped_current_index.row()));
} }
else { else {
emit currentMessagesRemoved(); emit currentMessagesRemoved();
} }
QTreeView::currentChanged(current, previous);
}
void MessagesView::selectionChanged(const QItemSelection &selected,
const QItemSelection &deselected) {
if (qApp->settings()->value(GROUP(Messages), "keep_cursor_center", false).toBool()) { if (qApp->settings()->value(GROUP(Messages), "keep_cursor_center", false).toBool()) {
scrollTo(currentIndex(), QAbstractItemView::PositionAtCenter); scrollTo(currentIndex(), QAbstractItemView::PositionAtCenter);
} }
@ -321,22 +316,18 @@ void MessagesView::setSelectedMessagesReadStatus(int read) {
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true); selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true);
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), mapped_current_index.column()));
mapped_current_index.column()));
if (read == 0) { if (read == 0) {
// User selected to mark some messages as unread, if one // User selected to mark some messages as unread, if one
// of them will be marked as current, then it will be read again. // of them will be marked as current, then it will be read again.
m_batchUnreadSwitch = true; m_batchUnreadSwitch = true;
setCurrentIndex(current_index);
m_batchUnreadSwitch = false;
}
else {
setCurrentIndex(current_index);
} }
setCurrentIndex(current_index);
scrollTo(current_index); scrollTo(current_index);
reselectIndexes(selected_indexes); reselectIndexes(selected_indexes);
m_batchUnreadSwitch = false;
} }
void MessagesView::deleteSelectedMessages() { void MessagesView::deleteSelectedMessages() {
@ -424,8 +415,6 @@ void MessagesView::switchSelectedMessagesImportance() {
} }
void MessagesView::reselectIndexes(const QModelIndexList &indexes) { void MessagesView::reselectIndexes(const QModelIndexList &indexes) {
selectionModel()->clearSelection();
QItemSelection selection; QItemSelection selection;
foreach (const QModelIndex &index, indexes) { foreach (const QModelIndex &index, indexes) {

View file

@ -96,7 +96,9 @@ class WebBrowser : public TabContent {
// Clears contents. // Clears contents.
inline void clear() { inline void clear() {
m_webView->load(QUrl()); if (m_webView->url() != QUrl()) {
m_webView->setHtml("<html><body></body></html>", QUrl());
}
} }
// Zoom manipulators. // Zoom manipulators.