Mantid
Loading...
Searching...
No Matches
Cell.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8#include <ostream>
9#include <utility>
10
12
13Cell::Cell(std::string contentText, std::string backgroundColor, int borderThickness, std::string borderColor,
14 int borderOpacity, bool isEditable)
15 : m_contentText(std::move(contentText)), m_backgroundColor(std::move(backgroundColor)),
16 m_borderThickness(borderThickness), m_borderOpacity(borderOpacity), m_borderColor(std::move(borderColor)),
17 m_iconFilePath(), m_isEditable(isEditable), m_toolTip(""), m_direction(Direction::INPUT) {}
18
19Cell::Cell(std::string contentText)
20 : m_contentText(std::move(contentText)), m_backgroundColor("white"), m_borderThickness(1), m_borderOpacity(255),
21 m_borderColor("darkGrey"), m_iconFilePath(), m_isEditable(true), m_toolTip(""), m_direction(Direction::INPUT) {}
22
23std::string const &Cell::contentText() const { return m_contentText; }
24
25std::string const &Cell::toolTip() const { return m_toolTip; }
26
27bool Cell::isEditable() const { return m_isEditable; }
28
30
31std::string const &Cell::borderColor() const { return m_borderColor; }
32
33int Cell::borderOpacity() const { return m_borderOpacity; }
34
35void Cell::setContentText(std::string const &contentText) { m_contentText = contentText; }
36
37void Cell::setToolTip(std::string const &toolTip) { m_toolTip = toolTip; }
38
40
41void Cell::setBorderColor(std::string const &borderColor) { m_borderColor = borderColor; }
42
43void Cell::setBackgroundColor(std::string const &backgroundColor) { m_backgroundColor = backgroundColor; }
44
45void Cell::setForegroundColor(std::string const &foregroundColor) {
49 else
51}
52
53std::string const &Cell::backgroundColor() const { return m_backgroundColor; }
54
55std::string const &Cell::foregroundColor() const { return m_foregroundColor; }
56
58
59void Cell::setIconFilePath(std::string const &iconFilePath) { m_iconFilePath = iconFilePath; }
60
61std::string const &Cell::iconFilePath() const { return m_iconFilePath; }
62
63void Cell::setEditable(bool isEditable) { m_isEditable = isEditable; }
64
66
68
69bool Cell::isInput() const { return m_direction == Direction::INPUT; }
70
71bool Cell::isOutput() const { return m_direction == Direction::OUTPUT; }
72
76}
77
81}
82
83std::ostream &operator<<(std::ostream &os, Cell const &cell) {
84 os << '|' << cell.contentText() << '|';
85 return os;
86}
87
88bool operator==(Cell const &lhs, Cell const &rhs) {
89 return lhs.contentText() == rhs.contentText() && lhs.isEditable() == rhs.isEditable() &&
90 lhs.borderThickness() == rhs.borderThickness() && lhs.borderColor() == rhs.borderColor();
91}
92
93bool operator!=(Cell const &lhs, Cell const &rhs) { return !(lhs == rhs); }
94
95std::vector<Cell> paddedCellsToWidth(std::vector<Cell> const &cells, Cell const &paddingCell, int paddedWidth) {
96 auto paddedCells = cells;
97 for (auto i = static_cast<int>(cells.size()); i < paddedWidth; i++)
98 paddedCells.emplace_back(paddingCell);
99 return paddedCells;
100}
101} // namespace MantidQt::MantidWidgets::Batch
const std::vector< double > & rhs
std::string const & backgroundColor() const
Definition: Cell.cpp:53
void setForegroundColor(std::string const &foregroundColor)
Definition: Cell.cpp:45
void setBackgroundColor(std::string const &backgroundColor)
Definition: Cell.cpp:43
void setBorderColor(std::string const &borderColor)
Definition: Cell.cpp:41
std::string const & borderColor() const
Definition: Cell.cpp:31
std::string const & foregroundColor() const
Definition: Cell.cpp:55
std::string const & iconFilePath() const
Definition: Cell.cpp:61
void setContentText(std::string const &contentText)
Definition: Cell.cpp:35
static constexpr const char * INPUT_FOREGROUND_COLOR
Definition: Cell.h:24
void setToolTip(std::string const &toolTip)
Definition: Cell.cpp:37
std::string const & toolTip() const
Definition: Cell.cpp:25
void setIconFilePath(std::string const &iconPath)
Definition: Cell.cpp:59
static constexpr const char * OUTPUT_FOREGROUND_COLOR
Definition: Cell.h:25
void setBorderOpacity(int transparency)
Definition: Cell.cpp:57
Cell(std::string contentText)
Definition: Cell.cpp:19
void setEditable(bool isEditable)
Definition: Cell.cpp:63
std::string const & contentText() const
Definition: Cell.cpp:23
void setBorderThickness(int borderThickness)
Definition: Cell.cpp:39
EXPORT_OPT_MANTIDQT_COMMON std::vector< Cell > paddedCellsToWidth(std::vector< Cell > const &cells, Cell const &paddingCell, int paddedWidth)
Definition: Cell.cpp:95
EXPORT_OPT_MANTIDQT_COMMON std::ostream & operator<<(std::ostream &os, Cell const &cell)
Definition: Cell.cpp:83
EXPORT_OPT_MANTIDQT_COMMON bool operator==(Cell const &lhs, Cell const &rhs)
Definition: Cell.cpp:88
EXPORT_OPT_MANTIDQT_COMMON bool operator!=(Cell const &lhs, Cell const &rhs)
Definition: Cell.cpp:93
STL namespace.