9#include "AbstractProjectItemView.h"
13#include <QDragEnterEvent>
14#include <QDragMoveEvent>
21#include <QGuiApplication>
24#include "ProjectItem.h"
25#include "ProjectItemModel.h"
26#include "ProjectItemProxyModel.h"
38 setWindowFlags(Qt::Widget);
40 QSizePolicy policy = sizePolicy();
41 policy.setHorizontalPolicy(QSizePolicy::Expanding);
42 policy.setVerticalPolicy(QSizePolicy::Expanding);
43 setSizePolicy(policy);
59 QRect availableSpace = (QGuiApplication::primaryScreen()->availableGeometry());
60 return QSize( .89 * availableSpace.width(), .5 * availableSpace.height() );
73 proxyModel->setSourceModel(
model);
87 return proxyModel->sourceModel();
123 0, 0, QModelIndex() ) ) {
124 event->acceptProposedAction();
138 0, 0, QModelIndex() ) ) {
139 event->acceptProposedAction();
152 0, 0, QModelIndex() ) ) {
153 internalModel()->dropMimeData( event->mimeData(), event->dropAction(),
154 0, 0, QModelIndex() );
155 event->acceptProposedAction();
160 void AbstractProjectItemView::moveEvent(QMoveEvent *event) {
161 QMainWindow::moveEvent(event);
163 emit windowChangeEvent(
false);
167 void AbstractProjectItemView::resizeEvent(QResizeEvent *event) {
168 QMainWindow::resizeEvent(event);
170 emit windowChangeEvent(
false);
198 foreach (
QAction *action, actions()) {
199 action->setDisabled(
true);
208 foreach (
QAction *action, actions()) {
209 action->setEnabled(
true);
220 return QList<QAction *>();
230 return model()->currentItem();
240 return model()->selectedItems();
253 proxyModel->addItem(item);
267 proxyModel->addItems(items);
282 proxyModel->removeItem(item);
virtual QList< QAction * > contextMenuActions()
Returns a list of actions appropriate for a context menu.
virtual void dropEvent(QDropEvent *event)
Drops the data into the internal model if it can accept the data.
virtual void enableActions()
Enables toolbars and toolpad actions.
virtual void dragEnterEvent(QDragEnterEvent *event)
Accepts the drag enter event if the internal model can accept the mime data.
virtual void dragMoveEvent(QDragMoveEvent *event)
Accepts the drag event if the internal model can accept the mime data.
virtual void disableActions()
Disables toolbars and toolpad actions.
virtual void enterEvent(QEvent *event)
Enables actions when cursor enters the view.
virtual QList< ProjectItem * > selectedItems()
Return the selected items of the model.
virtual void addItem(ProjectItem *item)
Adds an item to the view.
ProjectItemModel * m_internalModel
The internal model used by the view.
virtual QSize sizeHint() const
Returns the suggested size.
virtual void removeItems(QList< ProjectItem * > items)
Removes several items from the view.
virtual ProjectItemModel * model()
Returns the model used by the view.
virtual void setInternalModel(ProjectItemModel *model)
Sets the internal model of the view.
virtual void addItems(QList< ProjectItem * > items)
Adds several items to the view.
virtual void removeItem(ProjectItem *item)
Removes an item to the view.
AbstractProjectItemView(QWidget *parent=0)
Constructs the AbstractProjectItemView.
virtual void setModel(ProjectItemModel *model)
Sets the model used by the view.
virtual ProjectItem * currentItem()
Returns the current item of the model.
virtual ProjectItemModel * internalModel()
Returns the internal model of the view.
virtual void leaveEvent(QEvent *event)
Disables actions when cursor leaves the view.
Represents an item of a ProjectItemModel in Qt's model-view framework.
Provides access to data stored in a Project through Qt's model-view framework.
Allows access to items in a ProjectItemModel through a proxy model.
This is free and unencumbered software released into the public domain.