-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddmTableViewModel.cpp
60 lines (45 loc) · 1.29 KB
/
ddmTableViewModel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <QStandardItemModel>
#include <QSize>
#include "ddmTableViewmodel.h"
ddmTableViewModel::ddmTableViewModel( QObject *parent ) : QAbstractTableModel(parent)
{
m_row = 3;
m_col = 3;
}
QVariant ddmTableViewModel::headerData( int section, Qt::Orientation orientation, int role ) const
{
if (orientation != Qt::Horizontal)
return QVariant();
if( role == Qt::DisplayRole )
{
switch ( section )
{
case 0: return "Колонка 1";
case 1: return "Колонка 2";
case 2: return "Колонка 3";
default: return QVariant();
}
}
return QVariant();
}
int ddmTableViewModel::columnCount( const QModelIndex& index ) const
{
return m_col;
}
Qt::ItemFlags ddmTableViewModel::flags( const QModelIndex& index ) const
{
return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
}
int ddmTableViewModel::rowCount( const QModelIndex& index ) const
{
return m_row;
}
QVariant ddmTableViewModel::data( const QModelIndex &index, int role ) const
{
if ( role == Qt::DisplayRole && index.isValid() )
{
if ( index.isValid() )
return QObject::tr( "Строка %1 Столбец %2" ).arg( index.row() ).arg( index.column() );
}
return QVariant();
}