Reload merge data (#252,#241)

* Added reloadSource() method to Merge class.
* Added reload button to MergeView
This commit is contained in:
Jaye Evins
2025-11-29 00:16:21 -05:00
committed by GitHub
parent 1ebddfc534
commit 1f4f4aa221
6 changed files with 76 additions and 2 deletions
+35
View File
@@ -77,6 +77,41 @@ namespace glabels
} }
///
/// Reload source
///
void Merge::reloadSource()
{
// temporary map of original selections
QMap<QString,bool> origSelectionMap;
for ( auto& record : mRecordList )
{
origSelectionMap[ record[ primaryKey() ] ] = record.isSelected();
}
// Clear the original records
mRecordList.clear();
// Read the new records, preserve any original selections
open();
for ( Record record = readNextRecord(); !record.isEmpty(); record = readNextRecord() )
{
auto key = record[ primaryKey() ];
auto it = origSelectionMap.find( key );
if ( it != origSelectionMap.end() )
{
record.setSelected( it.value() );
}
mRecordList.push_back( record );
}
close();
emit sourceChanged();
}
/// ///
/// Get record list /// Get record list
/// ///
+1
View File
@@ -70,6 +70,7 @@ namespace glabels
QString id() const; QString id() const;
QString source() const; QString source() const;
void setSource( const QString& source ); void setSource( const QString& source );
void reloadSource();
const QList<Record>& recordList( ) const; const QList<Record>& recordList( ) const;
+9
View File
@@ -203,6 +203,15 @@ namespace glabels
} }
///
/// Reload button clicked handler
///
void MergeView::onReloadButtonClicked()
{
mModel->merge()->reloadSource();
}
/// ///
/// Cell changed handler /// Cell changed handler
/// ///
+1
View File
@@ -70,6 +70,7 @@ namespace glabels
void onLocationBrowseButtonClicked(); void onLocationBrowseButtonClicked();
void onSelectAllButtonClicked(); void onSelectAllButtonClicked();
void onUnselectAllButtonClicked(); void onUnselectAllButtonClicked();
void onReloadButtonClicked();
void onCellChanged( int iRow, int iCol ); void onCellChanged( int iRow, int iCol );
+26 -2
View File
@@ -131,6 +131,13 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Reload</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@@ -197,8 +204,8 @@
<slot>onLocationBrowseButtonClicked()</slot> <slot>onLocationBrowseButtonClicked()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>296</x> <x>534</x>
<y>130</y> <y>165</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>565</x> <x>565</x>
@@ -206,11 +213,28 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>MergeView</receiver>
<slot>onReloadButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>510</x>
<y>552</y>
</hint>
<hint type="destinationlabel">
<x>539</x>
<y>602</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>onSelectAllButtonClicked()</slot> <slot>onSelectAllButtonClicked()</slot>
<slot>onUnselectAllButtonClicked()</slot> <slot>onUnselectAllButtonClicked()</slot>
<slot>onFormatComboActivated()</slot> <slot>onFormatComboActivated()</slot>
<slot>onLocationBrowseButtonClicked()</slot> <slot>onLocationBrowseButtonClicked()</slot>
<slot>onReloadButtonClicked()</slot>
</slots> </slots>
</ui> </ui>
+4
View File
@@ -301,6 +301,10 @@
<source>Browse...</source> <source>Browse...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Reload</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>ObjectEditor</name> <name>ObjectEditor</name>