summaryrefslogtreecommitdiffstats
path: root/scribus/plugins/scriptplugin
diff options
context:
space:
mode:
authorjghali <jghali@11d20701-8431-0410-a711-e3c959e3b870>2012-01-22 15:04:57 +0000
committerjghali <jghali@11d20701-8431-0410-a711-e3c959e3b870>2012-01-22 15:04:57 +0000
commit11bc8e3e0a97380b06148867c29732d080adfa4d (patch)
tree892a5ac90b5d0beb95ba31090359d2310554a269 /scribus/plugins/scriptplugin
parent6469d1c8b98607365a114611033560fd0693b23a (diff)
downloadscribus-11bc8e3e0a97380b06148867c29732d080adfa4d.tar.gz
scribus-11bc8e3e0a97380b06148867c29732d080adfa4d.tar.xz
scribus-11bc8e3e0a97380b06148867c29732d080adfa4d.zip
#10536 : sending group objects to other layer does not work from within scripter
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17220 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/plugins/scriptplugin')
-rw-r--r--scribus/plugins/scriptplugin/cmdmisc.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/scribus/plugins/scriptplugin/cmdmisc.cpp b/scribus/plugins/scriptplugin/cmdmisc.cpp
index a6f5ce0..3f833ae 100644
--- a/scribus/plugins/scriptplugin/cmdmisc.cpp
+++ b/scribus/plugins/scriptplugin/cmdmisc.cpp
@@ -12,9 +12,11 @@ for which a new license (GPL+exception) is in place.
//Added by qt3to4:
#include <QList>
+#include "prefsmanager.h"
#include "scribuscore.h"
+#include "scribusdoc.h"
+#include "selection.h"
#include "fonts/scfontmetrics.h"
-#include "prefsmanager.h"
PyObject *scribus_setredraw(PyObject* /* self */, PyObject* args)
{
@@ -202,27 +204,31 @@ PyObject *scribus_senttolayer(PyObject* /* self */, PyObject* args)
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
return NULL;
}
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == NULL)
return NULL;
- ScCore->primaryMainWindow()->view->SelectItemNr(i->ItemNr);
- bool found = false;
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
- {
- ScCore->primaryMainWindow()->view->SelectItemNr(i->ItemNr);
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Layer))
- {
- i->LayerNr = static_cast<int>(lam);
- found = true;
- break;
- }
- }
- if (!found)
+ ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
+ ScribusView* currentView = ScCore->primaryMainWindow()->view;
+ const ScLayer *scLayer = currentDoc->Layers.layerByName( QString::fromUtf8(Layer) );
+ if (!scLayer)
{
PyErr_SetString(ScribusException, QString("Layer not found").toLocal8Bit().constData());
return NULL;
}
+ // If no name have been specified in args, process whole selection
+ currentView->SelectItemNr(item->ItemNr);
+ if ((Name == EMPTY_STRING) || (item->isGroupControl) || (item->Groups.count() > 0))
+ {
+ for (int i = 0; i < currentDoc->m_Selection->count(); ++i)
+ {
+ item = currentDoc->m_Selection->itemAt(i);
+ item->LayerNr = scLayer->LNr;
+ }
+ }
+ else
+ {
+ item->LayerNr = scLayer->LNr;
+ }
// Py_INCREF(Py_None);
// return Py_None;