Skip to content

Commit

Permalink
Merge pull request musescore#8949 from igorkorsukov/engraving/debug_t…
Browse files Browse the repository at this point in the history
…ree2

Added diagnostic engraving elements tree
  • Loading branch information
Eism authored Aug 27, 2021
2 parents a455378 + 5dd67b9 commit 56c8b43
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 74 deletions.
10 changes: 5 additions & 5 deletions src/diagnostics/idiagnosticengravingregister.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class IDiagnosticEngravingRegister : MODULE_EXPORT_INTERFACE
public:
virtual ~IDiagnosticEngravingRegister() = default;

virtual void reg(Ms::ScoreElement* e) = 0;
virtual void unreg(Ms::ScoreElement* e) = 0;
virtual std::list<Ms::ScoreElement*> elements() const = 0;
virtual async::Channel<Ms::ScoreElement*> registred() const = 0;
virtual async::Channel<Ms::ScoreElement*> unregistred() const = 0;
virtual void reg(const Ms::ScoreElement* e) = 0;
virtual void unreg(const Ms::ScoreElement* e) = 0;
virtual std::list<const Ms::ScoreElement*> elements() const = 0;
virtual async::Channel<const Ms::ScoreElement*> registred() const = 0;
virtual async::Channel<const Ms::ScoreElement*> unregistred() const = 0;
};
}

Expand Down
10 changes: 5 additions & 5 deletions src/diagnostics/internal/diagnosticengravingregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

using namespace mu::diagnostics;

void DiagnosticEngravingRegister::reg(Ms::ScoreElement* e)
void DiagnosticEngravingRegister::reg(const Ms::ScoreElement* e)
{
if (e->score()->isPaletteScore()) {
return;
Expand All @@ -35,23 +35,23 @@ void DiagnosticEngravingRegister::reg(Ms::ScoreElement* e)
m_registred.send(e);
}

void DiagnosticEngravingRegister::unreg(Ms::ScoreElement* e)
void DiagnosticEngravingRegister::unreg(const Ms::ScoreElement* e)
{
m_elements.remove(e);
m_unregistred.send(e);
}

std::list<Ms::ScoreElement*> DiagnosticEngravingRegister::elements() const
std::list<const Ms::ScoreElement*> DiagnosticEngravingRegister::elements() const
{
return m_elements;
}

mu::async::Channel<Ms::ScoreElement*> DiagnosticEngravingRegister::registred() const
mu::async::Channel<const Ms::ScoreElement*> DiagnosticEngravingRegister::registred() const
{
return m_registred;
}

mu::async::Channel<Ms::ScoreElement*> DiagnosticEngravingRegister::unregistred() const
mu::async::Channel<const Ms::ScoreElement*> DiagnosticEngravingRegister::unregistred() const
{
return m_unregistred;
}
16 changes: 8 additions & 8 deletions src/diagnostics/internal/diagnosticengravingregister.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ class DiagnosticEngravingRegister : public IDiagnosticEngravingRegister
public:
DiagnosticEngravingRegister() = default;

void reg(Ms::ScoreElement* e) override;
void unreg(Ms::ScoreElement* e) override;
std::list<Ms::ScoreElement*> elements() const override;
async::Channel<Ms::ScoreElement*> registred() const override;
async::Channel<Ms::ScoreElement*> unregistred() const override;
void reg(const Ms::ScoreElement* e) override;
void unreg(const Ms::ScoreElement* e) override;
std::list<const Ms::ScoreElement*> elements() const override;
async::Channel<const Ms::ScoreElement*> registred() const override;
async::Channel<const Ms::ScoreElement*> unregistred() const override;

private:

std::list<Ms::ScoreElement*> m_elements;
async::Channel<Ms::ScoreElement*> m_registred;
async::Channel<Ms::ScoreElement*> m_unregistred;
std::list<const Ms::ScoreElement*> m_elements;
async::Channel<const Ms::ScoreElement*> m_registred;
async::Channel<const Ms::ScoreElement*> m_unregistred;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Rectangle {
function positionViewAtIndex(index) {
var rows = -1
while (index.valid) {
var r = accessibleModel.indexRow(index) + 1
var r = index.row + 1
rows += r
index = view.model.parent(index)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Rectangle {

Item {
id: tools
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 8
Expand All @@ -58,39 +59,124 @@ Rectangle {
}

StyledTextLabel {
id: summaryLabel
anchors.top: parent.top
anchors.left: reloadBtn.right
anchors.right: parent.right
anchors.leftMargin: 8
height: 32
verticalAlignment: Text.AlignTop
horizontalAlignment: Text.AlignLeft
text: elementsModel.summary
visible: true
}

FlatButton {
id: moreBtn
anchors.right: parent.right
text: infoLable.visible ? "Less" : "More"
onClicked: infoLable.visible = !infoLable.visible
}

StyledTextLabel {
id: infoLable
anchors.top: reloadBtn.bottom
anchors.left: parent.left
anchors.right: parent.right
height: implicitHeight
height: visible ? implicitHeight : 0
verticalAlignment: Text.AlignTop
horizontalAlignment: Text.AlignLeft
text: elementsModel.info
visible: false
}
}

ListView {
TreeView {
id: view
anchors.top: tools.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
clip: true

headerVisible: false

model: elementsModel

delegate: Item {
id: delgt
width: parent.width
height: 48
function positionViewAtIndex(index) {
var rows = -1
while (index.valid) {
var r = index.row + 1
rows += r
index = view.model.parent(index)
}

__listView.positionViewAtIndex(rows, ListView.Center)
}

function expandBranch(index) {
var idxs = []
var parent = view.model.parent(index)
while (parent.valid) {
idxs.push(parent)
parent = view.model.parent(parent)
}

for(var i = (idxs.length - 1); i >= 0; --i) {
var idx = idxs[i]
view.expand(idx)
}
}

function collapseBranch(index) {
var idxs = []
idxs.push(index)
var parent = view.model.parent(index)
while (parent.valid) {
idxs.push(parent)
parent = view.model.parent(parent)
}

for(var i = 0; i < idxs.length; ++i) {
var idx = idxs[i]
view.collapse(idx)
}
}

TableViewColumn {
role: "itemData"
}

style: TreeViewStyle {
indentation: styleData.depth
rowDelegate: Rectangle {
height: 24
width: parent.width
color: styleData.row%2 == 0 ? root.color : ui.theme.backgroundSecondaryColor
}
}

property var item: itemData
itemDelegate: Item {
id: item

StyledTextLabel {
id: secLabel
anchors.fill: parent
anchors.margins: 8
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
elide: Text.ElideNone
text: model.index + ": " + delgt.item.name
text: styleData.value.name
}

MouseArea {
anchors.fill: parent
onClicked: {
if (!styleData.isExpanded) {
view.expand(styleData.index)
} else {
view.collapse(styleData.index)
}
}
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/diagnostics/view/diagnosticaccessiblemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ QModelIndex DiagnosticAccessibleModel::index(int row, int column, const QModelIn
return QModelIndex();
}

int DiagnosticAccessibleModel::indexRow(const QModelIndex& idx) const
{
return idx.row();
}

QModelIndex DiagnosticAccessibleModel::parent(const QModelIndex& child) const
{
if (!m_rootItem) {
Expand Down
2 changes: 0 additions & 2 deletions src/diagnostics/view/diagnosticaccessiblemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class DiagnosticAccessibleModel : public QAbstractItemModel, public async::Async
Q_INVOKABLE void init();
Q_INVOKABLE void reload();

Q_INVOKABLE int indexRow(const QModelIndex& idx) const;

static void dumpTree();

public slots:
Expand Down
Loading

0 comments on commit 56c8b43

Please sign in to comment.