Skip to content

Commit

Permalink
fix #190991 update scoreList order when tabMoved
Browse files Browse the repository at this point in the history
Also update the tab order for the other ScoreTab.
However since scoreList is a shared pointer between both ScoreTabs, make sure to only update the pointer once.
  • Loading branch information
Eric Fontaine authored and lasconic committed Apr 24, 2017
1 parent fb326d5 commit dd7fbe2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions mscore/scoretab.cpp
Expand Up @@ -79,6 +79,7 @@ ScoreTab::ScoreTab(QList<MasterScore*>* sl, QWidget* parent)
connect(tab, SIGNAL(currentChanged(int)), this, SLOT(setCurrent(int)));
connect(tab2, SIGNAL(currentChanged(int)), this, SLOT(setExcerpt(int)));
connect(tab, SIGNAL(tabCloseRequested(int)), this, SIGNAL(tabCloseRequested(int)));
connect(tab, SIGNAL(tabMoved(int,int)), this, SLOT(tabMoved(int,int)));
}

ScoreTab::~ScoreTab()
Expand Down Expand Up @@ -142,6 +143,31 @@ void ScoreTab::clearTab2()
tab2->blockSignals(false);
}

//---------------------------------------------------------
// tabMoved
//---------------------------------------------------------

void ScoreTab::tabMoved(int from, int to)
{
static bool scoreListChanged = false;
if (scoreListChanged == false) {
qDebug("Moved score tab %d to %d", from, to);
scoreList->move(from, to);

// now move the tab in the other ScoreTab...but don't update the scoreList a second time!
scoreListChanged = true;
if (this == mscore->getTab1()) {
if (mscore->getTab2())
mscore->getTab2()->getTab()->moveTab(from, to);
}
else if (this == mscore->getTab2()) {
if (mscore->getTab1())
mscore->getTab1()->getTab()->moveTab(from, to);
}
scoreListChanged = false;
}
}

//---------------------------------------------------------
// setCurrent
//---------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions mscore/scoretab.h
Expand Up @@ -62,11 +62,14 @@ class ScoreTab : public QWidget {
void updateExcerpts();
void setExcerpt(int);
void setCurrent(int);
void tabMoved(int, int);

public:
ScoreTab(QList<MasterScore*>*, QWidget* parent = 0);
~ScoreTab();

QTabBar* getTab() const { return tab; }

void insertTab(MasterScore*);
void setTabText(int, const QString&);
int currentIndex() const;
Expand Down

0 comments on commit dd7fbe2

Please sign in to comment.