<commit_before>/*=========================================================================

  Program:   Monteverdi2
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#include "mvdMainWindow.h"
#include "ui_mvdMainWindow.h"


/*****************************************************************************/
/* INCLUDE SECTION                                                           */

//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtGui>

//
// System includes (sorted by alphabetic order)

//
// ITK includes (sorted by alphabetic order)

//
// OTB includes (sorted by alphabetic order)

//
// Monteverdi includes (sorted by alphabetic order)
#include "Core/mvdDatabaseModel.h"
#include "Core/mvdDatasetModel.h"
#include "Core/mvdI18nApplication.h"
//
#include "Gui/mvdDatabaseBrowserController.h"
#include "Gui/mvdDatabaseBrowserWidget.h"
#include "Gui/mvdGLImageWidget.h"
#include "Gui/mvdImageModelRenderer.h"
#include "Gui/mvdQuicklookViewManipulator.h"
#include "Gui/mvdApplicationsToolBox.h"

#include "Core/mvdI18nApplication.h"
#include "mvdCatalogueApplication.h"

#ifdef OTB_WRAP_QT
#include "ApplicationsWrapper/mvdApplicationsToolBoxController.h"
#include "ApplicationsWrapper/mvdOTBApplicationsModel.h"
#endif

namespace mvd
{

/*
  TRANSLATOR mvd::MainWindow

  Necessary for lupdate to be aware of C++ namespaces.

  Context comment for translator.
*/


/*****************************************************************************/
/* CONSTANTS                                                                 */


/*****************************************************************************/
/* STATIC IMPLEMENTATION SECTION                                             */


/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION                                              */

/*****************************************************************************/
MainWindow
::MainWindow( QWidget* parent, Qt::WindowFlags flags ) :
  I18nMainWindow( parent, flags ), 
  m_UI( new mvd::Ui::MainWindow() ),
  m_DatabaseBrowserDock( NULL ),
  m_ApplicationsBrowserDock(NULL),
  m_QuicklookView( NULL )
{
  m_UI->setupUi( this );
}

/*****************************************************************************/
MainWindow
::~MainWindow()
{
}

/*****************************************************************************/
void
MainWindow
::virtual_SetupUI()
{
  setObjectName( "mvd::MainWindow" );
  setWindowTitle( PROJECT_NAME );

  InitializeDockWidgets();

  InitializeCentralWidget();

  assert( m_QuicklookView==NULL );
  m_QuicklookView = CreateQuicklookWidget();

  m_CentralWidgetTabs->addTab(m_QuicklookView, "Quicklook");
}

/*****************************************************************************/
void
MainWindow
::virtual_ConnectUI()
{

#ifdef OTB_WRAP_QT
  //
  // Done here cause needed to be done once
  SetControllerModel(m_ApplicationsBrowserDock, 
                     I18nApplication::Instance< CatalogueApplication >()->GetOTBApplicationsModel());

  //
  // need to get the ApplicationToolBox widget to setup connections.
  // a double click on the tree widget should trigger a signal connected
  // to this MainWindow slot. this slot will be in charge of getting the
  // widget of the application selected, and show it in the
  // MainWindow centralView.  
  
  // # Step 1 : get the ApplicationToolBoxWidget
  ApplicationsToolBox* appWidget = 
    qobject_cast< ApplicationsToolBox * >( 
      m_ApplicationsBrowserDock->findChild< ApplicationsToolBox* >( ) 
      );
  
  // # Step 2 : setup connections
  assert(appWidget != NULL);
  QObject::connect(appWidget,
                   SIGNAL( ApplicationToLaunchSelected(const QString &) ),
                   this,
                   SLOT( OnApplicationToLaunchSelected(const QString &) )
    );
#endif

  QObject::connect(m_CentralWidgetTabs,
                   SIGNAL(tabCloseRequested(int)),
                   this,
                   SLOT(OntabCloseRequested(int))
    );

}

/*****************************************************************************/
void
MainWindow
::InitializeDockWidgets()
{
  assert( m_DatabaseBrowserDock==NULL );
  m_DatabaseBrowserDock =
    AddDockWidget
    < DatabaseBrowserWidget, DatabaseBrowserController, QDockWidget >
    ( "DATABASE_BROWSER", tr( "Database browser" ), Qt::LeftDockWidgetArea );


#ifdef OTB_WRAP_QT

  assert (m_ApplicationsBrowserDock == NULL);
  m_ApplicationsBrowserDock =
    AddDockWidget
    < ApplicationsToolBox, ApplicationsToolBoxController, QDockWidget >
    ( "APPLICATIONS_BROWSER", tr( "Applications browser" ), Qt::RightDockWidgetArea );

#endif
}

/*****************************************************************************/
void
MainWindow
::InitializeCentralWidget()
{
  //
  // need to setup the central widget as QTabWidget to be able to <commit_msg>ENH: comment<commit_after>/*=========================================================================

  Program:   Monteverdi2
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#include "mvdMainWindow.h"
#include "ui_mvdMainWindow.h"


/*****************************************************************************/
/* INCLUDE SECTION                                                           */

//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtGui>

//
// System includes (sorted by alphabetic order)

//
// ITK includes (sorted by alphabetic order)

//
// OTB includes (sorted by alphabetic order)

//
// Monteverdi includes (sorted by alphabetic order)
#include "Core/mvdDatabaseModel.h"
#include "Core/mvdDatasetModel.h"
#include "Core/mvdI18nApplication.h"
//
#include "Gui/mvdDatabaseBrowserController.h"
#include "Gui/mvdDatabaseBrowserWidget.h"
#include "Gui/mvdGLImageWidget.h"
#include "Gui/mvdImageModelRenderer.h"
#include "Gui/mvdQuicklookViewManipulator.h"
#include "Gui/mvdApplicationsToolBox.h"

#include "Core/mvdI18nApplication.h"
#include "mvdCatalogueApplication.h"

#ifdef OTB_WRAP_QT
#include "ApplicationsWrapper/mvdApplicationsToolBoxController.h"
#include "ApplicationsWrapper/mvdOTBApplicationsModel.h"
#endif

namespace mvd
{

/*
  TRANSLATOR mvd::MainWindow

  Necessary for lupdate to be aware of C++ namespaces.

  Context comment for translator.
*/


/*****************************************************************************/
/* CONSTANTS                                                                 */


/*****************************************************************************/
/* STATIC IMPLEMENTATION SECTION                                             */


/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION                                              */

/*****************************************************************************/
MainWindow
::MainWindow( QWidget* parent, Qt::WindowFlags flags ) :
  I18nMainWindow( parent, flags ), 
  m_UI( new mvd::Ui::MainWindow() ),
  m_DatabaseBrowserDock( NULL ),
  m_ApplicationsBrowserDock(NULL),
  m_QuicklookView( NULL )
{
  m_UI->setupUi( this );
}

/*****************************************************************************/
MainWindow
::~MainWindow()
{
}

/*****************************************************************************/
void
MainWindow
::virtual_SetupUI()
{
  setObjectName( "mvd::MainWindow" );
  setWindowTitle( PROJECT_NAME );

  InitializeDockWidgets();

  InitializeCentralWidget();

  assert( m_QuicklookView==NULL );
  m_QuicklookView = CreateQuicklookWidget();

  m_CentralWidgetTabs->addTab(m_QuicklookView, "Quicklook");
}

/*****************************************************************************/
void
MainWindow
::virtual_ConnectUI()
{

#ifdef OTB_WRAP_QT
  //
  // Done here cause needed to be done once
  SetControllerModel(m_ApplicationsBrowserDock, 
                     I18nApplication::Instance< CatalogueApplication >()->GetOTBApplicationsModel());

  //
  // need to get the ApplicationToolBox widget to setup connections.
  // a double click on the tree widget should trigger a signal connected
  // to this MainWindow slot. this slot will be in charge of getting the
  // widget of the application selected, and show it in the
  // MainWindow centralView.  
  
  // # Step 1 : get the ApplicationToolBoxWidget
  ApplicationsToolBox* appWidget = 
    qobject_cast< ApplicationsToolBox * >( 
      m_ApplicationsBrowserDock->findChild< ApplicationsToolBox* >( ) 
      );
  
  // # Step 2 : setup connections
  assert(appWidget != NULL);
  QObject::connect(appWidget,
                   SIGNAL( ApplicationToLaunchSelected(const QString &) ),
                   this,
                   SLOT( OnApplicationToLaunchSelected(const QString &) )
    );
#endif

  QObject::connect(m_CentralWidgetTabs,
                   SIGNAL(tabCloseRequested(int)),
                   this,
                   SLOT(OntabCloseRequested(int))
    );

}

/*****************************************************************************/
void
MainWindow
::InitializeDockWidgets()
{
  assert( m_DatabaseBrowserDock==NULL );
  m_DatabaseBrowserDock =
    AddDockWidget
    < DatabaseBrowserWidget, DatabaseBrowserController, QDockWidget >
    ( "DATABASE_BROWSER", tr( "Database browser" ), Qt::LeftDockWidgetArea );


#ifdef OTB_WRAP_QT

  assert (m_ApplicationsBrowserDock == NULL);
  m_ApplicationsBrowserDock =
    AddDockWidget
    < ApplicationsToolBox, ApplicationsToolBoxController, QDockWidget >
    ( "APPLICATIONS_BROWSER", tr( "Applications browser" ), Qt::RightDockWidgetArea );

#endif
}

/*****************************************************************************/
void
MainWindow
::InitializeCentralWidget()
{
  //
  // need to setup the central widget as QTabWidget to be able to 
  // open several applications + the quicklook
{'fraction_non_alphanumeric': 0.2519494987003342, 'fraction_numerical': 0.0020423319717786854, 'mean_word_length': 3.824451410658307, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4729570', 'n_tokens_mistral': 2919, 'n_tokens_neox': 2673, 'n_words': 650}