r17411 by fschmid - Added a context menue that allows to insert items into the currently selected textframe.
scribus-commit
scribus-commit at lists.scribus.net
Sun Apr 1 19:33:21 UTC 2012
Author: fschmid
Date: Sun Apr 1 19:33:21 2012
New Revision: 17411
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17411
Log:
Added a context menue that allows to insert items into the currently selected textframe.
Modified:
trunk/Scribus/scribus/ui/inlinepalette.cpp
trunk/Scribus/scribus/ui/inlinepalette.h
Modified: trunk/Scribus/scribus/ui/inlinepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17411&path=/trunk/Scribus/scribus/ui/inlinepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/inlinepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/inlinepalette.cpp Sun Apr 1 19:33:21 2012
@@ -23,8 +23,12 @@
#include "inlinepalette.h"
#include <QPainter>
#include <QByteArray>
+#include "pageitem.h"
+#include "pageitem_table.h"
+#include "pageitem_textframe.h"
#include "scribusdoc.h"
#include "scribus.h"
+#include "selection.h"
InlineView::InlineView(QWidget* parent) : QListWidget(parent)
{
@@ -98,6 +102,59 @@
m_scMW = NULL;
languageChange();
connect(InlineViewWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
+ connect(InlineViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(handleContextMenue(QPoint)));
+}
+
+void InlinePalette::handleContextMenue(QPoint p)
+{
+ QListWidgetItem *item = InlineViewWidget->itemAt(p);
+ if (item)
+ {
+ actItem = item->data(Qt::UserRole).toInt();
+ bool txFrame = false;
+ if (!currDoc->m_Selection->isEmpty())
+ {
+ PageItem* selItem = currDoc->m_Selection->itemAt(0);
+ if ((selItem->isTextFrame() || selItem->isTable()))
+ txFrame = true;
+ }
+ QMenu *pmenu = new QMenu();
+ if (txFrame)
+ {
+ QAction* pasteAct = pmenu->addAction( tr("Paste to Item"));
+ connect(pasteAct, SIGNAL(triggered()), this, SLOT(handlePasteToItem()));
+ }
+ if ((currDoc->appMode != modeEdit) && (currDoc->appMode != modeEditTable))
+ {
+ QAction* editAct = pmenu->addAction( tr("Edit Item"));
+ connect(editAct, SIGNAL(triggered()), this, SLOT(handleEditItem()));
+ }
+ pmenu->exec(QCursor::pos());
+ delete pmenu;
+ actItem = -1;
+ }
+}
+
+void InlinePalette::handlePasteToItem()
+{
+ PageItem* selItem = currDoc->m_Selection->itemAt(0);
+ PageItem_TextFrame *currItem;
+ if (selItem->isTable())
+ currItem = selItem->asTable()->activeCell().textFrame();
+ else
+ currItem = selItem->asTextFrame();
+ if (currItem->HasSel)
+ currItem->deleteSelectedTextFromFrame();
+ currItem->itemText.insertObject(actItem);
+ if (selItem->isTable())
+ selItem->asTable()->update();
+ else
+ currItem->update();
+}
+
+void InlinePalette::handleEditItem()
+{
+ emit startEdit(actItem);
}
void InlinePalette::handleDoubleClick(QListWidgetItem *item)
Modified: trunk/Scribus/scribus/ui/inlinepalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17411&path=/trunk/Scribus/scribus/ui/inlinepalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/inlinepalette.h (original)
+++ trunk/Scribus/scribus/ui/inlinepalette.h Sun Apr 1 19:33:21 2012
@@ -81,6 +81,9 @@
virtual void changeEvent(QEvent *e);
public slots:
+ void handleContextMenue(QPoint p);
+ void handlePasteToItem();
+ void handleEditItem();
void handleDoubleClick(QListWidgetItem *item);
void handleUpdateRequest(int);
void languageChange();
@@ -94,6 +97,7 @@
QVBoxLayout* PaletteLayout;
ScribusDoc *currDoc;
ScribusMainWindow *m_scMW;
+ int actItem;
};
#endif
More information about the scribus-commit
mailing list