Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for rowCount update under Qt 5.11.
  • Loading branch information
shoops committed Jul 27, 2018
1 parent 8411b2f commit 1cd9dc4
Show file tree
Hide file tree
Showing 29 changed files with 139 additions and 101 deletions.
11 changes: 8 additions & 3 deletions copasi/MIRIAMUI/CQBiologicalDescriptionDM.h
@@ -1,4 +1,9 @@
// Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
Expand Down Expand Up @@ -26,8 +31,8 @@ class CQBiologicalDescriptionDM : public CQBaseDataModel

public:
CQBiologicalDescriptionDM(CMIRIAMInfo* MIRIAMInfo, QObject *parent = 0);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
Expand Down
11 changes: 8 additions & 3 deletions copasi/MIRIAMUI/CQCreatorDM.h
@@ -1,4 +1,9 @@
// Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
Expand Down Expand Up @@ -27,8 +32,8 @@ class CQCreatorDM : public CQBaseDataModel

public:
CQCreatorDM(CMIRIAMInfo* MIRIAMInfo, QObject *parent = 0);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
Expand Down
11 changes: 8 additions & 3 deletions copasi/MIRIAMUI/CQModifiedDM.h
@@ -1,4 +1,9 @@
// Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
Expand All @@ -24,8 +29,8 @@ class CQModifiedDM : public CQBaseDataModel

public:
CQModifiedDM(CMIRIAMInfo* MIRIAMInfo, QObject *parent = 0);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
Expand Down
11 changes: 8 additions & 3 deletions copasi/MIRIAMUI/CQReferenceDM.h
@@ -1,4 +1,9 @@
// Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
Expand Down Expand Up @@ -26,8 +31,8 @@ class CQReferenceDM : public CQBaseDataModel

public:
CQReferenceDM(CMIRIAMInfo* MIRIAMInfo, QObject *parent = 0);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
Expand Down
16 changes: 15 additions & 1 deletion copasi/UI/CQBaseDataModel.cpp
@@ -1,4 +1,4 @@
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -70,6 +70,16 @@ bool CQBaseDataModel::clear()

// virtual
void CQBaseDataModel::resetCache()
{
assert(mpDataModel != NULL);

beginResetModel();
resetCacheProtected();
endResetModel();
}

// virtual
void CQBaseDataModel::resetCacheProtected()
{}

bool CQBaseDataModel::isDefaultRow(const QModelIndex& i) const
Expand Down Expand Up @@ -110,8 +120,12 @@ QString CQBaseDataModel::createNewName(const QString name, const int nameCol)

void CQBaseDataModel::setDataModel(CDataModel * pDataModel)
{
beginResetModel();

mpDataModel = pDataModel;
resetCache();

endResetModel();
}

void CQBaseDataModel::setUndoStack(QUndoStack* undoStack)
Expand Down
5 changes: 3 additions & 2 deletions copasi/UI/CQBaseDataModel.h
@@ -1,4 +1,4 @@
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -50,9 +50,10 @@ class CQBaseDataModel : public QAbstractTableModel
CDataModel * getDataModel() const;

public slots:
virtual void resetCache();
void resetCache();

protected:
virtual void resetCacheProtected();
virtual bool insertRows(int position, int rows, const QModelIndex & source) = 0;
virtual bool removeRows(int position, int rows) = 0;

Expand Down
4 changes: 1 addition & 3 deletions copasi/UI/CQCompartmentDM.cpp
Expand Up @@ -325,10 +325,8 @@ bool CQCompartmentDM::setData(const QModelIndex &index, const QVariant &value,
}

// virtual
void CQCompartmentDM::resetCache()
void CQCompartmentDM::resetCacheProtected()
{
assert(mpDataModel != NULL);

mpCompartments = dynamic_cast< CDataVectorNS < CCompartment > * >(&mpDataModel->getModel()->getCompartments());
assert(mpCompartments != NULL);

Expand Down
9 changes: 4 additions & 5 deletions copasi/UI/CQCompartmentDM.h
@@ -1,4 +1,4 @@
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -51,8 +51,8 @@ class CQCompartmentDM : public CQBaseDataModel
CQCompartmentDM(QObject *parent = 0);
const QStringList& getTypes();
const std::vector< unsigned C_INT32 >& getItemToType();
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual QVariant data(const QModelIndex &index, int role) const;
virtual QVariant headerData(int section, Qt::Orientation orientation,
Expand All @@ -78,9 +78,8 @@ class CQCompartmentDM : public CQBaseDataModel
bool clear();

public slots:
virtual void resetCache();

protected:
virtual void resetCacheProtected();
QStringList mTypes;
/**
* A vector mapping the item index to a model value type
Expand Down
11 changes: 8 additions & 3 deletions copasi/UI/CQEFMNetReactionDM.h
@@ -1,4 +1,9 @@
// Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
Expand Down Expand Up @@ -29,8 +34,8 @@ class CQEFMNetReactionDM : public CQBaseDataModel

public:
CQEFMNetReactionDM(QObject *parent = 0);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
Expand Down
11 changes: 8 additions & 3 deletions copasi/UI/CQEFMReactionDM.h
@@ -1,4 +1,9 @@
// Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
Expand All @@ -25,8 +30,8 @@ class CQEFMReactionDM : public CQBaseDataModel

public:
CQEFMReactionDM(QObject *parent = 0);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
Expand Down
11 changes: 8 additions & 3 deletions copasi/UI/CQEFMSpeciesDM.h
@@ -1,4 +1,9 @@
// Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
Expand Down Expand Up @@ -27,8 +32,8 @@ class CQEFMSpeciesDM : public CQBaseDataModel
public:
CQEFMSpeciesDM(QObject *parent = 0);

virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;

virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
Expand Down
2 changes: 1 addition & 1 deletion copasi/UI/CQEventDM.cpp
@@ -1,4 +1,4 @@
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down
6 changes: 3 additions & 3 deletions copasi/UI/CQEventDM.h
@@ -1,4 +1,4 @@
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -37,8 +37,8 @@ class CQEventDM : public CQBaseDataModel

public:
CQEventDM(QObject *parent, CDataModel * pDataModel);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
Expand Down
11 changes: 8 additions & 3 deletions copasi/UI/CQFluxModeDM.h
@@ -1,4 +1,9 @@
// Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
Expand Down Expand Up @@ -29,8 +34,8 @@ class CQFluxModeDM : public CQBaseDataModel

public:
CQFluxModeDM(QObject *parent = 0);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
Expand Down
6 changes: 3 additions & 3 deletions copasi/UI/CQFunctionDM.h
@@ -1,4 +1,4 @@
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -31,8 +31,8 @@ class CQFunctionDM : public CQBaseDataModel

public:
CQFunctionDM(QObject *parent, CDataModel * pDataModel);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
Expand Down
4 changes: 1 addition & 3 deletions copasi/UI/CQGlobalQuantityDM.cpp
Expand Up @@ -301,10 +301,8 @@ bool CQGlobalQuantityDM::setData(const QModelIndex &index, const QVariant &value
}

// virtual
void CQGlobalQuantityDM::resetCache()
void CQGlobalQuantityDM::resetCacheProtected()
{
assert(mpDataModel != NULL);

mpGlobalQuantities = dynamic_cast< CDataVectorN < CModelValue > * >(&mpDataModel->getModel()->getModelValues());
assert(mpGlobalQuantities != NULL);

Expand Down
6 changes: 3 additions & 3 deletions copasi/UI/CQGlobalQuantityDM.h
@@ -1,4 +1,4 @@
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -77,9 +77,9 @@ class CQGlobalQuantityDM : public CQBaseDataModel
bool clear();

public slots:
virtual void resetCache();

protected:
virtual void resetCacheProtected();

QStringList mTypes;
/**
* A vector mapping the item index to a model valu type
Expand Down
6 changes: 3 additions & 3 deletions copasi/UI/CQLayoutsDM.h
@@ -1,4 +1,4 @@
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -28,8 +28,8 @@ class CQLayoutsDM : public CQBaseDataModel
CQLayoutsDM(QObject *parent = 0);
virtual ~CQLayoutsDM();

virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual QVariant data(const QModelIndex &index, int role) const;
virtual QVariant headerData(int section, Qt::Orientation orientation,
Expand Down

0 comments on commit 1cd9dc4

Please sign in to comment.