27 #include "ui_KDChartDatasetSelector.h" 29 #include <KDABLibFakes> 35 , mUi( new Ui::DatasetSelector() )
36 , mSourceRowCount( 0 )
37 , mSourceColumnCount( 0 )
39 qWarning(
"For DatasetSelectorWidget to become useful, it has to be connected to the proxy model it configures!" );
42 setMinimumSize( minimumSizeHint() );
50 void DatasetSelectorWidget::on_sbStartColumn_valueChanged(
int )
55 void DatasetSelectorWidget::on_sbStartRow_valueChanged(
int )
60 void DatasetSelectorWidget::on_sbColumnCount_valueChanged(
int )
65 void DatasetSelectorWidget::on_sbRowCount_valueChanged(
int )
70 void DatasetSelectorWidget::on_cbReverseRows_stateChanged(
int )
75 void DatasetSelectorWidget::on_cbReverseColumns_stateChanged(
int )
80 void DatasetSelectorWidget::on_groupBox_toggled(
bool state )
93 if ( rowCount != mSourceRowCount )
95 mSourceRowCount = rowCount;
102 if ( columnCount != mSourceColumnCount )
104 mSourceColumnCount = columnCount;
105 resetDisplayValues();
109 void DatasetSelectorWidget::resetDisplayValues()
111 mUi->sbStartRow->setValue( 0 );
112 mUi->sbStartRow->setMinimum( 0 );
113 mUi->sbStartRow->setMaximum( qMax( mSourceRowCount - 1, 0 ) );
114 mUi->sbStartColumn->setValue( 0 );
115 mUi->sbStartColumn->setMinimum( 0 );
116 mUi->sbStartColumn->setMaximum( qMax( mSourceColumnCount - 1, 0 ) );
117 mUi->sbRowCount->setMinimum( 1 );
118 mUi->sbRowCount->setMaximum( mSourceRowCount );
119 mUi->sbRowCount->setValue( mSourceRowCount );
120 mUi->sbColumnCount->setMinimum( 1 );
121 mUi->sbColumnCount->setMaximum( mSourceColumnCount );
122 mUi->sbColumnCount->setValue( mSourceColumnCount );
123 mUi->groupBox->setChecked(
false );
127 void DatasetSelectorWidget::calculateMapping()
129 if ( mSourceColumnCount < 2 && mSourceRowCount < 2 )
131 mUi->groupBox->setEnabled(
false );
134 mUi->groupBox->setEnabled(
true );
136 if ( ! mUi->groupBox->isChecked() )
143 int startRow = mUi->sbStartRow->value();
144 int startColumn = mUi->sbStartColumn->value();
145 int rowCount = mUi->sbRowCount->value();
146 int columnCount = mUi->sbColumnCount->value();
147 bool reverseColumns = mUi->cbReverseColumns->checkState() == Qt::Checked;
148 bool reverseRows = mUi->cbReverseRows->checkState() == Qt::Checked;
151 startRow = qMin( startRow, mSourceRowCount - 2 );
152 startRow = qMax( 0, startRow );
153 startColumn = qMin( startColumn, mSourceColumnCount - 2 );
154 startColumn = qMax( 0, startColumn );
156 rowCount = qMin( rowCount, mSourceRowCount - startRow );
157 rowCount = qMax( 1, rowCount );
158 columnCount = qMin( columnCount, mSourceColumnCount - startColumn );
159 columnCount = qMax( 1, columnCount );
162 Q_ASSERT( rowConfig.size() > 0 );
164 Q_ASSERT( columnConfig.size() > 0 );
167 for (
int row = 0; row < rowCount; ++row )
171 rowConfig[row] = startRow + rowCount - row - 1;
173 rowConfig[row] = startRow + row;
177 for (
int column = 0; column < columnCount; ++ column )
179 if ( reverseColumns )
181 columnConfig[column] = startColumn + columnCount - column -1;
183 columnConfig[column] = startColumn + column;
Class only listed here to document inheritance of some KDChart classes.