Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix changes list popup looking broken when empty #5119

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading