Skip to content

Commit

Permalink
Introduction of ScriptRepositoryView
Browse files Browse the repository at this point in the history
The class responsible for the UserInterface of ScriptRepository

re #6177
  • Loading branch information
gesnerpassos committed Apr 17, 2013
1 parent 81a384f commit b811db1
Show file tree
Hide file tree
Showing 3 changed files with 386 additions and 160 deletions.
63 changes: 53 additions & 10 deletions Code/Mantid/MantidQt/API/inc/MantidQtAPI/ScriptRepositoryView.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@
#define MANTID_API_SCRIPTREPOSITORYVIEW_H_

#include <QDialog>
#include "MantidKernel/System.h"
#include <QStyledItemDelegate>
#include "ui_ScriptRepositoryView.h"
#include "DllOption.h"
namespace Mantid{
namespace Kernel{
class Logger;
}
}
namespace MantidQt
{
namespace API
{
class RepoModel;
/** ScriptRepositoryView : TODO: DESCRIPTION
class RepoModel;
/** ScriptRepositoryView : Provide the User Interface to the ScriptRepository. It does so
through the Mantid Model View Framework. It is composed by a specialized QTreeView
(RepoTreeView) and a TextBrowser. The TreeView is populated with the RepoModel, wich wrappers
the ScriptRepository. Inside this class, there are two nested classes that will implement
delegates to the columns of Status and AutoUpdate in order to improve the User Experience.
Copyright &copy; 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Expand All @@ -35,21 +44,55 @@ namespace API
class EXPORT_OPT_MANTIDQT_API ScriptRepositoryView : public QDialog
{
Q_OBJECT
public:

class RepoDelegate : public QStyledItemDelegate
{
public:
RepoDelegate(QObject *parent = 0);

void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
bool editorEvent(QEvent *event,
QAbstractItemModel *model,
const QStyleOptionViewItem &option,
const QModelIndex &index);
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index ) const ;
};

class CheckBoxDelegate : public QStyledItemDelegate
{
public:
CheckBoxDelegate(QObject * parent = 0);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
bool editorEvent(QEvent *event,
QAbstractItemModel *model,
const QStyleOptionViewItem &option,
const QModelIndex &index);
};

public:
// constuctor
ScriptRepositoryView(QWidget * parent=0);
virtual ~ScriptRepositoryView();
public slots:
void filterValues(QString);
// destructor - not virtual, because this is not intended to be base
~ScriptRepositoryView();

signals:
// allow Mantid Plot to open a python file to be seen
void loadScript(const QString);

protected slots:

protected slots:
// allow to interact with the cells, in order to update the description of the files
void cell_activated(const QModelIndex & );
void cell_clicked(const QModelIndex & );
void updateModel();
void currentChanged ( const QModelIndex & current );


private:
Ui::ScriptRepositoryView * ui;
RepoModel * model;
// A static reference to the Logger
static Mantid::Kernel::Logger & g_log;
};


Expand Down
18 changes: 16 additions & 2 deletions Code/Mantid/MantidQt/API/inc/MantidQtAPI/ScriptRepositoryView.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Script Repository</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,2,0,1">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,2,0,1,0">
<item>
<widget class="QLabel" name="label">
<property name="text">
Expand All @@ -22,7 +22,7 @@
</widget>
</item>
<item>
<widget class="QTreeView" name="repo_treeView"/>
<widget class="MantidQt::API::RepoTreeView" name="repo_treeView"/>
</item>
<item>
<widget class="QLabel" name="desc_label">
Expand All @@ -34,9 +34,23 @@
<item>
<widget class="QTextBrowser" name="desc_textBrowser"/>
</item>
<item>
<widget class="QPushButton" name="reloadPushButton">
<property name="text">
<string>Reload</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>MantidQt::API::RepoTreeView</class>
<extends>QTreeView</extends>
<header>MantidQtAPI/RepoTreeView.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

0 comments on commit b811db1

Please sign in to comment.