Commit 769d1189 authored by Thorsten Zachmann's avatar Thorsten Zachmann

Merge branch 'master' of ssh://git.kde.org/calligra

parents 3249ad01 6e59e11a
......@@ -924,7 +924,7 @@ KisLayerSP KisImage::mergeDown(KisLayerSP layer, const KisMetaData::MergeStrateg
gc.bitBlt(layerProjectionExtent.topLeft(), layer->projection(), layerProjectionExtent);
}
KisPaintLayerSP mergedLayer = new KisPaintLayer(this, layer->name(), OPACITY_OPAQUE_U8, mergedDevice);
KisPaintLayerSP mergedLayer = new KisPaintLayer(this, prevLayer->name(), OPACITY_OPAQUE_U8, mergedDevice);
Q_CHECK_PTR(mergedLayer);
mergedLayer->setCompositeOp(COMPOSITE_OVER);
mergedLayer->setChannelFlags(layer->channelFlags());
......
......@@ -65,6 +65,7 @@ void testFiles(const QString& _dirname, const QStringList& exclusions, const QSt
KisDoc2 doc;
KoFilterManager manager(&doc);
manager.setBatchMode(true);
QByteArray nativeFormat = doc.nativeFormatMimeType();
KoFilter::ConversionStatus status;
QString s = manager.importDocument(sourceFileInfo.absoluteFilePath(), QString(),
......
......@@ -139,7 +139,7 @@ void KisDummiesFacadeBase::slotContinueAddNode(KisNodeSP node, KisNodeSP parent,
// Add one because this node does not exist yet
int index = parentDummy && aboveThisDummy ?
parentDummy->indexOf(aboveThisDummy) + 1 : 0;
emit sigBeginInsertDummy(parentDummy, index);
emit sigBeginInsertDummy(parentDummy, index, node->metaObject()->className());
addNodeImpl(node, parent, aboveThis);
......
......@@ -64,7 +64,7 @@ signals:
* The signals for controlling the node model
*/
void sigBeginInsertDummy(KisNodeDummy *parent, int index);
void sigBeginInsertDummy(KisNodeDummy *parent, int index, const QString &metaObjectType);
void sigEndInsertDummy(KisNodeDummy *dummy);
void sigBeginRemoveDummy(KisNodeDummy *dummy);
......
......@@ -37,6 +37,12 @@ inline bool KisModelIndexConverter::checkDummyType(KisNodeDummy *dummy)
return !mask;
}
inline bool KisModelIndexConverter::checkDummyMetaObjectType(const QString &type)
{
QString blacklistedType = KisSelectionMask::staticMetaObject.className();
return type != blacklistedType;
}
KisNodeDummy* KisModelIndexConverter::dummyFromRow(int row, QModelIndex parent)
{
......@@ -111,7 +117,11 @@ QModelIndex KisModelIndexConverter::indexFromDummy(KisNodeDummy *dummy)
return m_model->createIndex(row, 0, (void*)dummy);
}
bool KisModelIndexConverter::indexFromAddedDummy(KisNodeDummy *parentDummy, int index, QModelIndex &parentIndex, int &row)
bool KisModelIndexConverter::indexFromAddedDummy(KisNodeDummy *parentDummy,
int index,
const QString &newNodeMetaObjectType,
QModelIndex &parentIndex,
int &row)
{
// adding a root node
if(!parentDummy) {
......@@ -121,10 +131,9 @@ bool KisModelIndexConverter::indexFromAddedDummy(KisNodeDummy *parentDummy, int
// adding a child of the root node
if(!parentDummy->parent()) {
//TODO:
//if(!right_type) {
// return false;
//}
if(!checkDummyMetaObjectType(newNodeMetaObjectType)) {
return false;
}
row = 0;
......
......@@ -41,12 +41,15 @@ public:
KisNodeDummy* dummyFromIndex(QModelIndex index);
QModelIndex indexFromDummy(KisNodeDummy *dummy);
bool indexFromAddedDummy(KisNodeDummy *parentDummy, int index, QModelIndex &parentIndex, int &row);
bool indexFromAddedDummy(KisNodeDummy *parentDummy, int index,
const QString &newNodeMetaObjectType,
QModelIndex &parentIndex, int &row);
int rowCount(QModelIndex parent);
private:
static inline bool checkDummyType(KisNodeDummy *dummy);
static inline bool checkDummyMetaObjectType(const QString &type);
private:
KisDummiesFacadeBase *m_dummiesFacade;
......
......@@ -59,9 +59,15 @@ public:
/**
* Calculates the parent and the position in the model for newly created dummy
* \param newNodeMetaObjectType is a class name of a newly added node
* This name is got from Qt's meta object system so you must
* compare this value against a corresponding staticMetaObject
* object only.
* We do not pass a pointer to a real node to limit the access to
* real nodes.
* Return whether the new dummy will be shown in the model
*/
virtual bool indexFromAddedDummy(KisNodeDummy *parentDummy, int index, QModelIndex &parentIndex, int &row) = 0;
virtual bool indexFromAddedDummy(KisNodeDummy *parentDummy, int index, const QString &newNodeMetaObjectType, QModelIndex &parentIndex, int &row) = 0;
/**
* Returns the number of children of the given index of the model
......
......@@ -65,8 +65,14 @@ QModelIndex KisModelIndexConverterShowAll::indexFromDummy(KisNodeDummy *dummy)
return m_model->createIndex(row, 0, (void*)dummy);
}
bool KisModelIndexConverterShowAll::indexFromAddedDummy(KisNodeDummy *parentDummy, int index, QModelIndex &parentIndex, int &row)
bool KisModelIndexConverterShowAll::indexFromAddedDummy(KisNodeDummy *parentDummy,
int index,
const QString &newNodeMetaObjectType,
QModelIndex &parentIndex,
int &row)
{
Q_UNUSED(newNodeMetaObjectType);
Q_ASSERT(parentDummy || !index);
if(!parentDummy) {
......
......@@ -41,7 +41,9 @@ public:
KisNodeDummy* dummyFromIndex(QModelIndex index);
QModelIndex indexFromDummy(KisNodeDummy *dummy);
bool indexFromAddedDummy(KisNodeDummy *parentDummy, int index, QModelIndex &parentIndex, int &row);
bool indexFromAddedDummy(KisNodeDummy *parentDummy, int index,
const QString &newNodeMetaObjectType,
QModelIndex &parentIndex, int &row);
int rowCount(QModelIndex parent);
......
......@@ -173,8 +173,8 @@ void KisNodeModel::setDummiesFacade(KisDummiesFacadeBase *dummiesFacade, KisImag
connectDummies(rootDummy, true);
}
connect(m_d->dummiesFacade, SIGNAL(sigBeginInsertDummy(KisNodeDummy*, int)),
SLOT(slotBeginInsertDummy(KisNodeDummy*, int)));
connect(m_d->dummiesFacade, SIGNAL(sigBeginInsertDummy(KisNodeDummy*, int, const QString&)),
SLOT(slotBeginInsertDummy(KisNodeDummy*, int, QString)));
connect(m_d->dummiesFacade, SIGNAL(sigEndInsertDummy(KisNodeDummy*)),
SLOT(slotEndInsertDummy(KisNodeDummy*)));
connect(m_d->dummiesFacade, SIGNAL(sigBeginRemoveDummy(KisNodeDummy*)),
......@@ -189,13 +189,15 @@ void KisNodeModel::setDummiesFacade(KisDummiesFacadeBase *dummiesFacade, KisImag
reset();
}
void KisNodeModel::slotBeginInsertDummy(KisNodeDummy *parent, int index)
void KisNodeModel::slotBeginInsertDummy(KisNodeDummy *parent, int index, const QString &metaObjectType)
{
int row = 0;
QModelIndex parentIndex;
bool willAdd =
m_d->indexConverter->indexFromAddedDummy(parent, index, parentIndex, row);
m_d->indexConverter->indexFromAddedDummy(parent, index,
metaObjectType,
parentIndex, row);
if(willAdd) {
beginInsertRows(parentIndex, row, row);
......@@ -205,9 +207,8 @@ void KisNodeModel::slotBeginInsertDummy(KisNodeDummy *parent, int index)
void KisNodeModel::slotEndInsertDummy(KisNodeDummy *dummy)
{
connectDummy(dummy, true);
if(m_d->needFinishInsertRows) {
connectDummy(dummy, true);
endInsertRows();
m_d->needFinishInsertRows = false;
}
......@@ -215,8 +216,6 @@ void KisNodeModel::slotEndInsertDummy(KisNodeDummy *dummy)
void KisNodeModel::slotBeginRemoveDummy(KisNodeDummy *dummy)
{
connectDummy(dummy, false);
// FIXME: is it really what we want?
m_d->updateTimer->stop();
m_d->updateQueue.clear();
......@@ -231,6 +230,7 @@ void KisNodeModel::slotBeginRemoveDummy(KisNodeDummy *dummy)
QModelIndex itemIndex = m_d->indexConverter->indexFromDummy(dummy);
if(itemIndex.isValid()) {
connectDummy(dummy, false);
beginRemoveRows(parentIndex, itemIndex.row(), itemIndex.row());
m_d->needFinishRemoveRows = true;
}
......
......@@ -72,7 +72,7 @@ signals:
void requestMoveNode(KisNodeSP node, KisNodeSP parent, KisNodeSP aboveThis);
private slots:
void slotBeginInsertDummy(KisNodeDummy *parent, int index);
void slotBeginInsertDummy(KisNodeDummy *parent, int index, const QString &metaObjectType);
void slotEndInsertDummy(KisNodeDummy *dummy);
void slotBeginRemoveDummy(KisNodeDummy *dummy);
void slotEndRemoveDummy();
......
......@@ -73,7 +73,19 @@ inline void KisModelIndexConverterTest::checkInvalidIndexFromDummy(KisNodeSP nod
QVERIFY(!index.isValid());
}
inline void KisModelIndexConverterTest::checkIndexFromAddedDummy(KisNodeSP parent, int index, int parentRow, int childRow, bool parentValid)
inline void KisModelIndexConverterTest::checkIndexFromAddedAllowedDummy(KisNodeSP parent, int index, int parentRow, int childRow, bool parentValid)
{
QString type = KisLayer::staticMetaObject.className();
checkIndexFromAddedDummy(parent, index, type, parentRow, childRow, parentValid);
}
inline void KisModelIndexConverterTest::checkIndexFromAddedDeniedDummy(KisNodeSP parent, int index, int parentRow, int childRow, bool parentValid)
{
QString type = KisSelectionMask::staticMetaObject.className();
checkIndexFromAddedDummy(parent, index, type, parentRow, childRow, parentValid);
}
inline void KisModelIndexConverterTest::checkIndexFromAddedDummy(KisNodeSP parent, int index, const QString &type, int parentRow, int childRow, bool parentValid)
{
QModelIndex modelIndex;
KisNodeDummy *dummy;
......@@ -82,7 +94,9 @@ inline void KisModelIndexConverterTest::checkIndexFromAddedDummy(KisNodeSP paren
bool result;
dummy = parent ? m_dummiesFacade->dummyForNode(parent) : 0;
result = m_indexConverter->indexFromAddedDummy(dummy, index, modelIndex, row);
result = m_indexConverter->indexFromAddedDummy(dummy, index, type, modelIndex, row);
if(!result) qDebug() << "Failing parent:" << (parent ? parent->name() : "none") << "index:" << index;
QVERIFY(result);
QCOMPARE(modelIndex.isValid(), parentValid);
......@@ -91,10 +105,33 @@ inline void KisModelIndexConverterTest::checkIndexFromAddedDummy(KisNodeSP paren
QCOMPARE(modelIndex.column(), 0);
}
if(result) {
if(row != childRow) qDebug() << "Failing parent:" << (parent ? parent->name() : "none") << "index:" << index;
QCOMPARE(row, childRow);
}
if(row != childRow) qDebug() << "Failing parent:" << (parent ? parent->name() : "none") << "index:" << index;
QCOMPARE(row, childRow);
}
inline void KisModelIndexConverterTest::checkInvalidIndexFromAddedAllowedDummy(KisNodeSP parent, int index)
{
QString type = KisLayer::staticMetaObject.className();
checkInvalidIndexFromAddedDummy(parent, index, type);
}
inline void KisModelIndexConverterTest::checkInvalidIndexFromAddedDeniedDummy(KisNodeSP parent, int index)
{
QString type = KisSelectionMask::staticMetaObject.className();
checkInvalidIndexFromAddedDummy(parent, index, type);
}
inline void KisModelIndexConverterTest::checkInvalidIndexFromAddedDummy(KisNodeSP parent, int index, const QString &type)
{
QModelIndex modelIndex;
KisNodeDummy *dummy;
int row = 0;
bool result;
dummy = parent ? m_dummiesFacade->dummyForNode(parent) : 0;
result = m_indexConverter->indexFromAddedDummy(dummy, index, type, modelIndex, row);
QVERIFY(!result);
}
inline void KisModelIndexConverterTest::checkDummyFromRow(KisNodeSP parent, int row, KisNodeSP expectedNode)
......@@ -117,7 +154,6 @@ inline void KisModelIndexConverterTest::checkDummyFromRow(KisNodeSP parent, int
}
}
inline void KisModelIndexConverterTest::checkRowCount(KisNodeSP parent, int rowCount)
{
QModelIndex parentIndex;
......@@ -155,25 +191,46 @@ void KisModelIndexConverterTest::testIndexFromDummy()
checkInvalidIndexFromDummy(m_sel2);
}
void KisModelIndexConverterTest::testIndexFromAddedDummy()
void KisModelIndexConverterTest::testIndexFromAddedAllowedDummy()
{
m_indexConverter = new KisModelIndexConverter(m_dummiesFacade, m_nodeModel);
checkIndexFromAddedAllowedDummy(m_image->root(), 0, 0, 4, false);
checkIndexFromAddedAllowedDummy(m_image->root(), 1, 0, 4, false);
checkIndexFromAddedAllowedDummy(m_image->root(), 2, 0, 3, false);
checkIndexFromAddedAllowedDummy(m_image->root(), 3, 0, 2, false);
checkIndexFromAddedAllowedDummy(m_image->root(), 4, 0, 2, false);
checkIndexFromAddedAllowedDummy(m_image->root(), 5, 0, 1, false);
checkIndexFromAddedAllowedDummy(m_image->root(), 6, 0, 0, false);
checkIndexFromAddedAllowedDummy(m_layer1, 0, 3, 0, true);
checkIndexFromAddedAllowedDummy(m_layer3, 0, 1, 2, true);
checkIndexFromAddedAllowedDummy(m_layer3, 1, 1, 1, true);
checkIndexFromAddedAllowedDummy(m_layer3, 2, 1, 0, true);
checkInvalidIndexFromAddedAllowedDummy(0, 0);
}
void KisModelIndexConverterTest::testIndexFromAddedDeniedDummy()
{
m_indexConverter = new KisModelIndexConverter(m_dummiesFacade, m_nodeModel);
checkIndexFromAddedDummy(m_image->root(), 0, 0, 4, false);
checkIndexFromAddedDummy(m_image->root(), 1, 0, 4, false);
checkIndexFromAddedDummy(m_image->root(), 2, 0, 3, false);
checkIndexFromAddedDummy(m_image->root(), 3, 0, 2, false);
checkIndexFromAddedDummy(m_image->root(), 4, 0, 2, false);
checkIndexFromAddedDummy(m_image->root(), 5, 0, 1, false);
checkIndexFromAddedDummy(m_image->root(), 6, 0, 0, false);
checkInvalidIndexFromAddedDeniedDummy(m_image->root(), 0);
checkInvalidIndexFromAddedDeniedDummy(m_image->root(), 1);
checkInvalidIndexFromAddedDeniedDummy(m_image->root(), 2);
checkInvalidIndexFromAddedDeniedDummy(m_image->root(), 3);
checkInvalidIndexFromAddedDeniedDummy(m_image->root(), 4);
checkInvalidIndexFromAddedDeniedDummy(m_image->root(), 5);
checkInvalidIndexFromAddedDeniedDummy(m_image->root(), 6);
checkIndexFromAddedDummy(m_layer1, 0, 3, 0, true);
checkIndexFromAddedDeniedDummy(m_layer1, 0, 3, 0, true);
checkIndexFromAddedDummy(m_layer3, 0, 1, 2, true);
checkIndexFromAddedDummy(m_layer3, 1, 1, 1, true);
checkIndexFromAddedDummy(m_layer3, 2, 1, 0, true);
checkIndexFromAddedDeniedDummy(m_layer3, 0, 1, 2, true);
checkIndexFromAddedDeniedDummy(m_layer3, 1, 1, 1, true);
checkIndexFromAddedDeniedDummy(m_layer3, 2, 1, 0, true);
checkIndexFromAddedDummy(0, 0, 0, 0, false);
checkInvalidIndexFromAddedDeniedDummy(0, 0);
}
void KisModelIndexConverterTest::testDummyFromRow()
......@@ -224,25 +281,46 @@ void KisModelIndexConverterTest::testIndexFromDummyShowAll()
checkIndexFromDummy(m_image->root(), 0);
}
void KisModelIndexConverterTest::testIndexFromAddedDummyShowAll()
void KisModelIndexConverterTest::testIndexFromAddedAllowedDummyShowAll()
{
m_indexConverter = new KisModelIndexConverterShowAll(m_dummiesFacade, m_nodeModel);
checkIndexFromAddedAllowedDummy(m_image->root(), 0, 0, 6, true);
checkIndexFromAddedAllowedDummy(m_image->root(), 1, 0, 5, true);
checkIndexFromAddedAllowedDummy(m_image->root(), 2, 0, 4, true);
checkIndexFromAddedAllowedDummy(m_image->root(), 3, 0, 3, true);
checkIndexFromAddedAllowedDummy(m_image->root(), 4, 0, 2, true);
checkIndexFromAddedAllowedDummy(m_image->root(), 5, 0, 1, true);
checkIndexFromAddedAllowedDummy(m_image->root(), 6, 0, 0, true);
checkIndexFromAddedAllowedDummy(m_layer1, 0, 4, 0, true);
checkIndexFromAddedAllowedDummy(m_layer3, 0, 1, 2, true);
checkIndexFromAddedAllowedDummy(m_layer3, 1, 1, 1, true);
checkIndexFromAddedAllowedDummy(m_layer3, 2, 1, 0, true);
checkIndexFromAddedAllowedDummy(0, 0, 0, 0, false);
}
void KisModelIndexConverterTest::testIndexFromAddedDeniedDummyShowAll()
{
m_indexConverter = new KisModelIndexConverterShowAll(m_dummiesFacade, m_nodeModel);
checkIndexFromAddedDummy(m_image->root(), 0, 0, 6, true);
checkIndexFromAddedDummy(m_image->root(), 1, 0, 5, true);
checkIndexFromAddedDummy(m_image->root(), 2, 0, 4, true);
checkIndexFromAddedDummy(m_image->root(), 3, 0, 3, true);
checkIndexFromAddedDummy(m_image->root(), 4, 0, 2, true);
checkIndexFromAddedDummy(m_image->root(), 5, 0, 1, true);
checkIndexFromAddedDummy(m_image->root(), 6, 0, 0, true);
checkIndexFromAddedDeniedDummy(m_image->root(), 0, 0, 6, true);
checkIndexFromAddedDeniedDummy(m_image->root(), 1, 0, 5, true);
checkIndexFromAddedDeniedDummy(m_image->root(), 2, 0, 4, true);
checkIndexFromAddedDeniedDummy(m_image->root(), 3, 0, 3, true);
checkIndexFromAddedDeniedDummy(m_image->root(), 4, 0, 2, true);
checkIndexFromAddedDeniedDummy(m_image->root(), 5, 0, 1, true);
checkIndexFromAddedDeniedDummy(m_image->root(), 6, 0, 0, true);
checkIndexFromAddedDummy(m_layer1, 0, 4, 0, true);
checkIndexFromAddedDeniedDummy(m_layer1, 0, 4, 0, true);
checkIndexFromAddedDummy(m_layer3, 0, 1, 2, true);
checkIndexFromAddedDummy(m_layer3, 1, 1, 1, true);
checkIndexFromAddedDummy(m_layer3, 2, 1, 0, true);
checkIndexFromAddedDeniedDummy(m_layer3, 0, 1, 2, true);
checkIndexFromAddedDeniedDummy(m_layer3, 1, 1, 1, true);
checkIndexFromAddedDeniedDummy(m_layer3, 2, 1, 0, true);
checkIndexFromAddedDummy(0, 0, 0, 0, false);
checkIndexFromAddedDeniedDummy(0, 0, 0, 0, false);
}
void KisModelIndexConverterTest::testDummyFromRowShowAll()
......
......@@ -36,19 +36,26 @@ private slots:
void cleanup();
void testIndexFromDummy();
void testIndexFromAddedDummy();
void testIndexFromAddedAllowedDummy();
void testIndexFromAddedDeniedDummy();
void testDummyFromRow();
void testRowCount();
void testIndexFromDummyShowAll();
void testIndexFromAddedDummyShowAll();
void testIndexFromAddedAllowedDummyShowAll();
void testIndexFromAddedDeniedDummyShowAll();
void testDummyFromRowShowAll();
void testRowCountShowAll();
private:
inline void checkIndexFromDummy(KisNodeSP node, int row);
inline void checkInvalidIndexFromDummy(KisNodeSP node);
inline void checkIndexFromAddedDummy(KisNodeSP parent, int index, int parentRow, int childRow, bool parentValid);
inline void checkIndexFromAddedAllowedDummy(KisNodeSP parent, int index, int parentRow, int childRow, bool parentValid);
inline void checkIndexFromAddedDeniedDummy(KisNodeSP parent, int index, int parentRow, int childRow, bool parentValid);
inline void checkIndexFromAddedDummy(KisNodeSP parent, int index, const QString &type, int parentRow, int childRow, bool parentValid);
inline void checkInvalidIndexFromAddedAllowedDummy(KisNodeSP parent, int index);
inline void checkInvalidIndexFromAddedDeniedDummy(KisNodeSP parent, int index);
inline void checkInvalidIndexFromAddedDummy(KisNodeSP parent, int index, const QString &type);
inline void checkDummyFromRow(KisNodeSP parent, int row, KisNodeSP expectedNode);
inline void checkRowCount(KisNodeSP parent, int rowCount);
......
......@@ -43,6 +43,7 @@ KoTextEditingPlugin::~KoTextEditingPlugin()
void KoTextEditingPlugin::selectWord(QTextCursor &cursor, int cursorPosition) const
{
cursor.beginEditBlock(); //needed to work around qt4.8 bug
cursor.setPosition(cursorPosition);
QTextBlock block = cursor.block();
cursor.setPosition(block.position());
......@@ -64,6 +65,7 @@ void KoTextEditingPlugin::selectWord(QTextCursor &cursor, int cursorPosition) co
iter++;
}
cursor.setPosition(pos + block.position(), QTextCursor::KeepAnchor);
cursor.endEditBlock(); //needed to work around qt4.8 bug (see above)
}
QString KoTextEditingPlugin::paragraph(QTextDocument *document, int cursorPosition) const
......
......@@ -1531,7 +1531,9 @@ void TextTool::repaintSelection()
QRectF TextTool::caretRect(QTextCursor *cursor) const
{
QTextCursor tmpCursor(*cursor);
tmpCursor.beginEditBlock(); //needed to work around qt4.8 bug
tmpCursor.setPosition(cursor->position()); // looses the anchor
tmpCursor.endEditBlock();
QRectF rect = textRect(tmpCursor);
if (rect.size() == QSizeF(0,0)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment