예제 #1
0
void QgsCptCityColorRampDialog::mTreeView_clicked( const QModelIndex &index )
{
  const QModelIndex &sourceIndex = mTreeFilter->mapToSource( index );
  QgsCptCityDataItem *item = mModel->dataItem( sourceIndex );
  if ( ! item )
    return;
  QgsDebugMsg( QStringLiteral( "item %1 clicked" ).arg( item->name() ) );
  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
  updateTreeView( item );
}
 bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override
 {
   QgsCptCityDataItem* item = mModel->dataItem( mModel->index( sourceRow, 0, sourceParent ) );
   return ( item && !( item->type() == QgsCptCityDataItem::ColorRamp ) );
 }
예제 #3
0
void QgsCptCityColorRampDialog::pbtnLicenseDetails_pressed()
{
  QString path, title, copyFile, descFile;

  // get basic information, depending on if is color ramp or directory
  QgsCptCityDataItem *item = mModel->dataItem( mTreeFilter->mapToSource( mTreeView->currentIndex() ) );
  if ( ! item )
    return;

  path = item->path();
  if ( item->type() == QgsCptCityDataItem::Directory )
  {
    title = tr( "%1 Directory Details" ).arg( item->path() );
  }
  else if ( item->type() == QgsCptCityColorRampItem::Directory )
  {
    title = tr( "%1 Gradient Details" ).arg( path );
  }
  else
  {
    return;
  }
  copyFile = mArchive->copyingFileName( path );
  descFile = mArchive->descFileName( path );

  // prepare dialog
  QgsDialog dlg( this, nullptr, QDialogButtonBox::Close );
  QVBoxLayout *layout = dlg.layout();
  dlg.setWindowTitle( title );
  QTextEdit *textEdit = new QTextEdit( &dlg );
  textEdit->setReadOnly( true );
  layout->addWidget( textEdit );

  // add contents of DESC.xml and COPYING.xml
  QString copyText;
  if ( ! copyFile.isNull() )
  {
    QFile file( copyFile );
    if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
    {
      copyText = QString( file.readAll() );
      file.close();
    }
  }
  QString descText;
  if ( ! descFile.isNull() )
  {
    QFile file( descFile );
    if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
    {
      descText = QString( file.readAll() );
      file.close();
    }
  }
  textEdit->insertPlainText( title + "\n\n" );
  textEdit->insertPlainText( QStringLiteral( "===================" ) );
  textEdit->insertPlainText( QStringLiteral( " copying " ) );
  textEdit->insertPlainText( QStringLiteral( "===================\n" ) );
  textEdit->insertPlainText( copyText );
  textEdit->insertPlainText( QStringLiteral( "\n" ) );
  textEdit->insertPlainText( QStringLiteral( "==================" ) );
  textEdit->insertPlainText( QStringLiteral( " description " ) );
  textEdit->insertPlainText( QStringLiteral( "==================\n" ) );
  textEdit->insertPlainText( descText );
  textEdit->moveCursor( QTextCursor::Start );

  dlg.resize( 600, 600 );
  dlg.exec();
}