mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
This is a large squash of many small commits. Allow porting data from the legacy format to SQL. Store Binaries base64 encoded and use db->transaction Update password hash to be 8000 x SHA512 with 8 byte Salt Add revocations table and fixup CRL generation Add comment and insertion date columns Fix column saving, remove trust, add XcaDialog Allow changing the internal name and comment in Cert/Req details view Extend Comment functionality, Replace About.ui by XcaDialog.ui
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
/* vi: set sw=4 ts=4:
|
|
*
|
|
* Copyright (C) 2006 - 2015 Christian Hohnstaedt.
|
|
*
|
|
* All rights reserved.
|
|
*/
|
|
|
|
#include "XcaProxyModel.h"
|
|
#include "lib/db_base.h"
|
|
|
|
bool XcaProxyModel::lessThan(const QModelIndex &left,
|
|
const QModelIndex &right) const
|
|
{
|
|
db_base *db = (db_base *)sourceModel();
|
|
if (!db)
|
|
return QSortFilterProxyModel::lessThan(left, right);
|
|
|
|
if (left.column() < 0 || right.column() < 0) {
|
|
qDebug("BAD COLUMN: %d %d\n", left.column(), right.column());
|
|
return true;
|
|
}
|
|
if (db->isNumericCol(left.column()) &&
|
|
db->isNumericCol(right.column()))
|
|
{
|
|
int diff;
|
|
QString l = sourceModel()->data(left).toString();
|
|
QString r = sourceModel()->data(right).toString();
|
|
diff = l.size() - r.size();
|
|
if (diff<0)
|
|
return true;
|
|
else if (diff>0)
|
|
return false;
|
|
else
|
|
return l < r;
|
|
}
|
|
return QSortFilterProxyModel::lessThan(left, right);
|
|
}
|
|
|
|
bool XcaProxyModel::filterAcceptsRow(int sourceRow,
|
|
const QModelIndex &sourceParent) const
|
|
{
|
|
QModelIndex idx = sourceModel()->index(sourceRow, 0, sourceParent);
|
|
return sourceModel()->data(idx, Qt::UserRole).toBool();
|
|
}
|
|
|
|
QVariant XcaProxyModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
QModelIndex i;
|
|
QString number;
|
|
|
|
if (index.column() != 1)
|
|
return QSortFilterProxyModel::data(index, role);
|
|
|
|
/* Row number */
|
|
switch (role) {
|
|
case Qt::EditRole:
|
|
case Qt::DisplayRole:
|
|
for (i = index; i.isValid(); i = i.parent())
|
|
number += QString(" %1").arg(i.row()+1);
|
|
return QVariant(number);
|
|
default:
|
|
return QSortFilterProxyModel::data(index, role);
|
|
}
|
|
return QVariant();
|
|
}
|
|
|