r17789 by fschmid - Allow removal of inline frames from the context menue of the inline frames palette.
scribus-commit
scribus-commit at lists.scribus.net
Sat Oct 6 19:20:45 UTC 2012
Author: fschmid
Date: Sat Oct 6 19:20:45 2012
New Revision: 17789
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17789
Log:
Allow removal of inline frames from the context menue of the inline frames palette.
Modified:
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/scribusdoc.h
trunk/Scribus/scribus/ui/inlinepalette.cpp
trunk/Scribus/scribus/ui/inlinepalette.h
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17789&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sat Oct 6 19:20:45 2012
@@ -302,8 +302,9 @@
NrItems(0),
First(1), Last(0),
viewCount(0), viewID(0),
+ SnapGuides(false),
SnapElement(false),
- SnapGuides(false), GuideLock(false),
+ GuideLock(false),
minCanvasCoordinate(FPoint(0, 0)),
rulerXoffset(0.0), rulerYoffset(0.0),
Pages(0), MasterPages(), DocPages(),
@@ -15835,6 +15836,141 @@
return fIndex;
}
+void ScribusDoc::removeInlineFrame(int fIndex)
+{
+ QList<PageItem*> allItems;
+ PageItem* it = NULL;
+ uint counter = 0;
+ for (uint lc = 0; lc < 2; ++lc)
+ {
+ switch (lc)
+ {
+ case 0:
+ counter = MasterItems.count();
+ break;
+ case 1:
+ counter = DocItems.count();
+ break;
+ }
+ for (uint d = 0; d < counter; ++d)
+ {
+ switch (lc)
+ {
+ case 0:
+ it = MasterItems.at(d);
+ break;
+ case 1:
+ it = DocItems.at(d);
+ break;
+ }
+ if (it->isGroup())
+ allItems = it->asGroupFrame()->getItemList();
+ else
+ allItems.append(it);
+ for (int ii = 0; ii < allItems.count(); ii++)
+ {
+ it = allItems.at(ii);
+ if (it->isTable())
+ {
+ for (int row = 0; row < it->asTable()->rows(); ++row)
+ {
+ for (int col = 0; col < it->asTable()->columns(); col ++)
+ {
+ TableCell cell = it->asTable()->cellAt(row, col);
+ if (cell.row() == row && cell.column() == col)
+ {
+ PageItem* textFrame = cell.textFrame();
+ checkItemForFrames(textFrame, fIndex);
+ }
+ }
+ }
+ }
+ else
+ checkItemForFrames(it, fIndex);
+ }
+ allItems.clear();
+ }
+ }
+ for (QHash<int, PageItem*>::iterator itf = FrameItems.begin(); itf != FrameItems.end(); ++itf)
+ {
+ PageItem *ite = itf.value();
+ if (ite->isGroup())
+ allItems = ite->asGroupFrame()->getItemList();
+ else
+ allItems.append(ite);
+ for (int ii = 0; ii < allItems.count(); ii++)
+ {
+ ite = allItems.at(ii);
+ if (ite->isTable())
+ {
+ for (int row = 0; row < ite->asTable()->rows(); ++row)
+ {
+ for (int col = 0; col < ite->asTable()->columns(); col ++)
+ {
+ TableCell cell = ite->asTable()->cellAt(row, col);
+ if (cell.row() == row && cell.column() == col)
+ {
+ PageItem* textFrame = cell.textFrame();
+ checkItemForFrames(textFrame, fIndex);
+ }
+ }
+ }
+ }
+ else
+ checkItemForFrames(ite, fIndex);
+ }
+ allItems.clear();
+ }
+ QStringList patterns = getUsedPatterns();
+ for (int c = 0; c < patterns.count(); ++c)
+ {
+ ScPattern pa = docPatterns[patterns[c]];
+ for (int o = 0; o < pa.items.count(); o++)
+ {
+ it = pa.items.at(o);
+ if (it->isGroup())
+ allItems = it->asGroupFrame()->getItemList();
+ else
+ allItems.append(it);
+ for (int ii = 0; ii < allItems.count(); ii++)
+ {
+ it = allItems.at(ii);
+ checkItemForFrames(it, fIndex);
+ }
+ allItems.clear();
+ }
+ }
+ it = FrameItems.take(fIndex);
+ delete it;
+ changed();
+ regionsChanged()->update(QRect());
+}
+
+
+void ScribusDoc::checkItemForFrames(PageItem *it, int fIndex)
+{
+ QList<int> deleteList;
+ deleteList.clear();
+ if (!it->isTextFrame() && !it->isPathText())
+ return;
+ int start = 0;
+ int stop = it->itemText.length();
+ for (int e = start; e < stop; ++e)
+ {
+ ScText *hl = it->itemText.item(e);
+ if ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(this)))
+ {
+ if (hl->getItem(this)->inlineCharID == fIndex)
+ deleteList.prepend(e);
+ }
+ }
+ for (int a = 0; a < deleteList.count(); a++)
+ {
+ it->itemText.removeChars(deleteList[a], 1);
+ }
+ it->invalid = true;
+}
+
void ScribusDoc::itemResizeToMargin(PageItem* item, int direction)
{
//FIX ME: for now avoid for rotated items
Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17789&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Sat Oct 6 19:20:45 2012
@@ -1163,6 +1163,8 @@
void beginUpdate();
void endUpdate();
int addToInlineFrames(PageItem *item);
+ void removeInlineFrame(int fIndex);
+ void checkItemForFrames(PageItem *it, int fIndex);
protected:
void addSymbols();
Modified: trunk/Scribus/scribus/ui/inlinepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17789&path=/trunk/Scribus/scribus/ui/inlinepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/inlinepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/inlinepalette.cpp Sat Oct 6 19:20:45 2012
@@ -129,6 +129,8 @@
QAction* editAct = pmenu->addAction( tr("Edit Item"));
connect(editAct, SIGNAL(triggered()), this, SLOT(handleEditItem()));
}
+ QAction* delAct = pmenu->addAction( tr("Remove Item"));
+ connect(delAct, SIGNAL(triggered()), this, SLOT(handleDeleteItem()));
pmenu->exec(QCursor::pos());
delete pmenu;
actItem = -1;
@@ -161,6 +163,14 @@
{
if (item)
emit startEdit(item->data(Qt::UserRole).toInt());
+}
+
+void InlinePalette::handleDeleteItem()
+{
+ currDoc->removeInlineFrame(actItem);
+ QListWidgetItem* item = InlineViewWidget->takeItem(InlineViewWidget->currentRow());
+ delete item;
+ InlineViewWidget->update();
}
void InlinePalette::editingStart()
Modified: trunk/Scribus/scribus/ui/inlinepalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17789&path=/trunk/Scribus/scribus/ui/inlinepalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/inlinepalette.h (original)
+++ trunk/Scribus/scribus/ui/inlinepalette.h Sat Oct 6 19:20:45 2012
@@ -85,6 +85,7 @@
void handlePasteToItem();
void handleEditItem();
void handleDoubleClick(QListWidgetItem *item);
+ void handleDeleteItem();
void handleUpdateRequest(int);
void languageChange();
More information about the scribus-commit
mailing list