View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0016172 | Scribus | Internal | public | 2020-07-19 10:24 | 2020-07-20 13:05 |
Reporter | ale | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | N/A |
Status | new | Resolution | open | ||
Summary | 0016172: provide a an abstraction to check if a specific type of frame is selected | ||||
Description | currently, if i want to make sure that one text frame is selected i need to do: if (!HaveDoc) return; if (doc->m_Selection->count() != 1) return; if (doc->masterPageMode()) return; if (doc->appMode != modeEdit) return; PageItem* currItem = doc->m_Selection->itemAt(0); if (!currItem->isTextFrame()) return; it would be nice to have the high level function: item = doc->getSingleTextFrame() if (!item) return they will return nullptr if the conditions in the name of the function are not met. (it would be even better if it could return a "NoItem" object) another function would be item = doc->getSingleTextFrameFromPage() which would exclude items from master pages. for this to work, we should have a special doc that is a NoDoc (doc should never be a nullptr) the goal is to avoid functions like ScribusMainWindow::insertMark(MarkType mType) that hide what a dialog really does, because of the boilerplate. | ||||
Tags | No tags attached. | ||||
Patch | No | ||||
|
after PageItem* ScribusDoc::getItemFromName() : /** @brief return the currently selected item from the page or master page */ PageItem* getSinglePageItem() const; /** @brief return the currently selected item on the page */ PageItem* getSinglePageItemFromPage() const; /** @brief return the currently selected text frame on the page or master page*/ PageItem_TextFrame* getSingleTextFrame() const; /** @brief return the currently selected text frame on the page */ PageItem_TextFrame* getSingleTextFrameFromPage() const; PageItem* ScribusDoc::getSinglePageItem() const { if (m_Selection->count() != 1) return nullptr; return m_Selection->itemAt(0); } PageItem* ScribusDoc::getSinglePageItemFromPage() const { if (masterPageMode()) return nullptr; return getSinglePageItem(); } PageItem_TextFrame* ScribusDoc::getSingleTextFrame() const { auto currItem = getSinglePageItem(); if (!currItem) return nullptr; if (!currItem->isTextFrame()) return nullptr; return currItem->asTextFrame(); } PageItem_TextFrame* ScribusDoc::getSingleTextFrameFromPage() const { if (masterPageMode()) return nullptr; return getSingleTextFrame(); } |