DragDropHelper.h
75 lines
| 2.6 KiB
| text/x-c
|
CLexer
r844 | #ifndef SCIQLOP_DRAGDROPHELPER_H | |||
#define SCIQLOP_DRAGDROPHELPER_H | ||||
r837 | ||||
#include <Common/spimpl.h> | ||||
r850 | #include <QLoggingCategory> | |||
r837 | #include <QWidget> | |||
class QVBoxLayout; | ||||
class QScrollArea; | ||||
r886 | class QTabBar; | |||
r837 | class VisualizationDragWidget; | |||
r850 | class VisualizationDragDropContainer; | |||
r837 | class QMimeData; | |||
r850 | Q_DECLARE_LOGGING_CATEGORY(LOG_DragDropHelper) | |||
r840 | ||||
r837 | /** | |||
* @brief Helper class for drag&drop operations. | ||||
r850 | * @note The helper is accessible from the sqpApp singleton and has the same life as the whole | |||
* application (like a controller). But contrary to a controller, it doesn't live in a thread and | ||||
* can interect with the gui. | ||||
* @see SqpApplication | ||||
r837 | */ | |||
r844 | class DragDropHelper { | |||
r837 | public: | |||
static const QString MIME_TYPE_GRAPH; | ||||
static const QString MIME_TYPE_ZONE; | ||||
r881 | enum class PlaceHolderType { Default, Graph, Zone }; | |||
r844 | DragDropHelper(); | |||
virtual ~DragDropHelper(); | ||||
r850 | /// Resets some internal variables. Must be called before any new drag&drop operation. | |||
void resetDragAndDrop(); | ||||
/// Sets the visualization widget currently being drag on the visualization. | ||||
r844 | void setCurrentDragWidget(VisualizationDragWidget *dragWidget); | |||
r850 | ||||
/// Returns the visualization widget currently being drag on the visualization. | ||||
/// Can be null if a new visualization widget is intended to be created by the drag&drop | ||||
/// operation. | ||||
r844 | VisualizationDragWidget *getCurrentDragWidget() const; | |||
r837 | ||||
QWidget &placeHolder() const; | ||||
r881 | void insertPlaceHolder(QVBoxLayout *layout, int index, PlaceHolderType type, | |||
const QString &topLabelText); | ||||
r837 | void removePlaceHolder(); | |||
bool isPlaceHolderSet() const; | ||||
r850 | /// Checks if the specified mime data is valid for a drop in the visualization | |||
bool checkMimeDataForVisualization(const QMimeData *mimeData, | ||||
VisualizationDragDropContainer *dropContainer); | ||||
r844 | void addDragDropScrollArea(QScrollArea *scrollArea); | |||
void removeDragDropScrollArea(QScrollArea *scrollArea); | ||||
r837 | ||||
r886 | void addDragDropTabBar(QTabBar *tabBar); | |||
void removeDragDropTabBar(QTabBar *tabBar); | ||||
r844 | QUrl imageTemporaryUrl(const QImage &image) const; | |||
r837 | ||||
r873 | void setHightlightedDragWidget(VisualizationDragWidget *dragWidget); | |||
r875 | VisualizationDragWidget *getHightlightedDragWidget() const; | |||
r873 | ||||
Thibaud Rabillard
|
r911 | /// Delays the closing of a widget during a drag&drop operation | ||
void delayedCloseWidget(QWidget *widget); | ||||
void doCloseWidgets(); | ||||
r837 | private: | |||
class DragDropHelperPrivate; | ||||
spimpl::unique_impl_ptr<DragDropHelperPrivate> impl; | ||||
}; | ||||
r844 | #endif // SCIQLOP_DRAGDROPHELPER_H | |||