summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2013-12-30 23:10:53 +0100
committerJan Dalheimer <jan@dalheimer.de>2013-12-30 23:10:53 +0100
commite6be883d14a4147ffd58a1c8066bb70879d775fb (patch)
tree59b8d6217c0eab52e02642e6f2c1e38212f40561
parent1e1b2342f48a3dd1eff90229ac4005fb0d45d2ba (diff)
downloadMultiMC-e6be883d14a4147ffd58a1c8066bb70879d775fb.tar
MultiMC-e6be883d14a4147ffd58a1c8066bb70879d775fb.tar.gz
MultiMC-e6be883d14a4147ffd58a1c8066bb70879d775fb.tar.lz
MultiMC-e6be883d14a4147ffd58a1c8066bb70879d775fb.tar.xz
MultiMC-e6be883d14a4147ffd58a1c8066bb70879d775fb.zip
Fixing more bugs
-rw-r--r--CategorizedView.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/CategorizedView.cpp b/CategorizedView.cpp
index f660e8f3..27575b59 100644
--- a/CategorizedView.cpp
+++ b/CategorizedView.cpp
@@ -170,6 +170,8 @@ void CategorizedView::updateGeometries()
{
QListView::updateGeometries();
+ int previousScroll = verticalScrollBar()->value();
+
invalidateCaches();
QMap<QString, Category *> cats;
@@ -216,6 +218,8 @@ void CategorizedView::updateGeometries()
verticalScrollBar()->setRange(0, totalHeight- height());
}
+ verticalScrollBar()->setValue(qMin(previousScroll, verticalScrollBar()->maximum()));
+
update();
}
@@ -435,13 +439,7 @@ void CategorizedView::mousePressEvent(QMouseEvent *event)
selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
setAutoScroll(autoScroll);
QRect rect(m_pressedPosition, pos);
- if (command.testFlag(QItemSelectionModel::Toggle))
- {
- command &= ~QItemSelectionModel::Toggle;
- m_ctrlDragSelectionFlag = selectionModel()->isSelected(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
- command |= m_ctrlDragSelectionFlag;
- }
- setSelection(rect, command);
+ setSelection(rect, QItemSelectionModel::ClearAndSelect);
// signal handlers may change the model
emit pressed(index);
@@ -519,7 +517,7 @@ void CategorizedView::mouseMoveEvent(QMouseEvent *event)
}
void CategorizedView::mouseReleaseEvent(QMouseEvent *event)
{
- QPoint pos = event->pos() - offset();
+ QPoint pos = event->pos() + offset();
QPersistentModelIndex index = indexAt(pos);
bool click = (index == m_pressedIndex && index.isValid()) || (m_pressedCategory && m_pressedCategory == categoryAt(pos));
@@ -611,7 +609,7 @@ void CategorizedView::paintEvent(QPaintEvent *event)
option.rect = visualRect(index);
option.widget = this;
option.features |= wordWrap() ? QStyleOptionViewItemV2::WrapText : QStyleOptionViewItemV2::None;
- if (flags & Qt::ItemIsSelectable)
+ if (flags & Qt::ItemIsSelectable && selectionModel()->isSelected(index))
{
option.state |= selectionModel()->isSelected(index) ? QStyle::State_Selected : QStyle::State_None;
}
@@ -844,16 +842,15 @@ QModelIndex CategorizedView::indexAt(const QPoint &point) const
}
void CategorizedView::setSelection(const QRect &rect, const QItemSelectionModel::SelectionFlags commands)
{
- QItemSelection selection;
for (int i = 0; i < model()->rowCount(); ++i)
{
QModelIndex index = model()->index(i, 0);
if (visualRect(index).intersects(rect))
{
- selection.merge(QItemSelection(index, index), QItemSelectionModel::Select);
+ selectionModel()->select(index, commands);
}
}
- selectionModel()->select(selection, commands);
+ update();
}
QPixmap CategorizedView::renderToPixmap(const QModelIndexList &indices, QRect *r) const