From 3e8bac71c414a5b9f7c80bc9a6b0fb6a760519f6 Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 19 Jul 2018 17:37:04 +0200 Subject: Create file for MappingTreeView Single it out to a separate file to make editing easier. --- mappingtreeview.cpp | 38 ++++++++++++++++++++++++++++++++++++++ mappingtreeview.h | 32 ++++++++++++++++++++++++++++++++ mappingtreewidget.cpp | 25 +------------------------ mappingtreewidget.h | 15 --------------- newpicsdialog.cpp | 1 + shemov.pro | 6 ++++-- 6 files changed, 76 insertions(+), 41 deletions(-) create mode 100644 mappingtreeview.cpp create mode 100644 mappingtreeview.h diff --git a/mappingtreeview.cpp b/mappingtreeview.cpp new file mode 100644 index 0000000..b1aab32 --- /dev/null +++ b/mappingtreeview.cpp @@ -0,0 +1,38 @@ +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version + 2 of the License, or (at your option) any later version. +*/ + +#include +#include + +#include "mappingtreeview.h" + + +MappingTreeView::MappingTreeView(QWidget *parent) : SmTreeView(parent) {} + +void MappingTreeView::contextMenuEvent(QContextMenuEvent *e){ + QMenu ctxMenu(this); + ctxMenu.addActions(actions()); + ctxMenu.exec(e->globalPos()); +} + +void MappingTreeView::keyPressEvent(QKeyEvent *e){ + if(e->key() == Qt::Key_Right && (e->modifiers() & Qt::ControlModifier)){ + clearFocus(); + emit shiftFocus(); + return; + } + if(e->key() == Qt::Key_Return && (e->modifiers() & Qt::ControlModifier)){ + emit acceptPics(); + } + if(e->key() == Qt::Key_Right){ + emit addMapping(); + } + if(e->key() == Qt::Key_Delete){ + emit clearMappings(); + } + SmTreeView::keyPressEvent(e); +} diff --git a/mappingtreeview.h b/mappingtreeview.h new file mode 100644 index 0000000..22abaa6 --- /dev/null +++ b/mappingtreeview.h @@ -0,0 +1,32 @@ +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version + 2 of the License, or (at your option) any later version. +*/ + +#ifndef MAPPINGTREEVIEW_H +#define MAPPINGTREEVIEW_H + +#include + +#include + +class MappingTreeView : public SmTreeView { + Q_OBJECT + public: + MappingTreeView(QWidget *parent = 0); + + signals: + void addMapping(); + void removeMapping(); + void clearMappings(); + void shiftFocus(); + void acceptPics(); + + protected: + virtual void contextMenuEvent(QContextMenuEvent *e); + virtual void keyPressEvent(QKeyEvent *e); +}; + +#endif // MAPPINGTREEVIEW_H diff --git a/mappingtreewidget.cpp b/mappingtreewidget.cpp index 8477b0e..cbd24b1 100644 --- a/mappingtreewidget.cpp +++ b/mappingtreewidget.cpp @@ -25,6 +25,7 @@ #include "mappingtreewidget.h" #include "mappingtreemodel.h" +#include "mappingtreeview.h" #include "smglobals.h" MappingTreeWidget::MappingTreeWidget(QWidget *parent) : QWidget(parent){ @@ -326,31 +327,7 @@ const QModelIndex MappingTreeWidget::selected() const{ } -MappingTreeView::MappingTreeView(QWidget *parent) : SmTreeView(parent) {} -void MappingTreeView::contextMenuEvent(QContextMenuEvent *e){ - QMenu ctxMenu(this); - ctxMenu.addActions(actions()); - ctxMenu.exec(e->globalPos()); -} - -void MappingTreeView::keyPressEvent(QKeyEvent *e){ - if(e->key() == Qt::Key_Right && (e->modifiers() & Qt::ControlModifier)){ - clearFocus(); - emit shiftFocus(); - return; - } - if(e->key() == Qt::Key_Return && (e->modifiers() & Qt::ControlModifier)){ - emit acceptPics(); - } - if(e->key() == Qt::Key_Right){ - emit addMapping(); - } - if(e->key() == Qt::Key_Delete){ - emit clearMappings(); - } - SmTreeView::keyPressEvent(e); -} MappingTreeResultView::MappingTreeResultView(QWidget *parent) : SmTreeView(parent) { setAlternatingRowColors(true); diff --git a/mappingtreewidget.h b/mappingtreewidget.h index baf9fb1..d5c431f 100644 --- a/mappingtreewidget.h +++ b/mappingtreewidget.h @@ -75,22 +75,7 @@ class MappingTreeWidget : public QWidget { QAction *mEditChildA; }; -class MappingTreeView : public SmTreeView { - Q_OBJECT - public: - MappingTreeView(QWidget *parent = 0); - - signals: - void addMapping(); - void removeMapping(); - void clearMappings(); - void shiftFocus(); - void acceptPics(); - protected: - virtual void contextMenuEvent(QContextMenuEvent *e); - virtual void keyPressEvent(QKeyEvent *e); -}; class MappingTreeResultView : public SmTreeView { Q_OBJECT diff --git a/newpicsdialog.cpp b/newpicsdialog.cpp index 2d58a18..f5e5697 100644 --- a/newpicsdialog.cpp +++ b/newpicsdialog.cpp @@ -25,6 +25,7 @@ #include "helper.h" #include "mappingtreewidget.h" #include "mappingtreemodel.h" +#include "mappingtreeview.h" #include "delegates.h" #include "smglobals.h" diff --git a/shemov.pro b/shemov.pro index 075b300..95f4cc2 100644 --- a/shemov.pro +++ b/shemov.pro @@ -49,7 +49,8 @@ SOURCES = main.cpp \ moviepropertiesdialog.cpp \ sminputdialog.cpp \ editfiledialog.cpp \ - picturelistview.cpp + picturelistview.cpp \ + mappingtreeview.cpp HEADERS = \ shemov.h \ helper.h \ @@ -93,7 +94,8 @@ HEADERS = \ moviepropertiesdialog.h \ sminputdialog.h \ editfiledialog.h \ - picturelistview.h + picturelistview.h \ + mappingtreeview.h LIBS += -lmagic -lXfixes -lX11 -lMagick++-6.Q16HDRI INCLUDEPATH += /usr/include/ImageMagick-6/ RESOURCES = shemov.qrc -- cgit v1.2.3-70-g09d2