Engauge Digitizer  2
WindowModelBase.h
1 /******************************************************************************************************
2  * (C) 2016 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef WINDOW_MODEL_BASE_H
8 #define WINDOW_MODEL_BASE_H
9 
10 #include "ExportDelimiter.h"
11 #include <QStandardItemModel>
12 #include <QString>
13 #include <QVector>
14 
15 class WindowTable;
16 
18 class WindowModelBase : public QStandardItemModel
19 {
20 public:
22  WindowModelBase ();
23  virtual ~WindowModelBase ();
24 
27  QMimeData *mimeData (const QModelIndexList &indexes) const;
28 
30  QString selectionAsHtml () const;
31 
33  QString selectionAsText (ExportDelimiter delimiter) const;
34 
36  void setDelimiter (ExportDelimiter delimiter);
37 
39  void setView (WindowTable &view);
40 
41 private:
42  int fold2dIndexes (int row,
43  int col,
44  int rowLow,
45  int colLow,
46  int colHigh) const;
47  void selectionAsTable (int &rowLow,
48  int &colLow,
49  int &rowHigh,
50  int &colHigh,
51  QVector<QString> &table) const;
52 
53  ExportDelimiter m_delimiter;
54  WindowTable *m_view;
55 };
56 
57 #endif // WINDOW_MODEL_BASE_H
QMimeData * mimeData(const QModelIndexList &indexes) const
Support dragging of multiple cells.
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.
void setView(WindowTable &view)
Save the view so this class can access the current selection.
void setDelimiter(ExportDelimiter delimiter)
Save output delimiter.
Table view class with support for both drag-and-drop and copy-and-paste.
Definition: WindowTable.h:17
WindowModelBase()
Single constructor.
Model for WindowTable.