[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kspread
From: Stefan Nikolaus <stefan.nikolaus () kdemail ! net>
Date: 2006-08-06 18:12:44
Message-ID: 1154887964.062725.10516.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 570442 by nikolaus:
Operations Introduce the IncreasePrecisionManipulator.
M +35 -0 FormatManipulators.cpp
M +11 -0 FormatManipulators.h
M +0 -26 Sheet.cpp
M +0 -1 Sheet.h
M +13 -18 View.cpp
M +2 -3 View.h
M +10 -5 ViewAdaptor.cpp
M +2 -1 ViewAdaptor.h
--- trunk/koffice/kspread/FormatManipulators.cpp #570441:570442
@@ -570,3 +570,38 @@
}
+
+/***************************************************************************
+ class IncreasePrecisionManipulator
+****************************************************************************/
+
+IncreasePrecisionManipulator::IncreasePrecisionManipulator()
+ : Manipulator()
+{
+ m_format = false;
+}
+
+bool IncreasePrecisionManipulator::process( Cell* cell )
+{
+ if ( !m_reverse )
+ {
+ cell->incPrecision();
+ }
+ else // m_reverse
+ {
+ cell->decPrecision();
+ }
+ return true;
+}
+
+QString IncreasePrecisionManipulator::name() const
+{
+ if ( !m_reverse )
+ {
+ return i18n( "Increase Precision" );
+ }
+ else
+ {
+ return i18n( "Decrease Precision" );
+ }
+}
--- trunk/koffice/kspread/FormatManipulators.h #570441:570442
@@ -175,6 +175,17 @@
FormatType m_formatType;
};
+class IncreasePrecisionManipulator :public Manipulator
+{
+public:
+ IncreasePrecisionManipulator();
+
+protected:
+ virtual bool process( Cell* cell );
+
+ virtual QString name() const;
+};
+
} // namespace KSpread
#endif // KSPREAD_MANIPULATOR_FORMAT
--- trunk/koffice/kspread/Sheet.cpp #570441:570442
@@ -2352,32 +2352,6 @@
return cellValue.asString();
}
-struct SetSelectionPrecisionWorker : public Sheet::CellWorker {
- int _delta;
- SetSelectionPrecisionWorker( int delta ) : Sheet::CellWorker( ), _delta( delta ) { }
-
- class UndoAction* createUndoAction( Doc* doc, Sheet* sheet, const KSpread::Region& region ) {
- QString title=i18n("Change Precision");
- return new UndoCellFormat( doc, sheet, region, title );
- }
- bool testCondition( Cell* cell ) {
- return ( !cell->isPartOfMerged() );
- }
- void doWork( Cell* cell, bool, int, int ) {
- if ( _delta == 1 )
- cell->incPrecision();
- else
- cell->decPrecision();
- }
-};
-
-void Sheet::setSelectionPrecision( Selection* selectionInfo,
- int _delta )
-{
- SetSelectionPrecisionWorker w( _delta );
- workOnCells( selectionInfo, w );
-}
-
struct SetSelectionStyleWorker : public Sheet::CellWorkerTypeA
{
Style * m_style;
--- trunk/koffice/kspread/Sheet.h #570441:570442
@@ -967,7 +967,6 @@
void setArrayFormula (Selection* selection, const QString &_text);
- void setSelectionPrecision( Selection* selection, int _delta );
void setSelectionStyle( Selection* selection, Style * style );
/**
--- trunk/koffice/kspread/View.cpp #570441:570442
@@ -605,12 +605,12 @@
actions->percent->setToolTip(i18n("Set the cell formatting to look like a percentage"));
actions->precplus = new KAction( KIcon( "prec_plus" ), i18n("Increase Precision"), ac, "precplus");
- connect(actions->precplus, SIGNAL(triggered(bool)), view, SLOT( precisionPlus() ));
+ connect(actions->precplus, SIGNAL(triggered(bool)), view, SLOT( increasePrecision() ));
actions->precplus->setToolTip(i18n("Increase the decimal precision shown onscreen"));
actions->precminus = new KAction( KIcon( "prec_minus" ), i18n("Decrease Precision"), ac, "precminus");
- connect(actions->precminus, SIGNAL(triggered(bool)), view, SLOT( precisionMinus() ));
+ connect(actions->precminus, SIGNAL(triggered(bool)), view, SLOT( decreasePrecision() ));
actions->precminus->setToolTip(i18n("Decrease the decimal precision shown onscreen"));
@@ -6326,28 +6326,23 @@
}
}
-void View::precisionPlus()
+void View::increasePrecision()
{
- setSelectionPrecision( 1 );
+ IncreasePrecisionManipulator* manipulator = new IncreasePrecisionManipulator();
+ manipulator->setSheet( d->activeSheet );
+ manipulator->add( *selectionInfo() );
+ manipulator->execute();
}
-void View::precisionMinus()
+void View::decreasePrecision()
{
- setSelectionPrecision( -1 );
+ IncreasePrecisionManipulator* manipulator = new IncreasePrecisionManipulator();
+ manipulator->setSheet( d->activeSheet );
+ manipulator->setReverse( true );
+ manipulator->add( *selectionInfo() );
+ manipulator->execute();
}
-void View::setSelectionPrecision( int delta )
-{
- if ( d->activeSheet != 0 )
- {
- doc()->emitBeginOperation( false );
- d->activeSheet->setSelectionPrecision( selectionInfo(), delta );
-
- markSelectionAsDirty();
- doc()->emitEndOperation();
- }
-}
-
void View::percent( bool b )
{
if ( d->toolbarLock )
--- trunk/koffice/kspread/View.h #570441:570442
@@ -333,11 +333,10 @@
void alignMiddle( bool b );
void alignBottom( bool b );
void wrapText( bool b );
- void precisionMinus();
- void precisionPlus();
+ void decreasePrecision();
+ void increasePrecision();
void createStyleFromCell();
void styleSelected( const QString & );
- void setSelectionPrecision(int delta);
void percent(bool b);
void fontSelected( const QString &_font );
void fontSizeSelected( int size );
--- trunk/koffice/kspread/ViewAdaptor.cpp #570441:570442
@@ -304,11 +304,6 @@
m_view->moneyFormat(b);
}
-void ViewAdaptor::setSelectionPrecision( int delta )
-{
- m_view->setSelectionPrecision(delta);
-}
-
void ViewAdaptor::setSelectionPercent( bool b )
{
m_view->percent(b);
@@ -429,6 +424,16 @@
m_view->increaseIndent();
}
+void ViewAdaptor::increasePrecision()
+{
+ m_view->increasePrecision();
+}
+
+void ViewAdaptor::decreasePrecision()
+{
+ m_view->decreasePrecision();
+}
+
void ViewAdaptor::subtotals()
{
m_view->subtotals();
--- trunk/koffice/kspread/ViewAdaptor.h #570441:570442
@@ -102,7 +102,6 @@
virtual void copyAsText();
virtual void setSelectionMoneyFormat( bool b );
- virtual void setSelectionPrecision( int delta );
virtual void setSelectionPercent( bool b );
virtual void setSelectionMultiRow( bool enable );
virtual void setSelectionSize(int size);
@@ -130,6 +129,8 @@
virtual void increaseIndent();
virtual void decreaseIndent();
+ virtual void increasePrecision();
+ virtual void decreasePrecision();
void subtotals();
void sortInc();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic