QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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  if ( index == 0 )
311  {
314  }
315  else if ( index == 1 )
316  {
319  }
320  else
321  {
322  QgsDebugMsg( QString( "invalid index %1" ).arg( index ) );
325  }
326 
327  mListWidget->blockSignals( true );
328  updateRamp();
329  mListWidget->blockSignals( false );
330 }
331 
332 
334 {
335  QString path, title, copyFile, descFile;
336 
337  // get basic information, depending on if is color ramp or directory
338  QgsCptCityDataItem *item = mModel->dataItem( mTreeFilter->mapToSource( mTreeView->currentIndex() ) );
339  if ( ! item )
340  return;
341 
342  path = item->path();
343  if ( item->type() == QgsCptCityDataItem::Directory )
344  {
345  title = tr( "%1 directory details" ).arg( item->path() );
346  }
347  else if ( item->type() == QgsCptCityColorRampItem::Directory )
348  {
349  title = tr( "%1 gradient details" ).arg( path );
350  }
351  else
352  {
353  return;
354  }
355  copyFile = mArchive->copyingFileName( path );
356  descFile = mArchive->descFileName( path );
357 
358  // prepare dialog
359  QgsDialog dlg( this, nullptr, QDialogButtonBox::Close );
360  QVBoxLayout *layout = dlg.layout();
361  dlg.setWindowTitle( title );
362  QTextEdit *textEdit = new QTextEdit( &dlg );
363  textEdit->setReadOnly( true );
364  layout->addWidget( textEdit );
365 
366  // add contents of DESC.xml and COPYING.xml
367  QString copyText;
368  if ( ! copyFile.isNull() )
369  {
370  QFile file( copyFile );
371  if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
372  {
373  copyText = QString( file.readAll() );
374  file.close();
375  }
376  }
377  QString descText;
378  if ( ! descFile.isNull() )
379  {
380  QFile file( descFile );
381  if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
382  {
383  descText = QString( file.readAll() );
384  file.close();
385  }
386  }
387  textEdit->insertPlainText( title + "\n\n" );
388  textEdit->insertPlainText( "===================" );
389  textEdit->insertPlainText( " copying " );
390  textEdit->insertPlainText( "===================\n" );
391  textEdit->insertPlainText( copyText );
392  textEdit->insertPlainText( "\n" );
393  textEdit->insertPlainText( "==================" );
394  textEdit->insertPlainText( " description " );
395  textEdit->insertPlainText( "==================\n" );
396  textEdit->insertPlainText( descText );
397  textEdit->moveCursor( QTextCursor::Start );
398 
399  dlg.resize( 600, 600 );
400  dlg.exec();
401 }
402 
404 {
405  QSize size = lblPreview->size();
406 
407  if ( clear || mRamp->schemeName() == "" )
408  {
409  lblSchemeName->setText( "" );
410  lblSchemePath->setText( "" );
411  lblLicensePreview->setText( "" );
412  QPixmap blankPixmap( size );
413  blankPixmap.fill( Qt::transparent );
414  lblPreview->setPixmap( blankPixmap );
415  return;
416  }
417 
418  mRamp->loadFile();
419 
420  lblSchemePath->setText( mRamp->schemeName() + mRamp->variantName() );
421 
422  // update pixmap
423  // TODO draw checker-board/transparent background
424  // for transparent, add [ pixmap.fill( Qt::transparent ); ] to QgsSymbolLayerV2Utils::colorRampPreviewPixmap
426  lblPreview->setPixmap( pixmap );
427 
428  // add copyright information from COPYING.xml file
430 }
431 
433 {
435 }
436 
438 {
439  QString authorStr = copyingMap.value( "authors" );
440  if ( authorStr.length() > 80 )
441  authorStr.replace( authorStr.indexOf( ' ', 80 ), 1, "\n" );
442  lblAuthorName->setText( authorStr );
443  QString licenseStr = copyingMap.value( "license/informal" );
444  if ( copyingMap.contains( "license/year" ) )
445  licenseStr += " (" + copyingMap.value( "license/year" ) + ')';
446  if ( licenseStr.length() > 80 )
447  licenseStr.replace( licenseStr.indexOf( ' ', 80 ), 1, "\n" );
448  if ( copyingMap.contains( "license/url" ) )
449  licenseStr += "\n[ " + copyingMap.value( "license/url" ) + " ]";
450  else
451  licenseStr += '\n';
452  lblLicenseName->setText( licenseStr );
453  licenseStr.replace( '\n', " " );
454  lblLicensePreview->setText( licenseStr );
455  lblLicensePreview->setCursorPosition( 0 );
456  if ( copyingMap.contains( "src/link" ) )
457  lblSrcLink->setText( copyingMap.value( "src/link" ) );
458  else
459  lblSrcLink->setText( "" );
460 }
461 
463 {
464  Q_UNUSED( index );
465  if ( cboVariantName->currentIndex() != -1 )
466  mRamp->setVariantName( cboVariantName->itemData( cboVariantName->currentIndex(), Qt::UserRole ).toString() );
467  QgsDebugMsg( QString( "variant= %1 - %2 variants" ).arg( mRamp->variantName() ).arg( mRamp->variantList().count() ) );
468  updatePreview();
469 }
470 
472 {
473  // save settings
474  QSettings settings;
475  settings.setValue( "/Windows/CptCityColorRampV2Dialog/geometry", saveGeometry() );
476  settings.setValue( "/Windows/CptCityColorRampV2Dialog/splitter", mSplitter->saveState() );
477 }
478 
480 {
481  // show error message to use color ramp manager to get more gradients
482  QString helpText = tr( "You can download a more complete set of cpt-city gradients "
483  "by installing the \"Color Ramp Manager\" plugin "
484  "(you must enable Experimental plugins in the plugin manager).\n\n"
485  );
486  QMessageBox* msg = new QMessageBox( this );
487  msg->setText( helpText );
488  msg->exec();
489 }
490 
492 {
493  QgsDebugMsg( QString( "result: %1 checked: %2" ).arg( result() ).arg( cboConvertStandard->isChecked() ) );
494  // if "save as standard gradient" is checked, convert to QgsVectorGradientColorRampV2
495  return ( result() == Accepted && cboConvertStandard->isChecked() );
496 }
497 
499 {
500  mListWidget->blockSignals( true );
501  mListWidget->clear();
502  mListRamps.clear();
503  QgsCptCityCollectionItem* colItem = dynamic_cast<QgsCptCityCollectionItem*>( item );
504  if ( colItem )
505  {
506  QgsDebugMsg( "path= " + item->path() );
507  // recursively get children ramps
508  QVector<QgsCptCityDataItem*> childrenRamps = colItem->childrenRamps( true );
509  for ( int i = 0; i < childrenRamps.count(); i++ )
510  {
511  QgsCptCityColorRampItem* rampItem = dynamic_cast<QgsCptCityColorRampItem*>( childrenRamps[i] );
512  if ( ! rampItem )
513  {
514  QgsDebugMsg( "invalid item " + childrenRamps[i]->path() );
515  continue;
516  }
517  QListWidgetItem* listItem = new QListWidgetItem();
518  listItem->setText( rampItem->shortInfo() );
519  listItem->setIcon( rampItem->icon( QSize( 75, 50 ) ) );
520  listItem->setToolTip( rampItem->path() + '\n' + rampItem->info() );
521  listItem->setData( Qt::UserRole, QVariant( i ) );
522  mListWidget->addItem( listItem );
523  mListRamps << rampItem;
524  }
525  }
526  else
527  {
528  QgsDebugMsg( "invalid item" );
529  }
530  mListWidget->blockSignals( false );
531 }
532 
533 // this function is for a svg preview, available if the svg files have been processed with svgx
534 // e.g. for f in `ls */*/*/*/*.svg`; do echo $f ; svgx -p -t svg $f > tmp1.svg; mv tmp1.svg $f; done
535 // perhaps a future version of the cpt-city svg gradients will have them by default
537 {
538  QSize size = lblPreview->size();
539 
540  if ( event->type() == QEvent::MouseButtonPress )
541  {
542  // create preview from svg file if supported - depends on file versions
543  QPixmap pixmap( mRamp->fileName() );
544  if ( ! pixmap.isNull() )
545  lblPreview->setPixmap( pixmap.scaled( size ) );
546  return true;
547  }
548  else if ( event->type() == QEvent::MouseButtonRelease )
549  {
550  // restore preview
552  lblPreview->setPixmap( pixmap );
553  return true;
554  }
555  else
556  {
557  // standard event processing
558  return QObject::eventFilter( obj, event );
559  }
560 }
561 
563 {
564  mListWidget->clear();
565  mListRamps.clear();
566  cboVariantName->clear();
568  lblCollectionInfo->clear();
569 
570  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
571  updatePreview( true );
572 
573  QgsDebugMsg( "schemeName= " + mRamp->schemeName() );
574  if ( mRamp->schemeName() == "" )
575  {
576  showAll();
577  return false;
578  }
579 
580  // search for item in model
581  QModelIndex modelIndex = mModel->findPath( mRamp->schemeName() );
582  if ( modelIndex == QModelIndex() )
583  {
584  return false;
585  }
586  QgsCptCityColorRampItem* childItem =
587  dynamic_cast<QgsCptCityColorRampItem*>( mModel->dataItem( modelIndex ) );
588  if ( ! childItem )
589  return false;
590  if ( mRamp->schemeName() != childItem->ramp().schemeName() )
591  return false;
592 
593  // found child, set mRamp variantList
594  // mRamp->copy( &childItem->ramp() );
595  mRamp->setVariantList( childItem->ramp().variantList() );
596 
597  // found child, update tree
598  QgsDebugMsg( QString( "found item %1" ).arg( mRamp->schemeName() ) );
599  lblSchemeName->setText( QFileInfo( mRamp->schemeName() ).fileName() );
600  QModelIndex parentIndex = modelIndex.parent();
601  QModelIndex selIndex = mTreeFilter->mapFromSource( parentIndex );
602 
603  // QgsDebugMsg(QString("parent row=%1 path=%2 parentRow=%3").arg(parentIndex.row()).arg(mModel->dataItem( parentIndex )->path()).arg(parentIndex.parent().row()));
604  mTreeView->setCurrentIndex( selIndex );
605  mTreeView->setExpanded( selIndex, true );
606  mTreeView->scrollTo( selIndex, QAbstractItemView::PositionAtCenter );
607  updateTreeView( mModel->dataItem( parentIndex ), false );
608 
609  // update listWidget, find appropriate item in mListRamps
610  for ( int i = 0; i < mListRamps.count(); i++ )
611  {
612  if ( mListRamps.at( i ) == childItem )
613  {
614  QgsDebugMsg( QString( "found matching item %1 target=%2" ).arg( mListRamps.at( i )->path(), childItem->path() ) );
615  QListWidgetItem* listItem = mListWidget->item( i );
616  mListWidget->setCurrentItem( listItem );
617  // on_mListWidget_itemClicked( listItem );
619  mListWidget->scrollToItem( listItem, QAbstractItemView::EnsureVisible );
620  // mListView->selectionModel()->select( childIndex, QItemSelectionModel::Select );
621  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true );
622  return true;
623  }
624  }
625 
626  return false;
627 }
628 
630 {
631  QModelIndex modelIndex = mModel->findPath( "" );
632  if ( modelIndex != QModelIndex() )
633  {
634  QModelIndex selIndex = mTreeFilter->mapFromSource( modelIndex );
635  mTreeView->setCurrentIndex( selIndex );
636  mTreeView->setExpanded( selIndex, true );
637  mTreeView->scrollTo( selIndex, QAbstractItemView::PositionAtCenter );
638  updateTreeView( mModel->dataItem( modelIndex ), false );
639  }
640 }
641 
643 {
644  mModel = model;
645 
646  if ( mTreeFilter )
647  delete mTreeFilter;
648  mTreeFilter = new TreeFilterProxyModel( this, mModel );
649  mTreeView->setModel( mTreeFilter );
650 }
651 
652 #if 0
653 void QgsCptCityColorRampV2Dialog::refresh()
654 {
655  QApplication::setOverrideCursor( Qt::WaitCursor );
656  refreshModel( QModelIndex() );
658 }
659 
660 void QgsCptCityColorRampV2Dialog::refreshModel( const QModelIndex& index )
661 {
662  if ( index.isValid() )
663  {
664  QgsCptCityDataItem *item = mModel->dataItem( index );
665  if ( item )
666  {
667  QgsDebugMsg( "path = " + item->path() );
668  }
669  else
670  {
671  QgsDebugMsg( "invalid item" );
672  }
673  }
674 
675  mModel->refresh( index );
676 
677  for ( int i = 0 ; i < mModel->rowCount( index ); i++ )
678  {
679  QModelIndex idx = mModel->index( i, 0, index );
680  if ( mTreeView->isExpanded( idx ) || !mModel->hasChildren( idx ) )
681  {
682  refreshModel( idx );
683  }
684  }
685 }
686 #endif
687 
689 
690 TreeFilterProxyModel::TreeFilterProxyModel( QObject* parent, QgsCptCityBrowserModel* model )
691  : QSortFilterProxyModel( parent )
692  , mModel( model )
693 {
694  setSourceModel( mModel );
695 }
696 
697 bool TreeFilterProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
698 {
699  QgsCptCityDataItem* item = mModel->dataItem( mModel->index( sourceRow, 0, sourceParent ) );
700  return ( item && !( item->type() == QgsCptCityDataItem::ColorRamp ) );
701 }
702 
703 
QLayout * layout() const
void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode)
QgsStringMap copyingInfo() const
QByteArray toByteArray() const
QString descFileName(const QString &dirName) 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)
QgsCptCityDataItem * dataItem(const QModelIndex &idx) const
Returns a list of mime that can describe model indexes.
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
const QgsCptCityColorRampV2 & ramp() const
QString name() 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()
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
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)
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)
Base class for all items in the model.
QString path() const
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
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
QString shortInfo() const
static void initDefaultArchive()
QString archiveName() const
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
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
QString info() const
int length() const
void setReadOnly(bool ro)
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)
QVector< QgsCptCityDataItem * > childrenRamps(bool recursive)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual int leafCount() const
void insertPlainText(const QString &text)
QStringList variantList() const
QString copyingFileName(const QString &dirName) const
void setText(const QString &text)
void setTreeModel(QgsCptCityBrowserModel *model)
const T value(const Key &key) const