Ejemplo n.º 1
0
void QgsGrassTools::showTabs()
{
  QgsDebugMsg( "entered." );

  QString title;
  if ( QgsGrass::activeMode() )
  {
    title = tr( "GRASS Tools: %1/%2" ).arg( QgsGrass::getDefaultLocation() ).arg( QgsGrass::getDefaultMapset() );
  }
  else
  {
#ifdef GRASS_DIRECT
    title = tr( "GRASS Direct Tools" );
#else
    title = tr( "GRASS Tools" );
#endif
  }
  setWindowTitle( title );

  // we always show tabs but disabled if not active
  // direct mode currently disabled
  mTabWidget->removeTab( mTabWidget->indexOf( mDirectModulesTreeTab ) );
  mTabWidget->removeTab( mTabWidget->indexOf( mDirectModulesListTab ) );
#if 0
  mTabWidget->removeTab( mTabWidget->indexOf( mModulesListTab ) );
  mTabWidget->removeTab( mTabWidget->indexOf( mModulesTreeTab ) );

  mTabWidget->insertTab( 0, mModulesTreeTab, tr( "Modules Tree" ) );
  mTabWidget->insertTab( 1, mModulesListTab, tr( "Modules List" ) );

  repaint();
#endif

  QString conf = QgsApplication::pkgDataPath() + "/grass/config/default.qgc";
  if ( QgsGrass::activeMode() )
  {
    QgsDebugMsg( QString( "topLevelItemCount = %1" ).arg( mModulesTree->topLevelItemCount() ) );
    if ( mModulesTree->topLevelItemCount() == 0 )
    {
      // Load the modules lists
      QApplication::setOverrideCursor( Qt::WaitCursor );
      loadConfig( conf, mModulesTree, mModulesListModel, false );
      QApplication::restoreOverrideCursor();
    }
    QgsDebugMsg( QString( "topLevelItemCount = %1" ).arg( mModulesTree->topLevelItemCount() ) );
    mTabWidget->setEnabled( true );
  }
  else
  {
#ifdef GRASS_DIRECT
    // Remove open indirect modules tabs
    for ( int i = mTabWidget->count() - 1; i >= 0; i-- )
    {
      QgsGrassModule *module = qobject_cast<QgsGrassModule *>( mTabWidget->widget( i ) );
      if ( module && !module->isDirect() )
      {
        mTabWidget->removeTab( i );
        delete module;
      }
    }

    mTabWidget->insertTab( 0, mDirectModulesTreeTab, tr( "Direct Modules Tree" ) );
    mTabWidget->insertTab( 1, mDirectModulesListTab, tr( "Direct Modules List" ) );
    repaint();
    if ( mDirectModulesTree->topLevelItemCount() == 0 )
    {
      QApplication::setOverrideCursor( Qt::WaitCursor );
      loadConfig( conf, mDirectModulesTree, mDirectModulesListModel, true );
      QApplication::restoreOverrideCursor();
    }
#else
    mTabWidget->setEnabled( false );
#endif
  }
}
Ejemplo n.º 2
0
void QgsGrassTools::showTabs()
{
  QgsDebugMsg( "entered." );

  QString title;
  if ( QgsGrass::activeMode() )
  {
    title = tr( "GRASS Tools: %1/%2" ).arg( QgsGrass::getDefaultLocation() ).arg( QgsGrass::getDefaultMapset() );
    mBrowser->setLocation( QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation() );
  }
  else
  {
    title = tr( "GRASS Direct Tools" );
  }
  setWindowTitle( title );

  mTabWidget->removeTab( mTabWidget->indexOf( mModulesTreeTab ) );
  mTabWidget->removeTab( mTabWidget->indexOf( mDirectModulesTreeTab ) );
  mTabWidget->removeTab( mTabWidget->indexOf( mModulesListTab ) );
  mTabWidget->removeTab( mTabWidget->indexOf( mDirectModulesListTab ) );
  mTabWidget->removeTab( mTabWidget->indexOf( mBrowser ) );

  QString conf = QgsApplication::pkgDataPath() + "/grass/config/default.qgc";
  if ( QgsGrass::activeMode() )
  {
    mTabWidget->insertTab( 0, mModulesTreeTab, tr( "Modules Tree" ) );
    mTabWidget->insertTab( 1, mModulesListTab, tr( "Modules List" ) );
    mTabWidget->insertTab( 2, mBrowser, tr( "Browser" ) );
    repaint();
    QgsDebugMsg( QString( "topLevelItemCount = %1" ).arg( mModulesTree->topLevelItemCount() ) );
    if ( mModulesTree->topLevelItemCount() == 0 )
    {
      // Load the modules lists
      QApplication::setOverrideCursor( Qt::WaitCursor );
      loadConfig( conf, mModulesTree, mModulesListModel, false );
      QApplication::restoreOverrideCursor();
    }
    QgsDebugMsg( QString( "topLevelItemCount = %1" ).arg( mModulesTree->topLevelItemCount() ) );
  }
  else
  {
    // Remove open indirect modules tabs
    for ( int i = mTabWidget->count() - 1; i >= 0; i-- )
    {
      QgsGrassModule *module = qobject_cast<QgsGrassModule *>( mTabWidget->widget( i ) );
      if ( module && !module->isDirect() )
      {
        mTabWidget->removeTab( i );
        delete module;
      }
    }

    mTabWidget->insertTab( 0, mDirectModulesTreeTab, tr( "Direct Modules Tree" ) );
    mTabWidget->insertTab( 1, mDirectModulesListTab, tr( "Direct Modules List" ) );
    repaint();
    if ( mDirectModulesTree->topLevelItemCount() == 0 )
    {
      QApplication::setOverrideCursor( Qt::WaitCursor );
      loadConfig( conf, mDirectModulesTree, mDirectModulesListModel, true );
      QApplication::restoreOverrideCursor();
    }
  }
}