LCOV - code coverage report
Current view: top level - muse/framework/diagnostics/qml/Muse/Diagnostics/system - profilerviewmodel.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 60 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) 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              : #include "profilerviewmodel.h"
      23              : 
      24              : #include "global/profiler.h"
      25              : 
      26              : #include "log.h"
      27              : 
      28              : using namespace muse::diagnostics;
      29              : using namespace muse::profiler;
      30              : 
      31            0 : ProfilerViewModel::ProfilerViewModel(QObject* parent)
      32            0 :     : QAbstractListModel(parent)
      33              : {
      34            0 : }
      35              : 
      36            0 : QVariant ProfilerViewModel::data(const QModelIndex& index, int role) const
      37              : {
      38            0 :     if (!index.isValid()) {
      39            0 :         return QVariant();
      40              :     }
      41              : 
      42            0 :     const Item& item = m_list.at(index.row());
      43            0 :     switch (role) {
      44            0 :     case rData: return QVariant::fromValue(item.data);
      45            0 :     case rGroup: return QVariant::fromValue(item.group);
      46            0 :     default: break;
      47              :     }
      48              : 
      49            0 :     return QVariant();
      50              : }
      51              : 
      52            0 : int ProfilerViewModel::rowCount(const QModelIndex& parent) const
      53              : {
      54              :     Q_UNUSED(parent);
      55            0 :     return m_list.count();
      56              : }
      57              : 
      58            0 : QHash<int, QByteArray> ProfilerViewModel::roleNames() const
      59              : {
      60              :     static const QHash<int, QByteArray> roles = {
      61            0 :         { rData, "dataRole" },
      62            0 :         { rGroup, "groupRole" },
      63            0 :     };
      64            0 :     return roles;
      65            0 : }
      66              : 
      67            0 : void ProfilerViewModel::reload()
      68              : {
      69            0 :     m_allList.clear();
      70              : 
      71            0 :     QString group = "Main thread";
      72            0 :     QString str = QString::fromStdString(Profiler::instance()->threadsDataString(Profiler::Data::OnlyMain));
      73            0 :     QStringList list = str.split("\n", Qt::SkipEmptyParts);
      74            0 :     foreach (const QString& data, list) {
      75            0 :         Item item;
      76            0 :         item.group = group;
      77            0 :         item.data = data;
      78              : 
      79            0 :         m_allList.append(item);
      80            0 :     }
      81              : 
      82            0 :     group = "Other thread";
      83            0 :     str = QString::fromStdString(Profiler::instance()->threadsDataString(Profiler::Data::OnlyOther));
      84            0 :     list = str.split("\n", Qt::SkipEmptyParts);
      85            0 :     foreach (const QString& data, list) {
      86            0 :         Item item;
      87            0 :         item.group = group;
      88            0 :         item.data = data;
      89              : 
      90            0 :         m_allList.append(item);
      91            0 :     }
      92              : 
      93            0 :     find(m_searchText);
      94            0 : }
      95              : 
      96            0 : void ProfilerViewModel::find(const QString& str)
      97              : {
      98            0 :     beginResetModel();
      99              : 
     100            0 :     m_searchText = str;
     101              : 
     102            0 :     if (m_searchText.isEmpty()) {
     103            0 :         m_list = m_allList;
     104              :     } else {
     105            0 :         m_list.clear();
     106            0 :         for (const Item& item : m_allList) {
     107            0 :             if (item.data.contains(m_searchText, Qt::CaseInsensitive)) {
     108            0 :                 m_list.append(item);
     109              :             }
     110              :         }
     111              :     }
     112              : 
     113            0 :     endResetModel();
     114            0 : }
     115              : 
     116            0 : void ProfilerViewModel::clear()
     117              : {
     118            0 :     PROFILER_CLEAR;
     119            0 :     reload();
     120            0 : }
     121              : 
     122            0 : void ProfilerViewModel::print()
     123              : {
     124            0 :     PROFILER_PRINT;
     125            0 : }
        

Generated by: LCOV version 2.0-1