|
Isis 3 Programmer Reference
|
9 #include "AbstractProjectItemView.h"
13 #include <QDesktopWidget>
14 #include <QDragEnterEvent>
15 #include <QDragMoveEvent>
18 #include <QMainWindow>
20 #include <QSizePolicy>
23 #include "ProjectItem.h"
24 #include "ProjectItemModel.h"
25 #include "ProjectItemProxyModel.h"
36 setWindowFlags(Qt::Widget);
38 QSizePolicy policy = sizePolicy();
39 policy.setHorizontalPolicy(QSizePolicy::Expanding);
40 policy.setVerticalPolicy(QSizePolicy::Expanding);
41 setSizePolicy(policy);
57 QDesktopWidget deskTop;
58 QRect availableSpace = deskTop.availableGeometry(deskTop.primaryScreen());
59 return QSize( .89 * availableSpace.width(), .5 * availableSpace.height() );
72 proxyModel->setSourceModel(
model);
86 return proxyModel->sourceModel();
122 0, 0, QModelIndex() ) ) {
123 event->acceptProposedAction();
137 0, 0, QModelIndex() ) ) {
138 event->acceptProposedAction();
151 0, 0, QModelIndex() ) ) {
152 internalModel()->dropMimeData( event->mimeData(), event->dropAction(),
153 0, 0, QModelIndex() );
154 event->acceptProposedAction();
159 void AbstractProjectItemView::moveEvent(QMoveEvent *event) {
160 QMainWindow::moveEvent(event);
162 emit windowChangeEvent(
false);
166 void AbstractProjectItemView::resizeEvent(QResizeEvent *event) {
167 QMainWindow::resizeEvent(event);
169 emit windowChangeEvent(
false);
197 foreach (
QAction *action, actions()) {
198 action->setDisabled(
true);
207 foreach (
QAction *action, actions()) {
208 action->setEnabled(
true);
252 proxyModel->addItem(item);
266 proxyModel->addItems(items);
281 proxyModel->removeItem(item);
AbstractProjectItemView(QWidget *parent=0)
Constructs the AbstractProjectItemView.
Provides access to data stored in a Project through Qt's model-view framework.
virtual ProjectItemModel * model()
Returns the model used by the view.
virtual void leaveEvent(QEvent *event)
Disables actions when cursor leaves the view.
virtual void dropEvent(QDropEvent *event)
Drops the data into the internal model if it can accept the data.
virtual void setModel(ProjectItemModel *model)
Sets the model used by the view.
virtual QList< ProjectItem * > selectedItems()
Return the selected items of the model.
Allows access to items in a ProjectItemModel through a proxy model.
virtual void addItems(QList< ProjectItem * > items)
Adds several items to the view.
virtual void removeItem(ProjectItem *item)
Removes an item to the view.
virtual ProjectItem * currentItem()
Returns the current item of the model.
ProjectItemModel * m_internalModel
The internal model used by the view.
virtual void enableActions()
Enables toolbars and toolpad actions.
virtual void enterEvent(QEvent *event)
Enables actions when cursor enters the view.
virtual void addItem(ProjectItem *item)
Adds an item to the view.
virtual void dragEnterEvent(QDragEnterEvent *event)
Accepts the drag enter event if the internal model can accept the mime data.
virtual void setInternalModel(ProjectItemModel *model)
Sets the internal model of the view.
QList< ProjectItem * > selectedItems()
Returns a list of the selected items of the internal selection model.
virtual ProjectItemModel * internalModel()
Returns the internal model of the view.
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 removeItems(QList< ProjectItem * > items)
Removes several items from the view.
virtual QSize sizeHint() const
Returns the suggested size.
ProjectItem * currentItem()
Returns the current item of the internal selection model.
virtual QList< QAction * > contextMenuActions()
Returns a list of actions appropriate for a context menu.
This is free and unencumbered software released into the public domain.
Represents an item of a ProjectItemModel in Qt's model-view framework.