Mantid
Loading...
Searching...
No Matches
Public Member Functions | List of all members
MantidQt::API::ScriptRepositoryView::RepoDelegate Class Reference

Delegate to show the icons Download and Upload. More...

Inheritance diagram for MantidQt::API::ScriptRepositoryView::RepoDelegate:

Public Member Functions

bool editorEvent (QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
 Reacts to the iteraction with the user when he clicks on the buttons displayed at paint. More...
 
QIcon getIcon (const QString &state) const
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Draws the column 1 (Status) of ScriptRepositoryView. More...
 
 RepoDelegate (QObject *parent=nullptr)
 
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Provides the ideal size for this column. More...
 

Detailed Description

Delegate to show the icons Download and Upload.

Definition at line 29 of file ScriptRepositoryView.h.

Constructor & Destructor Documentation

◆ RepoDelegate()

MantidQt::API::ScriptRepositoryView::RepoDelegate::RepoDelegate ( QObject *  parent = nullptr)

Definition at line 278 of file ScriptRepositoryView.cpp.

Member Function Documentation

◆ editorEvent()

bool MantidQt::API::ScriptRepositoryView::RepoDelegate::editorEvent ( QEvent *  event,
QAbstractItemModel *  model,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
)
override

Reacts to the iteraction with the user when he clicks on the buttons displayed at paint.

Given the state of an entry (folder/file) there is only on available action. So, it is enough to get the event that the user interact with the pushbutton to decide what to do.

It will filter the event in order to get the Left-Click of mouse. If it gets the click of the mouse, it will trigger the action:

  • Upload: if the file/folder is local_only or local_changed
  • No Action when the entry is in Updated state.
  • Download: for the other cases
Parameters
eventThe event given by the framework
modelPointer to the model needed to retrive the status of the entry
indexidentifies the entry (file/folder)
optionProvided by the framewor, and passed on to the base class.
Returns
true if it handles or false to ignore.

Definition at line 373 of file ScriptRepositoryView.cpp.

References MantidQt::API::RepoModel::data(), index, MantidQt::API::RepoModel::localChangedSt(), MantidQt::API::RepoModel::localOnlySt(), MantidQt::API::ScriptRepositoryView::model, MantidQt::API::RepoModel::setData(), MantidQt::API::RepoModel::updatedSt(), and value.

◆ getIcon()

QIcon MantidQt::API::ScriptRepositoryView::RepoDelegate::getIcon ( const QString &  state) const

◆ paint()

void MantidQt::API::ScriptRepositoryView::RepoDelegate::paint ( QPainter *  painter,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
override

Draws the column 1 (Status) of ScriptRepositoryView.

This function is called every time the ScriptRepository needs to draw the widget for the Status of the file/folder inside the ScriptRepository. Instead of displaying the status (REMOTE_ONLY, LOCAL_ONLY, and so on), it will draw an Icon that 'hoppefully' will better indicate to the user the condition of the entry as well as encourage him to act. The action will be dealt with through the editorEvent.

When this method is called, it will get the index in order to retrieve the information about the status of the entry (folder/file).

It will them decide which icon better describes the current status of the entry, and will draw it using the option and the painter given.

Parameters
painterRequired to draw the widget
optionProvided by the framework and has information displaying the widget.
indexIdentifies the entry inside the RepoModel (indirectly the file/folder).

Definition at line 303 of file ScriptRepositoryView.cpp.

References index.

◆ sizeHint()

QSize MantidQt::API::ScriptRepositoryView::RepoDelegate::sizeHint ( const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
override

Provides the ideal size for this column.

Returns
ideal size for this column

Definition at line 393 of file ScriptRepositoryView.cpp.


The documentation for this class was generated from the following files: