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

Display newlines in merge view #108

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 19 additions & 2 deletions glabels/MergeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

namespace glabels
{
const QChar NEWLINE_CHAR = QChar(0x23CE);

///
/// Constructor
Expand Down Expand Up @@ -283,7 +284,8 @@ namespace glabels
auto* item = new QTableWidgetItem();
if ( record->contains( mPrimaryKey ) )
{
item->setText( (*record)[mPrimaryKey] );
auto text = printableTextForView( (*record)[mPrimaryKey] );
item->setText( text );
}
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
item->setCheckState( record->isSelected() ? Qt::Checked : Qt::Unchecked );
Expand All @@ -298,7 +300,8 @@ namespace glabels
{
if ( record->contains( key ) )
{
auto* item = new QTableWidgetItem( (*record)[key] );
auto text = printableTextForView( (*record)[key] );
auto* item = new QTableWidgetItem( text );
item->setFlags( Qt::ItemIsEnabled );
recordsTable->setItem( iRow, iCol, item );
recordsTable->resizeColumnToContents( iCol );
Expand All @@ -319,4 +322,18 @@ namespace glabels
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
1 change: 1 addition & 0 deletions glabels/MergeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace glabels
private:
void loadHeaders( merge::Merge* merge );
void loadTable( merge::Merge* merge );
static QString printableTextForView( QString text );


/////////////////////////////////
Expand Down