Skip to content

Commit

Permalink
Merge pull request #2270 from vgstef/partsOrder
Browse files Browse the repository at this point in the history
Add reorder parts buttons in parts dialog
  • Loading branch information
lasconic committed Nov 3, 2015
2 parents b9d5001 + 2f28070 commit 528018b
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
43 changes: 43 additions & 0 deletions mscore/excerptsdialog.cpp
Expand Up @@ -80,6 +80,8 @@ ExcerptsDialog::ExcerptsDialog(Score* s, QWidget* parent)
connect(newButton, SIGNAL(clicked()), SLOT(newClicked()));
connect(newAllButton, SIGNAL(clicked()), SLOT(newAllClicked()));
connect(deleteButton, SIGNAL(clicked()), SLOT(deleteClicked()));
connect(moveUpButton, SIGNAL(clicked()), SLOT(moveUpClicked()));
connect(moveDownButton, SIGNAL(clicked()), SLOT(moveDownClicked()));
connect(excerptList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
SLOT(excerptChanged(QListWidgetItem*, QListWidgetItem*)));
connect(partList, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
Expand Down Expand Up @@ -188,6 +190,47 @@ void ExcerptsDialog::newAllClicked()
}
}

//---------------------------------------------------------
// moveUpClicked
//---------------------------------------------------------

void ExcerptsDialog::moveUpClicked()
{
QListWidgetItem* cur = excerptList->currentItem();
if (cur == 0)
return;
int currentRow = excerptList->currentRow();
if (currentRow <= 0)
return;
QListWidgetItem* currentItem = excerptList->takeItem(currentRow);
excerptList->insertItem(currentRow - 1, currentItem);
excerptList->setCurrentRow(currentRow - 1);

score->excerpts().swap(currentRow, currentRow-1);
score->setExcerptsChanged(true);
}

//---------------------------------------------------------
// moveDownClicked
//---------------------------------------------------------

void ExcerptsDialog::moveDownClicked()
{
QListWidgetItem* cur = excerptList->currentItem();
if (cur == 0)
return;
int currentRow = excerptList->currentRow();
int nbRows = excerptList->count();
if (currentRow >= nbRows - 1)
return;
QListWidgetItem* currentItem = excerptList->takeItem(currentRow);
excerptList->insertItem(currentRow + 1, currentItem);
excerptList->setCurrentRow(currentRow + 1);

score->excerpts().swap(currentRow, currentRow+1);
score->setExcerptsChanged(true);
}

//---------------------------------------------------------
// excerptChanged
//---------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions mscore/excerptsdialog.h
Expand Up @@ -69,6 +69,8 @@ class ExcerptsDialog : public QDialog, private Ui::ExcerptsDialog {
void deleteClicked();
void newClicked();
void newAllClicked();
void moveUpClicked();
void moveDownClicked();
void excerptChanged(QListWidgetItem* cur, QListWidgetItem* prev);
void partDoubleClicked(QListWidgetItem*);
void partClicked(QListWidgetItem*);
Expand Down
17 changes: 17 additions & 0 deletions mscore/excerptsdialog.ui
Expand Up @@ -57,6 +57,9 @@
<layout class="QVBoxLayout">
<item>
<widget class="QListWidget" name="excerptList">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -84,6 +87,20 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="moveUpButton">
<property name="text">
<string>Up</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveDownButton">
<property name="text">
<string>Down</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="newAllButton">
<property name="text">
Expand Down

0 comments on commit 528018b

Please sign in to comment.