Commit 6546a292 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Gerrit: Properly sort timestamps in Gerrit dialog



Task-number: QTCREATORBUG-13602
Change-Id: Iba4b2d85d6b75752214b4f53684b9e90df9b1b69
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent ee64a062
......@@ -158,6 +158,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
m_filterModel->setSourceModel(m_model);
m_filterModel->setFilterRole(GerritModel::FilterRole);
m_filterModel->setSortRole(GerritModel::SortRole);
m_treeView->setRootIsDecorated(true);
m_treeView->setModel(m_filterModel);
m_treeView->setMinimumWidth(600);
......
......@@ -419,7 +419,14 @@ GerritModel::GerritModel(const QSharedPointer<GerritParameters> &p, QObject *par
}
GerritModel::~GerritModel()
{ }
QVariant GerritModel::data(const QModelIndex &index, int role) const
{
QVariant value = QStandardItemModel::data(index, role);
if (role == SortRole && value.isNull())
return QStandardItemModel::data(index, Qt::DisplayRole);
return value;
}
static inline GerritChangePtr changeFromItem(const QStandardItem *item)
......@@ -704,7 +711,8 @@ QList<QStandardItem *> GerritModel::changeToRow(const GerritChangePtr &c) const
const QString dateString = c->lastUpdated.date() == QDate::currentDate() ?
c->lastUpdated.time().toString(Qt::SystemLocaleShortDate) :
c->lastUpdated.date().toString(Qt::SystemLocaleShortDate);
row[DateColumn]->setText(dateString);
row[DateColumn]->setData(dateString, Qt::DisplayRole);
row[DateColumn]->setData(c->lastUpdated, SortRole);
QString project = c->project;
if (c->branch != QLatin1String("master"))
......@@ -726,6 +734,7 @@ QList<QStandardItem *> GerritModel::changeToRow(const GerritChangePtr &c) const
for (int i = 0; i < GerritModel::ColumnCount; ++i)
row[i]->setFont(font);
}
return row;
}
......
......@@ -112,11 +112,14 @@ public:
enum CustomModelRoles {
FilterRole = Qt::UserRole + 1,
GerritChangeRole = Qt::UserRole + 2
GerritChangeRole = Qt::UserRole + 2,
SortRole = Qt::UserRole + 3
};
GerritModel(const QSharedPointer<GerritParameters> &, QObject *parent = 0);
~GerritModel();
QVariant data(const QModelIndex &index, int role) const;
GerritChangePtr change(const QModelIndex &index) const;
QString toHtml(const QModelIndex &index) const;
......
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