QGIS API Documentation  2.12.0-Lyon
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 
37 {
38  // Q_OBJECT
39 
40  public:
42  : QSortFilterProxyModel( parent ), mModel( model )
43  { setSourceModel( mModel ); }
44 
45  protected:
46  bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override
47  {
48  QgsCptCityDataItem* item = mModel->dataItem( mModel->index( sourceRow, 0, sourceParent ) );
49  return ( item && !( item->type() == QgsCptCityDataItem::ColorRamp ) );
50  }
51  // bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
52 
53  private:
54  QgsCptCityBrowserModel* mModel;
55 };
56 
57 
58 // ----------------------
59 
61  : QDialog( parent )
62  , mRamp( 0 )
63  , mArchiveViewType( QgsCptCityBrowserModel::Selections )
64 {
65  setupUi( this );
66 
67  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
68 
69  QSettings settings;
70  restoreGeometry( settings.value( "/Windows/CptCityColorRampV2Dialog/geometry" ).toByteArray() );
71  mSplitter->setSizes( QList<int>() << 250 << 550 );
72  mSplitter->restoreState( settings.value( "/Windows/CptCityColorRampV2Dialog/splitter" ).toByteArray() );
73 
74  mModel = mAuthorsModel = mSelectionsModel = 0; //mListModel = 0;
75  mTreeFilter = 0;
76 
79 
80  // show information on how to install cpt-city files if none are found
81  if ( ! mArchive || mArchive->isEmpty() )
82  {
83  // QgsDialog dlg( this );
84  // dlg.setWindowTitle( tr( "cpt-city gradient files not found" ) );
85  QTextEdit *edit = new QTextEdit( 0 );
86  edit->setReadOnly( true );
87  // not sure if we want this long string to be translated
88  QString helpText = tr( "Error - cpt-city gradient files not found.\n\n"
89  "You have two means of installing them:\n\n"
90  "1) Install the \"Color Ramp Manager\" python plugin "
91  "(you must enable Experimental plugins in the plugin manager) "
92  "and use it to download latest cpt-city package.\n"
93  "You can install the entire cpt-city archive or a selection for QGIS.\n\n"
94  "2) Download the complete archive (in svg format) "
95  "and unzip it to your QGIS settings directory [%1] .\n\n"
96  "This file can be found at [%2]\nand current file is [%3]"
98  "http://soliton.vm.bytemark.co.uk/pub/cpt-city/pkg/",
99  "http://soliton.vm.bytemark.co.uk/pub/cpt-city/pkg/cpt-city-svg-2.07.zip" );
100  edit->setText( helpText );
101  mStackedWidget->addWidget( edit );
102  mStackedWidget->setCurrentIndex( 1 );
103  tabBar->setVisible( false );
104  // dlg.layout()->addWidget( edit );
105  // dlg.resize(500,400);
106  // dlg.exec();
107  return;
108  }
109 
110  if ( ! mArchive )
111  return;
112  QgsDebugMsg( "archive: " + mArchive->archiveName() );
113 
114  if ( ramp )
115  {
116  mRamp = ramp;
117  }
118  else
119  {
120  mRamp = new QgsCptCityColorRampV2( "", "", false );
121  ramp = mRamp;
122  }
123  QgsDebugMsg( QString( "ramp name= %1 variant= %2 - %3 variants" ).arg( ramp->schemeName(), ramp->variantName() ).arg( ramp->variantList().count() ) );
124 
125  // model / view
126  QgsDebugMsg( "loading model/view objects" );
127  if ( mAuthorsModel )
128  delete mAuthorsModel;
130  if ( mSelectionsModel )
131  delete mSelectionsModel;
134 
135  mTreeView->setSelectionMode( QAbstractItemView::SingleSelection );
136  mTreeView->setColumnHidden( 1, true );
137  QgsDebugMsg( "done loading model/view objects" );
138 
139  // setup ui
140  tabBar->blockSignals( true );
141  tabBar->addTab( tr( "Selections by theme" ) );
142  tabBar->addTab( tr( "All by author" ) );
143  cboVariantName->setIconSize( QSize( 100, 15 ) );
144  lblPreview->installEventFilter( this ); // mouse click on preview label shows svg render
145 
146  // look for item, if not found in selections archive, look for in authors
147  QgsDebugMsg( "looking for ramp " + mRamp->schemeName() );
148  if ( mRamp->schemeName() != "" )
149  {
150  bool found = updateRamp();
151  if ( ! found )
152  {
153  tabBar->setCurrentIndex( 1 );
155  found = updateRamp();
156  // if not found, go back to selections model
157  if ( ! found )
158  {
159  tabBar->setCurrentIndex( 0 );
161  }
162  }
163  if ( found )
164  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true );
165  }
166  else
167  {
168  updateRamp();
169  }
170 
171  tabBar->blockSignals( false );
172 
173  connect( this, SIGNAL( finished( int ) ), this, SLOT( onFinished() ) );
174 
175 }
176 
178 {
179 }
180 
182 {
183  QStringList variantList = mRamp->variantList();
184 
185  QgsDebugMsg( QString( "ramp %1%2 has %3 variants" ).arg( mRamp->schemeName(), mRamp->variantName() ).arg( variantList.count() ) );
186 
187  cboVariantName->blockSignals( true );
188  cboVariantName->clear();
189 
190  if ( variantList.isEmpty() )
191  {
192  cboVariantName->setEnabled( false );
193  cboVariantName->setVisible( false );
195  }
196  else
197  {
198  // populate variant combobox
199  QString oldVariant = cboVariantName->currentText();
201  QPixmap blankPixmap( cboVariantName->iconSize() );
202  blankPixmap.fill( Qt::white );
203  QIcon blankIcon( blankPixmap );
204  int index;
205 
206  Q_FOREACH ( const QString& variant, variantList )
207  {
208  QString variantStr = variant;
209  if ( variantStr.startsWith( "-" ) || variantStr.startsWith( "_" ) )
210  variantStr.remove( 0, 1 );
211  cboVariantName->addItem( " " + variantStr );
212  index = cboVariantName->count() - 1;
213  cboVariantName->setItemData( index, variant, Qt::UserRole );
214 
215  ramp.setVariantName( variant );
216  if ( ramp.loadFile() )
217  cboVariantName->setItemIcon( index,
218  QgsSymbolLayerV2Utils::colorRampPreviewIcon( &ramp, cboVariantName->iconSize() ) );
219  else
220  cboVariantName->setItemIcon( index, blankIcon );
221  cboVariantName->setItemData( index, Qt::AlignHCenter, Qt::TextAlignmentRole );
222  }
223 
224  cboVariantName->blockSignals( false );
225 
226  // try to set the original variant again (if exists)
227  int idx = -1;
228  QString newVariant = mRamp->variantName();
229  QgsDebugMsg( QString( "variant= %1 - %2 variants" ).arg( mRamp->variantName() ).arg( mRamp->variantList().count() ) );
230  if ( newVariant != QString() )
231  {
232  if ( newVariant.startsWith( "-" ) || newVariant.startsWith( "_" ) )
233  newVariant.remove( 0, 1 );
234  newVariant = " " + newVariant;
235  idx = cboVariantName->findText( newVariant );
236  }
237  else
238  idx = cboVariantName->findText( oldVariant );
239 
240  // if not found use the item in the middle
241  if ( idx == -1 )
242  {
243  idx = cboVariantName->count() / 2;
244  }
245  cboVariantName->setCurrentIndex( idx );
246  // updatePreview();
247 
248  cboVariantName->setEnabled( true );
249  cboVariantName->setVisible( true );
250  }
251 
252 }
253 
255 {
256  const QModelIndex &sourceIndex = mTreeFilter->mapToSource( index );
257  QgsCptCityDataItem *item = mModel->dataItem( sourceIndex );
258  if ( ! item )
259  return;
260  QgsDebugMsg( QString( "item %1 clicked" ).arg( item->name() ) );
261  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
262  updateTreeView( item );
263 }
264 
266 {
267  if ( ! item )
268  {
269  QgsDebugMsg( "invalid item" );
270  return;
271  }
272  if ( item->type() == QgsCptCityDataItem::Directory )
273  {
274  if ( resetRamp )
275  {
276  mRamp->setName( "", "" );
277  QgsDebugMsg( QString( "variant= %1 - %2 variants" ).arg( mRamp->variantName() ).arg( mRamp->variantList().count() ) );
278  lblSchemeName->setText( "" );
280  }
281  updateListWidget( item );
282  lblSchemePath->setText( item->path() );
283  lblCollectionInfo->setText( QString( "%1 (%2)" ).arg( item->info() ).arg( item->leafCount() ) );
285  }
286  else if ( item->type() == QgsCptCityDataItem::Selection )
287  {
288  lblSchemePath->setText( "" );
290  updateListWidget( item );
291  lblCollectionInfo->setText( QString( "%1 (%2)" ).arg( item->info() ).arg( item->leafCount() ) );
292  }
293  else if ( item->type() == QgsCptCityDataItem::AllRamps )
294  {
295  lblSchemePath->setText( "" );
297  updateListWidget( item );
298  lblCollectionInfo->setText( tr( "All Ramps (%1)" ).arg( item->leafCount() ) );
299  }
300  else
301  {
302  QgsDebugMsg( QString( "item %1 has invalid type %2" ).arg( item->path() ).arg(( int )item->type() ) );
303  }
304 }
305 
307 {
308  QgsCptCityColorRampItem *rampItem = mListRamps.at( item->data( Qt::UserRole ).toInt() );
309  if ( rampItem )
310  {
311  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true );
312  lblSchemeName->setText( QFileInfo( rampItem->name() ).fileName() );
313  mRamp->copy( &rampItem->ramp() );
314  QgsDebugMsg( QString( "variant= %1 - %2 variants" ).arg( mRamp->variantName() ).arg( mRamp->variantList().count() ) );
316  }
317  else
318  {
319  QgsDebugMsg( "invalid item" );
320  }
321 }
322 
324 {
325  if ( mListWidget->selectedItems().count() == 0 )
326  {
327  mRamp->setName( "", "" );
328  }
329 }
330 
332 {
333  QgsDebugMsg( "Entered" );
334  if ( index == 0 )
335  {
338  }
339  else if ( index == 1 )
340  {
343  }
344  else
345  {
346  QgsDebugMsg( QString( "invalid index %1" ).arg( index ) );
349  }
350 
351  mListWidget->blockSignals( true );
352  updateRamp();
353  mListWidget->blockSignals( false );
354 }
355 
356 
358 {
359  QString path, title, copyFile, descFile;
360 
361  // get basic information, depending on if is color ramp or directory
362  QgsCptCityDataItem *item = mModel->dataItem( mTreeFilter->mapToSource( mTreeView->currentIndex() ) );
363  if ( ! item )
364  return;
365 
366  path = item->path();
367  if ( item->type() == QgsCptCityDataItem::Directory )
368  {
369  title = tr( "%1 directory details" ).arg( item->path() );
370  }
371  else if ( item->type() == QgsCptCityColorRampItem::Directory )
372  {
373  title = tr( "%1 gradient details" ).arg( path );
374  }
375  else
376  {
377  return;
378  }
379  copyFile = mArchive->copyingFileName( path );
380  descFile = mArchive->descFileName( path );
381 
382  // prepare dialog
383  QgsDialog dlg( this, 0, QDialogButtonBox::Close );
384  QVBoxLayout *layout = dlg.layout();
385  dlg.setWindowTitle( title );
386  QTextEdit *textEdit = new QTextEdit( &dlg );
387  textEdit->setReadOnly( true );
388  layout->addWidget( textEdit );
389 
390  // add contents of DESC.xml and COPYING.xml
391  QString copyText;
392  if ( ! copyFile.isNull() )
393  {
394  QFile file( copyFile );
395  if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
396  {
397  copyText = QString( file.readAll() );
398  file.close();
399  }
400  }
401  QString descText;
402  if ( ! descFile.isNull() )
403  {
404  QFile file( descFile );
405  if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
406  {
407  descText = QString( file.readAll() );
408  file.close();
409  }
410  }
411  textEdit->insertPlainText( title + "\n\n" );
412  textEdit->insertPlainText( "===================" );
413  textEdit->insertPlainText( " copying " );
414  textEdit->insertPlainText( "===================\n" );
415  textEdit->insertPlainText( copyText );
416  textEdit->insertPlainText( "\n" );
417  textEdit->insertPlainText( "==================" );
418  textEdit->insertPlainText( " description " );
419  textEdit->insertPlainText( "==================\n" );
420  textEdit->insertPlainText( descText );
421  textEdit->moveCursor( QTextCursor::Start );
422 
423  dlg.resize( 600, 600 );
424  dlg.exec();
425 }
426 
428 {
429  QSize size = lblPreview->size();
430 
431  if ( clear || mRamp->schemeName() == "" )
432  {
433  lblSchemeName->setText( "" );
434  lblSchemePath->setText( "" );
435  lblLicensePreview->setText( "" );
436  QPixmap blankPixmap( size );
437  blankPixmap.fill( Qt::transparent );
438  lblPreview->setPixmap( blankPixmap );
439  return;
440  }
441 
442  mRamp->loadFile();
443 
444  lblSchemePath->setText( mRamp->schemeName() + mRamp->variantName() );
445 
446  // update pixmap
447  // TODO draw checker-board/transparent background
448  // for transparent, add [ pixmap.fill( Qt::transparent ); ] to QgsSymbolLayerV2Utils::colorRampPreviewPixmap
450  lblPreview->setPixmap( pixmap );
451 
452  // add copyright information from COPYING.xml file
454 }
455 
457 {
459 }
460 
462 {
463  QString authorStr = copyingMap.value( "authors" );
464  if ( authorStr.length() > 80 )
465  authorStr.replace( authorStr.indexOf( " ", 80 ), 1, "\n" );
466  lblAuthorName->setText( authorStr );
467  QString licenseStr = copyingMap.value( "license/informal" );
468  if ( copyingMap.contains( "license/year" ) )
469  licenseStr += " (" + copyingMap.value( "license/year" ) + ")";
470  if ( licenseStr.length() > 80 )
471  licenseStr.replace( licenseStr.indexOf( " ", 80 ), 1, "\n" );
472  if ( copyingMap.contains( "license/url" ) )
473  licenseStr += "\n[ " + copyingMap.value( "license/url" ) + " ]";
474  else
475  licenseStr += "\n";
476  lblLicenseName->setText( licenseStr );
477  licenseStr.replace( "\n", " " );
478  lblLicensePreview->setText( licenseStr );
479  lblLicensePreview->setCursorPosition( 0 );
480  if ( copyingMap.contains( "src/link" ) )
481  lblSrcLink->setText( copyingMap.value( "src/link" ) );
482  else
483  lblSrcLink->setText( "" );
484 }
485 
487 {
488  Q_UNUSED( index );
489  if ( cboVariantName->currentIndex() != -1 )
490  mRamp->setVariantName( cboVariantName->itemData( cboVariantName->currentIndex(), Qt::UserRole ).toString() );
491  QgsDebugMsg( QString( "variant= %1 - %2 variants" ).arg( mRamp->variantName() ).arg( mRamp->variantList().count() ) );
492  updatePreview();
493 }
494 
496 {
497  // save settings
498  QSettings settings;
499  settings.setValue( "/Windows/CptCityColorRampV2Dialog/geometry", saveGeometry() );
500  settings.setValue( "/Windows/CptCityColorRampV2Dialog/splitter", mSplitter->saveState() );
501 }
502 
504 {
505  // show error message to use color ramp manager to get more gradients
506  QString helpText = tr( "You can download a more complete set of cpt-city gradients "
507  "by installing the \"Color Ramp Manager\" plugin "
508  "(you must enable Experimental plugins in the plugin manager).\n\n"
509  );
510  QMessageBox* msg = new QMessageBox( this );
511  msg->setText( helpText );
512  msg->exec();
513 }
514 
516 {
517  QgsDebugMsg( QString( "result: %1 checked: %2" ).arg( result() ).arg( cboConvertStandard->isChecked() ) );
518  // if "save as standard gradient" is checked, convert to QgsVectorGradientColorRampV2
519  return ( result() == Accepted && cboConvertStandard->isChecked() );
520 }
521 
523 {
524  mListWidget->blockSignals( true );
525  mListWidget->clear();
526  mListRamps.clear();
527  QgsCptCityCollectionItem* colItem = dynamic_cast<QgsCptCityCollectionItem*>( item );
528  if ( colItem )
529  {
530  QgsDebugMsg( "path= " + item->path() );
531  // recursively get children ramps
532  QVector<QgsCptCityDataItem*> childrenRamps = colItem->childrenRamps( true );
533  for ( int i = 0; i < childrenRamps.count(); i++ )
534  {
535  QgsCptCityColorRampItem* rampItem = dynamic_cast<QgsCptCityColorRampItem*>( childrenRamps[i] );
536  if ( ! rampItem )
537  {
538  QgsDebugMsg( "invalid item " + childrenRamps[i]->path() );
539  continue;
540  }
541  QListWidgetItem* listItem = new QListWidgetItem();
542  listItem->setText( rampItem->shortInfo() );
543  listItem->setIcon( rampItem->icon( QSize( 75, 50 ) ) );
544  listItem->setToolTip( rampItem->path() + "\n" + rampItem->info() );
545  listItem->setData( Qt::UserRole, QVariant( i ) );
546  mListWidget->addItem( listItem );
547  mListRamps << rampItem;
548  }
549  }
550  else
551  {
552  QgsDebugMsg( "invalid item" );
553  }
554  mListWidget->blockSignals( false );
555 }
556 
557 // this function is for a svg preview, available if the svg files have been processed with svgx
558 // e.g. for f in `ls */*/*/*/*.svg`; do echo $f ; svgx -p -t svg $f > tmp1.svg; mv tmp1.svg $f; done
559 // perhaps a future version of the cpt-city svg gradients will have them by default
561 {
562  QSize size = lblPreview->size();
563 
564  if ( event->type() == QEvent::MouseButtonPress )
565  {
566  // create preview from svg file if supported - depends on file versions
567  QPixmap pixmap( mRamp->fileName() );
568  if ( ! pixmap.isNull() )
569  lblPreview->setPixmap( pixmap.scaled( size ) );
570  return true;
571  }
572  else if ( event->type() == QEvent::MouseButtonRelease )
573  {
574  // restore preview
576  lblPreview->setPixmap( pixmap );
577  return true;
578  }
579  else
580  {
581  // standard event processing
582  return QObject::eventFilter( obj, event );
583  }
584 }
585 
587 {
588  QgsDebugMsg( "Entered" );
589  mListWidget->clear();
590  mListRamps.clear();
591  cboVariantName->clear();
593  lblCollectionInfo->clear();
594 
595  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
596  updatePreview( true );
597 
598  QgsDebugMsg( "schemeName= " + mRamp->schemeName() );
599  if ( mRamp->schemeName() == "" )
600  {
601  showAll();
602  return false;
603  }
604 
605  // search for item in model
606  QModelIndex modelIndex = mModel->findPath( mRamp->schemeName() );
607  if ( modelIndex == QModelIndex() )
608  {
609  return false;
610  }
611  QgsCptCityColorRampItem* childItem =
612  dynamic_cast<QgsCptCityColorRampItem*>( mModel->dataItem( modelIndex ) );
613  if ( ! childItem )
614  return false;
615  if ( mRamp->schemeName() != childItem->ramp().schemeName() )
616  return false;
617 
618  // found child, set mRamp variantList
619  // mRamp->copy( &childItem->ramp() );
620  mRamp->setVariantList( childItem->ramp().variantList() );
621 
622  // found child, update tree
623  QgsDebugMsg( QString( "found item %1" ).arg( mRamp->schemeName() ) );
624  lblSchemeName->setText( QFileInfo( mRamp->schemeName() ).fileName() );
625  QModelIndex parentIndex = modelIndex.parent();
626  QModelIndex selIndex = mTreeFilter->mapFromSource( parentIndex );
627 
628  // QgsDebugMsg(QString("parent row=%1 path=%2 parentRow=%3").arg(parentIndex.row()).arg(mModel->dataItem( parentIndex )->path()).arg(parentIndex.parent().row()));
629  mTreeView->setCurrentIndex( selIndex );
630  mTreeView->setExpanded( selIndex, true );
631  mTreeView->scrollTo( selIndex, QAbstractItemView::PositionAtCenter );
632  updateTreeView( mModel->dataItem( parentIndex ), false );
633 
634  // update listWidget, find appropriate item in mListRamps
635  for ( int i = 0; i < mListRamps.count(); i++ )
636  {
637  if ( mListRamps[i] == childItem )
638  {
639  QgsDebugMsg( QString( "found matching item %1 target=%2" ).arg( mListRamps[i]->path(), childItem->path() ) );
640  QListWidgetItem* listItem = mListWidget->item( i );
641  mListWidget->setCurrentItem( listItem );
642  // on_mListWidget_itemClicked( listItem );
644  mListWidget->scrollToItem( listItem, QAbstractItemView::EnsureVisible );
645  // mListView->selectionModel()->select( childIndex, QItemSelectionModel::Select );
646  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true );
647  return true;
648  }
649  }
650 
651  return false;
652 }
653 
655 {
656  QModelIndex modelIndex = mModel->findPath( "" );
657  if ( modelIndex != QModelIndex() )
658  {
659  QModelIndex selIndex = mTreeFilter->mapFromSource( modelIndex );
660  mTreeView->setCurrentIndex( selIndex );
661  mTreeView->setExpanded( selIndex, true );
662  mTreeView->scrollTo( selIndex, QAbstractItemView::PositionAtCenter );
663  updateTreeView( mModel->dataItem( modelIndex ), false );
664  }
665 }
666 
668 {
669  QgsDebugMsg( "Entered" );
670  mModel = model;
671 
672  if ( mTreeFilter )
673  delete mTreeFilter;
674  mTreeFilter = new TreeFilterProxyModel( this, mModel );
675  mTreeView->setModel( mTreeFilter );
676 }
677 
678 #if 0
679 void QgsCptCityColorRampV2Dialog::refresh()
680 {
681  QApplication::setOverrideCursor( Qt::WaitCursor );
682  refreshModel( QModelIndex() );
684 }
685 
686 void QgsCptCityColorRampV2Dialog::refreshModel( const QModelIndex& index )
687 {
688  if ( index.isValid() )
689  {
690  QgsCptCityDataItem *item = mModel->dataItem( index );
691  if ( item )
692  {
693  QgsDebugMsg( "path = " + item->path() );
694  }
695  else
696  {
697  QgsDebugMsg( "invalid item" );
698  }
699  }
700 
701  mModel->refresh( index );
702 
703  for ( int i = 0 ; i < mModel->rowCount( index ); i++ )
704  {
705  QModelIndex idx = mModel->index( i, 0, index );
706  if ( mTreeView->isExpanded( idx ) || !mModel->hasChildren( idx ) )
707  {
708  refreshModel( idx );
709  }
710  }
711 }
712 #endif
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)
Type type() const
void setupUi(QWidget *widget)
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
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's home dir.
QgsCptCityBrowserModel * mSelectionsModel
void fill(const QColor &color)
void copy(const QgsCptCityColorRampV2 *other)
virtual void setSourceModel(QAbstractItemModel *sourceModel)
#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
TreeFilterProxyModel(QObject *parent, QgsCptCityBrowserModel *model)
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)
QgsCptCityColorRampV2Dialog(QgsCptCityColorRampV2 *ramp, QWidget *parent=NULL)
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
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)
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
bool eventFilter(QObject *obj, QEvent *event) override
QByteArray saveGeometry() const
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) 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