Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
WindowModelBase Class Reference

Model for WindowTable. More...

#include <WindowModelBase.h>

Inheritance diagram for WindowModelBase:
Inheritance graph
Collaboration diagram for WindowModelBase:
Collaboration graph

Public Member Functions

 WindowModelBase ()
 Single constructor.
 
virtual ~WindowModelBase ()
 
QMimeData * mimeData (const QModelIndexList &indexes) const
 Support dragging of multiple cells.
 
QString selectionAsHtml () const
 Convert the selection into exportable html which is good for spreadsheets.
 
QString selectionAsText (ExportDelimiter delimiter) const
 Convert the selection into exportable text which is good for text editors.
 
void setDelimiter (ExportDelimiter delimiter)
 Save output delimiter.
 
void setView (WindowTable &view)
 Save the view so this class can access the current selection.
 

Detailed Description

Model for WindowTable.

Definition at line 18 of file WindowModelBase.h.

Constructor & Destructor Documentation

◆ WindowModelBase()

WindowModelBase::WindowModelBase ( )

Single constructor.

Definition at line 16 of file WindowModelBase.cpp.

16 :
17 m_view (nullptr)
18{
19}

◆ ~WindowModelBase()

WindowModelBase::~WindowModelBase ( )
virtual

Definition at line 21 of file WindowModelBase.cpp.

22{
23}

Member Function Documentation

◆ mimeData()

QMimeData * WindowModelBase::mimeData ( const QModelIndexList & indexes) const

Support dragging of multiple cells.

Without this only one cell can be copied by dragging. Clipboard copying is handled elsewhere in the window class

Definition at line 34 of file WindowModelBase.cpp.

35{
36 if (indexes.isEmpty ()) {
37 return nullptr;
38 }
39
40 QMimeData *data = new QMimeData ();
41
42 data->setHtml (selectionAsHtml ());
43 data->setText (selectionAsText (m_delimiter));
44
45 return data;
46}
const int INNER_RADIUS_MIN
QString selectionAsText(ExportDelimiter delimiter) const
Convert the selection into exportable text which is good for text editors.
QString selectionAsHtml() const
Convert the selection into exportable html which is good for spreadsheets.

◆ selectionAsHtml()

QString WindowModelBase::selectionAsHtml ( ) const

Convert the selection into exportable html which is good for spreadsheets.

Definition at line 48 of file WindowModelBase.cpp.

49{
50 ENGAUGE_CHECK_PTR (m_view);
51
54
55 // Get raw data as a rectangular table. Size may be zero
56 selectionAsTable (rowLow,
57 colLow,
58 rowHigh,
59 colHigh,
60 table);
61
62 // Concatenate table into output string
65
66 str << "<table>";
67 for (int row = rowLow; row <= rowHigh; row++) {
68 str << "<tr>";
69 for (int col = colLow; col <= colHigh; col++) {
70 str << "<td>" << table [fold2dIndexes (row, col, rowLow, colLow, colHigh)] << "</td>";
71 }
72 str << "<tr>\n";
73 }
74 str << "</table>";
75
76 return html;
77}
#define ENGAUGE_CHECK_PTR(ptr)
#endif

◆ selectionAsText()

QString WindowModelBase::selectionAsText ( ExportDelimiter delimiter) const

Convert the selection into exportable text which is good for text editors.

Definition at line 132 of file WindowModelBase.cpp.

133{
134 const bool NOT_GNUPLOT = false;
135
136 ENGAUGE_CHECK_PTR (m_view);
137
140
141 // Get raw data as a rectangular table. Size may be zero
142 selectionAsTable (rowLow,
143 colLow,
144 rowHigh,
145 colHigh,
146 table);
147
148 // Concatenate table into output string
151 for (int row = rowLow; row <= rowHigh; row++) {
153 for (int col = colLow; col <= colHigh; col++) {
154 str << delimiterStr << table [fold2dIndexes (row, col, rowLow, colLow, colHigh)];
157 }
158 str << "\n";
159 }
160
161 return text;
162}
QString exportDelimiterToText(ExportDelimiter exportDelimiter, bool isGnuplotDelimiter)

◆ setDelimiter()

void WindowModelBase::setDelimiter ( ExportDelimiter delimiter)

Save output delimiter.

Definition at line 164 of file WindowModelBase.cpp.

165{
166 m_delimiter = delimiter;
167}

◆ setView()

void WindowModelBase::setView ( WindowTable & view)

Save the view so this class can access the current selection.

Definition at line 169 of file WindowModelBase.cpp.

170{
171 m_view = &view;
172}

The documentation for this class was generated from the following files: