Skip to content

Commit fad9f0a

Browse files
committed
Merge origin/master
2 parents da01286 + 1d1f811 commit fad9f0a

File tree

6 files changed

+91
-79
lines changed

6 files changed

+91
-79
lines changed

OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,8 @@ bool LibraryTreeProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
10231023
}
10241024
// check current index itself
10251025
if (pLibraryTreeItem) {
1026-
if ((pLibraryTreeItem->getAccess() == LibraryTreeItem::hide)
1026+
if ((pLibraryTreeItem->getAccess() == LibraryTreeItem::hide
1027+
&& !OptionsDialog::instance()->getGeneralSettingsPage()->getShowHiddenClasses())
10271028
|| (pLibraryTreeItem->isProtected() && !OptionsDialog::instance()->getGeneralSettingsPage()->getShowProtectedClasses())) {
10281029
return false;
10291030
} else {

OMEdit/OMEditGUI/Options/OptionsDialog.cpp

Lines changed: 35 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ void OptionsDialog::readGeneralSettings()
192192
if (mpSettings->contains("showProtectedClasses")) {
193193
mpGeneralSettingsPage->setShowProtectedClasses(mpSettings->value("showProtectedClasses").toBool());
194194
}
195+
// read show hidden classes
196+
if (mpSettings->contains("showHiddenClasses")) {
197+
mpGeneralSettingsPage->setShowHiddenClasses(mpSettings->value("showHiddenClasses").toBool());
198+
}
195199
// read the modeling view mode
196200
if (mpSettings->contains("modeling/viewmode")) {
197201
mpGeneralSettingsPage->setModelingViewMode(mpSettings->value("modeling/viewmode").toString());
@@ -839,6 +843,8 @@ void OptionsDialog::saveGeneralSettings()
839843
mpSettings->setValue("libraryIconSize", mpGeneralSettingsPage->getLibraryIconSizeSpinBox()->value());
840844
// save show protected classes
841845
mpSettings->setValue("showProtectedClasses", mpGeneralSettingsPage->getShowProtectedClasses());
846+
// save show hidden classes
847+
mpSettings->setValue("showHiddenClasses", mpGeneralSettingsPage->getShowHiddenClasses());
842848
// show/hide the protected classes
843849
MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->showHideProtectedClasses();
844850
// save modeling view mode
@@ -1585,13 +1591,16 @@ GeneralSettingsPage::GeneralSettingsPage(OptionsDialog *pOptionsDialog)
15851591
mpLibraryIconSizeSpinBox->setValue(24);
15861592
// show protected classes
15871593
mpShowProtectedClasses = new QCheckBox(tr("Show Protected Classes"));
1594+
// show hidden classes
1595+
mpShowHiddenClasses = new QCheckBox(tr("Show Hidden Classes (Ignores the annotation(Protection(access = Access.hide))"));
15881596
// Libraries Browser group box layout
15891597
QGridLayout *pLibrariesBrowserLayout = new QGridLayout;
15901598
pLibrariesBrowserLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
15911599
pLibrariesBrowserLayout->setColumnStretch(1, 1);
15921600
pLibrariesBrowserLayout->addWidget(mpLibraryIconSizeLabel, 0, 0);
15931601
pLibrariesBrowserLayout->addWidget(mpLibraryIconSizeSpinBox, 0, 1);
15941602
pLibrariesBrowserLayout->addWidget(mpShowProtectedClasses, 1, 0, 1, 2);
1603+
pLibrariesBrowserLayout->addWidget(mpShowHiddenClasses, 2, 0, 1, 2);
15951604
mpLibrariesBrowserGroupBox->setLayout(pLibrariesBrowserLayout);
15961605
// Modeling View Mode
15971606
mpModelingViewModeGroupBox = new QGroupBox(tr("Default Modeling View Mode"));
@@ -1690,73 +1699,50 @@ GeneralSettingsPage::GeneralSettingsPage(OptionsDialog *pOptionsDialog)
16901699
setLayout(pMainLayout);
16911700
}
16921701

1693-
QComboBox* GeneralSettingsPage::getLanguageComboBox()
1694-
{
1695-
return mpLanguageComboBox;
1696-
}
1697-
1698-
//! Sets the working directory text box value.
1699-
//! @param value the working directory value.
1700-
//! @see getWorkingDirectory();
1701-
void GeneralSettingsPage::setWorkingDirectory(QString value)
1702-
{
1703-
mpWorkingDirectoryTextBox->setText(value);
1704-
}
1705-
1706-
//! Returns the working directory text box value.
1707-
//! @return working directory as string.
1708-
//! @see setWorkingDirectory();
1709-
QString GeneralSettingsPage::getWorkingDirectory()
1710-
{
1711-
return mpWorkingDirectoryTextBox->text();
1712-
}
1713-
1714-
void GeneralSettingsPage::setPreserveUserCustomizations(bool value)
1715-
{
1716-
mpPreserveUserCustomizations->setChecked(value);
1717-
}
1718-
1719-
bool GeneralSettingsPage::getPreserveUserCustomizations()
1720-
{
1721-
return mpPreserveUserCustomizations->isChecked();
1722-
}
1723-
1724-
void GeneralSettingsPage::setShowProtectedClasses(bool value)
1725-
{
1726-
mpShowProtectedClasses->setChecked(value);
1727-
}
1728-
1729-
bool GeneralSettingsPage::getShowProtectedClasses()
1730-
{
1731-
return mpShowProtectedClasses->isChecked();
1732-
}
1733-
1702+
/*!
1703+
* \brief GeneralSettingsPage::setModelingViewMode
1704+
* Sets the Modeling view mode.
1705+
* \param value
1706+
*/
17341707
void GeneralSettingsPage::setModelingViewMode(QString value)
17351708
{
1736-
if (value.compare(Helper::subWindow) == 0)
1709+
if (value.compare(Helper::subWindow) == 0) {
17371710
mpModelingSubWindowViewRadioButton->setChecked(true);
1738-
else
1711+
} else {
17391712
mpModelingTabbedViewRadioButton->setChecked(true);
1713+
}
17401714
}
17411715

1716+
/*!
1717+
* \brief GeneralSettingsPage::getModelingViewMode
1718+
* Gets the Modeling view mode.
1719+
* \return
1720+
*/
17421721
QString GeneralSettingsPage::getModelingViewMode()
17431722
{
1744-
if (mpModelingSubWindowViewRadioButton->isChecked())
1723+
if (mpModelingSubWindowViewRadioButton->isChecked()) {
17451724
return Helper::subWindow;
1746-
else
1725+
} else {
17471726
return Helper::tabbed;
1727+
}
17481728
}
17491729

1730+
/*!
1731+
* \brief GeneralSettingsPage::setDefaultView
1732+
* Sets the default view.
1733+
* \param value
1734+
*/
17501735
void GeneralSettingsPage::setDefaultView(QString value)
17511736
{
1752-
if (value.compare(Helper::iconView) == 0)
1737+
if (value.compare(Helper::iconView) == 0) {
17531738
mpIconViewRadioButton->setChecked(true);
1754-
else if (value.compare(Helper::textView) == 0)
1739+
} else if (value.compare(Helper::textView) == 0) {
17551740
mpTextViewRadioButton->setChecked(true);
1756-
else if (value.compare(Helper::documentationView) == 0)
1741+
} else if (value.compare(Helper::documentationView) == 0) {
17571742
mpDocumentationViewRadioButton->setChecked(true);
1758-
else
1743+
} else {
17591744
mpDiagramViewRadioButton->setChecked(true);
1745+
}
17601746
}
17611747

17621748
/*!

OMEdit/OMEditGUI/Options/OptionsDialog.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,22 @@ class GeneralSettingsPage : public QWidget
198198
Q_OBJECT
199199
public:
200200
GeneralSettingsPage(OptionsDialog *pOptionsDialog);
201-
QComboBox* getLanguageComboBox();
202-
void setWorkingDirectory(QString value);
203-
QString getWorkingDirectory();
201+
QComboBox* getLanguageComboBox() {return mpLanguageComboBox;}
202+
void setWorkingDirectory(QString value) {mpWorkingDirectoryTextBox->setText(value);}
203+
QString getWorkingDirectory() {return mpWorkingDirectoryTextBox->text();}
204204
QSpinBox* getToolbarIconSizeSpinBox() {return mpToolbarIconSizeSpinBox;}
205-
void setPreserveUserCustomizations(bool value);
206-
bool getPreserveUserCustomizations();
205+
void setPreserveUserCustomizations(bool value) {mpPreserveUserCustomizations->setChecked(value);}
206+
bool getPreserveUserCustomizations() {return mpPreserveUserCustomizations->isChecked();}
207207
void setTerminalCommand(QString value) {mpTerminalCommandTextBox->setText(value);}
208208
QString getTerminalCommand() {return mpTerminalCommandTextBox->text();}
209209
void setTerminalCommandArguments(QString value) {mpTerminalCommandArgumentsTextBox->setText(value);}
210210
QString getTerminalCommandArguments() {return mpTerminalCommandArgumentsTextBox->text();}
211211
QCheckBox* getHideVariablesBrowserCheckBox() {return mpHideVariablesBrowserCheckBox;}
212212
QSpinBox* getLibraryIconSizeSpinBox() {return mpLibraryIconSizeSpinBox;}
213-
void setShowProtectedClasses(bool value);
214-
bool getShowProtectedClasses();
213+
void setShowProtectedClasses(bool value) {mpShowProtectedClasses->setChecked(value);}
214+
bool getShowProtectedClasses() {return mpShowProtectedClasses->isChecked();}
215+
void setShowHiddenClasses(bool value) {mpShowHiddenClasses->setChecked(value);}
216+
bool getShowHiddenClasses() {return mpShowHiddenClasses->isChecked();}
215217
void setModelingViewMode(QString value);
216218
QString getModelingViewMode();
217219
void setDefaultView(QString value);
@@ -242,6 +244,7 @@ class GeneralSettingsPage : public QWidget
242244
Label *mpLibraryIconSizeLabel;
243245
QSpinBox *mpLibraryIconSizeSpinBox;
244246
QCheckBox *mpShowProtectedClasses;
247+
QCheckBox *mpShowHiddenClasses;
245248
QGroupBox *mpModelingViewModeGroupBox;
246249
QRadioButton *mpModelingTabbedViewRadioButton;
247250
QRadioButton *mpModelingSubWindowViewRadioButton;

OMEdit/OMEditGUI/Plotting/PlotWindowContainer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ void PlotWindowContainer::addParametricPlotWindow()
241241
pPlotWindow->setAutoScale(OptionsDialog::instance()->getPlottingPage()->getAutoScaleCheckBox()->isChecked());
242242
pPlotWindow->installEventFilter(this);
243243
QMdiSubWindow *pSubWindow = addSubWindow(pPlotWindow);
244-
245244
addCloseActionsToSubWindowSystemMenu(pSubWindow);
246245
pSubWindow->setWindowIcon(QIcon(":/Resources/icons/parametric-plot-window.svg"));
247246
pPlotWindow->show();
@@ -276,6 +275,7 @@ void PlotWindowContainer::addArrayPlotWindow(bool maximized)
276275
pPlotWindow->setXLabel(QString("index"));
277276
pPlotWindow->installEventFilter(this);
278277
QMdiSubWindow *pSubWindow = addSubWindow(pPlotWindow);
278+
addCloseActionsToSubWindowSystemMenu(pSubWindow);
279279
pSubWindow->setWindowIcon(QIcon(":/Resources/icons/array-plot-window.svg"));
280280
pPlotWindow->show();
281281
if (maximized) {

OMEdit/OMEditGUI/Plotting/VariablesWidget.cpp

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,26 @@ void VariablesTreeView::mouseReleaseEvent(QMouseEvent *event)
962962
QTreeView::mouseReleaseEvent(event);
963963
}
964964

965+
/*!
966+
* \brief VariablesTreeView::keyPressEvent
967+
* Reimplementation of keypressevent.
968+
* \param event
969+
*/
970+
void VariablesTreeView::keyPressEvent(QKeyEvent *event)
971+
{
972+
QModelIndexList indexes = selectionModel()->selectedIndexes();
973+
if (!indexes.isEmpty()) {
974+
QModelIndex index = indexes.at(0);
975+
index = mpVariablesWidget->getVariableTreeProxyModel()->mapToSource(index);
976+
VariablesTreeItem *pVariablesTreeItem = static_cast<VariablesTreeItem*>(index.internalPointer());
977+
if (event->key() == Qt::Key_Delete && pVariablesTreeItem->isRootItem()) {
978+
mpVariablesWidget->getVariablesTreeModel()->removeVariableTreeItem(pVariablesTreeItem->getVariableName());
979+
return;
980+
}
981+
}
982+
QTreeView::keyPressEvent(event);
983+
}
984+
965985
VariablesWidget::VariablesWidget(QWidget *pParent)
966986
: QWidget(pParent)
967987
{
@@ -1531,13 +1551,13 @@ void VariablesWidget::plotVariables(const QModelIndex &index, qreal curveThickne
15311551
if (xUnit.isEmpty()) {
15321552
pPlotWindow->setXLabel(xVariable);
15331553
} else {
1534-
pPlotWindow->setXLabel(xVariable + " [" + xUnit + "]");
1554+
pPlotWindow->setXLabel(xVariable + " (" + xUnit + ")");
15351555
}
15361556

15371557
if (yUnit.isEmpty()) {
15381558
pPlotWindow->setYLabel(yVariable);
15391559
} else {
1540-
pPlotWindow->setYLabel(yVariable + " [" + yUnit + "]");
1560+
pPlotWindow->setYLabel(yVariable + " (" + yUnit + ")");
15411561
}
15421562
}
15431563
if (pPlotWindow->getAutoScaleButton()->isChecked()) {
@@ -1600,13 +1620,13 @@ void VariablesWidget::plotVariables(const QModelIndex &index, qreal curveThickne
16001620
if (xUnit.isEmpty()) {
16011621
pPlotWindow->setXLabel(xVariable);
16021622
} else {
1603-
pPlotWindow->setXLabel(xVariable + " [" + xUnit + "]");
1623+
pPlotWindow->setXLabel(xVariable + " (" + xUnit + ")");
16041624
}
16051625

16061626
if (yUnit.isEmpty()) {
16071627
pPlotWindow->setYLabel(yVariable);
16081628
} else {
1609-
pPlotWindow->setYLabel(yVariable + " [" + yUnit + "]");
1629+
pPlotWindow->setYLabel(yVariable + " (" + yUnit + ")");
16101630
}
16111631
} else {
16121632
pPlotWindow->setXLabel("");
@@ -1839,32 +1859,32 @@ void VariablesWidget::selectInteractivePlotWindow(VariablesTreeItem *pVariablesT
18391859
*/
18401860
void VariablesWidget::timeUnitChanged(QString unit)
18411861
{
1862+
if (unit.isEmpty()) {
1863+
return;
1864+
}
18421865
try {
18431866
OMPlot::PlotWindow *pPlotWindow = MainWindow::instance()->getPlotWindowContainer()->getCurrentWindow();
18441867
// if still pPlotWindow is 0 then return.
18451868
if (!pPlotWindow) {
18461869
return;
18471870
}
18481871
if (pPlotWindow->getPlotType()==PlotWindow::PLOTARRAY ||
1849-
pPlotWindow->getPlotType()==PlotWindow::PLOTARRAYPARAMETRIC)
1850-
{
1851-
pPlotWindow->setTimeUnit(unit);
1852-
pPlotWindow->updateTimeText(unit);
1853-
}
1854-
else
1855-
{
1856-
OMCInterface::convertUnits_res convertUnit = MainWindow::instance()->getOMCProxy()->convertUnits(pPlotWindow->getTimeUnit(), unit);
1857-
if (convertUnit.unitsCompatible) {
1858-
foreach (PlotCurve *pPlotCurve, pPlotWindow->getPlot()->getPlotCurvesList()) {
1859-
for (int i = 0 ; i < pPlotCurve->mXAxisVector.size() ; i++) {
1860-
pPlotCurve->updateXAxisValue(i, Utilities::convertUnit(pPlotCurve->mXAxisVector.at(i), convertUnit.offset, convertUnit.scaleFactor));
1861-
}
1862-
pPlotCurve->setData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(), pPlotCurve->getSize());
1872+
pPlotWindow->getPlotType()==PlotWindow::PLOTARRAYPARAMETRIC) {
1873+
pPlotWindow->setTimeUnit(unit);
1874+
pPlotWindow->updateTimeText(unit);
1875+
} else {
1876+
OMCInterface::convertUnits_res convertUnit = MainWindow::instance()->getOMCProxy()->convertUnits(pPlotWindow->getTimeUnit(), unit);
1877+
if (convertUnit.unitsCompatible) {
1878+
foreach (PlotCurve *pPlotCurve, pPlotWindow->getPlot()->getPlotCurvesList()) {
1879+
for (int i = 0 ; i < pPlotCurve->mXAxisVector.size() ; i++) {
1880+
pPlotCurve->updateXAxisValue(i, Utilities::convertUnit(pPlotCurve->mXAxisVector.at(i), convertUnit.offset, convertUnit.scaleFactor));
18631881
}
1864-
pPlotWindow->setXLabel(QString("time [%1]").arg(unit));
1865-
pPlotWindow->setTimeUnit(unit);
1866-
pPlotWindow->getPlot()->replot();
1882+
pPlotCurve->setData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(), pPlotCurve->getSize());
18671883
}
1884+
pPlotWindow->setXLabel(QString("time (%1)").arg(unit));
1885+
pPlotWindow->setTimeUnit(unit);
1886+
pPlotWindow->getPlot()->replot();
1887+
}
18681888
}
18691889
} catch (PlotException &e) {
18701890
QMessageBox::critical(this, QString(Helper::applicationName).append(" - ").append(Helper::error), e.what(), Helper::ok);
@@ -1901,6 +1921,7 @@ void VariablesWidget::showContextMenu(QPoint point)
19011921
/* delete result action */
19021922
QAction *pDeleteResultAction = new QAction(QIcon(":/Resources/icons/delete.svg"), tr("Delete Result"), this);
19031923
pDeleteResultAction->setData(pVariablesTreeItem->getVariableName());
1924+
pDeleteResultAction->setShortcut(QKeySequence::Delete);
19041925
pDeleteResultAction->setStatusTip(tr("Delete the result"));
19051926
connect(pDeleteResultAction, SIGNAL(triggered()), mpVariablesTreeModel, SLOT(removeVariableTreeItem()));
19061927

OMEdit/OMEditGUI/Plotting/VariablesWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class VariablesTreeView : public QTreeView
166166
VariablesWidget *mpVariablesWidget;
167167
protected:
168168
virtual void mouseReleaseEvent(QMouseEvent *event);
169+
virtual void keyPressEvent(QKeyEvent *event);
169170
};
170171

171172
class VariablesWidget : public QWidget

0 commit comments

Comments
 (0)