r23386 by craig - Add StoryText isSelected() and clean up Enablde-DisableTxEdit in ScribusMainWindow
scribus-commit
scribus-commit at lists.scribus.net
Thu Nov 28 22:23:44 UTC 2019
Author: craig
Date: Thu Nov 28 22:23:44 2019
New Revision: 23386
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23386
Log:
Add StoryText isSelected() and clean up Enablde-DisableTxEdit in ScribusMainWindow
Modified:
trunk/Scribus/scribus/canvasmode_edit.cpp
trunk/Scribus/scribus/hyphenator.cpp
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem_textframe.cpp
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribus.h
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/scribusview.cpp
trunk/Scribus/scribus/text/storytext.cpp
trunk/Scribus/scribus/text/storytext.h
trunk/Scribus/scribus/ui/search.cpp
Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp Thu Nov 28 22:23:44 2019
@@ -382,7 +382,7 @@
currItem->itemText.setCursorPosition(newPos);
}
}
- currItem->HasSel = (currItem->itemText.selectionLength() > 0);
+ currItem->HasSel = currItem->itemText.isSelected();
}
}
else
@@ -459,9 +459,9 @@
currItem->HasSel = true;
}
}
+ m_ScMW->setCopyCutEnabled(currItem->HasSel);
if (currItem->HasSel)
{
- m_ScMW->EnableTxEdit();
m_canvas->m_viewMode.operTextSelecting = true;
if ((refStartSel != currItem->asTextFrame()->itemText.startOfSelection()) ||
(refEndSel != currItem->asTextFrame()->itemText.endOfSelection()))
@@ -470,8 +470,6 @@
m_canvas->update(QRectF(m_canvas->canvasToLocal(br.topLeft()), br.size() * m_canvas->scale()).toRect());
}
}
- else
- m_ScMW->DisableTxEdit();
}
}
if (!m_canvas->m_viewMode.m_MouseButtonPressed)
@@ -642,7 +640,7 @@
//<<CB Add in shift select to text frames
if (m->modifiers() & Qt::ShiftModifier)
{
- if (currItem->itemText.selectionLength() > 0)
+ if (currItem->itemText.isSelected())
{
if (currItem->itemText.cursorPosition() < (currItem->itemText.startOfSelection() + currItem->itemText.endOfSelection()) / 2)
{
@@ -949,12 +947,7 @@
m_doc->nodeEdit.finishTransaction(currItem);
}
if (GetItem(&currItem) && currItem->asTextFrame())
- {
- if (currItem->itemText.selectionLength() > 0)
- m_ScMW->EnableTxEdit();
- else
- m_ScMW->DisableTxEdit();
- }
+ m_ScMW->setCopyCutEnabled(currItem->itemText.isSelected());
}
//CB-->Doc/Fix
Modified: trunk/Scribus/scribus/hyphenator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/hyphenator.cpp
==============================================================================
--- trunk/Scribus/scribus/hyphenator.cpp (original)
+++ trunk/Scribus/scribus/hyphenator.cpp Thu Nov 28 22:23:44 2019
@@ -137,7 +137,7 @@
QString text = "";
int startC = 0;
- if (it->itemText.selectionLength() > 0)
+ if (it->itemText.isSelected())
{
startC = it->itemText.startOfSelection();
text = it->itemText.text(startC, it->itemText.selectionLength());
@@ -340,7 +340,7 @@
if (!(it->asTextFrame()) || (it ->itemText.length() == 0))
return;
- if (it->itemText.selectionLength() > 0)
+ if (it->itemText.isSelected())
it->itemText.hyphenateWord(it->itemText.startOfSelection(), it->itemText.selectionLength(), nullptr);
else
{
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Thu Nov 28 22:23:44 2019
@@ -1543,7 +1543,7 @@
const ParagraphStyle& PageItem::currentStyle() const
{
int cursorPosition = itemText.cursorPosition();
- if (itemText.selectionLength() > 0)
+ if (itemText.isSelected())
{
int firstSelected = itemText.startOfSelection();
int lastSelected = qMax(itemText.endOfSelection() - 1, 0);
@@ -1559,7 +1559,7 @@
ParagraphStyle& PageItem::changeCurrentStyle()
{
int cursorPosition = itemText.cursorPosition();
- if (itemText.selectionLength() > 0)
+ if (itemText.isSelected())
{
int firstSelected = itemText.startOfSelection();
int lastSelected = qMax(itemText.endOfSelection() - 1, 0);
@@ -1575,7 +1575,7 @@
const CharStyle& PageItem::currentCharStyle() const
{
int cursorPosition = itemText.cursorPosition();
- if (itemText.selectionLength() > 0)
+ if (itemText.isSelected())
{
int firstSelected = itemText.startOfSelection();
int lastSelected = qMax(itemText.endOfSelection() - 1, 0);
@@ -1594,7 +1594,7 @@
parStyle = curStyle;
int position = itemText.cursorPosition();
- if (itemText.selectionLength() > 0)
+ if (itemText.isSelected())
position = qMin(qMax(itemText.endOfSelection() - 1, 0), qMax(position, itemText.startOfSelection()));
// Note: cursor position can be past last characters, don't use frameDisplays() here
Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Thu Nov 28 22:23:44 2019
@@ -3786,7 +3786,7 @@
{
ParagraphStyle defaultStyle = this->itemText.defaultStyle();
int pos = itemText.cursorPosition();
- if (itemText.selectionLength() == 0)
+ if (!itemText.isSelected())
{
itemText.select(maxCharsInFrame(), itemText.length() - maxCharsInFrame(), true);
deleteSelectedTextFromFrame();
@@ -3921,7 +3921,7 @@
UndoTransaction trans;
if (UndoManager::undoEnabled())
trans = undoManager->beginTransaction(Um::Selection,Um::ITextFrame,Um::InsertText,"",Um::IDelete);
- if (itemText.selectionLength() > 0)
+ if (itemText.isSelected())
deleteSelectedTextFromFrame();
if (conv < 31)
conv = 32;
@@ -4229,7 +4229,7 @@
case Qt::Key_Delete:
if (itemText.cursorPosition() == itemText.length())
{
- if (itemText.selectionLength() > 0)
+ if (itemText.isSelected())
{
deleteSelectedTextFromFrame();
m_Doc->scMW()->setTBvals(this);
@@ -4253,7 +4253,7 @@
keyRepeat = false;
return;
}
- if (itemText.selectionLength() == 0)
+ if (!itemText.isSelected())
{
int pos1 = itemText.cursorPosition();
itemText.moveCursorForward();
@@ -4287,7 +4287,7 @@
case Qt::Key_Backspace:
if (itemText.cursorPosition() == 0)
{
- if (itemText.selectionLength() > 0)
+ if (itemText.isSelected())
{
deleteSelectedTextFromFrame();
m_Doc->scMW()->setTBvals(this);
@@ -4306,7 +4306,7 @@
}
if (itemText.length() == 0)
break;
- if (itemText.selectionLength() == 0)
+ if (!itemText.isSelected())
{
itemText.setCursorPosition(-1, true);
itemText.select(itemText.cursorPosition(), 1, true);
@@ -4354,7 +4354,7 @@
break; //avoid inserting chars before first note mark
bool doUpdate = false;
UndoTransaction activeTransaction;
- if (itemText.selectionLength() > 0) //(kk < 0x1000)
+ if (itemText.isSelected()) //(kk < 0x1000)
{
bool x11Hack=false;
bool controlCharHack=false;
@@ -4519,7 +4519,7 @@
{
if (itemText.length() <= 0)
return;
- if (itemText.selectionLength() == 0)
+ if (!itemText.isSelected())
{
itemText.select(itemText.cursorPosition(), 1);
HasSel = true;
@@ -4704,7 +4704,7 @@
itemText.removeSelection();
HasSel = false;
// m_Doc->updateFrameItems();
- m_Doc->scMW()->DisableTxEdit();
+ m_Doc->scMW()->setCopyCutEnabled(false);
}
bool PageItem_TextFrame::checkKeyIsShortcut(QKeyEvent *k)
@@ -4866,17 +4866,8 @@
{
itemText.extendSelection(oldPos, itemText.cursorPosition());
}
- HasSel = (itemText.selectionLength() > 0);
- if (HasSel)
- {
- //CB Replace with direct call for now //emit HasTextSel();
- m_Doc->scMW()->EnableTxEdit();
- }
- else
- {
- //CB Replace with direct call for now //emit HasNoTextSel();
- m_Doc->scMW()->DisableTxEdit();
- }
+ HasSel = itemText.isSelected();
+ m_Doc->scMW()->setCopyCutEnabled(HasSel);
cursorBiasBackward = (oldPos > itemText.cursorPosition());
// layoutWeakLock = true;
@@ -4886,7 +4877,7 @@
void PageItem_TextFrame::deselectAll()
{
- if ( itemText.selectionLength() > 0 )
+ if (itemText.isSelected())
{
itemText.deselectAll();
PageItem *item = this;
@@ -4902,7 +4893,7 @@
m_Doc->regionsChanged()->update(getBoundingRect());
}
//CB Replace with direct call for now //emit HasNoTextSel();
- m_Doc->scMW()->DisableTxEdit();
+ m_Doc->scMW()->setCopyCutEnabled(false);
}
double PageItem_TextFrame::columnWidth()
@@ -5542,7 +5533,7 @@
int stop = 0;
if (onlySelection)
{
- if (itemText.selectionLength() > 0)
+ if (itemText.isSelected())
{
//only selection
start = itemText.startOfSelection();
@@ -5594,7 +5585,7 @@
int stop = itemText.length();
if (onlySelection)
{
- if (itemText.selectionLength() > 0)
+ if (itemText.isSelected())
{
start = itemText.startOfSelection();
stop = start + itemText.selectionLength();
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Thu Nov 28 22:23:44 2019
@@ -5102,7 +5102,7 @@
nextItem->HasSel = true;
nextItem = nextItem->nextInChain();
}
- EnableTxEdit();
+ setCopyCutEnabled(true);
}
else
{
@@ -5174,16 +5174,11 @@
scrActions["editPaste"]->setEnabled(HaveDoc && (hasScribusData || textFrameEditMode || tableEditMode || hasExternalData));
}
-void ScribusMainWindow::EnableTxEdit()
-{
- scrActions["editCut"]->setEnabled(true);
- scrActions["editCopy"]->setEnabled(true);
-}
-
-void ScribusMainWindow::DisableTxEdit()
-{
- scrActions["editCut"]->setEnabled(false);
- scrActions["editCopy"]->setEnabled(false);
+
+void ScribusMainWindow::setCopyCutEnabled(bool b)
+{
+ scrActions["editCut"]->setEnabled(b);
+ scrActions["editCopy"]->setEnabled(b);
}
void ScribusMainWindow::slotHelpAbout()
Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Thu Nov 28 22:23:44 2019
@@ -380,12 +380,11 @@
void slotEditPaste();
void slotEditCopyContents();
void slotEditPasteContents(int absolute=0);
- void EnableTxEdit();
- void DisableTxEdit();
void SelectAll(bool docWideSelect=false);
void SelectAllOnLayer();
void deselectAll();
void ClipChange();
+ void setCopyCutEnabled(bool b);
/** \brief shows an about dialog*/
void slotHelpAbout();
void slotHelpAboutPlugins();
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Thu Nov 28 22:23:44 2019
@@ -9304,7 +9304,7 @@
int length = currItem->lastInFrame() - start + 1;
if ((appMode == modeEdit) || (appMode == modeEditTable))
{
- if (currItem->itemText.selectionLength() > 0)
+ if (currItem->itemText.isSelected())
{
start = currItem->itemText.startOfSelection();
length = currItem->itemText.endOfSelection() - start;
@@ -9435,7 +9435,7 @@
int length = currItem->lastInFrame() - start + 1;
if ((appMode == modeEdit) || (appMode == modeEditTable))
{
- if (currItem->itemText.selectionLength() > 0)
+ if (currItem->itemText.isSelected())
{
start = currItem->itemText.startOfSelection();
length = currItem->itemText.endOfSelection() - start;
@@ -9515,7 +9515,7 @@
int length = currItem->lastInFrame() - start + 1;
if ((appMode == modeEdit) || (appMode == modeEditTable))
{
- if (currItem->itemText.selectionLength() > 0)
+ if (currItem->itemText.isSelected())
{
start = currItem->itemText.startOfSelection();
length = currItem->itemText.endOfSelection() - start;
@@ -14539,12 +14539,12 @@
currItem->Sizing = false;
if ((!(currItem->isGroup() || currItem->isSymbol())) || includeGroup)
{
- double oldX = currItem->xPos();
- double oldY = currItem->yPos();
- double oldW = currItem->width();
- double oldH = currItem->height();
- double oldgW = currItem->groupWidth;
- double oldgH = currItem->groupHeight;
+// double oldX = currItem->xPos();
+// double oldY = currItem->yPos();
+// double oldW = currItem->width();
+// double oldH = currItem->height();
+// double oldgW = currItem->groupWidth;
+// double oldgH = currItem->groupHeight;
FPointArray clip = currItem->PoLine;
QRectF clipRect = clip.toQPainterPath(false).boundingRect();
FPoint tp2(clipRect.left(), clipRect.top());
Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Thu Nov 28 22:23:44 2019
@@ -1708,7 +1708,7 @@
if (textFrame->itemText.length() > 0)
{
int pos = qMax(0, qMin(textFrame->itemText.cursorPosition(), textFrame->itemText.length()));
- if (textFrame->itemText.selectionLength() > 0)
+ if (textFrame->itemText.isSelected())
{
int firstSelected = textFrame->itemText.startOfSelection();
int lastSelected = qMax(textFrame->itemText.endOfSelection() - 1, 0);
Modified: trunk/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/text/storytext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/storytext.cpp (original)
+++ trunk/Scribus/scribus/text/storytext.cpp Thu Nov 28 22:23:44 2019
@@ -1757,6 +1757,11 @@
if (m_selLast >= length())
last = length() -1;
return m_selFirst <= last? last - m_selFirst + 1 : 0;
+}
+
+bool StoryText::isSelected() const
+{
+ return selectionLength() > 0;
}
Modified: trunk/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/text/storytext.h
==============================================================================
--- trunk/Scribus/scribus/text/storytext.h (original)
+++ trunk/Scribus/scribus/text/storytext.h Thu Nov 28 22:23:44 2019
@@ -246,6 +246,7 @@
int startOfSelection() const;
int endOfSelection() const;
int selectionLength() const;
+ bool isSelected() const;
// break iterators
static BreakIterator* getGraphemeIterator();
Modified: trunk/Scribus/scribus/ui/search.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23386&path=/trunk/Scribus/scribus/ui/search.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/search.cpp (original)
+++ trunk/Scribus/scribus/ui/search.cpp Thu Nov 28 22:23:44 2019
@@ -757,7 +757,7 @@
m_doc->itemSelection_SetFont(RFontVal->currentText());
if (RSize->isChecked())
m_doc->itemSelection_SetFontSize(qRound(RSizeVal->value() * 10.0));
- if (REffect->isChecked() && (m_item->itemText.selectionLength() > 0))
+ if (REffect->isChecked() && (m_item->itemText.isSelected()))
{
int s = REffVal->getStyle() & ScStyle_UserStyles;
m_doc->currentStyle.charStyle().setFeatures(static_cast<StyleFlag>(s).featureList()); // ???
@@ -1055,7 +1055,7 @@
}
replaceEnabled |= RText->isChecked();
if (m_itemMode)
- replaceEnabled &= (m_item->itemText.selectionLength() > 0);
+ replaceEnabled &= (m_item->itemText.isSelected());
else if (m_doc->scMW()->CurrStED != nullptr)
replaceEnabled &= m_doc->scMW()->CurrStED->Editor->textCursor().hasSelection();
else
More information about the scribus-commit
mailing list