Skip to content

Commit

Permalink
Merge pull request #5119 from opengisch/QF-3983-broken-changes
Browse files Browse the repository at this point in the history
Fix changes list popup looking broken when empty
  • Loading branch information
suricactus committed Mar 22, 2024
2 parents 34e5c6e + fca430d commit 11083eb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/core/deltalistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ DeltaListModel::DeltaListModel( QJsonDocument deltasStatusList )
mIsValid = true;
mDeltas.append( delta );
}

connect( this, &DeltaListModel::rowsInserted, this, &DeltaListModel::rowCountChanged );
connect( this, &DeltaListModel::rowsRemoved, this, &DeltaListModel::rowCountChanged );
}

int DeltaListModel::rowCount( const QModelIndex &parent ) const
Expand Down
7 changes: 6 additions & 1 deletion src/core/deltalistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ class DeltaListModel : public QAbstractListModel
DeltaListModel() = default;
explicit DeltaListModel( QJsonDocument deltasStatusList );

Q_PROPERTY( int rowCount READ rowCount NOTIFY rowCountChanged )

//! Returns number of rows.
int rowCount( const QModelIndex &parent ) const override;
int rowCount( const QModelIndex &parent = QModelIndex() ) const override;

//! Returns the data at given \a index with given \a role.
QVariant data( const QModelIndex &index, int role ) const override;
Expand All @@ -89,6 +91,9 @@ class DeltaListModel : public QAbstractListModel
//! Returns a combined output for all deltas, separated by a new line.
QString combinedOutput() const;

signals:
void rowCountChanged();

private:
QJsonDocument mJson;
bool mIsValid = false;
Expand Down
17 changes: 15 additions & 2 deletions src/qml/QFieldCloudDeltaHistory.qml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Popup {
}
iconSource: Theme.getThemeIcon( 'ic_close_black_24dp' )
iconColor: Theme.mainTextColor
bgcolor: "white"
bgcolor: Theme.mainBackgroundColor

onClicked: {
popup.close();
Expand All @@ -74,10 +74,23 @@ Popup {
spacing: 4
width: parent.width

Label {
leftPadding: 48
rightPadding: 48
width: parent.width
visible: !!model && model.rowCount === 0

text: qsTr( "No changes have been pushed yet!" )
color: Theme.mainTextDisabledColor
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
}

ListView {
id: deltaList
width: parent.width
height: mainWindow.height - 160
height: visible ? mainWindow.height - 160 : 0
visible: deltaList.model && deltaList.model.rowCount !== 0
clip: true

delegate: Rectangle {
Expand Down

0 comments on commit 11083eb

Please sign in to comment.