summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Feck <christoph@maxiom.de>2011-08-20 09:00:54 (GMT)
committerChristoph Feck <christoph@maxiom.de>2011-08-20 09:00:54 (GMT)
commit0e4754a0eacd4528a4d2b369704afca9f36e366f (patch)
tree44d30631c98f2585f4a4713ec5f66d298411ad05
parentaa8589d816880190c5f18eda1aeb5b709eebbf13 (diff)
Fix crash in KCharSelect
- use Selected instead of Current table cell item - emit correct signals on layout changes Thanks Albert for confirmation! BUG: 235020 FIXED-IN: 4.7.1 REVIEW: 102263
-rw-r--r--kdeui/widgets/kcharselect.cpp13
-rw-r--r--kdeui/widgets/kcharselect_p.h6
2 files changed, 10 insertions, 9 deletions
diff --git a/kdeui/widgets/kcharselect.cpp b/kdeui/widgets/kcharselect.cpp
index c511191..5b8a1be 100644
--- a/kdeui/widgets/kcharselect.cpp
+++ b/kdeui/widgets/kcharselect.cpp
@@ -58,7 +58,7 @@ public:
void _k_resizeCells();
void _k_doubleClicked(const QModelIndex & index);
- void _k_slotCurrentChanged(const QModelIndex & current, const QModelIndex & previous);
+ void _k_slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
};
class KCharSelect::KCharSelectPrivate
@@ -196,7 +196,7 @@ void KCharSelectTable::setContents(QList<QChar> chars)
setSelectionModel(selectionModel);
setSelectionBehavior(QAbstractItemView::SelectItems);
setSelectionMode(QAbstractItemView::SingleSelection);
- connect(selectionModel, SIGNAL(currentChanged(const QModelIndex & , const QModelIndex &)), this, SLOT(_k_slotCurrentChanged(const QModelIndex &, const QModelIndex &)));
+ connect(selectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(_k_slotSelectionChanged(const QItemSelection &, const QItemSelection &)));
connect(d->model, SIGNAL(showCharRequested(QChar)), this, SIGNAL(showCharRequested(QChar)));
delete m; // this should hopefully delete aold selection models too, since it is the parent of them (didn't track, if there are setParent calls somewhere. Check that (jowenn)
}
@@ -211,11 +211,12 @@ void KCharSelectTable::scrollTo(const QModelIndex & index, ScrollHint hint)
}
}
-void KCharSelectTablePrivate::_k_slotCurrentChanged(const QModelIndex & current, const QModelIndex & previous)
+void KCharSelectTablePrivate::_k_slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
{
- Q_UNUSED(previous);
- if (!model) return;
- QVariant temp = model->data(current, KCharSelectItemModel::CharacterRole);
+ Q_UNUSED(deselected);
+ if (!model || selected.indexes().isEmpty())
+ return;
+ QVariant temp = model->data(selected.indexes().at(0), KCharSelectItemModel::CharacterRole);
if (temp.type() != QVariant::Char)
return;
QChar c = temp.toChar();
diff --git a/kdeui/widgets/kcharselect_p.h b/kdeui/widgets/kcharselect_p.h
index d414d23..6188f9f 100644
--- a/kdeui/widgets/kcharselect_p.h
+++ b/kdeui/widgets/kcharselect_p.h
@@ -103,7 +103,7 @@ Q_SIGNALS:
void showCharRequested(const QChar& c);
private:
- Q_PRIVATE_SLOT(d, void _k_slotCurrentChanged(const QModelIndex & current, const QModelIndex & previous))
+ Q_PRIVATE_SLOT(d, void _k_slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected))
Q_PRIVATE_SLOT(d, void _k_resizeCells())
Q_PRIVATE_SLOT(d, void _k_doubleClicked(const QModelIndex & index))
@@ -199,7 +199,7 @@ public:
void updateColumnCount(int maxWidth)
{
-
+ emit layoutAboutToBeChanged();
QFontMetrics fm(m_font);
int maxChar = fm.maxWidth();
if (maxChar < 2*fm.xHeight()) {
@@ -212,7 +212,7 @@ public:
if (m_columns <= 0) {
m_columns = 1;
}
- reset();
+ emit layoutChanged();
}
private:
QList<QChar> m_chars;