Engauge Digitizer  2
WindowTable.cpp
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 #include <qdebug.h>
8 #include <QHeaderView>
9 #include <QMouseEvent>
10 #include <QStandardItemModel>
11 #include "WindowModelBase.h"
12 #include "WindowTable.h"
13 
14 // Modes:
15 // -ContiguousSelection is an ok selection mode when dragging is disabled since user can click and drag
16 // to easily define a rectangular selection. However, dragging changes that sequence into the start of a drag and drop.
17 // -ExtendedSelection is best selection mode when dragging is disabled since it acts as ContiguousSelection and also
18 // allows control-click to select/unselect individual cells
19 // -MultiSelection is frustrating since user cannot easily remove existing selection by clicking on an unselected cell,
20 // which results in tedious deselections
21 const QAbstractItemView::SelectionMode SELECTION_MODE = QAbstractItemView::ExtendedSelection;
22 
24 {
25  horizontalHeader()->setStretchLastSection (true);
26  setModel (&model);
27  setSelectionMode (SELECTION_MODE);
28  // setDragEnabled (true); This is set later from MainWindowModel
29  setDragDropMode (QAbstractItemView::DragOnly);
30  horizontalHeader()->hide();
31  verticalHeader()->hide();
32  setEditTriggers (QAbstractItemView::NoEditTriggers); // Control is read only
33 
34  // No WhatsThis text is needed since this table is within a dockable widget that has the same WhatsThis text for
35  // a click anywhere in that widget
36 
37  // Connect model to view so model can access the current selection
38  model.setView (*this);
39 }
40 
41 WindowTable::~WindowTable()
42 {
43 }
44 
45 void WindowTable::focusInEvent (QFocusEvent *event)
46 {
47  QTableView::focusInEvent (event);
48 
50 }
51 
52 void WindowTable::focusOutEvent (QFocusEvent *event)
53 {
54  QTableView::focusOutEvent (event);
55 
57 }
58 
59 void WindowTable::selectionChanged(const QItemSelection &selected,
60  const QItemSelection &deselected)
61 {
62  QTableView::selectionChanged (selected,
63  deselected);
64 
66 }
virtual void focusOutEvent(QFocusEvent *)
Catch this table status change.
Definition: WindowTable.cpp:52
WindowTable(WindowModelBase &model)
Single constructor.
Definition: WindowTable.cpp:23
void setView(WindowTable &view)
Save the view so this class can access the current selection.
void signalTableStatusChange()
Sent when a change occurs that should affect the Copy menu item.
virtual void focusInEvent(QFocusEvent *)
Catch this table status change.
Definition: WindowTable.cpp:45
Model for WindowTable.
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Catch this table status change.
Definition: WindowTable.cpp:59