Skip to content

Commit

Permalink
- fix for bug 2082: the issue was caused by a change in CQComboDelega…
Browse files Browse the repository at this point in the history
…te, that now also commits the data automatically when selected. This caused references / relationships to be created twice. I now introduced an argument to the combo delegate, that determines whether a commit happens or not.
  • Loading branch information
fbergmann committed Aug 14, 2014
1 parent 019b9bc commit f3a509b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 25 deletions.
24 changes: 12 additions & 12 deletions copasi/MIRIAMUI/CQMiriamWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
// Copyright (C) 2010 - 2014 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.

// Copyright (C) 2009 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.
// Copyright (C) 2009 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.

#include "CQMiriamWidget.h"

Expand Down Expand Up @@ -53,13 +53,13 @@ CQMiriamWidget::CQMiriamWidget(QWidget* parent, const char* name)
mpModifiedPDM = new CQSortFilterProxyModel();

//Create Required Delegates
mpResourceDelegate1 = new CQComboDelegate(&mResources, this);
mpResourceDelegate1 = new CQComboDelegate(&mResources, this, false);
mpTblReferences->setItemDelegateForColumn(COL_RESOURCE_REFERENCE, mpResourceDelegate1);

mpResourceDelegate2 = new CQComboDelegate(&mReferences, this);
mpResourceDelegate2 = new CQComboDelegate(&mReferences, this, false);
mpTblDescription->setItemDelegateForColumn(COL_RESOURCE_BD, mpResourceDelegate2);

mpPredicateDelegate = new CQComboDelegate(&mPredicates, this);
mpPredicateDelegate = new CQComboDelegate(&mPredicates, this, false);
mpTblDescription->setItemDelegateForColumn(COL_RELATIONSHIP, mpPredicateDelegate);

mWidgets.push_back(mpTblAuthors); mDMs.push_back(mpCreatorDM); mProxyDMs.push_back(mpCreatorPDM);
Expand Down Expand Up @@ -326,7 +326,7 @@ bool CQMiriamWidget::enterProtected()

CCopasiMessage::clearDeque();

if(mKeyToCopy != "")
if (mKeyToCopy != "")
{
CAnnotation * pAnnotation = CAnnotation::castObject(dynamic_cast< CCopasiObject * >(CCopasiRootContainer::getKeyFactory()->get(mKeyToCopy)));

Expand Down
37 changes: 26 additions & 11 deletions copasi/UI/CQComboDelegate.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
// Copyright (C) 2010 - 2014 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.

// Copyright (C) 2009 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.
// Copyright (C) 2009 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.

#include <QtGui/QComboBox>
#include <QtGui/QSortFilterProxyModel>
Expand All @@ -15,11 +15,12 @@

#include "copasi.h"

CQComboDelegate::CQComboDelegate(const QStringList *pComboItems, QObject *parent):
CQComboDelegate::CQComboDelegate(const QStringList *pComboItems, QObject *parent, bool commitOnSelect):
QItemDelegate(parent),
mpComboItems(pComboItems),
mEditorToIndex(),
mRowToItems()
mRowToItems(),
mCommitOnSelect(commitOnSelect)
{}

CQComboDelegate::~CQComboDelegate()
Expand Down Expand Up @@ -111,7 +112,9 @@ void CQComboDelegate::slotCurrentIndexChanged(int index)
if (found != mEditorToIndex.end())
{
emit currentIndexChanged(found.value().row(), index);
commitData(pEditor);

if (mCommitOnSelect)
commitData(pEditor);
}
}
}
Expand All @@ -121,6 +124,18 @@ void CQComboDelegate::slotEditorDeleted(QObject * pObject)
mEditorToIndex.remove(static_cast< QWidget * >(pObject));
}

bool
CQComboDelegate::isCommitOnSelect() const
{
return mCommitOnSelect;
}

void
CQComboDelegate::setCommitOnSelect(bool commitOnSelect)
{
mCommitOnSelect = commitOnSelect;
}

CQIndexComboDelegate::CQIndexComboDelegate(const QStringList *pComboItems, QObject *parent)
: CQComboDelegate(pComboItems, parent)
{}
Expand Down
9 changes: 7 additions & 2 deletions copasi/UI/CQComboDelegate.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
// Copyright (C) 2010 - 2014 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
Expand All @@ -19,7 +19,7 @@ class CQComboDelegate : public QItemDelegate

public:
CQComboDelegate(const QStringList* pComboItems,
QObject *parent = NULL);
QObject *parent = NULL, bool commitOnSelect = true);

virtual ~CQComboDelegate();

Expand All @@ -42,6 +42,9 @@ class CQComboDelegate : public QItemDelegate

const QStringList *getItems(int row) const;

bool isCommitOnSelect() const;
void setCommitOnSelect(bool commitOnSelect);

protected slots:
void slotCurrentIndexChanged(int index);
void slotEditorDeleted(QObject * pObject);
Expand All @@ -54,6 +57,8 @@ protected slots:

mutable QMap< QWidget * , QModelIndex > mEditorToIndex;
mutable QMap< int, const QStringList * > mRowToItems;

bool mCommitOnSelect;
};

class CQIndexComboDelegate : public CQComboDelegate
Expand Down

0 comments on commit f3a509b

Please sign in to comment.