fixed updating state of the instruments panel controls when there is no opened notation
This commit is contained in:
parent
dbccb8664c
commit
7fc1c5abed
4 changed files with 45 additions and 31 deletions
|
@ -28,9 +28,11 @@ Item {
|
|||
|
||||
InstrumentsControlPanel {
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
isMovingUpAvailable: instrumentTreeModel.isMovingUpAvailable
|
||||
isMovingDownAvailable: instrumentTreeModel.isMovingDownAvailable
|
||||
isAddingAvailable: instrumentTreeModel.isAddingAvailable
|
||||
isRemovingAvailable: instrumentTreeModel.isRemovingAvailable
|
||||
|
||||
onAddRequested: {
|
||||
|
@ -51,14 +53,14 @@ Item {
|
|||
}
|
||||
|
||||
StyledTextLabel {
|
||||
Layout.topMargin: 12
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.topMargin: 12
|
||||
Layout.leftMargin: 20
|
||||
Layout.rightMargin: 20
|
||||
|
||||
text: qsTrc("instruments", "There are no instruments in your score. To choose some, press <b>Add</b>, or use the shortcut <b>‘i’</b>")
|
||||
visible: instrumentsTreeView.isEmpty
|
||||
visible: instrumentTreeModel.isEmpty && instrumentTreeModel.isAddingAvailable
|
||||
|
||||
verticalAlignment: Qt.AlignTop
|
||||
wrapMode: Text.WordWrap
|
||||
|
@ -70,8 +72,7 @@ Item {
|
|||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
property alias isEmpty: instrumentTreeModel.isEmpty
|
||||
visible: !isEmpty
|
||||
visible: !instrumentTreeModel.isEmpty
|
||||
|
||||
model: InstrumentPanelTreeModel {
|
||||
id: instrumentTreeModel
|
||||
|
|
|
@ -9,8 +9,8 @@ RowLayout {
|
|||
|
||||
property bool isMovingUpAvailable: false
|
||||
property bool isMovingDownAvailable: false
|
||||
property bool isRearrangementAvailable: false
|
||||
property bool isRemovingAvailable: false
|
||||
property bool isAddingAvailable: value
|
||||
|
||||
signal addRequested()
|
||||
signal moveUpRequested()
|
||||
|
@ -21,8 +21,11 @@ RowLayout {
|
|||
|
||||
FlatButton {
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: qsTrc("instruments", "Add")
|
||||
|
||||
enabled: root.isAddingAvailable
|
||||
|
||||
onClicked: {
|
||||
root.addRequested()
|
||||
}
|
||||
|
|
|
@ -70,10 +70,12 @@ InstrumentPanelTreeModel::~InstrumentPanelTreeModel()
|
|||
void InstrumentPanelTreeModel::clear()
|
||||
{
|
||||
beginResetModel();
|
||||
m_selectionModel->clear();
|
||||
deleteItems();
|
||||
endResetModel();
|
||||
|
||||
emit isEmptyChanged();
|
||||
emit isAddingAvailableChanged(false);
|
||||
}
|
||||
|
||||
void InstrumentPanelTreeModel::deleteItems()
|
||||
|
@ -120,6 +122,9 @@ void InstrumentPanelTreeModel::load()
|
|||
});
|
||||
|
||||
endResetModel();
|
||||
|
||||
emit isEmptyChanged();
|
||||
emit isAddingAvailableChanged(true);
|
||||
}
|
||||
|
||||
IDList InstrumentPanelTreeModel::currentNotationPartIdList() const
|
||||
|
@ -401,6 +406,11 @@ bool InstrumentPanelTreeModel::isRemovingAvailable() const
|
|||
return m_isRemovingAvailable;
|
||||
}
|
||||
|
||||
bool InstrumentPanelTreeModel::isAddingAvailable() const
|
||||
{
|
||||
return m_notationParts != nullptr;
|
||||
}
|
||||
|
||||
bool InstrumentPanelTreeModel::isEmpty() const
|
||||
{
|
||||
return m_rootItem ? m_rootItem->isEmpty() : true;
|
||||
|
|
|
@ -45,34 +45,16 @@ class InstrumentPanelTreeModel : public QAbstractItemModel, public async::Asynca
|
|||
INJECT(instruments, framework::IInteractive, interactive)
|
||||
|
||||
Q_PROPERTY(QItemSelectionModel * selectionModel READ selectionModel NOTIFY selectionChanged)
|
||||
Q_PROPERTY(bool isMovingUpAvailable READ isMovingUpAvailable WRITE setIsMovingUpAvailable NOTIFY isMovingUpAvailableChanged)
|
||||
Q_PROPERTY(bool isMovingDownAvailable READ isMovingDownAvailable WRITE setIsMovingDownAvailable NOTIFY isMovingDownAvailableChanged)
|
||||
Q_PROPERTY(bool isRemovingAvailable READ isRemovingAvailable WRITE setIsRemovingAvailable NOTIFY isRemovingAvailableChanged)
|
||||
Q_PROPERTY(bool isMovingUpAvailable READ isMovingUpAvailable NOTIFY isMovingUpAvailableChanged)
|
||||
Q_PROPERTY(bool isMovingDownAvailable READ isMovingDownAvailable NOTIFY isMovingDownAvailableChanged)
|
||||
Q_PROPERTY(bool isRemovingAvailable READ isRemovingAvailable NOTIFY isRemovingAvailableChanged)
|
||||
Q_PROPERTY(bool isAddingAvailable READ isAddingAvailable NOTIFY isAddingAvailableChanged)
|
||||
Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY isEmptyChanged)
|
||||
|
||||
public:
|
||||
enum RoleNames {
|
||||
ItemRole = Qt::UserRole + 1
|
||||
};
|
||||
|
||||
explicit InstrumentPanelTreeModel(QObject* parent = nullptr);
|
||||
~InstrumentPanelTreeModel() override;
|
||||
|
||||
Q_INVOKABLE void load();
|
||||
Q_INVOKABLE void selectRow(const QModelIndex& rowIndex, const bool isMultipleSelectionModeOn);
|
||||
Q_INVOKABLE void addInstruments();
|
||||
Q_INVOKABLE void moveSelectedRowsUp();
|
||||
Q_INVOKABLE void moveSelectedRowsDown();
|
||||
Q_INVOKABLE void removeSelectedRows();
|
||||
|
||||
bool isMovingUpAvailable() const;
|
||||
bool isMovingDownAvailable() const;
|
||||
bool isRemovingAvailable() const;
|
||||
bool isEmpty() const;
|
||||
|
||||
Q_INVOKABLE bool moveRows(const QModelIndex& sourceParent, int sourceRow, int count, const QModelIndex& destinationParent,
|
||||
int destinationChild) override;
|
||||
|
||||
QModelIndex index(int row, int column, const QModelIndex& parent) const override;
|
||||
QModelIndex parent(const QModelIndex& child) const override;
|
||||
int rowCount(const QModelIndex& parent) const override;
|
||||
|
@ -81,16 +63,26 @@ public:
|
|||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
QItemSelectionModel* selectionModel() const;
|
||||
bool isMovingUpAvailable() const;
|
||||
bool isMovingDownAvailable() const;
|
||||
bool isRemovingAvailable() const;
|
||||
bool isAddingAvailable() const;
|
||||
bool isEmpty() const;
|
||||
|
||||
public slots:
|
||||
void setIsMovingUpAvailable(bool isMovingUpAvailable);
|
||||
void setIsMovingDownAvailable(bool isMovingDownAvailable);
|
||||
void setIsRemovingAvailable(bool isRemovingAvailable);
|
||||
Q_INVOKABLE void load();
|
||||
Q_INVOKABLE void selectRow(const QModelIndex& rowIndex, const bool isMultipleSelectionModeOn);
|
||||
Q_INVOKABLE void addInstruments();
|
||||
Q_INVOKABLE void moveSelectedRowsUp();
|
||||
Q_INVOKABLE void moveSelectedRowsDown();
|
||||
Q_INVOKABLE void removeSelectedRows();
|
||||
|
||||
Q_INVOKABLE bool moveRows(const QModelIndex& sourceParent, int sourceRow, int count, const QModelIndex& destinationParent,
|
||||
int destinationChild) override;
|
||||
signals:
|
||||
void selectionChanged();
|
||||
void isMovingUpAvailableChanged(bool isMovingUpAvailable);
|
||||
void isMovingDownAvailableChanged(bool isMovingDownAvailable);
|
||||
void isAddingAvailableChanged(bool isAddingAvailable);
|
||||
void isRemovingAvailableChanged(bool isRemovingAvailable);
|
||||
void isEmptyChanged();
|
||||
|
||||
|
@ -101,9 +93,17 @@ private slots:
|
|||
void updateRemovingAvailability();
|
||||
|
||||
private:
|
||||
enum RoleNames {
|
||||
ItemRole = Qt::UserRole + 1
|
||||
};
|
||||
|
||||
void clear();
|
||||
void deleteItems();
|
||||
|
||||
void setIsMovingUpAvailable(bool isMovingUpAvailable);
|
||||
void setIsMovingDownAvailable(bool isMovingDownAvailable);
|
||||
void setIsRemovingAvailable(bool isRemovingAvailable);
|
||||
|
||||
bool removeRows(int row, int count, const QModelIndex& parent) override;
|
||||
|
||||
notation::IDList currentNotationPartIdList() const;
|
||||
|
|
Loading…
Reference in a new issue