[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kspread
From: Robert Knight <robertknight () gmail ! com>
Date: 2005-10-05 0:29:37
Message-ID: 1128472177.768044.23477.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 467353 by knight:
GUI: AutoSum toolbar button now inserts complete formula with range reference as \
opposed to an empty SUM() template. What I am unsure about is whether the formula \
should be inserted in the last cell in the selection, or in the cell just below \
(depending on the direction in which the user created the selection). This is a \
usability point, comments welcome.
M +10 -0 kspread_util.cc
M +1 -1 kspread_util.h
M +42 -35 kspread_view.cc
--- trunk/koffice/kspread/kspread_util.cc #467352:467353
@@ -362,6 +362,16 @@
((pos.y() == cell.pos.y()) && (pos.x() < cell.pos.x()));
}
+KSpreadRange::KSpreadRange()
+{
+ sheet = 0;
+ range.setLeft( -1 );
+
+ leftFixed=false;
+ rightFixed=false;
+ topFixed=false;
+ bottomFixed=false;
+}
KSpreadRange::KSpreadRange(const QString & _str)
{
range.setLeft(-1);
--- trunk/koffice/kspread/kspread_util.h #467352:467353
@@ -87,7 +87,7 @@
struct KSPREAD_EXPORT KSpreadRange
{
- KSpreadRange() { sheet = 0; range.setLeft( -1 ); }
+ KSpreadRange();
KSpreadRange( const QString& );
KSpreadRange( const QString&, KSpreadMap*, KSpreadSheet* default_sheet = 0 );
KSpreadRange( const KSpreadRange& r ) {
--- trunk/koffice/kspread/kspread_view.cc #467352:467353
@@ -2449,46 +2449,53 @@
if ( d->canvas->editor() )
return;
- d->canvas->createEditor( KSpreadCanvas::CellEditor );
- d->canvas->editor()->setText( "=SUM()" );
- d->canvas->editor()->setCursorPosition( 5 );
+ //Get the selected range and remove the current cell from it (as that is
+ //where the result of the autosum will be stored - perhaps change
+ //this behaviour??)
+ KSpreadRange rg;
+ //rg.sheet=activeSheet();
+ QRect sel=selection(false);
- // Try to find numbers above
- if ( d->canvas->markerRow() > 1 )
- {
- KSpreadCell* cell = 0;
- int r = d->canvas->markerRow();
- do
- {
- cell = activeSheet()->cellAt( d->canvas->markerColumn(), --r );
- }
- while ( cell && cell->value().isNumber() );
+ if (sel.height() > 1)
+ {
+ if (marker().y()==sel.top())
+ sel.setTop(sel.top()+1);
+ if (marker().y()==sel.bottom())
+ sel.setBottom(sel.bottom()-1);
+ }
+ else
+ {
+ if (sel.width() > 1)
+ {
+ if (marker().x()==sel.left())
+ sel.setLeft(sel.left()+1);
- if ( r + 1 < d->canvas->markerRow() )
- {
- d->canvas->startChoose( QRect( d->canvas->markerColumn(), r + 1, 1, \
d->canvas->markerRow() - r - 1 ) );
- return;
- }
- }
+ if (marker().x()==sel.right())
+ sel.setRight(sel.right()-1);
+ }
+ else
+ {
+ sel=QRect();
+ }
+ }
+ if ( (sel.width() > 1) && (sel.height() > 1) )
+ sel=QRect();
- // Try to find numbers left
- if ( d->canvas->markerColumn() > 1 )
- {
- KSpreadCell* cell = 0;
- int c = d->canvas->markerColumn();
- do
- {
- cell = activeSheet()->cellAt( --c, d->canvas->markerRow() );
- }
- while ( cell && cell->value().isNumber() );
+ rg.range=sel;
- if ( c + 1 < d->canvas->markerColumn() )
- {
- d->canvas->startChoose( QRect( c + 1, d->canvas->markerRow(), \
d->canvas->markerColumn() - c - 1, 1 ) );
- return;
- }
- }
+ d->canvas->createEditor( KSpreadCanvas::CellEditor );
+
+ if ( (rg.range.isValid() ) && (!rg.range.isEmpty()) )
+ {
+ d->canvas->editor()->setText( "=SUM("+rg.toString()+")" );
+ d->canvas->deleteEditor(true);
+ }
+ else
+ {
+ d->canvas->editor()->setText( "=SUM( )" );
+ d->canvas->editor()->setCursorPosition( 5 );
+ }
}
/*
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic