Version: (using KDE KDE 3.5.3) Installed from: Compiled From Sources start kchart with Charts -> Blank Worksheet Menu Edit -> Edit Data... In the dialog KChart Data Editor click on Remove Rows or Remove Columns and remove all rows or columns click OK button -> chart crashes Menu Edit -> Edit Data... In the dialog KChart Data Editor type Rows: 0 click OK button -> Load 100 % -> I have to kill kchart
I looked at the data editor. It's a bloody mess (too many cooks, it seems). I will do a complete makeover of it.
SVN commit 566630 by ingwa: - Fix bug 129553: kchart: crash / heavy load with Row=0 in KChart Data Editor - Clean up the data editor BUG: 129553 M +14 -2 ChangeLog M +49 -19 kchartDataEditor.cc M +8 -0 kchartDataEditor.h M +4 -3 kchart_params.h M +1 -1 kchart_view.cc --- branches/koffice/1.6/koffice/kchart/ChangeLog #566629:566630 @@ -1,3 +1,16 @@ +2006-07-18 Inge Wallin <inge@lysator.liu.se> + + Clean up the data editor and fix bug 129553: kchart: crash / heavy + load with Row=0 in KChart Data Editor + * kchartDataEditor.{h,cc} (currentChanged): New method + (m_insertRowButton, m_removeRowButton, m_insertRowButton, + m_removeRowButton): New members + * kchartDataEditor.cc (removeCurrentRow, removeCurrentCol): Don't + allow to remove a row or column if it's the first column or if + there are only 2 of them. + + Some small cleaning. + 2006-07-17 Inge Wallin <inge@lysator.liu.se> Add "first row/col as legend" checkboxes to data editor. @@ -4,7 +17,6 @@ * kchartDataEditor.cc (kchartDataEditor): Enable existing code * kchartDataEditor.cc (setData): Enable existing code * kchartDataEditor.cc (getData): Enable existing code - * Simplify paintContent(): * kchart_part.{h,cc} (createLabelsAndLegend): New function @@ -13,7 +25,7 @@ ================================================================ KChart 1.5 released - <There are a lot of missed entries here. + <There are a lot of missed entries here.> 2005-09-15 Inge Wallin <inge@lysator.liu.se> --- branches/koffice/1.6/koffice/kchart/kchartDataEditor.cc #566629:566630 @@ -176,6 +176,9 @@ m_table->setRowMovingEnabled(true); m_table->setColumnMovingEnabled(true); + connect( m_table, SIGNAL( currentChanged(int, int) ), + this, SLOT( currentChanged(int, int) ) ); + // Create the Rows setting m_rowsLA = new QLabel( i18n("# Rows:" ), page ); m_rowsLA->resize( m_rowsLA->sizeHint() ); @@ -197,33 +200,32 @@ #endif //Buttons for Inserting / Removing rows & columns - QPushButton *insertRowButton = new QPushButton( i18n("Insert Row") , page); - connect( insertRowButton, SIGNAL( clicked() ), - this, SLOT( insertRow() ) ); + m_insertRowButton = new QPushButton( i18n("Insert Row") , page); + connect( m_insertRowButton, SIGNAL( clicked() ), + this, SLOT( insertRow() ) ); - QPushButton *insertColButton = new QPushButton( i18n("Insert Column") , page); - connect( insertColButton, SIGNAL( clicked() ), - this, SLOT( insertColumn() ) ); + m_insertColButton = new QPushButton( i18n("Insert Column") , page); + connect( m_insertColButton, SIGNAL( clicked() ), + this, SLOT( insertColumn() ) ); - QPushButton* removeRowButton = new QPushButton( i18n("Remove Row") , page); - connect( removeRowButton, SIGNAL( clicked() ), - this, SLOT( removeCurrentRow() ) ); + m_removeRowButton = new QPushButton( i18n("Remove Row") , page); + connect( m_removeRowButton, SIGNAL( clicked() ), + this, SLOT( removeCurrentRow() ) ); - QPushButton* removeColButton = new QPushButton( i18n("Remove Column") , page); - connect( removeColButton, SIGNAL( clicked() ), - this, SLOT( removeCurrentColumn() ) ); - - + m_removeColButton = new QPushButton( i18n("Remove Column") , page); + connect( m_removeColButton, SIGNAL( clicked() ), + this, SLOT( removeCurrentColumn() ) ); + // Start the layout. The buttons are at the top. QVBoxLayout *topLayout = new QVBoxLayout( page ); QHBoxLayout* insertRemoveLayout = new QHBoxLayout( ); insertRemoveLayout->setSpacing(5); - insertRemoveLayout->addWidget(insertRowButton); - insertRemoveLayout->addWidget(insertColButton); - insertRemoveLayout->addWidget(removeRowButton); - insertRemoveLayout->addWidget(removeColButton); + insertRemoveLayout->addWidget(m_insertRowButton); + insertRemoveLayout->addWidget(m_insertColButton); + insertRemoveLayout->addWidget(m_removeRowButton); + insertRemoveLayout->addWidget(m_removeColButton); insertRemoveLayout->addStretch(1); topLayout->addLayout(insertRemoveLayout); @@ -262,7 +264,6 @@ connect(m_colsSB, SIGNAL(valueChangedSpecial(int)), this, SLOT(setCols(int))); - #if 0 // -- Changed data editor to use top row and leftmost column for @@ -285,6 +286,11 @@ // The data is not modified at the start. m_modified = false; + // If the cursor starts at cell (0, 0), that is the header row and + // col, and the user isn't allowed to remove those. + m_removeRowButton->setEnabled( false ); + m_removeColButton->setEnabled( false ); + // Add tooltips and WhatsThis help. addDocs(); } @@ -589,6 +595,14 @@ { int row = m_table->currentRow(); + // Can't remove the header row. + if ( row == 0 ) + return; + + // Need at least one data row. + if ( m_table->numRows() == 2 ) + return; + m_table->removeRow(row); m_rowsSB->setValue(m_table->numRows()); @@ -602,6 +616,14 @@ { int col = m_table->currentColumn(); + // Can't remove the header column. + if ( col == 0 ) + return; + + // Need at least one data column. + if ( m_table->numCols() == 2 ) + return; + m_table->removeColumn(col); m_colsSB->setValue(m_table->numCols()); @@ -803,6 +825,14 @@ m_modified = true; } + +void kchartDataEditor::currentChanged(int row, int col) +{ + m_removeRowButton->setEnabled( row != 0 && m_table->numRows() > 2 ); + m_removeColButton->setEnabled( col != 0 && m_table->numCols() > 2 ); +} + + void kchartDataEditor::updateRowHeaders() { for (int i=0;i<m_table->numRows();i++) --- branches/koffice/1.6/koffice/kchart/kchartDataEditor.h #566629:566630 @@ -149,10 +149,18 @@ // Called when something changes in the table. void tableChanged(int row, int col); + // Called when the current cell is changed + void currentChanged(int row, int col); private: // Widgets in the editor kchartDataTable *m_table; + + QPushButton *m_insertRowButton; + QPushButton *m_insertColButton; + QPushButton *m_removeRowButton; + QPushButton *m_removeColButton; + QLabel *m_rowsLA; kchartDataSpinBox *m_rowsSB; QLabel *m_colsLA; --- branches/koffice/1.6/koffice/kchart/kchart_params.h #566629:566630 @@ -124,9 +124,10 @@ void saveOasisPlotArea( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles ) const; void saveOasisAxis( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles, - KDChartAxisParams::AxisPos axisPos, const char* axisName ) const; - - QString saveOasisFont( KoGenStyles& mainStyles, const QFont& font, const QColor& color ) const; + KDChartAxisParams::AxisPos axisPos, + const char* axisName ) const; + QString saveOasisFont( KoGenStyles& mainStyles, const QFont& font, + const QColor& color ) const; private: KChartPart *m_part; --- branches/koffice/1.6/koffice/kchart/kchart_view.cc #566629:566630 @@ -238,7 +238,7 @@ return; } if (!ed.modified()) - return; + return; // Get the data and legend back. ed.getData(params, dat);
You need to log in before you can comment on or make changes to this bug.