Skip to content

Commit

Permalink
Add support for author
Browse files Browse the repository at this point in the history
  • Loading branch information
gesnerpassos committed Apr 17, 2013
1 parent 84d6068 commit 1b784a7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/MantidQt/API/inc/MantidQtAPI/RepoModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ const QString BOTHCHANGED = "CHANGED";

QString fileDescription(const QModelIndex & index);
QString filePath(const QModelIndex & index);
QString author(const QModelIndex& index);


private:
Expand Down
36 changes: 30 additions & 6 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,0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
Expand All @@ -25,11 +25,35 @@
<widget class="MantidQt::API::RepoTreeView" name="repo_treeView"/>
</item>
<item>
<widget class="QLabel" name="desc_label">
<property name="text">
<string>Description</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="desc_label">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>228</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="authorNameLabel">
<property name="text">
<string>AuthorName</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextBrowser" name="desc_textBrowser"/>
Expand Down
12 changes: 12 additions & 0 deletions Code/Mantid/MantidQt/API/src/RepoModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,18 @@ QString RepoModel::fileDescription(const QModelIndex & index){
return desc;
}

QString RepoModel::author(const QModelIndex & index){
RepoItem * item = static_cast<RepoItem*>(index.internalPointer());
QString author = "Not defined";
if (!item)
return author;
try{
author = QString::fromStdString(repo_ptr->info(item->path().toStdString()).author);
}catch(...){
// just ignore
}
return author;
}
/** Return the operative system file path if it exists.
otherwise it returns an empty string
@param index: to find the entry
Expand Down
11 changes: 7 additions & 4 deletions Code/Mantid/MantidQt/API/src/ScriptRepositoryView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <QPushButton>
#include <QFileDialog>
#include <QPainter>

namespace MantidQt
{
namespace API
Expand Down Expand Up @@ -126,7 +125,6 @@ Mantid::Kernel::Logger & ScriptRepositoryView::g_log = Mantid::Kernel::Logger::g
deleteLater();
return;
}

// from this point, it is assumed that ScriptRepository is installed.

// configure the Ui
Expand Down Expand Up @@ -200,8 +198,13 @@ Mantid::Kernel::Logger & ScriptRepositoryView::g_log = Mantid::Kernel::Logger::g
if (_model){
// try to get the description of the file pointed at the current index.
// and update the description text browser.
QString description = _model->fileDescription(in);
ui->desc_textBrowser->setText(description);
QString description = _model->fileDescription(in);
ui->desc_textBrowser->setText(description);
QString author_name = _model->author(in);
if (author_name.isEmpty())
ui->authorNameLabel->setText("");
else
ui->authorNameLabel->setText(QString("<b>Author:</b> ")+ author_name);
return;
}
}
Expand Down

0 comments on commit 1b784a7

Please sign in to comment.