From 05d06516942be4bbb67cb6ef2852ef37f59add59 Mon Sep 17 00:00:00 2001 From: Etienne Tourigny Date: Mon, 13 Aug 2012 12:16:21 -0300 Subject: [PATCH] show license+description when directory is selected --- .../qgscptcitycolorrampv2dialog.cpp | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/gui/symbology-ng/qgscptcitycolorrampv2dialog.cpp b/src/gui/symbology-ng/qgscptcitycolorrampv2dialog.cpp index 99f161f97e43..17dcd4b782a6 100644 --- a/src/gui/symbology-ng/qgscptcitycolorrampv2dialog.cpp +++ b/src/gui/symbology-ng/qgscptcitycolorrampv2dialog.cpp @@ -252,17 +252,39 @@ void QgsCptCityColorRampV2Dialog::on_tabBar_currentChanged( int index ) void QgsCptCityColorRampV2Dialog::on_pbtnLicenseDetails_pressed() { + QString path, title, copyFile, descFile; + + // get basic information, depending on if is color ramp or directory + QgsCptCityDataItem *item = + dynamic_cast< QgsCptCityDataItem* >( mModel->dataItem( mBrowserView->currentIndex() ) ); + if ( item && item->type() == QgsCptCityDataItem::Directory ) + { + path = item->path(); + title = tr( "%1 directory details" ).arg( item->name() ); + copyFile = mCollection->copyingFileName( path ); + descFile = mCollection->descFileName( path ); + } + else if ( item ) + { + path = mRamp->schemeName() + mRamp->variantName(); + title = tr( "%1 gradient details" ).arg( path ); + copyFile = mRamp->copyingFileName(); + descFile = mRamp->descFileName(); + } + else + { + return; + } + // prepare dialog QgsDialog dlg( this, 0, QDialogButtonBox::Close ); QVBoxLayout *layout = dlg.layout(); - QString title = tr( "gradient %1 details" ).arg( mRamp->schemeName() + mRamp->variantName() ); dlg.setWindowTitle( title ); QTextEdit *textEdit = new QTextEdit( &dlg ); textEdit->setReadOnly( true ); layout->addWidget( textEdit ); // add contents of DESC.xml and COPYING.xml - QString copyFile = mRamp->copyingFileName(); QString copyText; if ( ! copyFile.isNull() ) { @@ -273,7 +295,6 @@ void QgsCptCityColorRampV2Dialog::on_pbtnLicenseDetails_pressed() file.close(); } } - QString descFile = mRamp->descFileName(); QString descText; if ( ! descFile.isNull() ) { @@ -284,6 +305,7 @@ void QgsCptCityColorRampV2Dialog::on_pbtnLicenseDetails_pressed() file.close(); } } + textEdit->insertPlainText( title + "\n\n" ); textEdit->insertPlainText( "===================" ); textEdit->insertPlainText( " copying " ); textEdit->insertPlainText( "===================\n" );