LCOV - code coverage report
Current view: top level - muse/framework/tours/internal - toursconfiguration.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 24 0
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) 2025 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              : #include "toursconfiguration.h"
      23              : 
      24              : #include "settings.h"
      25              : 
      26              : using namespace muse;
      27              : using namespace muse::tours;
      28              : using namespace muse::async;
      29              : 
      30              : static const Settings::Key UI_LAST_SHOWN_TOURS_KEY("tours", "tours/lastShownTours");
      31              : 
      32            0 : String ToursConfiguration::lastShownTourIdForEvent(const String& eventCode) const
      33              : {
      34            0 :     StringList allLastShownTours = lastShownTours();
      35            0 :     for (const String& tourChainId : allLastShownTours) {
      36            0 :         if (tourChainId.startsWith(eventCode)) {
      37            0 :             String chainId = tourChainId;
      38            0 :             return chainId.remove(eventCode + u"/");
      39            0 :         }
      40              :     }
      41              : 
      42            0 :     return String();
      43            0 : }
      44              : 
      45            0 : void ToursConfiguration::setLastShownTourIdForEvent(const String& eventCode, const String& tourId)
      46              : {
      47            0 :     StringList allLastShownTours = lastShownTours();
      48            0 :     bool changed = false;
      49              : 
      50            0 :     String newTourId = eventCode + u"/" + tourId;
      51              : 
      52            0 :     for (size_t i = 0; i < allLastShownTours.size(); ++i) {
      53            0 :         const String& lastTourId = allLastShownTours[i];
      54            0 :         if (lastTourId.startsWith(eventCode)) {
      55            0 :             allLastShownTours[i] = newTourId;
      56            0 :             changed = true;
      57              :         }
      58              :     }
      59              : 
      60            0 :     if (!changed) {
      61            0 :         allLastShownTours.push_back(newTourId);
      62              :     }
      63              : 
      64            0 :     settings()->setSharedValue(UI_LAST_SHOWN_TOURS_KEY, Val(allLastShownTours.join(u",").toStdString()));
      65            0 : }
      66              : 
      67            0 : StringList ToursConfiguration::lastShownTours() const
      68              : {
      69            0 :     return String::fromStdString(settings()->value(UI_LAST_SHOWN_TOURS_KEY).toString()).split(u",");
      70              : }
        

Generated by: LCOV version 2.0-1