From 2a3f27a80c9a09aaa3211c4a2d3ca6a29a2a6053 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 10 Mar 2010 21:00:34 +0000 Subject: [PATCH] Code simplification. TocTypeModel is not needed outside TocModel. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33707 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/TocModel.cpp | 63 ++++++++++++++++------------------ src/frontends/qt4/TocModel.h | 15 +------- 2 files changed, 31 insertions(+), 47 deletions(-) diff --git a/src/frontends/qt4/TocModel.cpp b/src/frontends/qt4/TocModel.cpp index e6d6d08b24..4ace85c7a8 100644 --- a/src/frontends/qt4/TocModel.cpp +++ b/src/frontends/qt4/TocModel.cpp @@ -33,34 +33,37 @@ using namespace std; namespace lyx { namespace frontend { -/////////////////////////////////////////////////////////////////////////////// -// -// TocTypeModel -// -/////////////////////////////////////////////////////////////////////////////// - -TocTypeModel::TocTypeModel(QObject * parent) - : QStandardItemModel(parent) -{} - - -void TocTypeModel::reset() +/// A QStandardItemModel that gives access to the reset method. +/// This is needed in order to fix http://www.lyx.org/trac/ticket/3740 +class TocTypeModel : public QStandardItemModel { - QStandardItemModel::reset(); -} - -#if QT_VERSION >= 0x040600 -void TocTypeModel::beginResetModel() { - QStandardItemModel::beginResetModel(); -} - - -void TocTypeModel::endResetModel() -{ - QStandardItemModel::endResetModel(); -} -#endif - +public: + /// + TocTypeModel(QObject * parent) : QStandardItemModel(parent) + {} + + /// + void reset() + { + QStandardItemModel::reset(); + } + /// + void beginResetModel() + { + #if QT_VERSION >= 0x040600 + QStandardItemModel::beginResetModel(); + #endif + } + /// + void endResetModel() + { + #if QT_VERSION >= 0x040600 + QStandardItemModel::endResetModel(); + #else + reset(); + #endif + } +}; /////////////////////////////////////////////////////////////////////////////// @@ -350,9 +353,7 @@ void TocModels::reset(BufferView const * bv) } names_->blockSignals(true); -#if QT_VERSION >= 0x040600 names_->beginResetModel(); -#endif names_->insertColumns(0, 1); TocList const & tocs = bv_->buffer().masterBuffer()->tocBackend().tocs(); TocList::const_iterator it = tocs.begin(); @@ -375,11 +376,7 @@ void TocModels::reset(BufferView const * bv) names_->setData(index, type, Qt::UserRole); } names_->blockSignals(false); -#if QT_VERSION >= 0x040600 names_->endResetModel(); -#else - names_->reset(); -#endif } diff --git a/src/frontends/qt4/TocModel.h b/src/frontends/qt4/TocModel.h index b177880878..b41e1006b9 100644 --- a/src/frontends/qt4/TocModel.h +++ b/src/frontends/qt4/TocModel.h @@ -29,20 +29,7 @@ class TocItem; namespace frontend { -/// A QStandardItemModel that gives access to the reset method. -/// This is needed in order to fix http://www.lyx.org/trac/ticket/3740 -class TocTypeModel : public QStandardItemModel -{ -public: - /// - TocTypeModel(QObject * parent); - /// - void reset(); -#if QT_VERSION >= 0x040600 - void beginResetModel(); - void endResetModel(); -#endif -}; +class TocTypeModel; /// A class that adapt the TocBackend of a Buffer into standard Qt models for /// GUI visualisation. -- 2.39.2