Skip to content

Commit

Permalink
Display merge file locations as relative paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevins committed Aug 13, 2019
1 parent d4f742e commit ec3d900
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 68 deletions.
32 changes: 11 additions & 21 deletions glabels/MergeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) );
Expand All @@ -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:
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -185,7 +175,7 @@ namespace glabels
///
/// Location button clicked handler
///
void MergeView::onLocationButtonClicked()
void MergeView::onLocationBrowseButtonClicked()
{
QString fileName =
QFileDialog::getOpenFileName( this,
Expand Down
2 changes: 1 addition & 1 deletion glabels/MergeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace glabels
void onMergeSelectionChanged();

void onFormatComboActivated();
void onLocationButtonClicked();
void onLocationBrowseButtonClicked();
void onSelectAllButtonClicked();
void onUnselectAllButtonClicked();
void onCellChanged( int iRow, int iCol );
Expand Down
82 changes: 40 additions & 42 deletions glabels/ui/MergeView.ui
Original file line number Diff line number Diff line change
Expand Up @@ -46,48 +46,46 @@
<property name="title">
<string>Source</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QPushButton" name="locationButton">
<property name="text">
<string>Location</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Format:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="formatCombo"/>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="locationLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="locationBrowseButton">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="locationLabel">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="formatCombo"/>
</item>
</layout>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>360</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -151,8 +149,8 @@
<slot>onSelectAllButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>63</x>
<y>571</y>
<x>97</x>
<y>570</y>
</hint>
<hint type="destinationlabel">
<x>69</x>
Expand All @@ -177,42 +175,42 @@
</hints>
</connection>
<connection>
<sender>locationButton</sender>
<signal>clicked()</signal>
<sender>formatCombo</sender>
<signal>activated(int)</signal>
<receiver>MergeView</receiver>
<slot>onLocationButtonClicked()</slot>
<slot>onFormatComboActivated()</slot>
<hints>
<hint type="sourcelabel">
<x>174</x>
<y>93</y>
<x>257</x>
<y>109</y>
</hint>
<hint type="destinationlabel">
<x>570</x>
<y>75</y>
<x>563</x>
<y>50</y>
</hint>
</hints>
</connection>
<connection>
<sender>formatCombo</sender>
<signal>activated(int)</signal>
<sender>locationBrowseButton</sender>
<signal>clicked()</signal>
<receiver>MergeView</receiver>
<slot>onFormatComboActivated()</slot>
<slot>onLocationBrowseButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>162</x>
<y>48</y>
<x>296</x>
<y>130</y>
</hint>
<hint type="destinationlabel">
<x>563</x>
<y>50</y>
<x>565</x>
<y>149</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onSelectAllButtonClicked()</slot>
<slot>onUnselectAllButtonClicked()</slot>
<slot>onLocationButtonClicked()</slot>
<slot>onFormatComboActivated()</slot>
<slot>onLocationBrowseButtonClicked()</slot>
</slots>
</ui>
8 changes: 4 additions & 4 deletions translations/glabels_C.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,6 @@
<source>Source</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Location</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Format:</source>
<translation type="unfinished"></translation>
Expand All @@ -310,6 +306,10 @@
<source>Unselect all</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Browse...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ObjectEditor</name>
Expand Down

0 comments on commit ec3d900

Please sign in to comment.