1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1
// --------------------------------------------------------------------------
2
// OpenMS -- Open-Source Mass Spectrometry
3
// --------------------------------------------------------------------------
4
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
7
// This software is released under a three-clause BSD license:
8
// * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above copyright
11
// notice, this list of conditions and the following disclaimer in the
12
// documentation and/or other materials provided with the distribution.
13
// * Neither the name of any author or any participating institution
14
// may be used to endorse or promote products derived from this software
15
// without specific prior written permission.
16
// For a full list of authors, refer to the file AUTHORS.
17
// --------------------------------------------------------------------------
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
30
// --------------------------------------------------------------------------
24
31
// $Maintainer: Johannes Junker $
44
TOPPASInputFileListVertex::TOPPASInputFileListVertex()
48
pen_color_ = Qt::black;
49
brush_color_ = Qt::lightGray;
52
TOPPASInputFileListVertex::TOPPASInputFileListVertex(const QStringList& files)
56
pen_color_ = Qt::black;
57
brush_color_ = Qt::lightGray;
51
TOPPASInputFileListVertex::TOPPASInputFileListVertex() :
55
pen_color_ = Qt::black;
56
brush_color_ = Qt::lightGray;
59
TOPPASInputFileListVertex::TOPPASInputFileListVertex(const QStringList & files) :
63
pen_color_ = Qt::black;
64
brush_color_ = Qt::lightGray;
58
65
setFilenames(files);
61
TOPPASInputFileListVertex::TOPPASInputFileListVertex(const TOPPASInputFileListVertex& rhs)
65
pen_color_ = Qt::black;
66
brush_color_ = Qt::lightGray;
69
TOPPASInputFileListVertex::~TOPPASInputFileListVertex()
74
TOPPASInputFileListVertex& TOPPASInputFileListVertex::operator= (const TOPPASInputFileListVertex& rhs)
76
TOPPASVertex::operator=(rhs);
83
void TOPPASInputFileListVertex::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* /*e*/)
88
void TOPPASInputFileListVertex::showFilesDialog()
68
TOPPASInputFileListVertex::TOPPASInputFileListVertex(const TOPPASInputFileListVertex & rhs) :
72
pen_color_ = Qt::black;
73
brush_color_ = Qt::lightGray;
76
TOPPASInputFileListVertex::~TOPPASInputFileListVertex()
81
TOPPASInputFileListVertex & TOPPASInputFileListVertex::operator=(const TOPPASInputFileListVertex & rhs)
83
TOPPASVertex::operator=(rhs);
90
String TOPPASInputFileListVertex::getName() const
95
void TOPPASInputFileListVertex::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * /*e*/)
100
void TOPPASInputFileListVertex::showFilesDialog()
90
102
TOPPASInputFilesDialog tifd(this->getFileNames());
93
105
QStringList updated_filelist;
94
tifd.getFilenames(updated_filelist);
106
tifd.getFilenames(updated_filelist);
95
107
this->setFilenames(updated_filelist); // to correct filenames (separators etc)
96
qobject_cast<TOPPASScene*>(scene())->setChanged(true);
97
qobject_cast<TOPPASScene*>(scene())->updateEdgeColors();
98
emit somethingHasChanged();
104
void TOPPASInputFileListVertex::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/)
106
QPen pen(pen_color_, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
110
painter->setBrush(brush_color_.darker(130));
111
pen.setColor(Qt::darkBlue);
115
painter->setBrush(brush_color_);
117
painter->setPen(pen);
120
path.addRoundRect(-70.0, -40.0, 140.0, 80.0, 20, 20);
121
painter->drawPath(path);
123
pen.setColor(pen_color_);
124
painter->setPen(pen);
108
qobject_cast<TOPPASScene *>(scene())->setChanged(true);
109
qobject_cast<TOPPASScene *>(scene())->updateEdgeColors();
110
emit somethingHasChanged();
114
void TOPPASInputFileListVertex::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
116
QPen pen(pen_color_, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
120
painter->setBrush(brush_color_.darker(130));
121
pen.setColor(Qt::darkBlue);
125
painter->setBrush(brush_color_);
127
painter->setPen(pen);
130
path.addRoundRect(-70.0, -40.0, 140.0, 80.0, 20, 20);
131
painter->drawPath(path);
133
pen.setColor(pen_color_);
134
painter->setPen(pen);
136
// display number of input files
125
137
QString text = QString::number(getFileNames().size())
127
+ (getFileNames().size() == 1 ? "" : "s");
128
QRectF text_boundings = painter->boundingRect(QRectF(0,0,0,0), Qt::AlignCenter, text);
129
painter->drawText(-(int)(text_boundings.width()/2.0), (int)(text_boundings.height()/4.0), text);
139
+ (getFileNames().size() == 1 ? "" : "s");
140
QRectF text_boundings = painter->boundingRect(QRectF(0, 0, 0, 0), Qt::AlignCenter, text);
141
painter->drawText(-(int)(text_boundings.width() / 2.0), (int)(text_boundings.height() / 4.0), text);
143
// display file type(s)
144
Map<QString, Size> suffices;
145
foreach(QString fn, getFileNames())
147
QStringList l = QFileInfo(fn).completeSuffix().split('.');
148
QString suf = ((l.size() > 1 && l[l.size() - 2].size() <= 4) ? l[l.size() - 2] + "." : QString()) + l.back(); // take up to two dots as suffix (the first only if its <=4 chars, e.g. we want ".prot.xml" or ".tar.gz", but not "stupid.filename.with.longdots.mzML")
152
for (Map<QString, Size>::const_iterator sit = suffices.begin(); sit != suffices.end(); ++sit)
154
if (suffices.size() > 1)
155
text_l.push_back(String(".") + sit->first + "(" + String(sit->second) + ")");
157
text_l.push_back(String(".") + sit->first);
159
text = text_l.concatenate(" | ").toQString();
160
text_boundings = painter->boundingRect(QRectF(0, 0, 0, 0), Qt::AlignCenter, text);
161
painter->drawText(-(int)(text_boundings.width() / 2.0), 35 - (int)(text_boundings.height() / 4.0), text);
163
// topological sort number
132
164
qreal x_pos = -63.0;
133
165
qreal y_pos = -19.0;
134
166
painter->drawText(x_pos, y_pos, QString::number(topo_nr_));
137
169
if (this->allow_output_recycling_)
139
171
painter->setPen(Qt::green);
140
QSvgRenderer* svg_renderer = new QSvgRenderer(QString(":/Recycling_symbol.svg"), 0);
172
QSvgRenderer * svg_renderer = new QSvgRenderer(QString(":/Recycling_symbol.svg"), 0);
141
173
svg_renderer->render(painter, QRectF(-7, -32, 14, 14));
146
QRectF TOPPASInputFileListVertex::boundingRect() const
148
return QRectF(-71,-41,142,82);
151
QPainterPath TOPPASInputFileListVertex::shape () const
154
shape.addRoundRect(-71.0, -41.0, 142.0, 81.0, 20, 20);
158
bool TOPPASInputFileListVertex::fileNamesValid()
178
QRectF TOPPASInputFileListVertex::boundingRect() const
180
return QRectF(-71, -41, 142, 82);
183
QPainterPath TOPPASInputFileListVertex::shape() const
186
shape.addRoundRect(-71.0, -41.0, 142.0, 81.0, 20, 20);
190
bool TOPPASInputFileListVertex::fileNamesValid()
160
192
QStringList fl = getFileNames();
161
foreach (const QString& file, fl)
193
foreach(const QString &file, fl)
163
195
if (!File::exists(file))
171
void TOPPASInputFileListVertex::openContainingFolder()
203
void TOPPASInputFileListVertex::openContainingFolder()
173
205
std::set<String> directories;
174
206
QStringList fl = getFileNames();
175
for (int i = 0; i < fl.size(); ++i)
176
{ // collect unique directories
207
for (int i = 0; i < fl.size(); ++i) // collect unique directories
177
209
QFileInfo fi(fl[i]);
178
210
directories.insert(String(QFileInfo(fi.canonicalFilePath()).path()));
182
for (std::set<String>::const_iterator it=directories.begin();it!=directories.end();++it)
214
for (std::set<String>::const_iterator it = directories.begin(); it != directories.end(); ++it)
184
216
QString path = QDir::toNativeSeparators(it->toQString());
217
#if defined(__APPLE__)
218
QProcess* p = new QProcess();
219
p->setProcessChannelMode(QProcess::ForwardedChannels);
220
QStringList app_args;
221
app_args.append(path);
222
p->start("/usr/bin/open", app_args);
223
if (!p->waitForStarted())
226
QMessageBox::warning(0, "Open Folder Error", "The folder " + path + " could not be opened!");
227
LOG_ERROR << "Failed to open folder " << path.toStdString() << std::endl;
228
LOG_ERROR << p->errorString().toStdString() << std::endl;
185
231
if (!QDir(path).exists() || (!QDesktopServices::openUrl(QUrl("file:///" + path, QUrl::TolerantMode))))
187
233
QMessageBox::warning(0, "Open Folder Error", String("The folder " + path + " could not be opened!").toQString());
192
void TOPPASInputFileListVertex::run()
239
void TOPPASInputFileListVertex::run()
194
241
round_total_ = (int) output_files_.size(); // for now each file is one round; for the future we might allow to create blocks of files (e.g. for replicate measurements)
195
242
round_counter_ = (int) round_total_;