All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DataExchangeSummaryWizardPage.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/plugins/exchanger/DataExchangeSummaryWizardPage.cpp
22 
23  \brief A Qt dialog for ....
24 */
25 
26 // TerraLib
27 #include "../../../dataaccess/dataset/DataSetType.h"
28 #include "ui_DataExchangeSummaryWizardPageForm.h"
29 #include "DataExchangeStatus.h"
31 
32 // Boost
33 #include <boost/lexical_cast.hpp>
34 
35 // Qt
36 #include <QIcon>
37 #include <QMessageBox>
38 
40  : QWizardPage(parent),
41  m_ui(new Ui::DataExchangeSummaryWizardPageForm)
42 {
43 // setup controls
44  m_ui->setupUi(this);
45 
46  m_status = true;
47 
48  m_ui->m_reportTableWidget->resizeColumnsToContents();
49 }
50 
52 {
53 }
54 
56 {
57  return m_status;
58 }
59 
60 void te::qt::widgets::DataExchangeSummaryWizardPage::set(const std::list<DataExchangeStatus>& result)
61 {
62  m_ui->m_reportTableWidget->clearContents();
63 
64  m_ui->m_reportTableWidget->setRowCount(static_cast<int>(result.size()));
65 
66  int row = 0;
67 
68  for(std::list<DataExchangeStatus>::const_iterator it = result.begin(); it != result.end(); ++it)
69  {
70  QTableWidgetItem* item = new QTableWidgetItem(it->m_successful ? QIcon::fromTheme("check") : QIcon::fromTheme("delete"), "");
71  m_ui->m_reportTableWidget->setItem(row, 0, item);
72 
73  item = new QTableWidgetItem(QString::fromStdString(it->m_dataset->getName()));
74  m_ui->m_reportTableWidget->setItem(row, 1, item);
75 
76  if(it->m_successful)
77  {
78  std::string t;
79 
80  double sec = it->m_time.count();
81 
82  if(sec < 1.0)
83  {
84  boost::chrono::milliseconds dmili(boost::chrono::duration_cast<boost::chrono::milliseconds>(it->m_time));
85 
86  t = boost::lexical_cast<std::string>(dmili.count());
87  t += " miliseconds";
88  }
89  else if(sec < 60.0)
90  {
91  boost::chrono::seconds dseconds(boost::chrono::duration_cast<boost::chrono::seconds>(it->m_time));
92  t = boost::lexical_cast<std::string>(dseconds.count());
93  t += " seconds";
94  }
95  else if(sec < 3600.0)
96  {
97  boost::chrono::minutes dminutes(boost::chrono::duration_cast<boost::chrono::minutes>(it->m_time));
98  t = boost::lexical_cast<std::string>(dminutes.count());
99  t += " minutes";
100  }
101  else
102  {
103  t = boost::lexical_cast<std::string>(it->m_time.count());
104  t += " seconds";
105  }
106 
107  item = new QTableWidgetItem(QString::fromStdString(t));
108  m_ui->m_reportTableWidget->setItem(row, 2, item);
109  }
110  else
111  m_status = false;
112 
113  item = new QTableWidgetItem(it->m_successful ? tr("Successfully transferred") : QString::fromStdString(it->m_exceptionMsg));
114  m_ui->m_reportTableWidget->setItem(row, 3, item);
115 
116  ++row;
117  }
118 
119  m_ui->m_reportTableWidget->resizeColumnsToContents();
120 }
121 
std::auto_ptr< Ui::DataExchangeSummaryWizardPageForm > m_ui
void set(const std::list< DataExchangeStatus > &result)