Reload merge data (#252,#241)
* Added reloadSource() method to Merge class. * Added reload button to MergeView
This commit is contained in:
@@ -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
|
||||
///
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace glabels
|
||||
QString id() const;
|
||||
QString source() const;
|
||||
void setSource( const QString& source );
|
||||
void reloadSource();
|
||||
|
||||
const QList<Record>& recordList( ) const;
|
||||
|
||||
|
||||
@@ -203,6 +203,15 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Reload button clicked handler
|
||||
///
|
||||
void MergeView::onReloadButtonClicked()
|
||||
{
|
||||
mModel->merge()->reloadSource();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Cell changed handler
|
||||
///
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace glabels
|
||||
void onLocationBrowseButtonClicked();
|
||||
void onSelectAllButtonClicked();
|
||||
void onUnselectAllButtonClicked();
|
||||
void onReloadButtonClicked();
|
||||
void onCellChanged( int iRow, int iCol );
|
||||
|
||||
|
||||
|
||||
+26
-2
@@ -131,6 +131,13 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Reload</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -197,8 +204,8 @@
|
||||
<slot>onLocationBrowseButtonClicked()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>296</x>
|
||||
<y>130</y>
|
||||
<x>534</x>
|
||||
<y>165</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>565</x>
|
||||
@@ -206,11 +213,28 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</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>
|
||||
<slots>
|
||||
<slot>onSelectAllButtonClicked()</slot>
|
||||
<slot>onUnselectAllButtonClicked()</slot>
|
||||
<slot>onFormatComboActivated()</slot>
|
||||
<slot>onLocationBrowseButtonClicked()</slot>
|
||||
<slot>onReloadButtonClicked()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
||||
@@ -301,6 +301,10 @@
|
||||
<source>Browse...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reload</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ObjectEditor</name>
|
||||
|
||||
Reference in New Issue
Block a user