~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kchart/shape/dialogs/TableEditorDialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
// Qt
26
26
#include <QDebug>
27
27
 
 
28
// KDE
 
29
#include <kdebug.h>
 
30
 
28
31
// KChart
29
32
#include "ChartProxyModel.h"
30
33
#include "ChartTableView.h"
47
50
    delete m_tableView;
48
51
}
49
52
 
50
 
void TableEditorDialog::setProxyModel( ChartProxyModel* proxyModel )
51
 
{
52
 
    if ( m_proxyModel == proxyModel )
53
 
        return;
54
 
 
55
 
    // Disconnect the old proxy model.
56
 
    if ( m_proxyModel ) {
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 ) ) );
63
 
    }
64
 
 
65
 
    m_proxyModel = proxyModel;
66
 
 
67
 
    // Connect the new proxy model.
68
 
    if ( m_proxyModel ) {
69
 
        m_tableView->setModel( m_proxyModel->sourceModel() );
70
 
 
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 ) ) );
77
 
    }
78
 
 
79
 
    update();
80
 
}
81
53
 
82
54
void TableEditorDialog::init()
83
55
{
136
108
    m_tableView->addAction( m_insertColumnsAction );
137
109
 
138
110
    m_tableView->setContextMenuPolicy( Qt::ActionsContextMenu );
139
 
}
 
111
 
 
112
    // Initialize the contents of the controls
 
113
    updateDialog();
 
114
}
 
115
 
 
116
void TableEditorDialog::setProxyModel( ChartProxyModel* proxyModel )
 
117
{
 
118
    if ( m_proxyModel == proxyModel )
 
119
        return;
 
120
 
 
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 ) ) );
 
129
    }
 
130
 
 
131
    m_proxyModel = proxyModel;
 
132
 
 
133
    // Connect the new proxy model.
 
134
    if ( m_proxyModel ) {
 
135
        m_tableView->setModel( m_proxyModel->sourceModel() );
 
136
 
 
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 ) ) );
 
143
    }
 
144
 
 
145
    updateDialog();
 
146
}
 
147
 
 
148
void TableEditorDialog::updateDialog()
 
149
{
 
150
    if ( !m_proxyModel )
 
151
        return;
 
152
 
 
153
    firstRowIsLabel->setChecked( m_proxyModel->firstRowIsLabel() );
 
154
    firstColumnIsLabel->setChecked( m_proxyModel->firstColumnIsLabel() );
 
155
 
 
156
    switch ( m_proxyModel->dataDirection() ) {
 
157
    case Qt::Horizontal:
 
158
        dataSetsInRows->setChecked( true );
 
159
        break;
 
160
    case Qt::Vertical:
 
161
        dataSetsInColumns->setChecked( true );
 
162
        break;
 
163
    default:
 
164
        kWarning(35001) << "Unrecognized value for data direction: " << m_proxyModel->dataDirection();
 
165
    }
 
166
}
 
167
 
 
168
 
 
169
// ----------------------------------------------------------------
 
170
//                             slots
 
171
 
140
172
 
141
173
void TableEditorDialog::slotInsertRowPressed()
142
174
{
227
259
    const bool isValid = index.isValid();
228
260
 
229
261
    m_deleteRowsAction->setEnabled( isValid );
 
262
    m_insertRowsAction->setEnabled( isValid );
230
263
    deleteRow->setEnabled( isValid );
 
264
    insertRow->setEnabled( isValid );
231
265
 
232
266
    m_deleteColumnsAction->setEnabled( isValid );
 
267
    m_insertColumnsAction->setEnabled( isValid );
233
268
    deleteColumn->setEnabled( isValid );
 
269
    insertColumn->setEnabled( isValid );
234
270
}
235
271
 
236
272
void TableEditorDialog::slotDataSetsInRowsToggled( bool enabled )
238
274
    Q_ASSERT( m_proxyModel );
239
275
    m_proxyModel->setDataDirection( enabled ? Qt::Horizontal : Qt::Vertical );
240
276
}
241
 
 
242
 
void TableEditorDialog::update()
243
 
{
244
 
    if ( !m_proxyModel )
245
 
        return;
246
 
 
247
 
    firstRowIsLabel->setChecked( m_proxyModel->firstRowIsLabel() );
248
 
    firstColumnIsLabel->setChecked( m_proxyModel->firstColumnIsLabel() );
249
 
    dataSetsInRows->setChecked( m_proxyModel->dataDirection() == Qt::Horizontal );
250
 
}