QGIS API Documentation  2.14.0-Essen
qgscptcitycolorrampv2dialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscptcitycolorrampv2dialog.cpp
3  ---------------------
4  begin : July 2012
5  copyright : (C) 2012 by Etienne Tourigny
6  email : etourigny dot dev at gmail.com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 
18 #include "qgscptcityarchive.h"
19 #include "qgsvectorcolorrampv2.h"
20 #include "qgslogger.h"
21 #include "qgsapplication.h"
22 #include "qgsdialog.h"
23 
24 #include <QPushButton>
25 #include <QTextEdit>
26 #include <QTime>
27 #include <QMessageBox>
28 #include <QSortFilterProxyModel>
29 
31 
32 // TODO
33 // - fix Diverging children when first show Selections
34 // - fix crash on Diverging?
35 
36 
38  : QDialog( parent )
39  , mRamp( nullptr )
40  , mArchiveViewType( QgsCptCityBrowserModel::Selections )
41 {
42  setupUi( this );
43 
44  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
45 
46  QSettings settings;
47  restoreGeometry( settings.value( "/Windows/CptCityColorRampV2Dialog/geometry" ).toByteArray() );
48  mSplitter->setSizes( QList<int>() << 250 << 550 );
49  mSplitter->restoreState( settings.value( "/Windows/CptCityColorRampV2Dialog/splitter" ).toByteArray() );
50 
51  mModel = mAuthorsModel = mSelectionsModel = nullptr; //mListModel = 0;
52  mTreeFilter = nullptr;
53 
56 
57  // show information on how to install cpt-city files if none are found
58  if ( ! mArchive || mArchive->isEmpty() )
59  {
60  // QgsDialog dlg( this );
61  // dlg.setWindowTitle( tr( "cpt-city gradient files not found" ) );
62  QTextEdit *edit = new QTextEdit( nullptr );
63  edit->setReadOnly( true );
64  // not sure if we want this long string to be translated
65  QString helpText = tr( "Error - cpt-city gradient files not found.\n\n"
66  "You have two means of installing them:\n\n"
67  "1) Install the \"Color Ramp Manager\" python plugin "
68  "(you must enable Experimental plugins in the plugin manager) "
69  "and use it to download latest cpt-city package.\n"
70  "You can install the entire cpt-city archive or a selection for QGIS.\n\n"
71  "2) Download the complete archive (in svg format) "
72  "and unzip it to your QGIS settings directory [%1] .\n\n"
73  "This file can be found at [%2]\nand current file is [%3]"
75  "http://soliton.vm.bytemark.co.uk/pub/cpt-city/pkg/",
76  "http://soliton.vm.bytemark.co.uk/pub/cpt-city/pkg/cpt-city-svg-2.07.zip" );
77  edit->setText( helpText );
78  mStackedWidget->addWidget( edit );
79  mStackedWidget->setCurrentIndex( 1 );
80  tabBar->setVisible( false );
81  // dlg.layout()->addWidget( edit );
82  // dlg.resize(500,400);
83  // dlg.exec();
84  return;
85  }
86 
87  if ( ! mArchive )
88  return;
89  QgsDebugMsg( "archive: " + mArchive->archiveName() );
90 
91  if ( ramp )
92  {
93  mRamp = ramp;
94  }
95  else
96  {
97  mRamp = new QgsCptCityColorRampV2( "", "", false );
98  ramp = mRamp;
99  }
100  QgsDebugMsg( QString( "ramp name= %1 variant= %2 - %3 variants" ).arg( ramp->schemeName(), ramp->variantName() ).arg( ramp->variantList().count() ) );
101 
102  // model / view
103  QgsDebugMsg( "loading model/view objects" );
104  if ( mAuthorsModel )
105  delete mAuthorsModel;
107  if ( mSelectionsModel )
108  delete mSelectionsModel;
111 
112  mTreeView->setSelectionMode( QAbstractItemView::SingleSelection );
113  mTreeView->setColumnHidden( 1, true );
114  QgsDebugMsg( "done loading model/view objects" );
115 
116  // setup ui
117  tabBar->blockSignals( true );
118  tabBar->addTab( tr( "Selections by theme" ) );
119  tabBar->addTab( tr( "All by author" ) );
120  cboVariantName->setIconSize( QSize( 100, 15 ) );
121  lblPreview->installEventFilter( this ); // mouse click on preview label shows svg render
122 
123  // look for item, if not found in selections archive, look for in authors
124  QgsDebugMsg( "looking for ramp " + mRamp->schemeName() );
125  if ( mRamp->schemeName() != "" )
126  {
127  bool found = updateRamp();
128  if ( ! found )
129  {
130  tabBar->setCurrentIndex( 1 );
132  found = updateRamp();
133  // if not found, go back to selections model
134  if ( ! found )
135  {
136  tabBar->setCurrentIndex( 0 );
138  }
139  }
140  if ( found )
141  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true );
142  }
143  else
144  {
145  updateRamp();
146  }
147 
148  tabBar->blockSignals( false );
149 
150  connect( this, SIGNAL( finished( int ) ), this, SLOT( onFinished() ) );
151 
152 }
153 
155 {
156 }
157 
159 {
160  QStringList variantList = mRamp->variantList();
161 
162  QgsDebugMsg( QString( "ramp %1%2 has %3 variants" ).arg( mRamp->schemeName(), mRamp->variantName() ).arg( variantList.count() ) );
163 
164  cboVariantName->blockSignals( true );
165  cboVariantName->clear();
166 
167  if ( variantList.isEmpty() )
168  {
169  cboVariantName->setEnabled( false );
170  cboVariantName->setVisible( false );
172  }
173  else
174  {
175  // populate variant combobox
176  QString oldVariant = cboVariantName->currentText();
178  QPixmap blankPixmap( cboVariantName->iconSize() );
179  blankPixmap.fill( Qt::white );
180  QIcon blankIcon( blankPixmap );
181  int index;
182 
183  Q_FOREACH ( const QString& variant, variantList )
184  {
185  QString variantStr = variant;
186  if ( variantStr.startsWith( '-' ) || variantStr.startsWith( '_' ) )
187  variantStr.remove( 0, 1 );
188  cboVariantName->addItem( ' ' + variantStr );
189  index = cboVariantName->count() - 1;
190  cboVariantName->setItemData( index, variant, Qt::UserRole );
191 
192  ramp.setVariantName( variant );
193  if ( ramp.loadFile() )
194  cboVariantName->setItemIcon( index,
195  QgsSymbolLayerV2Utils::colorRampPreviewIcon( &ramp, cboVariantName->iconSize() ) );
196  else
197  cboVariantName->setItemIcon( index, blankIcon );
198  cboVariantName->setItemData( index, Qt::AlignHCenter, Qt::TextAlignmentRole );
199  }
200 
201  cboVariantName->blockSignals( false );
202 
203  // try to set the original variant again (if exists)
204  int idx = -1;
205  QString newVariant = mRamp->variantName();
206  QgsDebugMsg( QString( "variant= %1 - %2 variants" ).arg( mRamp->variantName() ).arg( mRamp->variantList().count() ) );
207  if ( newVariant != QString() )
208  {
209  if ( newVariant.startsWith( '-' ) || newVariant.startsWith( '_' ) )
210  newVariant.remove( 0, 1 );
211  newVariant = ' ' + newVariant;
212  idx = cboVariantName->findText( newVariant );
213  }
214  else
215  idx = cboVariantName->findText( oldVariant );
216 
217  // if not found use the item in the middle
218  if ( idx == -1 )
219  {
220  idx = cboVariantName->count() / 2;
221  }
222  cboVariantName->setCurrentIndex( idx );
223  // updatePreview();
224 
225  cboVariantName->setEnabled( true );
226  cboVariantName->setVisible( true );
227  }
228 
229 }
230 
232 {
233  const QModelIndex &sourceIndex = mTreeFilter->mapToSource( index );
234  QgsCptCityDataItem *item = mModel->dataItem( sourceIndex );
235  if ( ! item )
236  return;
237  QgsDebugMsg( QString( "item %1 clicked" ).arg( item->name() ) );
238  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
239  updateTreeView( item );
240 }
241 
243 {
244  if ( ! item )
245  {
246  QgsDebugMsg( "invalid item" );
247  return;
248  }
249  if ( item->type() == QgsCptCityDataItem::Directory )
250  {
251  if ( resetRamp )
252  {
253  mRamp->setName( "", "" );
254  QgsDebugMsg( QString( "variant= %1 - %2 variants" ).arg( mRamp->variantName() ).arg( mRamp->variantList().count() ) );
255  lblSchemeName->setText( "" );
257  }
258  updateListWidget( item );
259  lblSchemePath->setText( item->path() );
260  lblCollectionInfo->setText( QString( "%1 (%2)" ).arg( item->info() ).arg( item->leafCount() ) );
262  }
263  else if ( item->type() == QgsCptCityDataItem::Selection )
264  {
265  lblSchemePath->setText( "" );
267  updateListWidget( item );
268  lblCollectionInfo->setText( QString( "%1 (%2)" ).arg( item->info() ).arg( item->leafCount() ) );
269  }
270  else if ( item->type() == QgsCptCityDataItem::AllRamps )
271  {
272  lblSchemePath->setText( "" );
274  updateListWidget( item );
275  lblCollectionInfo->setText( tr( "All Ramps (%1)" ).arg( item->leafCount() ) );
276  }
277  else
278  {
279  QgsDebugMsg( QString( "item %1 has invalid type %2" ).arg( item->path() ).arg(( int )item->type() ) );
280  }
281 }
282 
284 {
285  QgsCptCityColorRampItem *rampItem = mListRamps.at( item->data( Qt::UserRole ).toInt() );
286  if ( rampItem )
287  {
288  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true );
289  lblSchemeName->setText( QFileInfo( rampItem->name() ).fileName() );
290  mRamp->copy( &rampItem->ramp() );
291  QgsDebugMsg( QString( "variant= %1 - %2 variants" ).arg( mRamp->variantName() ).arg( mRamp->variantList().count() ) );
293  }
294  else
295  {
296  QgsDebugMsg( "invalid item" );
297  }
298 }
299 
301 {
302  if ( mListWidget->selectedItems().isEmpty() )
303  {
304  mRamp->setName( "", "" );
305  }
306 }
307 
309 {
310  QgsDebugMsg( "Entered" );
311  if ( index == 0 )
312  {
315  }
316  else if ( index == 1 )
317  {
320  }
321  else
322  {
323  QgsDebugMsg( QString( "invalid index %1" ).arg( index ) );
326  }
327 
328  mListWidget->blockSignals( true );
329  updateRamp();
330  mListWidget->blockSignals( false );
331 }
332 
333 
335 {
336  QString path, title, copyFile, descFile;
337 
338  // get basic information, depending on if is color ramp or directory
339  QgsCptCityDataItem *item = mModel->dataItem( mTreeFilter->mapToSource( mTreeView->currentIndex() ) );
340  if ( ! item )
341  return;
342 
343  path = item->path();
344  if ( item->type() == QgsCptCityDataItem::Directory )
345  {
346  title = tr( "%1 directory details" ).arg( item->path() );
347  }
348  else if ( item->type() == QgsCptCityColorRampItem::Directory )
349  {
350  title = tr( "%1 gradient details" ).arg( path );
351  }
352  else
353  {
354  return;
355  }
356  copyFile = mArchive->copyingFileName( path );
357  descFile = mArchive->descFileName( path );
358 
359  // prepare dialog
360  QgsDialog dlg( this, nullptr, QDialogButtonBox::Close );
361  QVBoxLayout *layout = dlg.layout();
362  dlg.setWindowTitle( title );
363  QTextEdit *textEdit = new QTextEdit( &dlg );
364  textEdit->setReadOnly( true );
365  layout->addWidget( textEdit );
366 
367  // add contents of DESC.xml and COPYING.xml
368  QString copyText;
369  if ( ! copyFile.isNull() )
370  {
371  QFile file( copyFile );
372  if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
373  {
374  copyText = QString( file.readAll() );
375  file.close();
376  }
377  }
378  QString descText;
379  if ( ! descFile.isNull() )
380  {
381  QFile file( descFile );
382  if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
383  {
384  descText = QString( file.readAll() );
385  file.close();
386  }
387  }
388  textEdit->insertPlainText( title + "\n\n" );
389  textEdit->insertPlainText( "===================" );
390  textEdit->insertPlainText( " copying " );
391  textEdit->insertPlainText( "===================\n" );
392  textEdit->insertPlainText( copyText );
393  textEdit->insertPlainText( "\n" );
394  textEdit->insertPlainText( "==================" );
395  textEdit->insertPlainText( " description " );
396  textEdit->insertPlainText( "==================\n" );
397  textEdit->insertPlainText( descText );
398  textEdit->moveCursor( QTextCursor::Start );
399 
400  dlg.resize( 600, 600 );
401  dlg.exec();
402 }
403 
405 {
406  QSize size = lblPreview->size();
407 
408  if ( clear || mRamp->schemeName() == "" )
409  {
410  lblSchemeName->setText( "" );
411  lblSchemePath->setText( "" );
412  lblLicensePreview->setText( "" );
413  QPixmap blankPixmap( size );
414  blankPixmap.fill( Qt::transparent );
415  lblPreview->setPixmap( blankPixmap );
416  return;
417  }
418 
419  mRamp->loadFile();
420 
421  lblSchemePath->setText( mRamp->schemeName() + mRamp->variantName() );
422 
423  // update pixmap
424  // TODO draw checker-board/transparent background
425  // for transparent, add [ pixmap.fill( Qt::transparent ); ] to QgsSymbolLayerV2Utils::colorRampPreviewPixmap
427  lblPreview->setPixmap( pixmap );
428 
429  // add copyright information from COPYING.xml file
431 }
432 
434 {
436 }
437 
439 {
440  QString authorStr = copyingMap.value( "authors" );
441  if ( authorStr.length() > 80 )
442  authorStr.replace( authorStr.indexOf( ' ', 80 ), 1, "\n" );
443  lblAuthorName->setText( authorStr );
444  QString licenseStr = copyingMap.value( "license/informal" );
445  if ( copyingMap.contains( "license/year" ) )
446  licenseStr += " (" + copyingMap.value( "license/year" ) + ')';
447  if ( licenseStr.length() > 80 )
448  licenseStr.replace( licenseStr.indexOf( ' ', 80 ), 1, "\n" );
449  if ( copyingMap.contains( "license/url" ) )
450  licenseStr += "\n[ " + copyingMap.value( "license/url" ) + " ]";
451  else
452  licenseStr += '\n';
453  lblLicenseName->setText( licenseStr );
454  licenseStr.replace( '\n', " " );
455  lblLicensePreview->setText( licenseStr );
456  lblLicensePreview->setCursorPosition( 0 );
457  if ( copyingMap.contains( "src/link" ) )
458  lblSrcLink->setText( copyingMap.value( "src/link" ) );
459  else
460  lblSrcLink->setText( "" );
461 }
462 
464 {
465  Q_UNUSED( index );
466  if ( cboVariantName->currentIndex() != -1 )
467  mRamp->setVariantName( cboVariantName->itemData( cboVariantName->currentIndex(), Qt::UserRole ).toString() );
468  QgsDebugMsg( QString( "variant= %1 - %2 variants" ).arg( mRamp->variantName() ).arg( mRamp->variantList().count() ) );
469  updatePreview();
470 }
471 
473 {
474  // save settings
475  QSettings settings;
476  settings.setValue( "/Windows/CptCityColorRampV2Dialog/geometry", saveGeometry() );
477  settings.setValue( "/Windows/CptCityColorRampV2Dialog/splitter", mSplitter->saveState() );
478 }
479 
481 {
482  // show error message to use color ramp manager to get more gradients
483  QString helpText = tr( "You can download a more complete set of cpt-city gradients "
484  "by installing the \"Color Ramp Manager\" plugin "
485  "(you must enable Experimental plugins in the plugin manager).\n\n"
486  );
487  QMessageBox* msg = new QMessageBox( this );
488  msg->setText( helpText );
489  msg->exec();
490 }
491 
493 {
494  QgsDebugMsg( QString( "result: %1 checked: %2" ).arg( result() ).arg( cboConvertStandard->isChecked() ) );
495  // if "save as standard gradient" is checked, convert to QgsVectorGradientColorRampV2
496  return ( result() == Accepted && cboConvertStandard->isChecked() );
497 }
498 
500 {
501  mListWidget->blockSignals( true );
502  mListWidget->clear();
503  mListRamps.clear();
504  QgsCptCityCollectionItem* colItem = dynamic_cast<QgsCptCityCollectionItem*>( item );
505  if ( colItem )
506  {
507  QgsDebugMsg( "path= " + item->path() );
508  // recursively get children ramps
509  QVector<QgsCptCityDataItem*> childrenRamps = colItem->childrenRamps( true );
510  for ( int i = 0; i < childrenRamps.count(); i++ )
511  {
512  QgsCptCityColorRampItem* rampItem = dynamic_cast<QgsCptCityColorRampItem*>( childrenRamps[i] );
513  if ( ! rampItem )
514  {
515  QgsDebugMsg( "invalid item " + childrenRamps[i]->path() );
516  continue;
517  }
518  QListWidgetItem* listItem = new QListWidgetItem();
519  listItem->setText( rampItem->shortInfo() );
520  listItem->setIcon( rampItem->icon( QSize( 75, 50 ) ) );
521  listItem->setToolTip( rampItem->path() + '\n' + rampItem->info() );
522  listItem->setData( Qt::UserRole, QVariant( i ) );
523  mListWidget->addItem( listItem );
524  mListRamps << rampItem;
525  }
526  }
527  else
528  {
529  QgsDebugMsg( "invalid item" );
530  }
531  mListWidget->blockSignals( false );
532 }
533 
534 // this function is for a svg preview, available if the svg files have been processed with svgx
535 // e.g. for f in `ls */*/*/*/*.svg`; do echo $f ; svgx -p -t svg $f > tmp1.svg; mv tmp1.svg $f; done
536 // perhaps a future version of the cpt-city svg gradients will have them by default
538 {
539  QSize size = lblPreview->size();
540 
541  if ( event->type() == QEvent::MouseButtonPress )
542  {
543  // create preview from svg file if supported - depends on file versions
544  QPixmap pixmap( mRamp->fileName() );
545  if ( ! pixmap.isNull() )
546  lblPreview->setPixmap( pixmap.scaled( size ) );
547  return true;
548  }
549  else if ( event->type() == QEvent::MouseButtonRelease )
550  {
551  // restore preview
553  lblPreview->setPixmap( pixmap );
554  return true;
555  }
556  else
557  {
558  // standard event processing
559  return QObject::eventFilter( obj, event );
560  }
561 }
562 
564 {
565  QgsDebugMsg( "Entered" );
566  mListWidget->clear();
567  mListRamps.clear();
568  cboVariantName->clear();
570  lblCollectionInfo->clear();
571 
572  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
573  updatePreview( true );
574 
575  QgsDebugMsg( "schemeName= " + mRamp->schemeName() );
576  if ( mRamp->schemeName() == "" )
577  {
578  showAll();
579  return false;
580  }
581 
582  // search for item in model
583  QModelIndex modelIndex = mModel->findPath( mRamp->schemeName() );
584  if ( modelIndex == QModelIndex() )
585  {
586  return false;
587  }
588  QgsCptCityColorRampItem* childItem =
589  dynamic_cast<QgsCptCityColorRampItem*>( mModel->dataItem( modelIndex ) );
590  if ( ! childItem )
591  return false;
592  if ( mRamp->schemeName() != childItem->ramp().schemeName() )
593  return false;
594 
595  // found child, set mRamp variantList
596  // mRamp->copy( &childItem->ramp() );
597  mRamp->setVariantList( childItem->ramp().variantList() );
598 
599  // found child, update tree
600  QgsDebugMsg( QString( "found item %1" ).arg( mRamp->schemeName() ) );
601  lblSchemeName->setText( QFileInfo( mRamp->schemeName() ).fileName() );
602  QModelIndex parentIndex = modelIndex.parent();
603  QModelIndex selIndex = mTreeFilter->mapFromSource( parentIndex );
604 
605  // QgsDebugMsg(QString("parent row=%1 path=%2 parentRow=%3").arg(parentIndex.row()).arg(mModel->dataItem( parentIndex )->path()).arg(parentIndex.parent().row()));
606  mTreeView->setCurrentIndex( selIndex );
607  mTreeView->setExpanded( selIndex, true );
608  mTreeView->scrollTo( selIndex, QAbstractItemView::PositionAtCenter );
609  updateTreeView( mModel->dataItem( parentIndex ), false );
610 
611  // update listWidget, find appropriate item in mListRamps
612  for ( int i = 0; i < mListRamps.count(); i++ )
613  {
614  if ( mListRamps.at( i ) == childItem )
615  {
616  QgsDebugMsg( QString( "found matching item %1 target=%2" ).arg( mListRamps.at( i )->path(), childItem->path() ) );
617  QListWidgetItem* listItem = mListWidget->item( i );
618  mListWidget->setCurrentItem( listItem );
619  // on_mListWidget_itemClicked( listItem );
621  mListWidget->scrollToItem( listItem, QAbstractItemView::EnsureVisible );
622  // mListView->selectionModel()->select( childIndex, QItemSelectionModel::Select );
623  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true );
624  return true;
625  }
626  }
627 
628  return false;
629 }
630 
632 {
633  QModelIndex modelIndex = mModel->findPath( "" );
634  if ( modelIndex != QModelIndex() )
635  {
636  QModelIndex selIndex = mTreeFilter->mapFromSource( modelIndex );
637  mTreeView->setCurrentIndex( selIndex );
638  mTreeView->setExpanded( selIndex, true );
639  mTreeView->scrollTo( selIndex, QAbstractItemView::PositionAtCenter );
640  updateTreeView( mModel->dataItem( modelIndex ), false );
641  }
642 }
643 
645 {
646  QgsDebugMsg( "Entered" );
647  mModel = model;
648 
649  if ( mTreeFilter )
650  delete mTreeFilter;
651  mTreeFilter = new TreeFilterProxyModel( this, mModel );
652  mTreeView->setModel( mTreeFilter );
653 }
654 
655 #if 0
656 void QgsCptCityColorRampV2Dialog::refresh()
657 {
658  QApplication::setOverrideCursor( Qt::WaitCursor );
659  refreshModel( QModelIndex() );
661 }
662 
663 void QgsCptCityColorRampV2Dialog::refreshModel( const QModelIndex& index )
664 {
665  if ( index.isValid() )
666  {
667  QgsCptCityDataItem *item = mModel->dataItem( index );
668  if ( item )
669  {
670  QgsDebugMsg( "path = " + item->path() );
671  }
672  else
673  {
674  QgsDebugMsg( "invalid item" );
675  }
676  }
677 
678  mModel->refresh( index );
679 
680  for ( int i = 0 ; i < mModel->rowCount( index ); i++ )
681  {
682  QModelIndex idx = mModel->index( i, 0, index );
683  if ( mTreeView->isExpanded( idx ) || !mModel->hasChildren( idx ) )
684  {
685  refreshModel( idx );
686  }
687  }
688 }
689 #endif
690 
692 
693 TreeFilterProxyModel::TreeFilterProxyModel( QObject* parent, QgsCptCityBrowserModel* model )
694  : QSortFilterProxyModel( parent ), mModel( model )
695 {
696  setSourceModel( mModel );
697 }
698 
699 bool TreeFilterProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
700 {
701  QgsCptCityDataItem* item = mModel->dataItem( mModel->index( sourceRow, 0, sourceParent ) );
702  return ( item && !( item->type() == QgsCptCityDataItem::ColorRamp ) );
703 }
704 
705 
QLayout * layout() const
void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode)
QByteArray toByteArray() const
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
static unsigned index
void updateListWidget(QgsCptCityDataItem *item)
virtual bool event(QEvent *e)
Type type() const
void setupUi(QWidget *widget)
static QIcon colorRampPreviewIcon(QgsVectorColorRampV2 *ramp, QSize size)
static QPixmap colorRampPreviewPixmap(QgsVectorColorRampV2 *ramp, QSize size)
bool contains(const Key &key) const
void setName(const QString &schemeName, const QString &variantName="", const QStringList &variantList=QStringList())
static QgsCptCityArchive * defaultArchive()
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user&#39;s home dir.
QgsCptCityBrowserModel * mSelectionsModel
void fill(const QColor &color)
void copy(const QgsCptCityColorRampV2 *other)
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
QString archiveName() const
A generic dialog with layout and button box.
Definition: qgsdialog.h:30
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the index of the item in the model specified by the given row, column and parent index...
Item that represents a layer that can be opened with one of the providers.
int exec()
QgsCptCityDataItem * dataItem(const QModelIndex &idx) const
Returns a list of mime that can describe model indexes.
QVector< QgsCptCityColorRampItem * > mListRamps
QString & remove(int position, int n)
QgsCptCityBrowserModel * mAuthorsModel
QModelIndex findPath(const QString &path)
return index of a path
QString tr(const char *sourceText, const char *disambiguation, int n)
bool isNull() const
QgsCptCityBrowserModel::ViewType mArchiveViewType
void finished(int result)
void setValue(const QString &key, const QVariant &value)
void resize(int w, int h)
void clear()
bool isValid() const
QString variantName() const
void updateTreeView(QgsCptCityDataItem *item, bool resetRamp=true)
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
int count(const T &value) const
void setVariantName(const QString &variantName)
QStringList variantList() const
QString copyingFileName(const QString &dirName) const
int toInt(bool *ok) const
bool restoreGeometry(const QByteArray &geometry)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Provides the number of rows of data exposed by the model.
void setToolTip(const QString &toolTip)
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
bool isEmpty() const
void setText(const QString &text)
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
QByteArray readAll()
void setOverrideCursor(const QCursor &cursor)
virtual QVariant data(int role) const
QgsCptCityColorRampV2Dialog(QgsCptCityColorRampV2 *ramp, QWidget *parent=nullptr)
QgsStringMap copyingInfo() const
Base class for all items in the model.
void restoreOverrideCursor()
static QMap< QString, QString > copyingInfo(const QString &fileName)
virtual bool eventFilter(QObject *watched, QEvent *event)
int result() const
A Collection: logical collection of subcollections and color ramps.
QModelIndex parent() const
QString descFileName(const QString &dirName) const
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
QString shortInfo() const
QString path() const
static void initDefaultArchive()
void setIcon(const QIcon &icon)
void on_mListWidget_itemClicked(QListWidgetItem *item)
virtual void setData(int role, const QVariant &value)
void updateCopyingInfo(const QMap< QString, QString > &copyingMap)
virtual void close()
QString & replace(int position, int n, QChar after)
const T & at(int i) const
QVariant value(const QString &key, const QVariant &defaultValue) const
virtual int leafCount() const
void refresh(const QString &path)
bool eventFilter(QObject *obj, QEvent *event) override
QByteArray saveGeometry() const
int count() const
void setWindowTitle(const QString &)
QVBoxLayout * layout()
Returns the central layout. Widgets added to it must have this dialog as parent.
Definition: qgsdialog.h:40
int count(const T &value) const
int length() const
void setReadOnly(bool ro)
QVector< QgsCptCityDataItem * > childrenRamps(bool recursive)
void on_mTreeView_clicked(const QModelIndex &)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const
void setText(const QString &text)
void setVariantList(const QStringList &variantList)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void insertPlainText(const QString &text)
QString info() const
QString name() const
const QgsCptCityColorRampV2 & ramp() const
void setText(const QString &text)
void setTreeModel(QgsCptCityBrowserModel *model)
const T value(const Key &key) const