[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/textshape-stylesWidget-PierreSt] plugins/textshape/dialogs: Keep the proper style selectio
From: Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date: 2012-12-28 20:57:18
Message-ID: 20121228205718.44E28A60C4 () git ! kde ! org
[Download RAW message or body]
Git commit 4c76a36083877e1a736bf5bbe3386cc6a9f4c150 by Pierre Stirnweiss.
Committed on 28/12/2012 at 21:28.
Pushed by pstirnweiss into branch 'textshape-stylesWidget-PierreSt'.
Keep the proper style selection after a style moves from unused to used
The view gets notified when the model is changed on moving a style
from unused to used.
M +1 -1 plugins/textshape/dialogs/AbstractStylesModel.h
M +8 -122 plugins/textshape/dialogs/DockerStylesComboModel.cpp
M +0 -4 plugins/textshape/dialogs/DockerStylesComboModel.h
M +0 -16 plugins/textshape/dialogs/SimpleCharacterWidget.cpp
M +0 -7 plugins/textshape/dialogs/SimpleParagraphWidget.cpp
M +1 -28 plugins/textshape/dialogs/StylesCombo.cpp
M +0 -2 plugins/textshape/dialogs/StylesCombo.h
M +6 -1 plugins/textshape/dialogs/StylesDelegate.cpp
M +4 -4 plugins/textshape/dialogs/StylesFilteredModelBase.cpp
M +1 -1 plugins/textshape/dialogs/StylesFilteredModelBase.h
M +4 -3 plugins/textshape/dialogs/StylesModel.cpp
M +1 -1 plugins/textshape/dialogs/StylesModel.h
http://commits.kde.org/calligra/4c76a36083877e1a736bf5bbe3386cc6a9f4c150
diff --git a/plugins/textshape/dialogs/AbstractStylesModel.h \
b/plugins/textshape/dialogs/AbstractStylesModel.h index 87b5a57..5ff2d56 100644
--- a/plugins/textshape/dialogs/AbstractStylesModel.h
+++ b/plugins/textshape/dialogs/AbstractStylesModel.h
@@ -86,7 +86,7 @@ public:
* If size isn't specified, the default size of the given @class \
KoStyleThumbnailer is used.
*/
virtual QImage stylePreview(int row, QSize size = QSize()) = 0;
- virtual QImage stylePreview(QModelIndex &index, QSize size = QSize()) = 0;
+// virtual QImage stylePreview(QModelIndex &index, QSize size = QSize()) = 0;
/** Returns the type of styles in the model */
virtual AbstractStylesModel::Type stylesType() const = 0;
diff --git a/plugins/textshape/dialogs/DockerStylesComboModel.cpp \
b/plugins/textshape/dialogs/DockerStylesComboModel.cpp index 0a62cba..c1ffaa1 100644
--- a/plugins/textshape/dialogs/DockerStylesComboModel.cpp
+++ b/plugins/textshape/dialogs/DockerStylesComboModel.cpp
@@ -40,42 +40,7 @@ Qt::ItemFlags DockerStylesComboModel::flags(const QModelIndex \
&index) const }
return (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
}
-/*
-QModelIndex DockerStylesComboModel::parent(const QModelIndex &child) const
-{
- if (child.data(isTitleRole).toBool()) {
- return QModelIndex();
- }
- else {
- if (m_usedStylesId.contains(child.internalId())) {
- return createIndex(0, 0, UsedStyleId);
- }
- else {
- return createIndex(1, 0, UnusedStyleId);
- }
- }
- return QModelIndex();
-}
-int DockerStylesComboModel::rowCount(const QModelIndex &parent) const
-{
- kDebug() << "parent: " << parent;
- kDebug() << "parent isValid: " << parent.isValid();
- if (!parent.isValid()) {
- return m_proxyToSource.count();
-// return 2;
- }
- if (parent.internalId() == UsedStyleId) {
- kDebug() << "rowCount used: "<< m_usedStyles.count();
- return m_usedStyles.count();
- }
- if (parent.internalId() == UnusedStyleId) {
- kDebug() << "rowCount unused: " << m_sourceModel->rowCount() - \
m_usedStyles.count();
- return (m_sourceModel->rowCount() - m_usedStyles.count());
- }
- return 0;
-}
-*/
QModelIndex DockerStylesComboModel::index(int row, int column, const QModelIndex \
&parent) const {
if (row < 0 || column != 0)
@@ -88,44 +53,6 @@ QModelIndex DockerStylesComboModel::index(int row, int column, \
const QModelIndex return createIndex(row, column, (m_proxyToSource.at(row) >= \
0)?int(m_sourceModel->index(m_proxyToSource.at(row), 0, \
QModelIndex()).internalId()):m_proxyToSource.at(row)); }
return QModelIndex();
- /*
- kDebug() << "index row: " << row;
- if (row < 0 || column != 0)
- return QModelIndex();
-
- if (!parent.isValid()) {
- if (row >= 2) {
- return QModelIndex();
- }
- return createIndex(row, 0, (row == 0)?UsedStyleId:UnusedStyleId);
- }
- else {
-// if (parent.internalId() == UsedStyleId) {
-// if (row >= m_usedStyles.count()) {
-// return QModelIndex();
-// }
-// return createIndex(row, 0, int(m_sourceModel->index(m_, 0, \
QModelIndex()).internalId()));
-// }
-// else {
-// if (row >= m_originalStylesCount) {
-// return QModelIndex();
-// }
-// return createIndex(row, 0, \
int(m_sourceModel->index(m_modifiedStylesCount + row, 0, \
QModelIndex()).internalId()));
-// }
- if (row >= m_proxyToSource.count()) {
- return QModelIndex();
- }
- kDebug() << "proxyToSource count: " << m_proxyToSource.count();
- kDebug() << "parent: " << parent;
- kDebug() << "parent internalId: " << parent.internalId();
- kDebug() << "parent rowCount: " << rowCount(parent);
- kDebug() << "parent internal id == UsedStyle: " << \
(parent.internalId()==UsedStyleId);
- kDebug() << "m_usedStyle count: " << m_usedStyles.count();
- kDebug() << "row+count: " << m_usedStyles.count()+row;
- return createIndex(row, 0, \
int(m_sourceModel->index(m_proxyToSource.at((parent.internalId()==UsedStyleId)?row:m_usedStyles.count()+row), \
0, QModelIndex()).internalId()));
- }
- return QModelIndex();
- */
}
QVariant DockerStylesComboModel::data(const QModelIndex &index, int role) const
@@ -158,53 +85,6 @@ QVariant DockerStylesComboModel::data(const QModelIndex &index, \
int role) const default: break;
};
return QVariant();
-
-/* if (!index.isValid()) {
- return QVariant();
- }
-
- switch (role) {
- case AbstractStylesModel::isTitleRole: {
- if (index.internalId() == UsedStyleId || index.internalId() == \
UnusedStyleId) {
- return true;
- }
- }
- case Qt::DisplayRole: {
- if (index.internalId() == UsedStyleId) {
- return i18n("Used Styles");
- }
- if (index.internalId() == UnusedStyleId) {
- return i18n("Unused Styles");
- }
- return QVariant();
- }
- case Qt::DecorationRole: {
- if (index.internalId() == UsedStyleId || index.internalId() == \
UnusedStyleId) {
- return QVariant();
- }
- if (index.parent().isValid()) {
- return m_sourceModel->data(m_sourceModel->index(m_proxyToSource.at((index \
.parent().internalId()==UsedStyleId)?index.row():m_usedStyles.count()+index.row()), \
0, QModelIndex()), role);
- }
-// if (index.parent().isValid() && index.parent().internalId() == \
OriginalStyleId) {
-// return m_sourceModel->data(m_sourceModel->index(index.row() + \
m_modifiedStylesCount, 0, QModelIndex()), role);
-// }
- return QVariant();
- }
- case Qt::SizeHintRole: {
- return QVariant(QSize(250, 48));
- }
- default: break;
-// if (index.parent().isValid()) {
-// }
-// kDebug() << "other role. style id: " << index.row();
-// kDebug() << "other role. data: " << m_sourceModel->data(index, role);
-
-// return KCategorizedSortFilterProxyModel::data(index, role);
-// return QSortFilterProxyModel::data(index, role);
- }
-
- return QVariant();
-*/
}
void DockerStylesComboModel::setInitialUsedStyles(QVector<int> usedStyles)
@@ -296,8 +176,9 @@ void DockerStylesComboModel::styleApplied(const KoCharacterStyle \
*style) }
m_usedStyles.insert(begin, \
m_sourceModel->indexForCharacterStyle(*(style)).row()); // We use the \
ForCharacterStyle variant also for parag styles because the signal exist only in \
charStyle variant. TODO merge these functions in StylesModel. they use the styleId \
anyway. }
- //we do not reset the model here, as it will mess up the view's visibility. \
perhaps this is very wrong. to be considered in case we have bugs. + \
beginResetModel(); createMapping();
+ endResetModel();
}
}
@@ -364,7 +245,12 @@ void DockerStylesComboModel::createMapping()
}
}
}
- m_proxyToSource << UsedStyleId << m_usedStyles << UnusedStyleId << \
m_unusedStyles; //UsedStyleId and -UnusedStyleId will be detected as title (in index \
method) and will be treated accordingly + if (!m_usedStyles.isEmpty()) {
+ m_proxyToSource << UsedStyleId << m_usedStyles;
+ }
+ if (!m_unusedStyles.isEmpty()) {
+ m_proxyToSource << UnusedStyleId << m_unusedStyles; //UsedStyleId and \
UnusedStyleId will be detected as title (in index method) and will be treated \
accordingly + }
m_sourceToProxy.fill(-1, m_sourceModel->rowCount((QModelIndex())));
for (int i = 0; i < m_proxyToSource.count(); ++i) {
if (m_proxyToSource.at(i) >= 0) { //we do not need to map to the titles
diff --git a/plugins/textshape/dialogs/DockerStylesComboModel.h \
b/plugins/textshape/dialogs/DockerStylesComboModel.h index 169d177..8c7d0dd 100644
--- a/plugins/textshape/dialogs/DockerStylesComboModel.h
+++ b/plugins/textshape/dialogs/DockerStylesComboModel.h
@@ -40,12 +40,8 @@ public:
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
-// virtual QModelIndex parent(const QModelIndex &child) const;
-
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
-// virtual int rowCount(const QModelIndex &parent) const;
-
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) \
const;
void setStyleManager(KoStyleManager *sm);
diff --git a/plugins/textshape/dialogs/SimpleCharacterWidget.cpp \
b/plugins/textshape/dialogs/SimpleCharacterWidget.cpp index 3df64d7..0e3b01d 100644
--- a/plugins/textshape/dialogs/SimpleCharacterWidget.cpp
+++ b/plugins/textshape/dialogs/SimpleCharacterWidget.cpp
@@ -94,7 +94,6 @@ SimpleCharacterWidget::SimpleCharacterWidget(TextTool *tool, \
QWidget *parent)
m_stylesModel->setStyleThumbnailer(m_thumbnailer);
widget.characterStyleCombo->setStylesModel(m_sortedStylesModel);
-// connect(widget.characterStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int)));
connect(widget.characterStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&)));
connect(widget.characterStyleCombo, SIGNAL(newStyleRequested(QString)), this, \
SIGNAL(newStyleRequested(QString)));
connect(widget.characterStyleCombo, SIGNAL(newStyleRequested(QString)), this, \
SIGNAL(doneWithFocus())); @@ -120,11 +119,9 @@ void \
SimpleCharacterWidget::setStyleManager(KoStyleManager *sm) }
m_styleManager = sm;
//we want to disconnect this before setting the stylemanager. Populating the \
model apparently selects the first inserted item. We don't want this to actually set \
a new style.
-// disconnect(widget.characterStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int)));
disconnect(widget.characterStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&))); m_stylesModel->setStyleManager(sm);
m_sortedStylesModel->setStyleManager(sm);
-// connect(widget.characterStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int)));
connect(widget.characterStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&)));
connect(m_styleManager, SIGNAL(styleApplied(const KoCharacterStyle*)), this, \
SLOT(slotCharacterStyleApplied(const KoCharacterStyle*))); }
@@ -140,7 +137,6 @@ void SimpleCharacterWidget::setCurrentFormat(const \
QTextCharFormat& format, cons return;
}
m_currentCharFormat = format;
- kDebug() << "set charFormat styleId: " << \
m_currentCharFormat.intProperty(KoCharacterStyle::StyleId);
KoCharacterStyle \
*style(m_styleManager->characterStyle(m_currentCharFormat.intProperty(KoCharacterStyle::StyleId)));
bool useParagraphStyle = false;
@@ -149,7 +145,6 @@ void SimpleCharacterWidget::setCurrentFormat(const \
QTextCharFormat& format, cons useParagraphStyle = true;
}
if (style) {
- kDebug() << "style name: " << style->name();
bool unchanged = true;
QTextCharFormat comparisonFormat = refBlockCharFormat;
style->applyStyle(comparisonFormat);
@@ -170,13 +165,11 @@ void SimpleCharacterWidget::setCurrentFormat(const \
QTextCharFormat& format, cons }
}
}
-// disconnect(widget.characterStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int)));
disconnect(widget.characterStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&))); //TODO, this is very brittle index 1 is because \
index 0 is the title. The proper solution to that would be for the "None" style to \
have a styleId which does not get applied on the text, but can be \
used in the ui
widget.characterStyleCombo->setCurrentIndex((useParagraphStyle)?1:m_sortedStylesModel->indexForCharacterStyle(*style).row());
widget.characterStyleCombo->setStyleIsOriginal(unchanged);
widget.characterStyleCombo->slotUpdatePreview();
-// connect(widget.characterStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int)));
connect(widget.characterStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&))); }
}
@@ -228,17 +221,14 @@ void SimpleCharacterWidget::setCurrentBlockFormat(const \
QTextBlockFormat &format m_currentBlockFormat = format;
m_stylesModel->setCurrentParagraphStyle(format.intProperty(KoParagraphStyle::StyleId));
-// disconnect(widget.characterStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int)));
disconnect(widget.characterStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&))); widget.characterStyleCombo->slotUpdatePreview();
connect(widget.characterStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&)));
-// connect(widget.characterStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int))); }
void SimpleCharacterWidget::styleSelected(int index)
{
KoCharacterStyle *charStyle = \
m_styleManager->characterStyle(m_sortedStylesModel->index(index, 0, \
QModelIndex()).internalId());
- kDebug() << "style selected num: " << index;
//if the selected item correspond to a null characterStyle, send the null \
pointer. the tool should set the characterStyle as per paragraph emit \
characterStyleSelected(charStyle); @@ -251,14 +241,8 @@ void \
SimpleCharacterWidget::styleSelected(QModelIndex &index) emit doneWithFocus();
return;
}
- kDebug() << "index internalId: " << index.internalId();
KoCharacterStyle *charStyle = \
m_styleManager->characterStyle(index.internalId());
- kDebug() << "charStyle: " << charStyle;
- if (charStyle) {
- kDebug() << "style name: " << charStyle->name();
- }
-
//if the selected item correspond to a null characterStyle, send the null \
pointer. the tool should set the characterStyle as per paragraph emit \
characterStyleSelected(charStyle); emit doneWithFocus();
diff --git a/plugins/textshape/dialogs/SimpleParagraphWidget.cpp \
b/plugins/textshape/dialogs/SimpleParagraphWidget.cpp index 5f1e3c2..189d7c2 100644
--- a/plugins/textshape/dialogs/SimpleParagraphWidget.cpp
+++ b/plugins/textshape/dialogs/SimpleParagraphWidget.cpp
@@ -278,14 +278,12 @@ void SimpleParagraphWidget::setCurrentFormat(const \
QTextBlockFormat &format) }
}
//we are updating the combo's selected item to what is the current format. \
we do not want this to apply the style as it would mess up the undo stack, the change \
tracking,...
-// disconnect(widget.paragraphStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int)));
disconnect(widget.paragraphStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&))); m_sortedStylesModel->styleApplied(style);
widget.paragraphStyleCombo->setCurrentIndex(m_sortedStylesModel->indexForParagraphStyle(*style).row());
widget.paragraphStyleCombo->setStyleIsOriginal(unchanged);
m_stylesModel->setCurrentParagraphStyle(id);
widget.paragraphStyleCombo->slotUpdatePreview();
-// connect(widget.paragraphStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int)));
connect(widget.paragraphStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&))); }
}
@@ -301,11 +299,9 @@ void SimpleParagraphWidget::setStyleManager(KoStyleManager *sm)
}
m_styleManager = sm;
//we want to disconnect this before setting the stylemanager. Populating the \
model apparently selects the first inserted item. We don't want this to actually set \
a new style.
-// disconnect(widget.paragraphStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int)));
disconnect(widget.paragraphStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&))); m_stylesModel->setStyleManager(sm);
m_sortedStylesModel->setStyleManager(sm);
-// connect(widget.paragraphStyleCombo, SIGNAL(selected(int)), this, \
SLOT(styleSelected(int)));
connect(widget.paragraphStyleCombo, SIGNAL(selected(QModelIndex&)), this, \
SLOT(styleSelected(QModelIndex&)));
connect(m_styleManager, SIGNAL(styleApplied(const KoParagraphStyle*)), this, \
SLOT(slotParagraphStyleApplied(const KoParagraphStyle*))); }
@@ -336,7 +332,6 @@ void SimpleParagraphWidget::styleSelected(int index)
void SimpleParagraphWidget::styleSelected(QModelIndex &index)
{
- kDebug() << "styleSelected. index: " << index;
if (!index.isValid()) {
return;
}
@@ -356,8 +351,6 @@ void SimpleParagraphWidget::slotShowStyleManager(int index)
void SimpleParagraphWidget::slotParagraphStyleApplied(const KoParagraphStyle *style)
{
- if (style) {
- }
m_sortedStylesModel->styleApplied(style);
}
diff --git a/plugins/textshape/dialogs/StylesCombo.cpp \
b/plugins/textshape/dialogs/StylesCombo.cpp index f2d5ffb..16f50a5 100644
--- a/plugins/textshape/dialogs/StylesCombo.cpp
+++ b/plugins/textshape/dialogs/StylesCombo.cpp
@@ -24,7 +24,6 @@
#include "StylesDelegate.h"
#include <QListView>
-#include <QTreeView>
#include <QMouseEvent>
#include <QStyleOptionViewItemV4>
@@ -34,7 +33,6 @@ StylesCombo::StylesCombo(QWidget *parent)
: QComboBox(parent),
m_stylesModel(0),
m_view(new QListView()),
-// m_view(new QTreeView()),
m_selectedItem(-1),
m_originalStyle(true)
{
@@ -54,10 +52,6 @@ StylesCombo::StylesCombo(QWidget *parent)
m_view->setMinimumWidth(250);
m_view->setMouseTracking(true);
-// m_view->setRootIsDecorated(false);
-// m_view->setItemsExpandable(false);
-// m_view->setHeaderHidden(true);
-// m_view->setIndentation(0);
setView(m_view);
view()->viewport()->installEventFilter(this);
@@ -97,8 +91,6 @@ void StylesCombo::setStylesModel(AbstractStylesModel *model)
{
m_stylesModel = model;
setModel(model);
-// connect(m_stylesModel, SIGNAL(modelReset()), this, SLOT(slotModelReset()));
-// m_view->expandAll();
}
void StylesCombo::setEditable(bool editable)
@@ -149,25 +141,13 @@ void StylesCombo::slotSelectionChanged(int index)
void StylesCombo::slotItemClicked(QModelIndex index)
{
//this slot allows us to emit a selected signal. There is a bit of redundancy if \
the item clicked was indeed a new selection, where we also emit the selectionChanged \
signal from the slot above.
-// kDebug() << "item parent: " << index.parent();
- kDebug() << "item row: " << index.row();
-/* if (index.parent().isValid()) {
- if (index.parent().row() == 0) {
- m_selectedItem = index.row();
- }
- else if (index.parent().row() == 1) {
- QModelIndex sibling = index.parent().sibling(0, 0);
- m_selectedItem = sibling.model()->rowCount(sibling) + index.row();
- }
- }
-*/
m_selectedItem = index.row();
m_preview->setPreview(m_stylesModel->stylePreview(m_selectedItem, \
m_preview->availableSize()));
-// m_preview->setPreview(m_stylesModel->stylePreview(index, \
m_preview->availableSize())); m_currentIndex = index;
update();
emit selected(m_selectedItem);
emit selected(index);
+ hidePopup(); //the editor event has accepted the mouseReleased event. Call \
hidePopup ourselves then. }
void StylesCombo::slotUpdatePreview()
@@ -175,10 +155,6 @@ void StylesCombo::slotUpdatePreview()
if (!m_stylesModel) {
return;
}
- if (m_stylesModel->stylesType() == AbstractStylesModel::CharacterStyle) {
- kDebug() << "currentIndex: " << currentIndex();
- }
-// m_preview->setPreview(m_stylesModel->stylePreview(m_currentIndex, \
m_preview->availableSize()));
m_preview->setPreview(m_stylesModel->stylePreview(currentIndex(), \
m_preview->availableSize())); update();
}
@@ -223,10 +199,7 @@ void StylesCombo::slotDeleteStyle(QModelIndex index)
void StylesCombo::slotModelReset()
{
- kDebug() << "model used style count: " << \
m_stylesModel->rowCount(m_stylesModel->index(0,0,QModelIndex()));
- kDebug() << "model unused style count: " << \
m_stylesModel->rowCount(m_stylesModel->index(1,0,QModelIndex())); m_view->reset();
-// m_view->expandAll();
}
void StylesCombo::showEditIcon(bool show){
diff --git a/plugins/textshape/dialogs/StylesCombo.h \
b/plugins/textshape/dialogs/StylesCombo.h index b58a367..d6ce959 100644
--- a/plugins/textshape/dialogs/StylesCombo.h
+++ b/plugins/textshape/dialogs/StylesCombo.h
@@ -22,7 +22,6 @@
#include <QComboBox>
class QListView;
-class QTreeView;
class AbstractStylesModel;
class StylesComboPreview;
@@ -100,7 +99,6 @@ private:
AbstractStylesModel *m_stylesModel;
StylesComboPreview *m_preview;
QListView *m_view;
-// QTreeView *m_view;
int m_selectedItem;
bool m_originalStyle;
QModelIndex m_currentIndex;
diff --git a/plugins/textshape/dialogs/StylesDelegate.cpp \
b/plugins/textshape/dialogs/StylesDelegate.cpp index aa8ae6d..76d3b97 100644
--- a/plugins/textshape/dialogs/StylesDelegate.cpp
+++ b/plugins/textshape/dialogs/StylesDelegate.cpp
@@ -245,6 +245,11 @@ bool StylesDelegate::editorEvent(QEvent *event, \
QAbstractItemModel *model, const m_deleteButtonPressed = false;
m_editButtonPressed = false;
emit needsUpdate(index);
+
+ if (index.flags() == Qt::NoItemFlags) { //if the item is NoItemFlagged, it \
means it is a separator in the view. In that case, we should not close the combo's \
drop down. + return true;
+ }
+
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
int dx1 = option.rect.width() - qMin(option.rect.height()-2, m_buttonSize) - \
m_buttonSize - m_buttonDistance -2;
int dy1 = 1 + (option.rect.height()-qMin(option.rect.height(), \
m_buttonSize))/2; @@ -267,7 +272,7 @@ bool StylesDelegate::editorEvent(QEvent *event, \
QAbstractItemModel *model, const return true;
}
emit clickedInItem(index);
- return false;
+ return true; //returning true here means the QComboBox mouseRelease code \
will not get called. The effect of it is that hidePopup will not get called. \
StylesCombo calls it in the corresponding slot. }
if (event->type() == QEvent::MouseMove) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
diff --git a/plugins/textshape/dialogs/StylesFilteredModelBase.cpp \
b/plugins/textshape/dialogs/StylesFilteredModelBase.cpp index 09a4636..f84df16 100644
--- a/plugins/textshape/dialogs/StylesFilteredModelBase.cpp
+++ b/plugins/textshape/dialogs/StylesFilteredModelBase.cpp
@@ -46,11 +46,13 @@ QModelIndex StylesFilteredModelBase::index(int row, int column, \
const QModelInde
QModelIndex StylesFilteredModelBase::parent(const QModelIndex &child) const
{
+ Q_UNUSED(child);
return QModelIndex();
}
int StylesFilteredModelBase::columnCount(const QModelIndex &parent) const
{
+ Q_UNUSED(parent);
return 1;
}
@@ -121,12 +123,10 @@ QImage StylesFilteredModelBase::stylePreview(int row, QSize \
size) if (row < 0) {
return QImage();
}
- kDebug() << "requested preview for: " << row;
- kDebug() << "proxyToSource item: " << m_proxyToSource.at(row);
return m_sourceModel->stylePreview(m_proxyToSource.at(row), size);
}
-
+/*
QImage StylesFilteredModelBase::stylePreview(QModelIndex &index, QSize size)
{
if (!index.isValid()) {
@@ -135,7 +135,7 @@ QImage StylesFilteredModelBase::stylePreview(QModelIndex &index, \
QSize size) return m_sourceModel->stylePreview(index, size); //TODO be carefull \
there. this is assuming the sourceModel is only using the internalId, and the index's \
internalId matches the model's
}
-
+*/
void StylesFilteredModelBase::setStylesModel(AbstractStylesModel *sourceModel)
{
if (m_sourceModel == sourceModel) {
diff --git a/plugins/textshape/dialogs/StylesFilteredModelBase.h \
b/plugins/textshape/dialogs/StylesFilteredModelBase.h index 7c6d723..b39a5fa 100644
--- a/plugins/textshape/dialogs/StylesFilteredModelBase.h
+++ b/plugins/textshape/dialogs/StylesFilteredModelBase.h
@@ -71,7 +71,7 @@ public:
* If size isn't specified, the default size of the given @class \
KoStyleThumbnailer is used.
*/
virtual QImage stylePreview(int row, QSize size = QSize());
- virtual QImage stylePreview(QModelIndex &index, QSize size = QSize());
+// virtual QImage stylePreview(QModelIndex &index, QSize size = QSize());
virtual AbstractStylesModel::Type stylesType() const;
diff --git a/plugins/textshape/dialogs/StylesModel.cpp \
b/plugins/textshape/dialogs/StylesModel.cpp index 32e4b67..4b1b9f6 100644
--- a/plugins/textshape/dialogs/StylesModel.cpp
+++ b/plugins/textshape/dialogs/StylesModel.cpp
@@ -77,6 +77,7 @@ QModelIndex StylesModel::index(int row, int column, const \
QModelIndex &parent) c
QModelIndex StylesModel::parent(const QModelIndex &child) const
{
+ Q_UNUSED(child);
return QModelIndex();
}
@@ -89,6 +90,7 @@ int StylesModel::rowCount(const QModelIndex &parent) const
int StylesModel::columnCount(const QModelIndex &parent) const
{
+ Q_UNUSED(parent);
return 1;
}
@@ -211,7 +213,6 @@ QImage StylesModel::stylePreview(int row, QSize size)
}
}
else {
- kDebug() << "request for preview. row: " << row << " internalId: " << \
index(row).internalId(); KoCharacterStyle *usedStyle = 0;
if (index(row).internalId() == -1) {
usedStyle = static_cast<KoCharacterStyle*>(m_currentParagraphStyle);
@@ -236,7 +237,7 @@ QImage StylesModel::stylePreview(int row, QSize size)
}
return QImage();
}
-
+/*
QImage StylesModel::stylePreview(QModelIndex &index, QSize size)
{
if (!m_styleManager || !m_styleThumbnailer) {
@@ -277,7 +278,7 @@ QImage StylesModel::stylePreview(QModelIndex &index, QSize size)
}
return QImage();
}
-
+*/
void StylesModel::setStyleManager(KoStyleManager *sm)
{
if (sm == m_styleManager)
diff --git a/plugins/textshape/dialogs/StylesModel.h \
b/plugins/textshape/dialogs/StylesModel.h index d477f3a..cd8117a 100644
--- a/plugins/textshape/dialogs/StylesModel.h
+++ b/plugins/textshape/dialogs/StylesModel.h
@@ -107,7 +107,7 @@ public:
* If size isn't specified, the default size of the given @class \
KoStyleThumbnailer is used.
*/
QImage stylePreview(int row, QSize size = QSize());
- QImage stylePreview(QModelIndex &index, QSize size = QSize());
+// QImage stylePreview(QModelIndex &index, QSize size = QSize());
/** Specifies which paragraph style is currently the active one (on the current \
paragraph). This is used in order to properly preview the "As paragraph" virtual \
character style. */ void setCurrentParagraphStyle(int styleId);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic