Skip to content

Commit

Permalink
Merge 980a836 into aa6d093
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Jun 27, 2018
2 parents aa6d093 + 980a836 commit 1daf39b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 21 deletions.
2 changes: 1 addition & 1 deletion doc/downloads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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>). Moved our API plugins to the third-party category and, in some cases, renamed them (see issue <a href=\"https://github.com/opencor/opencor/issues/1707\">#1707</a>)." },
{ "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>). Fixed a regression issue with the wrong view being potentially shown when switching between files in different modes/views (see issue <a href=\"https://github.com/opencor/opencor/issues/1699\">#1699</a>). Moved our API plugins to the third-party category and, in some cases, renamed them (see issue <a href=\"https://github.com/opencor/opencor/issues/1707\">#1707</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>). Fixed some GUI glitches (see issue <a href=\"https://github.com/opencor/opencor/issues/1696\">#1696</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>). Upgraded <a href=\"https://riverbankcomputing.com/software/qscintilla/intro\">QScintilla</a> to version 2.10.6 (see issue <a href=\"https://github.com/opencor/opencor/issues/1704\">#1704</a>)." }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,12 @@ QWidget * CellMLTextViewPlugin::viewWidget(const QString &pFileName)
// Make sure that we are dealing with a CellML 1.0/1.1 file

CellMLSupport::CellmlFile *cellmlFile = CellMLSupport::CellmlFileManager::instance()->cellmlFile(pFileName);
CellMLSupport::CellmlFile::Version cellmlVersion = cellmlFile->version();
CellMLSupport::CellmlFile::Version cellmlVersion = cellmlFile?
cellmlFile->version():
CellMLSupport::CellmlFile::Unknown;

if ( !cellmlFile
|| ( (cellmlVersion != CellMLSupport::CellmlFile::Cellml_1_0)
&& (cellmlVersion != CellMLSupport::CellmlFile::Cellml_1_1))) {
if ( (cellmlVersion != CellMLSupport::CellmlFile::Cellml_1_0)
&& (cellmlVersion != CellMLSupport::CellmlFile::Cellml_1_1)) {
return 0;
}

Expand Down
54 changes: 38 additions & 16 deletions src/plugins/miscellaneous/Core/src/centralwidget.cpp
Original file line number Diff line number Diff line change
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)

mFileTabs->setCurrentIndex(0);
setTabBarCurrentIndex(mFileTabs, 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)
mModeTabs->setCurrentIndex(mModeModeTabIndexes.value(fileMode));
setTabBarCurrentIndex(mModeTabs, 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())) {
mode->viewTabs()->setCurrentIndex(j);
setTabBarCurrentIndex(mode->viewTabs(), j);

break;
}
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)) {
mFileTabs->setCurrentIndex(i);
setTabBarCurrentIndex(mFileTabs, i);

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

updateFileTab(fileTabIndex);

mFileTabs->setCurrentIndex(fileTabIndex);
setTabBarCurrentIndex(mFileTabs, 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()) {
mFileTabs->setCurrentIndex(mFileTabs->currentIndex()?
mFileTabs->currentIndex()-1:
mFileTabs->count()-1);
setTabBarCurrentIndex(mFileTabs, mFileTabs->currentIndex()?
mFileTabs->currentIndex()-1:
mFileTabs->count()-1);
}
}

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

if (mFileTabs->count()) {
mFileTabs->setCurrentIndex((mFileTabs->currentIndex() == mFileTabs->count()-1)?
0:
mFileTabs->currentIndex()+1);
setTabBarCurrentIndex(mFileTabs, (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) {
mModeTabs->setCurrentIndex(mModeModeTabIndexes.value(mode));
setTabBarCurrentIndex(mModeTabs, 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)) {
mode->viewTabs()->setCurrentIndex(j);
setTabBarCurrentIndex(mode->viewTabs(), j);

return true;
}
Expand Down Expand Up @@ -1646,6 +1646,27 @@ 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());
Expand All @@ -1656,7 +1677,7 @@ void CentralWidget::updateGui()
// index, if possible

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

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

mModes.value(mModeTabIndexModes.value(fileModeTabIndex))->viewTabs()->setCurrentIndex(mFileModeViewTabIndexes.value(fileName).value(fileModeTabIndex));
setTabBarCurrentIndex(mModes.value(mModeTabIndexModes.value(fileModeTabIndex))->viewTabs(),
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
2 changes: 2 additions & 0 deletions src/plugins/miscellaneous/Core/src/centralwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ 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

0 comments on commit 1daf39b

Please sign in to comment.