Skip to content

Commit

Permalink
Nicer strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 16, 2019
1 parent 6246dd7 commit ed797c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
22 changes: 15 additions & 7 deletions src/gui/symbology/qgsstylemanagerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,14 @@ void QgsStyleManagerDialog::copyItemsToDefault()
if ( !items.empty() )
{
auto cursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
copyItems( items, mStyle, QgsStyle::defaultStyle(), this, cursorOverride, true, QStringList(), false, false );
const int count = copyItems( items, mStyle, QgsStyle::defaultStyle(), this, cursorOverride, true, QStringList(), false, false );
cursorOverride.reset();
QMessageBox::information( this, tr( "Import Symbols" ),
tr( "Symbols successfully imported." ) );
if ( count > 0 )
{
QMessageBox::information( this, tr( "Import Symbols" ),
count > 1 ? tr( "Successfully imported %1 items." ).arg( count )
: tr( "Successfully imported item." ) );
}
}
}

Expand Down Expand Up @@ -473,11 +477,12 @@ QList< QgsStyleManagerDialog::ItemDetails > QgsStyleManagerDialog::selectedItems
return res;
}

void QgsStyleManagerDialog::copyItems( const QList<QgsStyleManagerDialog::ItemDetails> &items, QgsStyle *src, QgsStyle *dst, QWidget *parentWidget,
std::unique_ptr< QgsTemporaryCursorOverride > &cursorOverride, bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags )
int QgsStyleManagerDialog::copyItems( const QList<QgsStyleManagerDialog::ItemDetails> &items, QgsStyle *src, QgsStyle *dst, QWidget *parentWidget,
std::unique_ptr< QgsTemporaryCursorOverride > &cursorOverride, bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags )
{
bool prompt = true;
bool overwriteAll = true;
int count = 0;

const QStringList favoriteSymbols = src->symbolsOfFavorite( QgsStyle::SymbolEntity );
const QStringList favoriteColorramps = src->symbolsOfFavorite( QgsStyle::ColorrampEntity );
Expand Down Expand Up @@ -521,7 +526,7 @@ void QgsStyleManagerDialog::copyItems( const QList<QgsStyleManagerDialog::ItemDe
switch ( res )
{
case QMessageBox::Cancel:
return;
return count;

case QMessageBox::No:
continue;
Expand All @@ -547,6 +552,7 @@ void QgsStyleManagerDialog::copyItems( const QList<QgsStyleManagerDialog::ItemDe
QgsSymbol *newSymbol = symbol.get();
dst->addSymbol( details.name, symbol.release() );
dst->saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
count++;
}
break;
}
Expand All @@ -573,7 +579,7 @@ void QgsStyleManagerDialog::copyItems( const QList<QgsStyleManagerDialog::ItemDe
switch ( res )
{
case QMessageBox::Cancel:
return;
return count;

case QMessageBox::No:
continue;
Expand All @@ -599,6 +605,7 @@ void QgsStyleManagerDialog::copyItems( const QList<QgsStyleManagerDialog::ItemDe
QgsColorRamp *newRamp = ramp.get();
dst->addColorRamp( details.name, ramp.release() );
dst->saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
count++;
}
break;
}
Expand All @@ -609,6 +616,7 @@ void QgsStyleManagerDialog::copyItems( const QList<QgsStyleManagerDialog::ItemDe

}
}
return count;
}

void QgsStyleManagerDialog::populateList()
Expand Down
9 changes: 6 additions & 3 deletions src/gui/symbology/qgsstylemanagerdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,12 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan

QList< ItemDetails > selectedItems();

static void copyItems( const QList< ItemDetails > &items, QgsStyle *src, QgsStyle *dst,
QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );
/**
* Returns count of items copied, excluding skipped items.
*/
static int copyItems( const QList< ItemDetails > &items, QgsStyle *src, QgsStyle *dst,
QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );


QgsStyle *mStyle = nullptr;
Expand Down

0 comments on commit ed797c9

Please sign in to comment.