Skip to content

Commit

Permalink
Merge 53e9683 into d48fa37
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Jun 15, 2018
2 parents d48fa37 + 53e9683 commit bc697f3
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 102 deletions.
1 change: 1 addition & 0 deletions doc/downloads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var jsonData = { "versions": [
"changes": [
{ "change": "<strong>General:</strong> General: fixed a problem with not being able to start OpenCOR from the system PATH (see issue <a href=\"https://github.com/opencor/opencor/issues/1688\">#1688</a>)." },
{ "change": "<strong>Text-based editors:</strong> prevent infinite \"Replace all\" actions (see issue <a href=\"https://github.com/opencor/opencor/issues/1677\">#1677</a>). Sped up our highlight/replace all method (see issue <a href=\"https://github.com/opencor/opencor/issues/1679\">#1679</a>). Now have word-wrap alignment <a href=\"https://github.com/opencor/opencor/issues/1680\">#1680</a>)." },
{ "change": "<strong>Simualtion Experiment view:</strong> fixed an issue with the Y axis being doubled in a very specific case (see issue <a href=\"https://github.com/opencor/opencor/issues/1683\">#1683</a>)." },
{ "change": "<strong>Third-party libraries:</strong> upgraded <a href=\"https://libgit2.github.com/\">libgit2</a> to version 0.27.1 (see issue <a href=\"https://github.com/opencor/opencor/issues/1672\">#1672</a>)." }
]
},
Expand Down
86 changes: 31 additions & 55 deletions src/plugins/miscellaneous/Core/src/centralwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ CentralWidget::CentralWidget(QWidget *pParent) :

// Create our modes

mModes.insert(ViewInterface::EditingMode, new CentralWidgetMode(this));
mModes.insert(ViewInterface::SimulationMode, new CentralWidgetMode(this));
mModes.insert(ViewInterface::AnalysisMode, new CentralWidgetMode(this));
#ifdef ENABLE_SAMPLE_PLUGINS
mModes.insert(ViewInterface::SampleMode, new CentralWidgetMode(this));
#endif
#ifdef ENABLE_TEST_PLUGINS
mModes.insert(ViewInterface::TestMode, new CentralWidgetMode(this));
#endif
mModes.insert(ViewInterface::EditingMode, new CentralWidgetMode(this));
mModes.insert(ViewInterface::SimulationMode, new CentralWidgetMode(this));
mModes.insert(ViewInterface::AnalysisMode, new CentralWidgetMode(this));
// Note: these will be deleted in CentralWidget's destructor...

// Create our files tab bar widget
Expand Down Expand Up @@ -441,7 +441,7 @@ void CentralWidget::loadSettings(QSettings *pSettings)
// The previously selected file doesn't exist anymore, so select the
// first file (otherwise the last file will be selected)

setTabBarCurrentIndex(mFileTabs, 0);
mFileTabs->setCurrentIndex(0);
}

// Retrieve the seleted modes and views, in case there are no files
Expand All @@ -450,7 +450,7 @@ void CentralWidget::loadSettings(QSettings *pSettings)
ViewInterface::Mode fileMode = ViewInterface::modeFromString(pSettings->value(SettingsFileMode.arg(QString())).toString());

if (fileMode != ViewInterface::UnknownMode)
setTabBarCurrentIndex(mModeTabs, mModeModeTabIndexes.value(fileMode));
mModeTabs->setCurrentIndex(mModeModeTabIndexes.value(fileMode));

for (int i = 0, iMax = mModeTabs->count(); i < iMax; ++i) {
fileMode = mModeTabIndexModes.value(i);
Expand All @@ -462,7 +462,7 @@ void CentralWidget::loadSettings(QSettings *pSettings)

for (int j = 0, jMax = viewPlugins.count(); j < jMax; ++j) {
if (!viewPluginName.compare(viewPlugins[j]->name())) {
setTabBarCurrentIndex(mode->viewTabs(), j);
mode->viewTabs()->setCurrentIndex(j);

break;
}
Expand Down Expand Up @@ -617,6 +617,12 @@ void CentralWidget::retranslateUi()
{
// Retranslate our modes tab bar

mModeTabs->setTabText(mModeModeTabIndexes.value(ViewInterface::EditingMode, -1),
tr("Editing"));
mModeTabs->setTabText(mModeModeTabIndexes.value(ViewInterface::SimulationMode, -1),
tr("Simulation"));
mModeTabs->setTabText(mModeModeTabIndexes.value(ViewInterface::AnalysisMode, -1),
tr("Analysis"));
#ifdef ENABLE_SAMPLE_PLUGINS
mModeTabs->setTabText(mModeModeTabIndexes.value(ViewInterface::SampleMode, -1),
tr("Sample"));
Expand All @@ -625,12 +631,6 @@ void CentralWidget::retranslateUi()
mModeTabs->setTabText(mModeModeTabIndexes.value(ViewInterface::TestMode, -1),
tr("Test"));
#endif
mModeTabs->setTabText(mModeModeTabIndexes.value(ViewInterface::EditingMode, -1),
tr("Editing"));
mModeTabs->setTabText(mModeModeTabIndexes.value(ViewInterface::SimulationMode, -1),
tr("Simulation"));
mModeTabs->setTabText(mModeModeTabIndexes.value(ViewInterface::AnalysisMode, -1),
tr("Analysis"));

// Retranslate our mode views tab bar

Expand Down Expand Up @@ -758,7 +758,7 @@ void CentralWidget::openFile(const QString &pFileName, File::Type pType,

for (int i = 0, iMax = mFileNames.count(); i < iMax; ++i) {
if (!mFileNames[i].compare(fileName)) {
setTabBarCurrentIndex(mFileTabs, i);
mFileTabs->setCurrentIndex(i);

return;
}
Expand Down Expand Up @@ -788,7 +788,7 @@ void CentralWidget::openFile(const QString &pFileName, File::Type pType,

updateFileTab(fileTabIndex);

setTabBarCurrentIndex(mFileTabs, fileTabIndex);
mFileTabs->setCurrentIndex(fileTabIndex);

// Everything went fine, so let our plugins know that our file has been
// opened
Expand Down Expand Up @@ -1231,9 +1231,9 @@ void CentralWidget::previousFile()
// Select the previous file

if (mFileTabs->count()) {
setTabBarCurrentIndex(mFileTabs, mFileTabs->currentIndex()?
mFileTabs->currentIndex()-1:
mFileTabs->count()-1);
mFileTabs->setCurrentIndex(mFileTabs->currentIndex()?
mFileTabs->currentIndex()-1:
mFileTabs->count()-1);
}
}

Expand All @@ -1244,9 +1244,9 @@ void CentralWidget::nextFile()
// Select the next file

if (mFileTabs->count()) {
setTabBarCurrentIndex(mFileTabs, (mFileTabs->currentIndex() == mFileTabs->count()-1)?
0:
mFileTabs->currentIndex()+1);
mFileTabs->setCurrentIndex((mFileTabs->currentIndex() == mFileTabs->count()-1)?
0:
mFileTabs->currentIndex()+1);
}
}

Expand Down Expand Up @@ -1434,7 +1434,7 @@ bool CentralWidget::selectMode(const QString &pModeName)
ViewInterface::Mode mode = ViewInterface::modeFromString(pModeName);

if (mode != ViewInterface::UnknownMode) {
setTabBarCurrentIndex(mModeTabs, mModeModeTabIndexes.value(mode));
mModeTabs->setCurrentIndex(mModeModeTabIndexes.value(mode));

return true;
} else {
Expand All @@ -1457,7 +1457,7 @@ bool CentralWidget::selectView(const QString &pViewName)

for (int j = 0, iMax = viewPlugins.count(); j < iMax; ++j) {
if (!viewPlugins[j]->name().compare(pViewName)) {
setTabBarCurrentIndex(mode->viewTabs(), j);
mode->viewTabs()->setCurrentIndex(j);

return true;
}
Expand Down Expand Up @@ -1646,38 +1646,17 @@ void CentralWidget::fileReloadedOrSaved(const QString &pFileName,

//==============================================================================

void CentralWidget::setTabBarCurrentIndex(TabBarWidget *pTabBar, int pIndex)
{
// Update the current index of the given tab bar widget, after having
// temporarily disabled its handling of the currentChanged() signal, if
// needed

if (mState == UpdatingGui) {
disconnect(pTabBar, &TabBarWidget::currentChanged,
this, &CentralWidget::updateGui);
}

pTabBar->setCurrentIndex(pIndex);

if (mState == UpdatingGui) {
connect(pTabBar, &TabBarWidget::currentChanged,
this, &CentralWidget::updateGui);
}
}

//==============================================================================

void CentralWidget::updateGui()
{
TabBarWidget *tabBar = qobject_cast<TabBarWidget *>(sender());

if (mState != Idling) {
// We are doing something, so too risky to update the GUI during that
// time (e.g. things may not be fully initialised), so revert to our old
// tab index, if possible
// We are doing something, so it's too risky to update the GUI for now
// (e.g. things may not be fully initialised), so revert to our old tab
// index, if possible

if (tabBar)
setTabBarCurrentIndex(tabBar, tabBar->oldIndex());
tabBar->setCurrentIndex(tabBar->oldIndex());

return;
}
Expand Down Expand Up @@ -1724,12 +1703,9 @@ void CentralWidget::updateGui()
if (changedModes)
fileModeTabIndex = mModeTabs->currentIndex();
else
setTabBarCurrentIndex(mModeTabs, fileModeTabIndex);

CentralWidgetMode *mode = mModes.value(mModeTabIndexModes.value(fileModeTabIndex));
QMap<int, int> modeViewTabIndexes = mFileModeViewTabIndexes.value(fileName);
mModeTabs->setCurrentIndex(fileModeTabIndex);

setTabBarCurrentIndex(mode->viewTabs(), modeViewTabIndexes.value(fileModeTabIndex));
mModes.value(mModeTabIndexModes.value(fileModeTabIndex))->viewTabs()->setCurrentIndex(mFileModeViewTabIndexes.value(fileName).value(fileModeTabIndex));
} else if (!changedViews) {
// We are opening a file, so determine the default views that we
// should try and if there are none, then try the Raw Text view
Expand Down Expand Up @@ -1776,15 +1752,15 @@ void CentralWidget::updateGui()

int fileModeTabIndex = mModeTabs->currentIndex();

mModes.value(ViewInterface::EditingMode)->viewTabs()->setVisible(fileModeTabIndex == mModeModeTabIndexes.value(ViewInterface::EditingMode));
mModes.value(ViewInterface::SimulationMode)->viewTabs()->setVisible(fileModeTabIndex == mModeModeTabIndexes.value(ViewInterface::SimulationMode));
mModes.value(ViewInterface::AnalysisMode)->viewTabs()->setVisible(fileModeTabIndex == mModeModeTabIndexes.value(ViewInterface::AnalysisMode));
#ifdef ENABLE_SAMPLE_PLUGINS
mModes.value(ViewInterface::SampleMode)->viewTabs()->setVisible(fileModeTabIndex == mModeModeTabIndexes.value(ViewInterface::SampleMode));
#endif
#ifdef ENABLE_TEST_PLUGINS
mModes.value(ViewInterface::TestMode)->viewTabs()->setVisible(fileModeTabIndex == mModeModeTabIndexes.value(ViewInterface::TestMode));
#endif
mModes.value(ViewInterface::EditingMode)->viewTabs()->setVisible(fileModeTabIndex == mModeModeTabIndexes.value(ViewInterface::EditingMode));
mModes.value(ViewInterface::SimulationMode)->viewTabs()->setVisible(fileModeTabIndex == mModeModeTabIndexes.value(ViewInterface::SimulationMode));
mModes.value(ViewInterface::AnalysisMode)->viewTabs()->setVisible(fileModeTabIndex == mModeModeTabIndexes.value(ViewInterface::AnalysisMode));

// Ask the GUI interface for the widget to use the current file (should
// there be one)
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/miscellaneous/Core/src/centralwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ class CentralWidget : public Widget

void fileReloadedOrSaved(const QString &pFileName, bool pFileReloaded);

void setTabBarCurrentIndex(TabBarWidget *pTabBar, int pIndex);

void reloadFile(int pIndex, bool pForce);

bool closeFile(int pIndex, bool pForceClosing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,11 +809,11 @@ void SimulationExperimentViewSimulationWidget::initialize(bool pReloadingView)

switch (sedmlFileIssue.type()) {
case SEDMLSupport::SedmlFileIssue::Unknown:
#ifdef QT_DEBUG
#ifdef QT_DEBUG
// We should never come here...

qFatal("FATAL ERROR | %s:%d: a SED-ML file issue cannot be of unknown type.", __FILE__, __LINE__);
#endif
#endif

break;
case SEDMLSupport::SedmlFileIssue::Information:
Expand Down
42 changes: 17 additions & 25 deletions src/plugins/viewinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ extern "C" Q_DECL_EXPORT int viewInterfaceVersion()
//==============================================================================

static const auto ViewModeUnknown = QStringLiteral("UnknownMode");
static const auto ViewModeEditing = QStringLiteral("EditingMode");
static const auto ViewModeSimulation = QStringLiteral("SimulationMode");
static const auto ViewModeAnalysis = QStringLiteral("AnalysisMode");
#ifdef ENABLE_SAMPLE_PLUGINS
static const auto ViewModeSample = QStringLiteral("SampleMode");
#endif
#ifdef ENABLE_TEST_PLUGINS
static const auto ViewModeTest = QStringLiteral("TestMode");
#endif
static const auto ViewModeEditing = QStringLiteral("EditingMode");
static const auto ViewModeSimulation = QStringLiteral("SimulationMode");
static const auto ViewModeAnalysis = QStringLiteral("AnalysisMode");

//==============================================================================

Expand All @@ -58,6 +58,12 @@ QString ViewInterface::modeAsString(Mode pMode)
switch (pMode) {
case UnknownMode:
return ViewModeUnknown;
case EditingMode:
return ViewModeEditing;
case SimulationMode:
return ViewModeSimulation;
case AnalysisMode:
return ViewModeAnalysis;
#ifdef ENABLE_SAMPLE_PLUGINS
case SampleMode:
return ViewModeSample;
Expand All @@ -66,12 +72,6 @@ QString ViewInterface::modeAsString(Mode pMode)
case TestMode:
return ViewModeTest;
#endif
case EditingMode:
return ViewModeEditing;
case SimulationMode:
return ViewModeSimulation;
case AnalysisMode:
return ViewModeAnalysis;
}

return "???";
Expand All @@ -85,28 +85,20 @@ ViewInterface::Mode ViewInterface::modeFromString(const QString &pMode)
{
// Return the mode string corresponding to the given mode

#if defined(ENABLE_SAMPLE_PLUGINS) && defined(ENABLE_TEST_PLUGINS)
if (!pMode.compare(ViewModeSample))
return SampleMode;
else if (!pMode.compare(ViewModeTest))
return TestMode;
else if (!pMode.compare(ViewModeEditing))
#elif defined(ENABLE_SAMPLE_PLUGINS)
if (!pMode.compare(ViewModeSample))
return SampleMode;
else if (!pMode.compare(ViewModeEditing))
#elif defined(ENABLE_TEST_PLUGINS)
if (!pMode.compare(ViewModeTest))
return TestMode;
else if (!pMode.compare(ViewModeEditing))
#else
if (!pMode.compare(ViewModeEditing))
#endif
return EditingMode;
else if (!pMode.compare(ViewModeSimulation))
return SimulationMode;
else if (!pMode.compare(ViewModeAnalysis))
return AnalysisMode;
#ifdef ENABLE_SAMPLE_PLUGINS
else if (!pMode.compare(ViewModeSample))
return SampleMode;
#endif
#ifdef ENABLE_TEST_PLUGINS
else if (!pMode.compare(ViewModeTest))
return TestMode;
#endif

return UnknownMode;
}
Expand Down
18 changes: 0 additions & 18 deletions src/plugins/widget/GraphPanelWidget/src/graphpanelplotwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3309,20 +3309,6 @@ void GraphPanelPlotWidget::alignWithNeighbors(bool pCanReplot,
axisWidget(QwtPlot::xBottom)->getMinBorderDist(oldMinBorderDistStartX, oldMinBorderDistEndX);

foreach (GraphPanelPlotWidget *plot, selfPlusNeighbors) {
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
plot->setUpdatesEnabled(false);
// Note #1: this is needed on Windows and Linux otherwise to switch
// files that use different modes (e.g. the N62 SED-ML file
// uses the Simulation Experiment view, i.e. Simulation mode,
// and the N62 CellML file uses the CellML Text view, i.e. the
// Editing mode) may result in the view tab of both modes being
// temporarily visible. No idea why to temporarily disable
// updates fixes things, but it does...
// Note #2: to have this on macOS may result in a graph panel becoming
// black, so we definitely don't want to do it on that
// platform...
#endif

// Determine how much space we should have directly to the left and
// right of the X axis
// Note: normally, we would initialise minBorderDistStartX and
Expand Down Expand Up @@ -3403,10 +3389,6 @@ void GraphPanelPlotWidget::alignWithNeighbors(bool pCanReplot,
replot();
}
}

#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
plot->setUpdatesEnabled(true);
#endif
}
}

Expand Down

0 comments on commit bc697f3

Please sign in to comment.