diff --git a/components/models/ContentsModel.h b/components/models/ContentsModel.h --- a/components/models/ContentsModel.h +++ b/components/models/ContentsModel.h @@ -98,6 +98,7 @@ private Q_SLOTS: void updateImpl(); + void reset(); private: class Private; diff --git a/components/models/ContentsModel.cpp b/components/models/ContentsModel.cpp --- a/components/models/ContentsModel.cpp +++ b/components/models/ContentsModel.cpp @@ -177,6 +177,12 @@ endResetModel(); } +void ContentsModel::reset() +{ + beginResetModel(); + endResetModel(); +} + QHash ContentsModel::roleNames() const { QHash roleNames; diff --git a/karbon/ui/dockers/KarbonLayerModel.h b/karbon/ui/dockers/KarbonLayerModel.h --- a/karbon/ui/dockers/KarbonLayerModel.h +++ b/karbon/ui/dockers/KarbonLayerModel.h @@ -52,6 +52,7 @@ virtual QStringList mimeTypes() const; virtual QMimeData * mimeData(const QModelIndexList & indexes) const; virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent); + virtual Qt::DropActions supportedDragActions() const; public Q_SLOTS: /// Triggers an update of the complete model diff --git a/karbon/ui/dockers/KarbonLayerModel.cpp b/karbon/ui/dockers/KarbonLayerModel.cpp --- a/karbon/ui/dockers/KarbonLayerModel.cpp +++ b/karbon/ui/dockers/KarbonLayerModel.cpp @@ -58,7 +58,11 @@ KarbonLayerModel::KarbonLayerModel(QObject * parent) : KoDocumentSectionModel(parent), m_document(0) { - setSupportedDragActions(Qt::MoveAction); +} + +Qt::DropActions KarbonLayerModel::supportedDragActions() const +{ + return Qt::MoveAction; } void KarbonLayerModel::update() @@ -69,8 +73,9 @@ void KarbonLayerModel::setDocument(KarbonDocument * newDocument) { + beginResetModel(); m_document = newDocument; - reset(); + endResetModel(); } int KarbonLayerModel::rowCount(const QModelIndex &parent) const diff --git a/libs/pageapp/KoPADocumentModel.h b/libs/pageapp/KoPADocumentModel.h --- a/libs/pageapp/KoPADocumentModel.h +++ b/libs/pageapp/KoPADocumentModel.h @@ -62,6 +62,7 @@ virtual QStringList mimeTypes() const; virtual QMimeData * mimeData( const QModelIndexList & indexes ) const; virtual bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ); + virtual Qt::DropActions supportedDragActions() const; public Q_SLOTS: /// Triggers an update of the complete model diff --git a/libs/pageapp/KoPADocumentModel.cpp b/libs/pageapp/KoPADocumentModel.cpp --- a/libs/pageapp/KoPADocumentModel.cpp +++ b/libs/pageapp/KoPADocumentModel.cpp @@ -58,7 +58,11 @@ , m_lastContainer( 0 ) { setDocument( document ); - setSupportedDragActions( Qt::MoveAction ); +} + +Qt::DropActions KoPADocumentModel::supportedDragActions() const +{ + return Qt::MoveAction; } void KoPADocumentModel::update() @@ -644,24 +648,26 @@ if (m_document == document) { return; } + if (m_document) { disconnect( m_document, SIGNAL(pageAdded(KoPAPageBase*)), this, SLOT(update()) ); disconnect( m_document, SIGNAL(pageRemoved(KoPAPageBase*)), this, SLOT(update()) ); disconnect( m_document, SIGNAL(update(KoPAPageBase*)), this, SLOT(update()) ); disconnect( m_document, SIGNAL(shapeAdded(KoShape*)), this, SLOT(update()) ); disconnect( m_document, SIGNAL(shapeRemoved(KoShape*)), this, SLOT(update()) ); } + + beginResetModel(); m_document = document; + endResetModel(); if ( m_document ) { connect( m_document, SIGNAL(pageAdded(KoPAPageBase*)), this, SLOT(update()) ); connect( m_document, SIGNAL(pageRemoved(KoPAPageBase*)), this, SLOT(update()) ); connect( m_document, SIGNAL(update(KoPAPageBase*)), this, SLOT(update()) ); connect( m_document, SIGNAL(shapeAdded(KoShape*)), this, SLOT(update()) ); connect( m_document, SIGNAL(shapeRemoved(KoShape*)), this, SLOT(update()) ); } - - reset(); } void KoPADocumentModel::setMasterMode(bool master) diff --git a/stage/part/KPrCustomSlideShowsModel.cpp b/stage/part/KPrCustomSlideShowsModel.cpp --- a/stage/part/KPrCustomSlideShowsModel.cpp +++ b/stage/part/KPrCustomSlideShowsModel.cpp @@ -237,9 +237,10 @@ void KPrCustomSlideShowsModel::setCustomSlideShows(KPrCustomSlideShows *customShows) { + beginResetModel(); m_customSlideShows = customShows; m_activeCustomSlideShowName.clear(); - reset(); + endResetModel(); } @@ -254,8 +255,9 @@ return; } if (m_customSlideShows->names().contains(name)) { + beginResetModel(); m_activeCustomSlideShowName = name; - reset(); + endResetModel(); } } diff --git a/stage/part/KPrSlidesSorterDocumentModel.h b/stage/part/KPrSlidesSorterDocumentModel.h --- a/stage/part/KPrSlidesSorterDocumentModel.h +++ b/stage/part/KPrSlidesSorterDocumentModel.h @@ -58,6 +58,7 @@ virtual QMimeData* mimeData(const QModelIndexList &indexes) const; + virtual Qt::DropActions supportedDragActions() const; virtual Qt::DropActions supportedDropActions() const; virtual bool removeRows(int row, int count, const QModelIndex &parent); diff --git a/stage/part/KPrSlidesSorterDocumentModel.cpp b/stage/part/KPrSlidesSorterDocumentModel.cpp --- a/stage/part/KPrSlidesSorterDocumentModel.cpp +++ b/stage/part/KPrSlidesSorterDocumentModel.cpp @@ -46,23 +46,27 @@ , m_viewModeSlidesSorter(viewModeSlidesSorter) { setDocument(document); - setSupportedDragActions(Qt::MoveAction); +} + +Qt::DropActions KPrSlidesSorterDocumentModel::supportedDragActions() const +{ + return Qt::MoveAction; } KPrSlidesSorterDocumentModel::~KPrSlidesSorterDocumentModel() { } void KPrSlidesSorterDocumentModel::setDocument(KoPADocument *document) { + beginResetModel(); m_document = document; + endResetModel(); if (m_document) { connect(m_document, SIGNAL(pageAdded(KoPAPageBase*)), this, SLOT(update())); connect(m_document, SIGNAL(pageRemoved(KoPAPageBase*)), this, SLOT(update())); connect(m_document, SIGNAL(update(KoPAPageBase*)), this, SLOT(update())); } - - reset(); } QModelIndex KPrSlidesSorterDocumentModel::index(int row, int column, const QModelIndex &parent) const diff --git a/stage/part/tools/animationtool/KPrCollectionItemModel.h b/stage/part/tools/animationtool/KPrCollectionItemModel.h --- a/stage/part/tools/animationtool/KPrCollectionItemModel.h +++ b/stage/part/tools/animationtool/KPrCollectionItemModel.h @@ -52,6 +52,7 @@ virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const; + virtual Qt::DropActions supportedDragActions() const; /** * @brief Set the list of KoCollectionItem to be stored in the model diff --git a/stage/part/tools/animationtool/KPrCollectionItemModel.cpp b/stage/part/tools/animationtool/KPrCollectionItemModel.cpp --- a/stage/part/tools/animationtool/KPrCollectionItemModel.cpp +++ b/stage/part/tools/animationtool/KPrCollectionItemModel.cpp @@ -26,7 +26,11 @@ KPrCollectionItemModel::KPrCollectionItemModel(QObject* parent) : QAbstractListModel(parent) { - setSupportedDragActions(Qt::IgnoreAction); +} + +Qt::DropActions KPrCollectionItemModel::supportedDragActions() const +{ + return Qt::IgnoreAction; } QVariant KPrCollectionItemModel::data(const QModelIndex &index, int role) const @@ -63,8 +67,9 @@ void KPrCollectionItemModel::setAnimationClassList(const QVector &newlist) { + beginResetModel(); m_animationClassList = newlist; - reset(); + endResetModel(); } KoXmlElement KPrCollectionItemModel::animationContext(const QModelIndex &index) const