Commit 1d14e7e4 authored by Thomas Hartmann's avatar Thomas Hartmann

Welcompage: allow highlighting of demos and examples

With this patch the attribute isHighlighted="true" in
the manifest.xml allows highlighting demos and examples.

The highlighted demos and examples appear first in the list
and have a blue highlight.

Task-number: QTCREATORBUG-8459
Change-Id: Ieeb888630235e07b1ae1398c5ccdc3d7e8d15dff
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@digia.com>
parent a6c8628c
......@@ -35,6 +35,18 @@ Rectangle {
height: 240
width: 216
Rectangle {
id: highlight
radius: 6
visible: isHighlighted
color: colors.strongForegroundColor
anchors.fill: parent
anchors.topMargin: 2
anchors.leftMargin: 4
anchors.rightMargin: 4
anchors.bottomMargin: 73
}
property alias caption: captionItem.text
property alias imageSource: imageItem.source
property alias videoSource: videoIcon.source
......@@ -201,11 +213,11 @@ Rectangle {
Rectangle {
id: border
color: "#00000000"
radius: 8
radius: 6
anchors.rightMargin: 4
anchors.leftMargin: 4
anchors.bottomMargin: 4
anchors.topMargin: 4
anchors.topMargin: 1
visible: false
anchors.fill: parent
border.color: "#dddcdc"
......@@ -276,6 +288,11 @@ Rectangle {
target: border
visible: true
}
PropertyChanges {
target: highlight
opacity: 0
}
}
]
......
......@@ -167,6 +167,7 @@ ExamplesListModel::ExamplesListModel(QObject *parent) :
roleNames[VideoUrl] = "videoUrl";
roleNames[VideoLength] = "videoLength";
roleNames[Platforms] = "platforms";
roleNames[IsHighlighted] = "isHighlighted";
setRoleNames(roleNames);
connect(Core::HelpManager::instance(), SIGNAL(setupFinished()),
......@@ -261,6 +262,10 @@ void ExamplesListModel::parseExamples(QXmlStreamReader *reader,
item.projectPath = relativeOrInstallPath(item.projectPath, projectsOffset, examplesInstallPath);
item.imageUrl = attributes.value(QLatin1String("imageUrl")).toString();
item.docUrl = attributes.value(QLatin1String("docUrl")).toString();
if (attributes.hasAttribute(QLatin1String("isHighlighted")))
item.isHighlighted = attributes.value(QLatin1String("isHighlighted")).toString() == QLatin1String("true");
} else if (reader->name() == QLatin1String("fileToOpen")) {
item.filesToOpen.append(relativeOrInstallPath(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement),
projectsOffset, examplesInstallPath));
......@@ -307,6 +312,10 @@ void ExamplesListModel::parseDemos(QXmlStreamReader *reader,
item.projectPath = relativeOrInstallPath(item.projectPath, projectsOffset, demosInstallPath);
item.imageUrl = attributes.value(QLatin1String("imageUrl")).toString();
item.docUrl = attributes.value(QLatin1String("docUrl")).toString();
if (attributes.hasAttribute(QLatin1String("isHighlighted")))
item.isHighlighted = attributes.value(QLatin1String("isHighlighted")).toString() == QLatin1String("true");
} else if (reader->name() == QLatin1String("fileToOpen")) {
item.filesToOpen.append(relativeOrInstallPath(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement),
projectsOffset, demosInstallPath));
......@@ -578,6 +587,13 @@ int ExamplesListModel::rowCount(const QModelIndex &) const
return m_exampleItems.size();
}
QString prefixForItem(const ExampleItem &item)
{
if (item.isHighlighted)
return QLatin1String("0000 ");
return QString();
}
QVariant ExamplesListModel::data(const QModelIndex &index, int role) const
{
ensureInitialized();
......@@ -590,7 +606,7 @@ QVariant ExamplesListModel::data(const QModelIndex &index, int role) const
switch (role)
{
case Qt::DisplayRole: // for search only
return QString(item.name + QLatin1Char(' ') + item.tags.join(QLatin1String(" ")));
return QString(prefixForItem(item) + item.name + QLatin1Char(' ') + item.tags.join(QLatin1String(" ")));
case Name:
return item.name;
case ProjectPath:
......@@ -621,6 +637,8 @@ QVariant ExamplesListModel::data(const QModelIndex &index, int role) const
return item.videoLength;
case Platforms:
return item.platforms;
case IsHighlighted:
return item.isHighlighted;
default:
qDebug() << Q_FUNC_INFO << "role type not supported";
return QVariant();
......
......@@ -44,7 +44,8 @@ enum ExampleRoles
{
Name = Qt::UserRole, ProjectPath, Description, ImageUrl,
DocUrl, FilesToOpen, Tags, Difficulty, HasSourceCode,
Type, Dependencies, IsVideo, VideoUrl, VideoLength, Platforms
Type, Dependencies, IsVideo, VideoUrl, VideoLength, Platforms,
IsHighlighted
};
enum InstructionalType
......@@ -54,7 +55,7 @@ enum InstructionalType
struct ExampleItem
{
ExampleItem(): difficulty(0), isVideo(false) {}
ExampleItem(): difficulty(0), isVideo(false), isHighlighted(false) {}
InstructionalType type;
QString name;
QString projectPath;
......@@ -70,6 +71,7 @@ struct ExampleItem
QString videoUrl;
QString videoLength;
QStringList platforms;
bool isHighlighted;
};
class ExamplesListModel : public QAbstractListModel
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment