forked from qt-creator/qt-creator
Gerrit: Properly sort timestamps in Gerrit dialog
Task-number: QTCREATORBUG-13602 Change-Id: Iba4b2d85d6b75752214b4f53684b9e90df9b1b69 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -158,6 +158,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
|
|||||||
|
|
||||||
m_filterModel->setSourceModel(m_model);
|
m_filterModel->setSourceModel(m_model);
|
||||||
m_filterModel->setFilterRole(GerritModel::FilterRole);
|
m_filterModel->setFilterRole(GerritModel::FilterRole);
|
||||||
|
m_filterModel->setSortRole(GerritModel::SortRole);
|
||||||
m_treeView->setRootIsDecorated(true);
|
m_treeView->setRootIsDecorated(true);
|
||||||
m_treeView->setModel(m_filterModel);
|
m_treeView->setModel(m_filterModel);
|
||||||
m_treeView->setMinimumWidth(600);
|
m_treeView->setMinimumWidth(600);
|
||||||
|
@@ -419,7 +419,14 @@ GerritModel::GerritModel(const QSharedPointer<GerritParameters> &p, QObject *par
|
|||||||
}
|
}
|
||||||
|
|
||||||
GerritModel::~GerritModel()
|
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)
|
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() ?
|
const QString dateString = c->lastUpdated.date() == QDate::currentDate() ?
|
||||||
c->lastUpdated.time().toString(Qt::SystemLocaleShortDate) :
|
c->lastUpdated.time().toString(Qt::SystemLocaleShortDate) :
|
||||||
c->lastUpdated.date().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;
|
QString project = c->project;
|
||||||
if (c->branch != QLatin1String("master"))
|
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)
|
for (int i = 0; i < GerritModel::ColumnCount; ++i)
|
||||||
row[i]->setFont(font);
|
row[i]->setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,11 +112,14 @@ public:
|
|||||||
|
|
||||||
enum CustomModelRoles {
|
enum CustomModelRoles {
|
||||||
FilterRole = Qt::UserRole + 1,
|
FilterRole = Qt::UserRole + 1,
|
||||||
GerritChangeRole = Qt::UserRole + 2
|
GerritChangeRole = Qt::UserRole + 2,
|
||||||
|
SortRole = Qt::UserRole + 3
|
||||||
};
|
};
|
||||||
GerritModel(const QSharedPointer<GerritParameters> &, QObject *parent = 0);
|
GerritModel(const QSharedPointer<GerritParameters> &, QObject *parent = 0);
|
||||||
~GerritModel();
|
~GerritModel();
|
||||||
|
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
|
||||||
GerritChangePtr change(const QModelIndex &index) const;
|
GerritChangePtr change(const QModelIndex &index) const;
|
||||||
QString toHtml(const QModelIndex &index) const;
|
QString toHtml(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user