chore: tweak ux for particles

This commit is contained in:
talksik
2026-01-28 16:20:49 -08:00
parent d9cd882e3b
commit 458a26b84a
8 changed files with 230 additions and 81 deletions
+39 -7
View File
@@ -1,4 +1,6 @@
#include "particlelistmodel.h"
#include <QApplication>
#include <QStyle>
ParticleListModel::ParticleListModel(Data *data, QObject *parent)
: QAbstractListModel(parent), m_data(data), m_currentStreamId()
@@ -22,7 +24,7 @@ int ParticleListModel::rowCount(const QModelIndex &parent) const
QVariant ParticleListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || role != Qt::DisplayRole)
if (!index.isValid())
{
return QVariant();
}
@@ -41,15 +43,33 @@ QVariant ParticleListModel::data(const QModelIndex &index, int role) const
const Particle &particle = particles.at(index.row());
// Show dot (•) for unseen, nothing for seen
if (particle.seen)
if (role == Qt::DisplayRole)
{
return particle.type;
QString emailPrefix = particle.createdBy.split("@")[0];
QString display = QString("[%1] - %2").arg(emailPrefix, particle.summary);
if (!particle.seen)
{
display += "";
}
return display;
}
else
else if (role == Qt::DecorationRole)
{
return QString("%1 •").arg(particle.type);
// Return icon based on type
QStyle::StandardPixmap pixmap;
if (particle.type == "text")
pixmap = QStyle::SP_FileIcon;
else if (particle.type == "link")
pixmap = QStyle::SP_CommandLink;
else if (particle.type == "image")
pixmap = QStyle::SP_FileDialogContentsView;
else
return QVariant();
return qApp->style()->standardIcon(pixmap);
}
return QVariant();
}
void ParticleListModel::setStreamId(const QString &streamId)
@@ -75,5 +95,17 @@ int ParticleListModel::firstUnseenRow() const
}
}
return -1; // All seen or empty
return -1; // All seen or empty
}
const Particle *ParticleListModel::particleAtRow(int row) const
{
if (m_currentStreamId.isEmpty())
return nullptr;
const QList<Particle> &particles = m_data->particlesForStream(m_currentStreamId);
if (row >= 0 && row < particles.size())
return &particles.at(row);
return nullptr;
}