From 8395c451189b09c2792dfae3415797e004c3d1f8 Mon Sep 17 00:00:00 2001 From: Adeel Asghar Date: Thu, 26 Mar 2015 13:51:55 +0000 Subject: [PATCH] - Do not use or & and as conditional operators. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25274 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- .../Modeling/DocumentationWidget.cpp | 31 +++----- .../Modeling/ModelWidgetContainer.cpp | 79 +++++++------------ 2 files changed, 41 insertions(+), 69 deletions(-) diff --git a/OMEdit/OMEditGUI/Modeling/DocumentationWidget.cpp b/OMEdit/OMEditGUI/Modeling/DocumentationWidget.cpp index e43e4c69a66..563ca517bf5 100644 --- a/OMEdit/OMEditGUI/Modeling/DocumentationWidget.cpp +++ b/OMEdit/OMEditGUI/Modeling/DocumentationWidget.cpp @@ -203,38 +203,33 @@ DocumentationViewer::DocumentationViewer(DocumentationWidget *pParent) connect(page(), SIGNAL(linkHovered(QString,QString,QString)), SLOT(processLinkHover(QString,QString,QString))); } -//! Slot activated when linkClicked signal of webview is raised. -//! Handles the link processing. Sends all the http starting links to the QDesktopServices and process all Modelica starting links. +/*! + * \brief DocumentationViewer::processLinkClick + * \param url + * Slot activated when linkClicked signal of webview is raised. + * Handles the link processing. Sends all the http starting links to the QDesktopServices and process all Modelica starting links. + */ void DocumentationViewer::processLinkClick(QUrl url) { // Send all http requests to desktop services for now. // if url contains http or mailto: send it to desktop services - if ((url.toString().startsWith("http")) or (url.toString().startsWith("mailto:"))) - { + if ((url.toString().startsWith("http")) || (url.toString().startsWith("mailto:"))) { QDesktopServices::openUrl(url); - } - // if the user has clicked on some Modelica Links like modelica:// - else if (url.scheme().compare("modelica") == 0) - { + } else if (url.scheme().compare("modelica") == 0) { // if the user has clicked on some Modelica Links like modelica:// // remove modelica:/// from Qurl QString resourceLink = url.toString().mid(12); /* if the link is a resource e.g .html, .txt or .pdf */ - if (resourceLink.endsWith(".html") || resourceLink.endsWith(".txt") || resourceLink.endsWith(".pdf")) - { + if (resourceLink.endsWith(".html") || resourceLink.endsWith(".txt") || resourceLink.endsWith(".pdf")) { QString resourceAbsoluteFileName = mpDocumentationWidget->getMainWindow()->getOMCProxy()->uriToFilename("modelica://" + resourceLink); QDesktopServices::openUrl("file:///" + resourceAbsoluteFileName); - } - else - { + } else { LibraryTreeNode *pLibraryTreeNode = mpDocumentationWidget->getMainWindow()->getLibraryTreeWidget()->getLibraryTreeNode(resourceLink); // send the new className to DocumentationWidget - if (pLibraryTreeNode) + if (pLibraryTreeNode) { mpDocumentationWidget->showDocumentation(pLibraryTreeNode->getNameStructure()); + } } - } - // if it is normal http request then check if its not redirected to https - else - { + } else { // if it is normal http request then check if its not redirected to https QNetworkAccessManager* accessManager = page()->networkAccessManager(); QNetworkRequest request(url); QNetworkReply* reply = accessManager->get(request); diff --git a/OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp b/OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp index 3a22519f6e4..45e34364cfc 100644 --- a/OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp +++ b/OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp @@ -379,112 +379,89 @@ bool GraphicsView::addComponent(QString className, QPointF position) MainWindow *pMainWindow = mpModelWidget->getModelWidgetContainer()->getMainWindow(); LibraryTreeNode *pLibraryTreeNode; pLibraryTreeNode = mpModelWidget->getModelWidgetContainer()->getMainWindow()->getLibraryTreeWidget()->getLibraryTreeNode(className); - if (!pLibraryTreeNode) + if (!pLibraryTreeNode) { return false; + } StringHandler::ModelicaClasses type = pLibraryTreeNode->getModelicaType(); QString name = pLibraryTreeNode->getName(); OptionsDialog *pOptionsDialog = mpModelWidget->getModelWidgetContainer()->getMainWindow()->getOptionsDialog(); // item not to be dropped on itself; if dropping an item on itself - if (mpModelWidget->getLibraryTreeNode()->getNameStructure().compare(pLibraryTreeNode->getNameStructure()) == 0) - { - if (pOptionsDialog->getNotificationsPage()->getItemDroppedOnItselfCheckBox()->isChecked()) - { + if (mpModelWidget->getLibraryTreeNode()->getNameStructure().compare(pLibraryTreeNode->getNameStructure()) == 0) { + if (pOptionsDialog->getNotificationsPage()->getItemDroppedOnItselfCheckBox()->isChecked()) { NotificationsDialog *pNotificationsDialog = new NotificationsDialog(NotificationsDialog::ItemDroppedOnItself, NotificationsDialog::InformationIcon, mpModelWidget->getModelWidgetContainer()->getMainWindow()); pNotificationsDialog->exec(); } return false; - } - else - { - // check if the model is partial - if (pMainWindow->getOMCProxy()->isPartial(className)) - { - if (pOptionsDialog->getNotificationsPage()->getReplaceableIfPartialCheckBox()->isChecked()) - { + } else { // check if the model is partial + if (pMainWindow->getOMCProxy()->isPartial(className)) { + if (pOptionsDialog->getNotificationsPage()->getReplaceableIfPartialCheckBox()->isChecked()) { NotificationsDialog *pNotificationsDialog = new NotificationsDialog(NotificationsDialog::ReplaceableIfPartial, NotificationsDialog::InformationIcon, mpModelWidget->getModelWidgetContainer()->getMainWindow()); pNotificationsDialog->setNotificationLabelString(GUIMessages::getMessage(GUIMessages::MAKE_REPLACEABLE_IF_PARTIAL) .arg(StringHandler::getModelicaClassType(type).toLower()).arg(name)); - if (!pNotificationsDialog->exec()) + if (!pNotificationsDialog->exec()) { return false; + } } } // get the model defaultComponentPrefixes QString defaultPrefix = pMainWindow->getOMCProxy()->getDefaultComponentPrefixes(className); // get the model defaultComponentName QString defaultName = pMainWindow->getOMCProxy()->getDefaultComponentName(className); - if (defaultName.isEmpty()) - { + if (defaultName.isEmpty()) { name = getUniqueComponentName(name.toLower()); - } - else - { - if (checkComponentName(defaultName)) + } else { + if (checkComponentName(defaultName)) { name = defaultName; - else - { + } else { name = getUniqueComponentName(defaultName); // show the information to the user if we have changed the name of some inner component. - if (defaultPrefix.contains("inner")) - { - if (pOptionsDialog->getNotificationsPage()->getInnerModelNameChangedCheckBox()->isChecked()) - { + if (defaultPrefix.contains("inner")) { + if (pOptionsDialog->getNotificationsPage()->getInnerModelNameChangedCheckBox()->isChecked()) { NotificationsDialog *pNotificationsDialog = new NotificationsDialog(NotificationsDialog::InnerModelNameChanged, NotificationsDialog::InformationIcon, mpModelWidget->getModelWidgetContainer()->getMainWindow()); pNotificationsDialog->setNotificationLabelString(GUIMessages::getMessage(GUIMessages::INNER_MODEL_NAME_CHANGED) .arg(defaultName).arg(name)); - if (!pNotificationsDialog->exec()) + if (!pNotificationsDialog->exec()) { return false; + } } } } } // if dropping an item on the diagram layer - if (mViewType == StringHandler::Diagram) - { + if (mViewType == StringHandler::Diagram) { // if item is a class, model, block, connector or record. then we can drop it to the graphicsview - if ((type == StringHandler::Class) or (type == StringHandler::Model) or (type == StringHandler::Block) or - (type == StringHandler::Connector) or (type == StringHandler::Record)) - { - if (type == StringHandler::Connector) - { + if ((type == StringHandler::Class) || (type == StringHandler::Model) || (type == StringHandler::Block) || + (type == StringHandler::Connector) || (type == StringHandler::Record)) { + if (type == StringHandler::Connector) { addComponentToView(name, className, "", position, 0, type, false); mpModelWidget->getIconGraphicsView()->addComponentToView(name, className, "", position, 0, type); /* When something is added in the icon layer then update the LibraryTreeNode in the Library Browser */ pMainWindow->getLibraryTreeWidget()->loadLibraryComponent(mpModelWidget->getLibraryTreeNode()); - } - else - { + } else { addComponentToView(name, className, "", position, 0, type); } return true; - } - else - { + } else { QMessageBox::information(pMainWindow, QString(Helper::applicationName).append(" - ").append(Helper::information), GUIMessages::getMessage(GUIMessages::DIAGRAM_VIEW_DROP_MSG).arg(className) .arg(StringHandler::getModelicaClassType(type)), Helper::ok); return false; } - } - // if dropping an item on the icon layer - else if (mViewType == StringHandler::Icon) - { + } else if (mViewType == StringHandler::Icon) { // if dropping an item on the icon layer // if item is a connector. then we can drop it to the graphicsview - if (type == StringHandler::Connector) - { + if (type == StringHandler::Connector) { addComponentToView(name, className, "", position, 0, type, false); mpModelWidget->getDiagramGraphicsView()->addComponentToView(name, className, "", position, 0, type); /* When something is added in the icon layer then update the LibraryTreeNode in the Library Browser */ pMainWindow->getLibraryTreeWidget()->loadLibraryComponent(mpModelWidget->getLibraryTreeNode()); return true; - } - else - { + } else { QMessageBox::information(pMainWindow, QString(Helper::applicationName).append(" - ").append(Helper::information), GUIMessages::getMessage(GUIMessages::ICON_VIEW_DROP_MSG).arg(className) .arg(StringHandler::getModelicaClassType(type)), Helper::ok); @@ -2508,7 +2485,7 @@ void ModelWidget::showIconView(bool checked) pSubWindow->setWindowIcon(QIcon(":/Resources/icons/model.svg")); } mpIconGraphicsView->setFocus(); - if (!checked or (checked and mpIconGraphicsView->isVisible())) { + if (!checked || (checked && mpIconGraphicsView->isVisible())) { return; } mpViewTypeLabel->setText(StringHandler::getViewType(StringHandler::Icon)); @@ -2540,7 +2517,7 @@ void ModelWidget::showDiagramView(bool checked) pSubWindow->setWindowIcon(QIcon(":/Resources/icons/modeling.png")); } mpDiagramGraphicsView->setFocus(); - if (!checked or (checked and mpDiagramGraphicsView->isVisible())) { + if (!checked || (checked && mpDiagramGraphicsView->isVisible())) { return; } mpViewTypeLabel->setText(StringHandler::getViewType(StringHandler::Diagram));