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 
53 
55 {
56  return m_status;
57 }
58 
59 void te::qt::widgets::DataExchangeSummaryWizardPage::set(const std::list<DataExchangeStatus>& result)
60 {
61  m_ui->m_reportTableWidget->clearContents();
62 
63  m_ui->m_reportTableWidget->setRowCount(static_cast<int>(result.size()));
64 
65  int row = 0;
66 
67  for(std::list<DataExchangeStatus>::const_iterator it = result.begin(); it != result.end(); ++it)
68  {
69  QTableWidgetItem* item = new QTableWidgetItem(it->m_successful ? QIcon::fromTheme("check") : QIcon::fromTheme("delete"), "");
70  m_ui->m_reportTableWidget->setItem(row, 0, item);
71 
72  item = new QTableWidgetItem(QString::fromUtf8(it->m_dataset->getName().c_str()));
73  m_ui->m_reportTableWidget->setItem(row, 1, item);
74 
75  if(it->m_successful)
76  {
77  std::string t;
78 
79  double sec = it->m_time.count();
80 
81  if(sec < 1.0)
82  {
83  boost::chrono::milliseconds dmili(boost::chrono::duration_cast<boost::chrono::milliseconds>(it->m_time));
84 
85  t = boost::lexical_cast<std::string>(dmili.count());
86  t += " miliseconds";
87  }
88  else if(sec < 60.0)
89  {
90  boost::chrono::seconds dseconds(boost::chrono::duration_cast<boost::chrono::seconds>(it->m_time));
91  t = boost::lexical_cast<std::string>(dseconds.count());
92  t += " seconds";
93  }
94  else if(sec < 3600.0)
95  {
96  boost::chrono::minutes dminutes(boost::chrono::duration_cast<boost::chrono::minutes>(it->m_time));
97  t = boost::lexical_cast<std::string>(dminutes.count());
98  t += " minutes";
99  }
100  else
101  {
102  t = boost::lexical_cast<std::string>(it->m_time.count());
103  t += " seconds";
104  }
105 
106  item = new QTableWidgetItem(QString::fromUtf8(t.c_str()));
107  m_ui->m_reportTableWidget->setItem(row, 2, item);
108  }
109  else
110  m_status = false;
111 
112  item = new QTableWidgetItem(it->m_successful ? tr("Successfully transferred") : QString::fromUtf8(it->m_exceptionMsg.c_str()));
113  m_ui->m_reportTableWidget->setItem(row, 3, item);
114 
115  ++row;
116  }
117 
118  m_ui->m_reportTableWidget->resizeColumnsToContents();
119 }
120 
std::unique_ptr< Ui::DataExchangeSummaryWizardPageForm > m_ui
void set(const std::list< DataExchangeStatus > &result)