LCOV - code coverage report
Current view: top level - muse/framework/ui/qml/Muse/Ui - navigationsection.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 58.9 % 95 56
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #include "navigationsection.h"
      24              : 
      25              : #include <QQuickWindow>
      26              : 
      27              : #include "log.h"
      28              : 
      29              : using namespace muse;
      30              : using namespace muse::ui;
      31              : 
      32            0 : NavigationSection::NavigationSection(QObject* parent)
      33            0 :     : AbstractNavigation(parent)
      34              : {
      35            0 : }
      36              : 
      37           64 : NavigationSection::NavigationSection(const muse::modularity::ContextPtr& iocCtx, QObject* parent)
      38           64 :     : AbstractNavigation(iocCtx, parent)
      39              : {
      40           64 : }
      41              : 
      42          128 : NavigationSection::~NavigationSection()
      43              : {
      44           64 :     if (m_type == QmlType::Ignore) {
      45            0 :         return;
      46              :     }
      47              : 
      48           64 :     if (navigationController()) {
      49           64 :         navigationController()->unreg(this);
      50              :     }
      51          128 : }
      52              : 
      53            0 : void NavigationSection::componentComplete()
      54              : {
      55              :     //! NOTE Reg after set properties.
      56            0 :     IF_ASSERT_FAILED(!m_name.isEmpty()) {
      57            0 :         return;
      58              :     }
      59              : 
      60            0 :     IF_ASSERT_FAILED(order() > -1) {
      61            0 :         return;
      62              :     }
      63              : 
      64            0 :     if (m_type == QmlType::Ignore) {
      65            0 :         LOGW() << "section is ignored, name: " << m_name;
      66            0 :         return;
      67              :     }
      68              : 
      69            0 :     navigationController()->reg(this);
      70              : }
      71              : 
      72           10 : QString NavigationSection::name() const
      73              : {
      74           10 :     return AbstractNavigation::name();
      75              : }
      76              : 
      77          117 : const INavigation::Index& NavigationSection::index() const
      78              : {
      79          117 :     return AbstractNavigation::index();
      80              : }
      81              : 
      82            0 : void NavigationSection::setIndex(const Index& index)
      83              : {
      84            0 :     AbstractNavigation::setIndex(index);
      85            0 : }
      86              : 
      87            0 : async::Channel<INavigation::Index> NavigationSection::indexChanged() const
      88              : {
      89            0 :     return AbstractNavigation::indexChanged();
      90              : }
      91              : 
      92          103 : bool NavigationSection::enabled() const
      93              : {
      94          103 :     if (!AbstractNavigation::enabled()) {
      95            8 :         return false;
      96              :     }
      97              : 
      98           95 :     bool enbl = false;
      99           95 :     for (INavigationPanel* p : m_panels) {
     100           91 :         if (p->enabled()) {
     101           91 :             enbl = true;
     102           91 :             break;
     103              :         }
     104              :     }
     105              : 
     106           95 :     return enbl;
     107              : }
     108              : 
     109           78 : async::Channel<bool> NavigationSection::enabledChanged() const
     110              : {
     111           78 :     return AbstractNavigation::enabledChanged();
     112              : }
     113              : 
     114          223 : bool NavigationSection::active() const
     115              : {
     116          223 :     return AbstractNavigation::active();
     117              : }
     118              : 
     119          141 : void NavigationSection::setActive(bool arg)
     120              : {
     121          141 :     AbstractNavigation::setActive(arg);
     122          141 : }
     123              : 
     124            0 : async::Channel<bool> NavigationSection::activeChanged() const
     125              : {
     126            0 :     return AbstractNavigation::activeChanged();
     127              : }
     128              : 
     129            0 : void NavigationSection::onEvent(EventPtr e)
     130              : {
     131            0 :     AbstractNavigation::onEvent(e);
     132            0 : }
     133              : 
     134            0 : QWindow* NavigationSection::window() const
     135              : {
     136            0 :     return AbstractNavigation::window();
     137              : }
     138              : 
     139            0 : QQuickItem* muse::ui::NavigationSection::visualItem() const
     140              : {
     141            0 :     return AbstractNavigation::visualItem();
     142              : }
     143              : 
     144          124 : void NavigationSection::addPanel(NavigationPanel* panel)
     145              : {
     146          125 :     TRACEFUNC;
     147          124 :     IF_ASSERT_FAILED(panel) {
     148            0 :         return;
     149              :     }
     150              : 
     151          124 :     m_panels.insert(panel);
     152              : 
     153          124 :     if (m_panelsListChanged.isConnected()) {
     154            0 :         m_panelsListChanged.notify();
     155              :     }
     156          124 : }
     157              : 
     158            4 : void NavigationSection::removePanel(NavigationPanel* panel)
     159              : {
     160            5 :     TRACEFUNC;
     161            4 :     IF_ASSERT_FAILED(panel) {
     162            0 :         return;
     163              :     }
     164              : 
     165            4 :     m_panels.erase(panel);
     166              : 
     167            4 :     if (m_panelsListChanged.isConnected()) {
     168            0 :         m_panelsListChanged.notify();
     169              :     }
     170            4 : }
     171              : 
     172          130 : void NavigationSection::setOnActiveRequested(const OnActiveRequested& func)
     173              : {
     174          130 :     m_onActiveRequested = func;
     175          130 : }
     176              : 
     177           30 : void NavigationSection::requestActive(INavigationPanel* panel, INavigationControl* control, bool enableHighlight,
     178              :                                       INavigation::ActivationType activationType)
     179              : {
     180           30 :     if (m_onActiveRequested) {
     181           30 :         m_onActiveRequested(this, panel, control, enableHighlight, activationType);
     182              :     }
     183           30 : }
     184              : 
     185            0 : void NavigationSection::requestPriority()
     186              : {
     187            0 :     if (navigationController()) {
     188            0 :         navigationController()->setPrioritySection(this);
     189              :     }
     190            0 : }
     191              : 
     192           24 : INavigationSection::Type NavigationSection::type() const
     193              : {
     194           24 :     return static_cast<INavigationSection::Type>(m_type);
     195              : }
     196              : 
     197            0 : NavigationSection::QmlType NavigationSection::type_property() const
     198              : {
     199            0 :     return m_type;
     200              : }
     201              : 
     202           70 : void NavigationSection::setType(QmlType type)
     203              : {
     204           70 :     if (m_type == type) {
     205           64 :         return;
     206              :     }
     207              : 
     208            6 :     m_type = type;
     209            6 :     emit typeChanged(m_type);
     210              : }
     211              : 
     212          171 : const std::set<INavigationPanel*>& NavigationSection::panels() const
     213              : {
     214          171 :     return m_panels;
     215              : }
     216              : 
     217            0 : async::Notification NavigationSection::panelsListChanged() const
     218              : {
     219            0 :     return m_panelsListChanged;
     220              : }
        

Generated by: LCOV version 2.0-1