Display newlines in merge view (#108)
Display newlines in merge view as printable character
This commit is contained in:
+19
-2
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
const QChar NEWLINE_CHAR = QChar(0x23CE);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
@@ -283,7 +284,8 @@ namespace glabels
|
|||||||
auto* item = new QTableWidgetItem();
|
auto* item = new QTableWidgetItem();
|
||||||
if ( record->contains( mPrimaryKey ) )
|
if ( record->contains( mPrimaryKey ) )
|
||||||
{
|
{
|
||||||
item->setText( (*record)[mPrimaryKey] );
|
auto text = printableTextForView( (*record)[mPrimaryKey] );
|
||||||
|
item->setText( text );
|
||||||
}
|
}
|
||||||
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
|
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
|
||||||
item->setCheckState( record->isSelected() ? Qt::Checked : Qt::Unchecked );
|
item->setCheckState( record->isSelected() ? Qt::Checked : Qt::Unchecked );
|
||||||
@@ -298,7 +300,8 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
if ( record->contains( key ) )
|
if ( record->contains( key ) )
|
||||||
{
|
{
|
||||||
auto* item = new QTableWidgetItem( (*record)[key] );
|
auto text = printableTextForView( (*record)[key] );
|
||||||
|
auto* item = new QTableWidgetItem( text );
|
||||||
item->setFlags( Qt::ItemIsEnabled );
|
item->setFlags( Qt::ItemIsEnabled );
|
||||||
recordsTable->setItem( iRow, iCol, item );
|
recordsTable->setItem( iRow, iCol, item );
|
||||||
recordsTable->resizeColumnToContents( iCol );
|
recordsTable->resizeColumnToContents( iCol );
|
||||||
@@ -319,4 +322,18 @@ namespace glabels
|
|||||||
mBlock = false;
|
mBlock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// modify text to be printable e.g. replace newlines
|
||||||
|
///
|
||||||
|
QString MergeView::printableTextForView( QString text )
|
||||||
|
{
|
||||||
|
// Replace windows style newlines
|
||||||
|
text.replace("\r\n", NEWLINE_CHAR);
|
||||||
|
|
||||||
|
// Replace unix style newlines
|
||||||
|
text.replace("\n", NEWLINE_CHAR);
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ namespace glabels
|
|||||||
private:
|
private:
|
||||||
void loadHeaders( merge::Merge* merge );
|
void loadHeaders( merge::Merge* merge );
|
||||||
void loadTable( merge::Merge* merge );
|
void loadTable( merge::Merge* merge );
|
||||||
|
static QString printableTextForView( QString text );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user