Commit 6cae330e authored by hjk's avatar hjk

QtSupport: style

Change-Id: Iabf3c96fc6d6b17282ec2ad43f32f76b04ac2ef0
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent f4a06ffd
......@@ -101,7 +101,7 @@ static inline QStringList trimStringList(const QStringList &stringlist)
return returnList;
}
QList<ExampleItem> ExamplesListModel::parseExamples(QXmlStreamReader* reader, const QString& projectsOffset)
QList<ExampleItem> ExamplesListModel::parseExamples(QXmlStreamReader *reader, const QString &projectsOffset)
{
QList<ExampleItem> examples;
ExampleItem item;
......@@ -149,7 +149,7 @@ QList<ExampleItem> ExamplesListModel::parseExamples(QXmlStreamReader* reader, co
return examples;
}
QList<ExampleItem> ExamplesListModel::parseDemos(QXmlStreamReader* reader, const QString& projectsOffset)
QList<ExampleItem> ExamplesListModel::parseDemos(QXmlStreamReader *reader, const QString &projectsOffset)
{
QList<ExampleItem> demos;
ExampleItem item;
......@@ -522,12 +522,11 @@ void ExamplesListModelFilter::updateFilter()
}
}
bool containsSubString(const QStringList& list, const QString& substr, Qt::CaseSensitivity cs)
bool containsSubString(const QStringList &list, const QString &substr, Qt::CaseSensitivity cs)
{
foreach (const QString &elem, list) {
foreach (const QString &elem, list)
if (elem.contains(substr, cs))
return true;
}
return false;
}
......@@ -549,10 +548,9 @@ bool ExamplesListModelFilter::filterAcceptsRow(int sourceRow, const QModelIndex
const QStringList tags = sourceModel()->index(sourceRow, 0, sourceParent).data(Tags).toStringList();
if (!m_filterTags.isEmpty()) {
foreach(const QString &tag, m_filterTags) {
foreach(const QString &tag, m_filterTags)
if (!tags.contains(tag, Qt::CaseInsensitive))
return false;
}
return true;
}
......@@ -617,7 +615,8 @@ void ExamplesListModelFilter::timerEvent(QTimerEvent *timerEvent)
}
}
struct SearchStringLexer {
struct SearchStringLexer
{
QString code;
const QChar *codePtr;
QChar yychar;
......
......@@ -31,20 +31,27 @@
#define EXAMPLESLISTMODEL_H
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include <QStringList>
#include <QXmlStreamReader>
#include <QSortFilterProxyModel>
namespace QtSupport {
namespace Internal {
enum ExampleRoles { Name=Qt::UserRole, ProjectPath, Description, ImageUrl,
DocUrl, FilesToOpen, Tags, Difficulty, HasSourceCode,
Type, Dependencies, IsVideo, VideoUrl, VideoLength, Platforms };
enum ExampleRoles
{
Name = Qt::UserRole, ProjectPath, Description, ImageUrl,
DocUrl, FilesToOpen, Tags, Difficulty, HasSourceCode,
Type, Dependencies, IsVideo, VideoUrl, VideoLength, Platforms
};
enum InstructionalType { Example=0, Demo, Tutorial };
enum InstructionalType
{
Example = 0, Demo, Tutorial
};
struct ExampleItem {
struct ExampleItem
{
ExampleItem(): difficulty(0), isVideo(false) {}
InstructionalType type;
QString name;
......@@ -63,24 +70,21 @@ struct ExampleItem {
QStringList platforms;
};
class ExamplesListModel : public QAbstractListModel {
class ExamplesListModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit ExamplesListModel(QObject *parent);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QStringList tags() const;
void ensureInitialized() const;
void beginReset()
{ beginResetModel(); }
void endReset()
{ endResetModel(); }
void beginReset() { beginResetModel(); }
void endReset() { endResetModel(); }
signals:
void tagsUpdated();
......@@ -92,9 +96,9 @@ public slots:
private:
void addItems(const QList<ExampleItem> &items);
QList<ExampleItem> parseExamples(QXmlStreamReader* reader, const QString& projectsOffset);
QList<ExampleItem> parseDemos(QXmlStreamReader* reader, const QString& projectsOffset);
QList<ExampleItem> parseTutorials(QXmlStreamReader* reader, const QString& projectsOffset);
QList<ExampleItem> parseExamples(QXmlStreamReader *reader, const QString &projectsOffset);
QList<ExampleItem> parseDemos(QXmlStreamReader *reader, const QString &projectsOffset);
QList<ExampleItem> parseTutorials(QXmlStreamReader *reader, const QString &projectsOffset);
void clear();
QStringList exampleSources(QString *examplesFallback, QString *demosFallback,
QString *sourceFallback);
......@@ -105,8 +109,10 @@ private:
bool m_helpInitialized;
};
class ExamplesListModelFilter : public QSortFilterProxyModel {
class ExamplesListModelFilter : public QSortFilterProxyModel
{
Q_OBJECT
public:
Q_PROPERTY(bool showTutorialsOnly READ showTutorialsOnly WRITE setShowTutorialsOnly NOTIFY showTutorialsOnlyChanged)
Q_PROPERTY(QStringList filterTags READ filterTags WRITE setFilterTags NOTIFY filterTagsChanged)
......@@ -120,11 +126,11 @@ public:
QStringList filterTags() const { return m_filterTags; }
QStringList searchStrings() const { return m_searchString; }
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
public slots:
void setFilterTags(const QStringList& arg)
void setFilterTags(const QStringList &arg)
{
if (m_filterTags != arg) {
m_filterTags = arg;
......@@ -133,7 +139,7 @@ public slots:
}
void updateFilter();
void setSearchStrings(const QStringList& arg)
void setSearchStrings(const QStringList &arg)
{
if (m_searchString != arg) {
m_searchString = arg;
......@@ -142,20 +148,16 @@ public slots:
}
}
void parseSearchString(const QString& arg);
void parseSearchString(const QString &arg);
void setShowTutorialsOnly(bool showTutorialsOnly);
signals:
void showTutorialsOnlyChanged();
void filterTagsChanged(const QStringList& arg);
void searchStrings(const QStringList& arg);
protected:
void timerEvent(QTimerEvent *event);
private:
void timerEvent(QTimerEvent *event);
void delayedUpdateFilter();
bool m_showTutorialsOnly;
......
......@@ -87,6 +87,7 @@ QPointer<ExamplesListModel> &examplesModelStatic()
class Fetcher : public QObject
{
Q_OBJECT
public:
Fetcher() : QObject(), m_shutdown(false)
{
......
......@@ -65,6 +65,7 @@ private:
class ExamplesWelcomePage : public Utils::IWelcomePage
{
Q_OBJECT
public:
ExamplesWelcomePage();
......
......@@ -32,10 +32,10 @@
#include "qtsupport_global.h"
#include <projectexplorer/kitinformation.h>
#include "baseqtversion.h"
#include <projectexplorer/kitinformation.h>
namespace QtSupport {
class QTSUPPORT_EXPORT QtKitInformation : public ProjectExplorer::KitInformation
......@@ -67,6 +67,7 @@ public:
static void setQtVersionId(ProjectExplorer::Kit *k, const int id);
static BaseQtVersion *qtVersion(const ProjectExplorer::Kit *k);
static void setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion *v);
private slots:
void qtVersionsChanged(const QList<int> &addedIds,
const QList<int> &removedIds,
......@@ -88,8 +89,8 @@ class QTSUPPORT_EXPORT QtVersionKitMatcher : public ProjectExplorer::KitMatcher
{
public:
explicit QtVersionKitMatcher(const Core::FeatureSet &required = Core::FeatureSet(),
const QtVersionNumber &min = QtVersionNumber(0, 0, 0),
const QtVersionNumber &max = QtVersionNumber(INT_MAX, INT_MAX, INT_MAX)) :
const QtVersionNumber &min = QtVersionNumber(0, 0, 0),
const QtVersionNumber &max = QtVersionNumber(INT_MAX, INT_MAX, INT_MAX)) :
m_min(min), m_max(max), m_features(required)
{ }
......
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