From ec3d900e874d096615e2fcb6dc25e09dbfe87144 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 12 Aug 2019 23:03:38 -0400 Subject: [PATCH] Display merge file locations as relative paths. --- glabels/MergeView.cpp | 32 ++++++--------- glabels/MergeView.h | 2 +- glabels/ui/MergeView.ui | 82 +++++++++++++++++++-------------------- translations/glabels_C.ts | 8 ++-- 4 files changed, 56 insertions(+), 68 deletions(-) diff --git a/glabels/MergeView.cpp b/glabels/MergeView.cpp index 0a1eea68..bf0f3062 100644 --- a/glabels/MergeView.cpp +++ b/glabels/MergeView.cpp @@ -63,14 +63,7 @@ namespace glabels mUndoRedoModel = undoRedoModel; // Initialize CWD - if ( model->fileName().isEmpty() ) - { - mCwd = "."; - } - else - { - mCwd = QFileInfo( model->fileName() ).absolutePath(); - } + mCwd = mModel->dir(); onMergeChanged(); connect( mModel, SIGNAL(mergeChanged()), this, SLOT(onMergeChanged()) ); @@ -87,26 +80,22 @@ namespace glabels mOldFormatComboIndex = index; formatCombo->setCurrentIndex( index ); + QString fn; + switch ( merge::Factory::idToType( mModel->merge()->id() ) ) { case merge::Factory::NONE: case merge::Factory::FIXED: locationLabel->setEnabled( false ); - locationButton->setEnabled( false ); - locationButton->setText( "" ); + locationLineEdit->setText( "" ); + locationBrowseButton->setVisible( false ); break; case merge::Factory::FILE: locationLabel->setEnabled( true ); - locationButton->setEnabled( true ); - if ( mModel->merge()->source().isEmpty() ) - { - locationButton->setText( "Select file..." ); - } - else - { - locationButton->setText( mModel->merge()->source() ); - } + fn = QDir(mModel->dir()).relativeFilePath( mModel->merge()->source() ); + locationLineEdit->setText( fn ); + locationBrowseButton->setVisible( true ); break; default: @@ -135,7 +124,8 @@ namespace glabels /// void MergeView::onMergeSourceChanged() { - locationButton->setText( mModel->merge()->source() ); + QString fn = QDir(mModel->dir()).relativeFilePath( mModel->merge()->source() ); + locationLineEdit->setText( fn ); recordsTable->clear(); recordsTable->setColumnCount( 0 ); @@ -185,7 +175,7 @@ namespace glabels /// /// Location button clicked handler /// - void MergeView::onLocationButtonClicked() + void MergeView::onLocationBrowseButtonClicked() { QString fileName = QFileDialog::getOpenFileName( this, diff --git a/glabels/MergeView.h b/glabels/MergeView.h index 87349945..e0ddead8 100644 --- a/glabels/MergeView.h +++ b/glabels/MergeView.h @@ -67,7 +67,7 @@ namespace glabels void onMergeSelectionChanged(); void onFormatComboActivated(); - void onLocationButtonClicked(); + void onLocationBrowseButtonClicked(); void onSelectAllButtonClicked(); void onUnselectAllButtonClicked(); void onCellChanged( int iRow, int iCol ); diff --git a/glabels/ui/MergeView.ui b/glabels/ui/MergeView.ui index 89517fd9..c7f682a3 100644 --- a/glabels/ui/MergeView.ui +++ b/glabels/ui/MergeView.ui @@ -46,16 +46,9 @@ Source - - + + - - - - Location - - - @@ -63,6 +56,27 @@ + + + + + + + + + true + + + + + + + Browse... + + + + + @@ -70,24 +84,8 @@ - - - - - - - Qt::Horizontal - - - - 360 - 20 - - - - @@ -151,8 +149,8 @@ onSelectAllButtonClicked() - 63 - 571 + 97 + 570 69 @@ -177,34 +175,34 @@ - locationButton - clicked() + formatCombo + activated(int) MergeView - onLocationButtonClicked() + onFormatComboActivated() - 174 - 93 + 257 + 109 - 570 - 75 + 563 + 50 - formatCombo - activated(int) + locationBrowseButton + clicked() MergeView - onFormatComboActivated() + onLocationBrowseButtonClicked() - 162 - 48 + 296 + 130 - 563 - 50 + 565 + 149 @@ -212,7 +210,7 @@ onSelectAllButtonClicked() onUnselectAllButtonClicked() - onLocationButtonClicked() onFormatComboActivated() + onLocationBrowseButtonClicked() diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index 575f40d6..d300fced 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -286,10 +286,6 @@ Source - - Location - - Format: @@ -310,6 +306,10 @@ Unselect all + + Browse... + + ObjectEditor