r19307 by craig - #11938: First part of this fix.. some clean up to come tomorrow

scribus-commit scribus-commit at lists.scribus.net
Tue Jul 1 21:44:33 UTC 2014


Author: craig
Date: Tue Jul  1 21:44:33 2014
New Revision: 19307

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19307
Log:
#11938: First part of this fix.. some clean up to come tomorrow

Modified:
    trunk/Scribus/scribus/canvasmode_edittable.cpp
    trunk/Scribus/scribus/canvasmode_edittable.h
    trunk/Scribus/scribus/pageitem_table.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/ui/contextmenu.cpp

Modified: trunk/Scribus/scribus/canvasmode_edittable.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19307&path=/trunk/Scribus/scribus/canvasmode_edittable.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edittable.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_edittable.cpp Tue Jul  1 21:44:33 2014
@@ -22,6 +22,7 @@
 #include "canvasgesture_rowresize.h"
 #include "canvasgesture_tableresize.h"
 #include "cellarea.h"
+#include "ui/contextmenu.h"
 #include "fpoint.h"
 #include "pageitem_table.h"
 #include "scribus.h"
@@ -50,7 +51,8 @@
 	m_tableResizeGesture(new TableResize(this)),
 	m_rowResizeGesture(new RowResize(this)),
 	m_columnResizeGesture(new ColumnResize(this)),
-	m_cellSelectGesture(new CellSelect(this))
+	m_cellSelectGesture(new CellSelect(this)),
+	m_ScMW(view->m_ScMW)
 {
 	connect(m_canvasUpdateTimer, SIGNAL(timeout()), this, SLOT(updateCanvas()));
 }
@@ -246,7 +248,9 @@
 	else if (event->button() == Qt::RightButton)
 	{
 		// Show the table popup menu.
-		m_view->m_ScMW->scrMenuMgr->runMenuAtPos("ItemTable", event->globalPos());
+		//m_view->m_ScMW->scrMenuMgr->runMenuAtPos("ItemTable", event->globalPos());
+		const FPoint mousePointDoc = m_canvas->globalToCanvas(event->globalPos());
+		createContextMenu(m_table, mousePointDoc.x(), mousePointDoc.y());
 	}
 }
 
@@ -376,3 +380,19 @@
 	m_longBlink = true;
 	m_blinkTime.restart();
 }
+
+void CanvasMode_EditTable::createContextMenu(PageItem *currItem, double mx, double my)
+{
+	ContextMenu* cmen=NULL;
+	m_view->setCursor(QCursor(Qt::ArrowCursor));
+//	Mxp = mx;
+//	Myp = my;
+	if(currItem!=NULL)
+		cmen = new ContextMenu(*(m_doc->m_Selection), m_ScMW, m_doc);
+	else
+		cmen = new ContextMenu(m_ScMW, m_doc, mx, my);
+	if (cmen)
+		cmen->exec(QCursor::pos());
+//	m_view->setGlobalUndoMode();
+	delete cmen;
+}

Modified: trunk/Scribus/scribus/canvasmode_edittable.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19307&path=/trunk/Scribus/scribus/canvasmode_edittable.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edittable.h (original)
+++ trunk/Scribus/scribus/canvasmode_edittable.h Tue Jul  1 21:44:33 2014
@@ -24,6 +24,7 @@
 class QPainter;
 class QTimer;
 class RowResize;
+class ScribusMainWindow;
 class ScribusView;
 class TableResize;
 
@@ -63,6 +64,8 @@
 	void drawTextCursor(QPainter* p);
 	/// Makes the next text cursor blink a long blink.
 	void makeLongTextCursorBlink();
+	/// Show the Context Menu
+	void createContextMenu(PageItem *currItem, double mx, double my);
 
 private:
 	/// Table being edited.
@@ -94,6 +97,9 @@
 	ColumnResize* m_columnResizeGesture;
 	/// Gesture for selecting cells.
 	CellSelect* m_cellSelectGesture;
+
+	///Parent for context menu
+	ScribusMainWindow* m_ScMW;
 };
 
 #endif // CANVASMODE_EDITTABLE_H

Modified: trunk/Scribus/scribus/pageitem_table.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19307&path=/trunk/Scribus/scribus/pageitem_table.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_table.cpp (original)
+++ trunk/Scribus/scribus/pageitem_table.cpp Tue Jul  1 21:44:33 2014
@@ -19,6 +19,7 @@
 #include <QTransform>
 #include <QtAlgorithms>
 
+#include "appmodes.h"
 #include "cellarea.h"
 #include "collapsedtablepainter.h"
 #include "pageitem.h"
@@ -870,14 +871,40 @@
 
 void PageItem_Table::applicableActions(QStringList& actionList)
 {
-	actionList << "tableInsertRows";
-	actionList << "tableInsertColumns";
-	actionList << "tableSetRowHeights";
-	actionList << "tableSetColumnWidths";
-	actionList << "tableDistributeRowsEvenly";
-	actionList << "tableDistributeColumnsEvenly";
+	const bool tableEdit = m_Doc->appMode == modeEditTable;
+	const int tableRows = rows();
+	const int tableColumns = columns();
+	const int selectedRows = tableEdit ? this->selectedRows().size() : 0;
+	const int selectedColumns = tableEdit ? this->selectedColumns().size() : 0;
+	const int selectedCells = tableEdit ? this->selectedCells().size() : 0;
+
+	if (!tableEdit || selectedCells<1)
+		actionList << "tableInsertRows";
+	if (!tableEdit || selectedCells<1)
+		actionList << "tableInsertColumns";
+	if (tableEdit && ((selectedRows < 1 && tableRows > 1) || (selectedRows > 0 && selectedRows < tableRows)))
+		actionList << "tableDeleteRows";
+	if ((selectedColumns < 1 && tableColumns > 1) || (selectedColumns > 0 && selectedColumns < tableColumns))
+		actionList << "tableDeleteColumns";
+	if (selectedCells > 1)
+		actionList << "tableMergeCells";
+	if (tableEdit)
+		actionList << "tableSetRowHeights";
+	if (tableEdit)
+		actionList << "tableSetColumnWidths";
+	if (!tableEdit || (tableEdit && selectedRows > 1))
+		actionList << "tableDistributeRowsEvenly";
+	if (!tableEdit || (tableEdit && selectedColumns > 1))
+		actionList << "tableDistributeColumnsEvenly";
 	actionList << "tableAdjustFrameToTable";
 	actionList << "tableAdjustTableToFrame";
+
+	if (tableEdit)
+	{
+		actionList << "editClearContents";
+		actionList << "editCopyContents";
+		actionList << "editPasteContents";
+	}
 }
 
 void PageItem_Table::DrawObj_Item(ScPainter *p, QRectF /*e*/)

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19307&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Jul  1 21:44:33 2014
@@ -10160,25 +10160,25 @@
 	// Determine state.
 	PageItem* item = doc ? doc->m_Selection->itemAt(0) : 0;
 	PageItem_Table* table = (item && item->isTable()) ? item->asTable() : 0;
-	const bool tableEdited = table && doc->appMode == modeEditTable;
+	const bool tableEdit = table && doc->appMode == modeEditTable;
 	const int tableRows = table ? table->rows() : 0;
 	const int tableColumns = table ? table->columns() : 0;
-	const int selectedRows = tableEdited ? table->selectedRows().size() : 0;
-	const int selectedColumns = tableEdited ? table->selectedColumns().size() : 0;
-	const int selectedCells = tableEdited ? table->selectedCells().size() : 0;
+	const int selectedRows = tableEdit ? table->selectedRows().size() : 0;
+	const int selectedColumns = tableEdit ? table->selectedColumns().size() : 0;
+	const int selectedCells = tableEdit ? table->selectedCells().size() : 0;
 
 	// Enable/disable menu actions.
 	scrMenuMgr->setMenuEnabled("ItemTable", table);
-	scrActions["tableInsertRows"]->setEnabled(table || (tableEdited && selectedCells < 1));
-	scrActions["tableInsertColumns"]->setEnabled(table || (tableEdited && selectedCells < 1));
-	scrActions["tableDeleteRows"]->setEnabled(tableEdited &&
+	scrActions["tableInsertRows"]->setEnabled(table || (tableEdit && selectedCells < 1));
+	scrActions["tableInsertColumns"]->setEnabled(table || (tableEdit && selectedCells < 1));
+	scrActions["tableDeleteRows"]->setEnabled(tableEdit &&
 		((selectedRows < 1 && tableRows > 1) || (selectedRows > 0 && selectedRows < tableRows)));
-	scrActions["tableDeleteColumns"]->setEnabled(tableEdited &&
+	scrActions["tableDeleteColumns"]->setEnabled(tableEdit &&
 		((selectedColumns < 1 && tableColumns > 1) || (selectedColumns > 0 && selectedColumns < tableColumns)));
 	scrActions["tableMergeCells"]->setEnabled(selectedCells > 1);
 	scrActions["tableSplitCells"]->setEnabled(false); // Not implemented.
-	scrActions["tableSetRowHeights"]->setEnabled(tableEdited);
-	scrActions["tableSetColumnWidths"]->setEnabled(tableEdited);
+	scrActions["tableSetRowHeights"]->setEnabled(tableEdit);
+	scrActions["tableSetColumnWidths"]->setEnabled(tableEdit);
 	if (doc)
 	{
 		if (doc->appMode == modeEditTable)

Modified: trunk/Scribus/scribus/ui/contextmenu.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19307&path=/trunk/Scribus/scribus/ui/contextmenu.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/contextmenu.cpp (original)
+++ trunk/Scribus/scribus/ui/contextmenu.cpp Tue Jul  1 21:44:33 2014
@@ -496,7 +496,7 @@
 		menuEdit->addAction(m_ScMW->scrActions["editCut"]);
 	if (!(currItem->isSingleSel))
 		menuEdit->addAction(m_ScMW->scrActions["editCopy"]);
-	if ((m_doc->appMode == modeEdit) && (ScMimeData::clipboardHasScribusText()||ScMimeData::clipboardHasPlainText()) && (currItem->itemType() == PageItem::TextFrame))
+	if (((m_doc->appMode == modeEdit && currItem->itemType() == PageItem::TextFrame) || (m_doc->appMode == modeEditTable && currItem->itemType() == PageItem::Table)) && (ScMimeData::clipboardHasScribusText()||ScMimeData::clipboardHasPlainText()) )
 		menuEdit->addAction(m_ScMW->scrActions["editPaste"]);
 	if (!currItem->locked() && (m_doc->appMode != modeEdit) && (!(currItem->isSingleSel)))
 		menuEdit->addAction(m_ScMW->scrActions["itemDelete"]);




More information about the scribus-commit mailing list