[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kspread/plugins/scripting
From:       Sebastian Sauer <mail () dipe ! org>
Date:       2007-07-08 1:44:03
Message-ID: 1183859043.994284.18977.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 685048 by sebsauer:

one signal for region changes and one for cell changes.

 M  +7 -5      ScriptingListener.cpp  
 M  +7 -3      ScriptingListener.h  
 M  +8 -3      scripts/logger.py  


--- trunk/koffice/kspread/plugins/scripting/ScriptingListener.cpp #685047:685048
@@ -32,6 +32,7 @@
     class ScriptingCellListener::Private
     {
         public:
+            KSpread::Sheet* sheet;
             KSpread::Binding* cellbinding;
     };
 }
@@ -40,6 +41,7 @@
     : QObject()
     , d(new Private())
 {
+    d->sheet = sheet;
     d->cellbinding = new KSpread::Binding(Region(area, sheet));
     connect(d->cellbinding->model(), SIGNAL(changed(const Region&)), this, \
                SLOT(slotChanged(const Region&)));
     sheet->cellStorage()->setBinding(Region(area, sheet), *d->cellbinding);
@@ -53,14 +55,14 @@
 
 void ScriptingCellListener::slotChanged(const Region& region)
 {
+    emit regionChanged( region.name(d->sheet).split(";") );
     Region::ConstIterator end(region.constEnd());
     for (Region::ConstIterator it = region.constBegin(); it != end; ++it)
     {
-        for (int row = (*it)->rect().top(); row <= (*it)->rect().bottom(); ++row)
-        {
-            for (int col = (*it)->rect().left(); col <= (*it)->rect().right(); \
                ++col)
-                emit changed(col, row);
-        }
+        const QRect r( (*it)->rect() );
+        for (int row = r.top(); row <= r.bottom(); ++row)
+            for (int col = r.left(); col <= r.right(); ++col)
+                emit cellChanged(col, row);
     }
 }
 
--- trunk/koffice/kspread/plugins/scripting/ScriptingListener.h #685047:685048
@@ -40,9 +40,12 @@
     * listener = KSpread.createListener("Sheet1", "A1:F50")
     * if not listener:
     *     raise "Failed to create listener."
-    * def changed(column, row):
+    * def regionChanged(regions):
+    *     print "regions=%s" % regions
+    * def cellChanged(column, row):
     *     print "column=%i row=%i" % (column,row)
-    * listener.connect("changed(int,int)", changed)
+    * listener.connect("regionChanged(QStringList)", regionChanged)
+    * listener.connect("cellChanged(int,int)", cellChanged)
     * \endcode
     */
     class ScriptingCellListener : public QObject
@@ -53,7 +56,8 @@
             virtual ~ScriptingCellListener();
 
         Q_SIGNALS:
-            void changed(int column, int row);
+            void regionChanged(const QStringList& ranges);
+            void cellChanged(int column, int row);
 
         private Q_SLOTS:
             void slotChanged(const Region&);
--- trunk/koffice/kspread/plugins/scripting/scripts/logger.py #685047:685048
@@ -46,11 +46,16 @@
         if not self.listener:
             raise "Failed to create listener for sheetname '%s' and range '%s'" % \
                (sheetname,cellrange)
         self.addLog( "Start logging sheet='%s' range='%s'" % (sheetname,cellrange) )
-        self.listener.connect("changed(int,int)", self.changed)
+        self.listener.connect("regionChanged(QStringList)", self.regionChanged)
+        self.listener.connect("cellChanged(int,int)", self.cellChanged)
 
-    def changed(self, column, row):
+    def regionChanged(self, regions):
+        print "Logger: Region changed %s" % regions
+        self.addLog( "regions=%s" % regions )
+    def cellChanged(self, column, row):
         text = self.sheet.text(column, row)
         print "Logger: Cell changed column=%i row=%i text=%s" % (column,row,text)
-        self.addLog( "%i:%i %s" % (column,row,text) )
+        self.addLog( "column=%i row=%i text=%s" % (column,row,text) )
+        self.lastRegionIdx += 1
 
 Logger( self )


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic