Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ExerciseManangement - Exercise Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-02-10
|
||||
*/
|
||||
|
||||
#include "tln_cache_dialog.h"
|
||||
#include "ui_tln_cache_dialog.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace Timeline
|
||||
{
|
||||
|
||||
TimelineCacheDialog::TimelineCacheDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::TimelineCacheDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbUncache, &QPushButton::clicked,
|
||||
this, [this]()
|
||||
{
|
||||
bool k = false;
|
||||
int index = m_ui->twCaches->item(m_ui->twCaches->selectionModel()->currentIndex().row(), 0)->text().toInt(&k);
|
||||
|
||||
if (!k)
|
||||
return;
|
||||
|
||||
emit signalUncache(index);
|
||||
close();
|
||||
});
|
||||
|
||||
|
||||
connect(m_ui->pbDelete, &QPushButton::clicked,
|
||||
this, [this]()
|
||||
{
|
||||
bool k = false;
|
||||
int index = m_ui->twCaches->item(m_ui->twCaches->selectionModel()->currentIndex().row(), 0)->text().toInt(&k);
|
||||
|
||||
if (!k)
|
||||
return;
|
||||
|
||||
emit signalDelete(index);
|
||||
close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
TimelineCacheDialog::~TimelineCacheDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void TimelineCacheDialog::addCache(const CacheRange &cr, const QString &indexString)
|
||||
{
|
||||
int rowCount = m_ui->twCaches->rowCount();
|
||||
m_ui->twCaches->insertRow(rowCount);
|
||||
int row = m_ui->twCaches->rowCount() - 1;
|
||||
int c = 0;
|
||||
|
||||
m_ui->twCaches->setItem(row, c++ /* pun not intended */, new QTableWidgetItem(indexString));
|
||||
|
||||
QString hash(QStringLiteral("<%1:%2:%3>").arg(cr.start).arg(cr.end).arg(cr.events.count()));
|
||||
m_ui->twCaches->setItem(row, c++, new QTableWidgetItem(QString::number(qHash(hash), 16)));
|
||||
|
||||
m_ui->twCaches->setItem(row, c++, new QTableWidgetItem(QStringLiteral("%1 (%2)").arg(QDateTime::fromMSecsSinceEpoch(cr.start).toString()).arg(cr.start)));
|
||||
m_ui->twCaches->setItem(row, c++, new QTableWidgetItem(QStringLiteral("%1 (%2)").arg(QDateTime::fromMSecsSinceEpoch(cr.end).toString()).arg(cr.end)));
|
||||
m_ui->twCaches->setItem(row, c++, new QTableWidgetItem(QString::number(cr.events.count())));
|
||||
}
|
||||
|
||||
|
||||
bool TimelineCacheDialog::init(const QVector<QPair<qint64, CacheRange>> &cachedRanges, const CacheRange &liveCache)
|
||||
{
|
||||
m_ui->twCaches->setRowCount(0);
|
||||
|
||||
int eventCount = 0;
|
||||
{
|
||||
int i = 0;
|
||||
for (auto it = cachedRanges.constBegin(); it != cachedRanges.constEnd(); ++it)
|
||||
{
|
||||
const CacheRange &cr = it->second;
|
||||
|
||||
eventCount += cr.events.count();
|
||||
addCache(cr, QString::number(i));
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
addCache(liveCache, QStringLiteral("live")); // add live events from its own cache
|
||||
m_ui->lblEventCount->setText(QString::number(eventCount));
|
||||
|
||||
|
||||
for (int i = 0; i < m_ui->twCaches->columnCount(); i++)
|
||||
{
|
||||
m_ui->twCaches->resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Timeline
|
||||
Reference in new issue
Block a user