mirror of https://github.com/JakubMelka/PDF4QT.git
DocPage Organizer: Clear action
This commit is contained in:
parent
8442143efc
commit
fd67f8f898
|
@ -35,7 +35,8 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
m_model(new PageItemModel(this)),
|
m_model(new PageItemModel(this)),
|
||||||
m_delegate(new PageItemDelegate(m_model, this))
|
m_delegate(new PageItemDelegate(m_model, this)),
|
||||||
|
m_dropAction(Qt::IgnoreAction)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||||
ui->documentItemsView->setItemDelegate(m_delegate);
|
ui->documentItemsView->setItemDelegate(m_delegate);
|
||||||
setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(800, 600)));
|
setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(800, 600)));
|
||||||
|
|
||||||
|
ui->actionClear->setData(int(Operation::Clear));
|
||||||
ui->actionCloneSelection->setData(int(Operation::CloneSelection));
|
ui->actionCloneSelection->setData(int(Operation::CloneSelection));
|
||||||
ui->actionRemoveSelection->setData(int(Operation::RemoveSelection));
|
ui->actionRemoveSelection->setData(int(Operation::RemoveSelection));
|
||||||
ui->actionReplaceSelection->setData(int(Operation::ReplaceSelection));
|
ui->actionReplaceSelection->setData(int(Operation::ReplaceSelection));
|
||||||
|
@ -258,6 +260,9 @@ bool MainWindow::canPerformOperation(Operation operation) const
|
||||||
|
|
||||||
switch (operation)
|
switch (operation)
|
||||||
{
|
{
|
||||||
|
case Operation::Clear:
|
||||||
|
return true;
|
||||||
|
|
||||||
case Operation::CloneSelection:
|
case Operation::CloneSelection:
|
||||||
case Operation::RemoveSelection:
|
case Operation::RemoveSelection:
|
||||||
case Operation::ReplaceSelection:
|
case Operation::ReplaceSelection:
|
||||||
|
@ -318,18 +323,59 @@ void MainWindow::performOperation(Operation operation)
|
||||||
{
|
{
|
||||||
switch (operation)
|
switch (operation)
|
||||||
{
|
{
|
||||||
|
case Operation::Clear:
|
||||||
|
{
|
||||||
|
m_model->clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Operation::CloneSelection:
|
case Operation::CloneSelection:
|
||||||
case Operation::RemoveSelection:
|
case Operation::RemoveSelection:
|
||||||
case Operation::ReplaceSelection:
|
case Operation::ReplaceSelection:
|
||||||
case Operation::RestoreRemovedItems:
|
case Operation::RestoreRemovedItems:
|
||||||
case Operation::Cut:
|
|
||||||
case Operation::Copy:
|
|
||||||
case Operation::Paste:
|
|
||||||
case Operation::RotateLeft:
|
case Operation::RotateLeft:
|
||||||
case Operation::RotateRight:
|
case Operation::RotateRight:
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Operation::Cut:
|
||||||
|
case Operation::Copy:
|
||||||
|
{
|
||||||
|
QModelIndexList indices = ui->documentItemsView->selectionModel()->selection().indexes();
|
||||||
|
|
||||||
|
if (indices.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QMimeData* mimeData = m_model->mimeData(indices))
|
||||||
|
{
|
||||||
|
QApplication::clipboard()->setMimeData(mimeData);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->documentItemsView->clearSelection();
|
||||||
|
m_dropAction = (operation == Operation::Cut) ? Qt::MoveAction : Qt::CopyAction;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Operation::Paste:
|
||||||
|
{
|
||||||
|
QModelIndexList indices = ui->documentItemsView->selectionModel()->selection().indexes();
|
||||||
|
|
||||||
|
int insertRow = m_model->rowCount(QModelIndex()) - 1;
|
||||||
|
if (!indices.isEmpty())
|
||||||
|
{
|
||||||
|
insertRow = indices.back().row();
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex insertIndex = m_model->index(insertRow, 0, QModelIndex());
|
||||||
|
const QMimeData* mimeData = QApplication::clipboard()->mimeData();
|
||||||
|
if (m_model->canDropMimeData(mimeData, m_dropAction, -1, -1, insertIndex))
|
||||||
|
{
|
||||||
|
m_model->dropMimeData(mimeData, m_dropAction, -1, -1, insertIndex);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case Operation::Group:
|
case Operation::Group:
|
||||||
m_model->group(ui->documentItemsView->selectionModel()->selection().indexes());
|
m_model->group(ui->documentItemsView->selectionModel()->selection().indexes());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
|
|
||||||
enum class Operation
|
enum class Operation
|
||||||
{
|
{
|
||||||
|
Clear,
|
||||||
CloneSelection,
|
CloneSelection,
|
||||||
RemoveSelection,
|
RemoveSelection,
|
||||||
ReplaceSelection,
|
ReplaceSelection,
|
||||||
|
@ -102,6 +103,7 @@ private:
|
||||||
PageItemDelegate* m_delegate;
|
PageItemDelegate* m_delegate;
|
||||||
Settings m_settings;
|
Settings m_settings;
|
||||||
QSignalMapper m_mapper;
|
QSignalMapper m_mapper;
|
||||||
|
Qt::DropAction m_dropAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pdfdocpage
|
} // namespace pdfdocpage
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
<string>File</string>
|
<string>File</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionAddDocument"/>
|
<addaction name="actionAddDocument"/>
|
||||||
|
<addaction name="actionClear"/>
|
||||||
<addaction name="actionClose"/>
|
<addaction name="actionClose"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuEdit">
|
<widget class="QMenu" name="menuEdit">
|
||||||
|
@ -143,7 +144,7 @@
|
||||||
<string>Close</string>
|
<string>Close</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+W</string>
|
<string>Alt+F4</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionCloneSelection">
|
<action name="actionCloneSelection">
|
||||||
|
@ -467,6 +468,18 @@
|
||||||
<string>Ctrl+Shift+G</string>
|
<string>Ctrl+Shift+G</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionClear">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources.qrc">
|
||||||
|
<normaloff>:/pdfdocpage/resources/clear.svg</normaloff>:/pdfdocpage/resources/clear.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+W</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="resources.qrc"/>
|
<include location="resources.qrc"/>
|
||||||
|
|
|
@ -548,4 +548,13 @@ Qt::ItemFlags PageItemModel::flags(const QModelIndex& index) const
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PageItemModel::clear()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
m_pageGroupItems.clear();
|
||||||
|
m_documents.clear();
|
||||||
|
m_trashBin.clear();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace pdfdocpage
|
} // namespace pdfdocpage
|
||||||
|
|
|
@ -80,6 +80,9 @@ public:
|
||||||
virtual Qt::DropActions supportedDragActions() const override;
|
virtual Qt::DropActions supportedDragActions() const override;
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
|
virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||||
|
|
||||||
|
/// Clear all data and undo/redo
|
||||||
|
void clear();
|
||||||
|
|
||||||
/// Adds document to the model, inserts one single page group containing
|
/// Adds document to the model, inserts one single page group containing
|
||||||
/// the whole document. Returns index of a newly added document. If document
|
/// the whole document. Returns index of a newly added document. If document
|
||||||
/// cannot be added (for example, it already exists), -1 is returned.
|
/// cannot be added (for example, it already exists), -1 is returned.
|
||||||
|
|
|
@ -29,5 +29,6 @@
|
||||||
<file>resources/ungroup.svg</file>
|
<file>resources/ungroup.svg</file>
|
||||||
<file>resources/zoom-in.svg</file>
|
<file>resources/zoom-in.svg</file>
|
||||||
<file>resources/zoom-out.svg</file>
|
<file>resources/zoom-out.svg</file>
|
||||||
|
<file>resources/clear.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="30mm"
|
||||||
|
height="30mm"
|
||||||
|
viewBox="0 0 30 30"
|
||||||
|
version="1.1"
|
||||||
|
id="svg5291"
|
||||||
|
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
||||||
|
sodipodi:docname="cut.svg">
|
||||||
|
<defs
|
||||||
|
id="defs5285">
|
||||||
|
<inkscape:perspective
|
||||||
|
sodipodi:type="inkscape:persp3d"
|
||||||
|
inkscape:vp_x="0 : 15 : 1"
|
||||||
|
inkscape:vp_y="0 : 1000 : 0"
|
||||||
|
inkscape:vp_z="30 : 15 : 1"
|
||||||
|
inkscape:persp3d-origin="15 : 10 : 1"
|
||||||
|
id="perspective5921" />
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="5.656854"
|
||||||
|
inkscape:cx="148.43961"
|
||||||
|
inkscape:cy="135.18316"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:window-width="3840"
|
||||||
|
inkscape:window-height="2035"
|
||||||
|
inkscape:window-x="-13"
|
||||||
|
inkscape:window-y="-13"
|
||||||
|
inkscape:window-maximized="1" />
|
||||||
|
<metadata
|
||||||
|
id="metadata5288">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
<dc:creator>
|
||||||
|
<cc:Agent>
|
||||||
|
<dc:title>Jakub Melka</dc:title>
|
||||||
|
</cc:Agent>
|
||||||
|
</dc:creator>
|
||||||
|
<cc:license
|
||||||
|
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
|
||||||
|
</cc:Work>
|
||||||
|
<cc:License
|
||||||
|
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Notice" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
|
||||||
|
</cc:License>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Vrstva 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(0,-267)">
|
||||||
|
<flowRoot
|
||||||
|
xml:space="preserve"
|
||||||
|
id="flowRoot5913"
|
||||||
|
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"><flowRegion
|
||||||
|
id="flowRegion5915"><rect
|
||||||
|
id="rect5917"
|
||||||
|
width="129.22377"
|
||||||
|
height="91.747108"
|
||||||
|
x="-13.788582"
|
||||||
|
y="-33.515606" /></flowRegion><flowPara
|
||||||
|
id="flowPara5919" /></flowRoot> <g
|
||||||
|
aria-label="?"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:25.39999962px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||||
|
id="text849"
|
||||||
|
transform="translate(-4.7625002,-4.2333335)">
|
||||||
|
<path
|
||||||
|
d="m 25.373474,281.70442 q 0,1.21543 -0.434082,2.17041 -0.434082,0.94258 -1.141016,1.67432 -0.694531,0.70693 -1.599902,1.32705 -0.905371,0.62011 -1.922363,1.20302 v 2.79053 h -2.22002 v -3.78271 q 0.806153,-0.45889 1.736328,-1.00459 0.942578,-0.54571 1.537891,-1.10381 0.719336,-0.64492 1.116211,-1.32705 0.396875,-0.69453 0.396875,-1.76114 0,-1.40146 -0.954981,-2.08359 -0.942578,-0.69453 -2.443261,-0.69453 -1.339453,0 -2.542481,0.42168 -1.190625,0.42168 -1.885156,0.85576 h -0.124023 v -2.53008 q 0.868164,-0.33486 2.195214,-0.59531 1.339454,-0.27285 2.530079,-0.27285 2.666503,0 4.204394,1.30224 1.550293,1.28985 1.550293,3.41065 z m -4.898926,14.12627 H 17.94447 v -2.6169 h 2.530078 z"
|
||||||
|
style="stroke-width:0.26458332"
|
||||||
|
id="path851"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.4 KiB |
|
@ -51,6 +51,7 @@ QRect PDFPainterHelper::drawBubble(QPainter* painter, QPoint point, QColor color
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFPainterStateGuard guard(painter);
|
PDFPainterStateGuard guard(painter);
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->setBrush(QBrush(color));
|
painter->setBrush(QBrush(color));
|
||||||
painter->drawRoundedRect(rectangle, rectangle.height() / 2, rectangle.height() / 2, Qt::AbsoluteSize);
|
painter->drawRoundedRect(rectangle, rectangle.height() / 2, rectangle.height() / 2, Qt::AbsoluteSize);
|
||||||
|
|
Loading…
Reference in New Issue