VPTissue Reference Manual
Compressor.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "../../../cpp_simptshell/workspace/util/Compressor.h"
21 
22 #include "fileformats/PTreeFile.h"
23 
24 #include <QAction>
25 #include <QFile>
26 
27 namespace SimPT_Shell{
28 namespace Ws {
29 namespace Util {
30 
31 using namespace std;
32 using namespace SimPT_Sim::Util;
33 
34 Compressor::Compressor(const string& path)
35  : m_path(path)
36 {
37  m_a_compress = new QAction("Compress", this);
38  m_a_decompress = new QAction("Decompress", this);
39 
40  connect(m_a_compress, SIGNAL(triggered()), this, SLOT(SLOT_Compress()));
41  connect(m_a_decompress, SIGNAL(triggered()), this, SLOT(SLOT_Decompress()));
42 }
43 
44 QAction* Compressor::GetActionCompress() const
45 {
46  return m_a_compress;
47 }
48 
49 QAction* Compressor::GetActionDecompress() const
50 {
51  return m_a_decompress;
52 }
53 
54 void Compressor::SLOT_Compress()
55 {
56  string new_path = m_path + ".gz";
57  PTreeFile::Compress(m_path, new_path);
58 
59  // delete this file - will be sensed by project, and cause this object to be deleted.
60  QFile::remove(QString::fromStdString(m_path));
61 }
62 
63 void Compressor::SLOT_Decompress()
64 {
65  string new_path = m_path.substr(0, m_path.length()-3); // strip .gz extension
66  PTreeFile::Decompress(m_path, new_path);
67 
68  // delete this file - will be sensed by project, and cause this object to be deleted.
69  QFile::remove(QString::fromStdString(m_path));
70 }
71 
72 } // namespace
73 } // namespace
74 } // namespace
STL namespace.
Interface for PTreeFile.
Namespace for miscellaneous utilities.
Definition: PTreeFile.cpp:44
Namespace for SimPT shell package.
Definition: Client.cpp:50