47
50
delete m_tableView;
50
void TableEditorDialog::setProxyModel( ChartProxyModel* proxyModel )
52
if ( m_proxyModel == proxyModel )
55
// Disconnect the old proxy model.
57
disconnect( m_proxyModel, SIGNAL( modelReset() ),
58
this, SLOT( update() ) );
59
disconnect( firstRowIsLabel, SIGNAL( clicked( bool ) ),
60
m_proxyModel, SLOT( setFirstRowIsLabel( bool ) ) );
61
disconnect( firstColumnIsLabel, SIGNAL( clicked( bool ) ),
62
m_proxyModel, SLOT( setFirstColumnIsLabel( bool ) ) );
65
m_proxyModel = proxyModel;
67
// Connect the new proxy model.
69
m_tableView->setModel( m_proxyModel->sourceModel() );
71
connect( m_proxyModel, SIGNAL( modelReset() ),
72
this, SLOT( update() ) );
73
connect( firstRowIsLabel, SIGNAL( clicked( bool ) ),
74
m_proxyModel, SLOT( setFirstRowIsLabel( bool ) ) );
75
connect( firstColumnIsLabel, SIGNAL( clicked( bool ) ),
76
m_proxyModel, SLOT( setFirstColumnIsLabel( bool ) ) );
82
54
void TableEditorDialog::init()
136
108
m_tableView->addAction( m_insertColumnsAction );
138
110
m_tableView->setContextMenuPolicy( Qt::ActionsContextMenu );
112
// Initialize the contents of the controls
116
void TableEditorDialog::setProxyModel( ChartProxyModel* proxyModel )
118
if ( m_proxyModel == proxyModel )
121
// Disconnect the old proxy model.
122
if ( m_proxyModel ) {
123
disconnect( m_proxyModel, SIGNAL( modelReset() ),
124
this, SLOT( updateDialog() ) );
125
disconnect( firstRowIsLabel, SIGNAL( clicked( bool ) ),
126
m_proxyModel, SLOT( setFirstRowIsLabel( bool ) ) );
127
disconnect( firstColumnIsLabel, SIGNAL( clicked( bool ) ),
128
m_proxyModel, SLOT( setFirstColumnIsLabel( bool ) ) );
131
m_proxyModel = proxyModel;
133
// Connect the new proxy model.
134
if ( m_proxyModel ) {
135
m_tableView->setModel( m_proxyModel->sourceModel() );
137
connect( m_proxyModel, SIGNAL( modelReset() ),
138
this, SLOT( updateDialog() ) );
139
connect( firstRowIsLabel, SIGNAL( clicked( bool ) ),
140
m_proxyModel, SLOT( setFirstRowIsLabel( bool ) ) );
141
connect( firstColumnIsLabel, SIGNAL( clicked( bool ) ),
142
m_proxyModel, SLOT( setFirstColumnIsLabel( bool ) ) );
148
void TableEditorDialog::updateDialog()
153
firstRowIsLabel->setChecked( m_proxyModel->firstRowIsLabel() );
154
firstColumnIsLabel->setChecked( m_proxyModel->firstColumnIsLabel() );
156
switch ( m_proxyModel->dataDirection() ) {
158
dataSetsInRows->setChecked( true );
161
dataSetsInColumns->setChecked( true );
164
kWarning(35001) << "Unrecognized value for data direction: " << m_proxyModel->dataDirection();
169
// ----------------------------------------------------------------
141
173
void TableEditorDialog::slotInsertRowPressed()
227
259
const bool isValid = index.isValid();
229
261
m_deleteRowsAction->setEnabled( isValid );
262
m_insertRowsAction->setEnabled( isValid );
230
263
deleteRow->setEnabled( isValid );
264
insertRow->setEnabled( isValid );
232
266
m_deleteColumnsAction->setEnabled( isValid );
267
m_insertColumnsAction->setEnabled( isValid );
233
268
deleteColumn->setEnabled( isValid );
269
insertColumn->setEnabled( isValid );
236
272
void TableEditorDialog::slotDataSetsInRowsToggled( bool enabled )
238
274
Q_ASSERT( m_proxyModel );
239
275
m_proxyModel->setDataDirection( enabled ? Qt::Horizontal : Qt::Vertical );
242
void TableEditorDialog::update()
247
firstRowIsLabel->setChecked( m_proxyModel->firstRowIsLabel() );
248
firstColumnIsLabel->setChecked( m_proxyModel->firstColumnIsLabel() );
249
dataSetsInRows->setChecked( m_proxyModel->dataDirection() == Qt::Horizontal );