Commit 64a95a4d authored by Rolf Eike Beer's avatar Rolf Eike Beer
Browse files

port refreshing of trust colors to model/view

svn path=/branches/work/kgpg2/; revision=762726
parent 0affdbed
......@@ -567,70 +567,6 @@ void KeyListView::refreshGroups()
emit statusMessage(i18nc("No operation in progress", "Ready"), 0);
}
void KeyListView::refreshTrust(int color, const QColor &newColor)
{
if (!newColor.isValid())
return;
QPixmap blankFrame;
QPixmap newtrust;
int trustFinger = 0;
blankFrame.load(KStandardDirs::locate("appdata", "pics/kgpg_blank.png"));
newtrust.load(KStandardDirs::locate("appdata", "pics/kgpg_fill.png"));
newtrust.fill(newColor);
QPainter p(&newtrust);
p.drawPixmap(QPoint(0, 0), blankFrame, QRect(0, 0, 50, 15));
switch (color)
{
case kgpgOptions::UltimateColor:
trustFinger = trustultimate.serialNumber();
trustultimate = newtrust;
break;
case kgpgOptions::GoodColor:
trustFinger = trustgood.serialNumber();
trustgood = newtrust;
break;
case kgpgOptions::MarginalColor:
trustFinger = trustmarginal.serialNumber();
trustmarginal = newtrust;
break;
case kgpgOptions::ExpiredColor:
trustFinger = trustexpired.serialNumber();
trustexpired = newtrust;
break;
case kgpgOptions::BadColor:
trustFinger = trustbad.serialNumber();
trustbad = newtrust;
break;
case kgpgOptions::UnknownColor:
trustFinger = trustunknown.serialNumber();
trustunknown = newtrust;
break;
case kgpgOptions::RevColor:
trustFinger = trustrevoked.serialNumber();
trustrevoked = newtrust;
break;
}
KeyListViewItem *item = firstChild();
while (item)
{
if (item->pixmap(2))
if (item->pixmap(2)->serialNumber() == trustFinger)
item->setPixmap(2, newtrust);
item = item->nextSibling();
}
}
void KeyListView::expandKey(Q3ListViewItem *item2)
{
KeyListViewItem *item = static_cast<KeyListViewItem *>(item2);
......
......@@ -141,7 +141,6 @@ private slots:
void insertOrphans(const KgpgKeyList &keys);
void refreshGroups();
void refreshTrust(int color, const QColor &newColor);
void expandKey(Q3ListViewItem *item);
void expandGroup(KeyListViewItem *item);
......
......@@ -1199,7 +1199,7 @@ void KeysManager::showOptions()
kgpgOptions *optionsDialog = new kgpgOptions(this, "settings");
connect(optionsDialog, SIGNAL(settingsUpdated()), this, SLOT(readAllOptions()));
connect(optionsDialog, SIGNAL(homeChanged()), imodel, SLOT(refreshKeys()));
connect(optionsDialog, SIGNAL(refreshTrust(int, QColor)), keysList2, SLOT(refreshTrust(int, QColor)));
connect(optionsDialog, SIGNAL(refreshTrust(KgpgCore::KgpgKeyTrust, QColor)), imodel, SLOT(refreshTrust(KgpgCore::KgpgKeyTrust, QColor)));
connect(optionsDialog, SIGNAL(changeFont(QFont)), this, SIGNAL(fontChanged(QFont)));
optionsDialog->exec();
delete optionsDialog;
......
......@@ -390,3 +390,27 @@ KGpgItemModel::invalidateIndexes(KGpgNode *nd)
changePersistentIndex(idx, QModelIndex());
}
}
void
KGpgItemModel::refreshTrust(const KgpgCore::KgpgKeyTrust &trust, const QColor &color)
{
updateNodeTrustColor(m_root, trust, color);
}
void
KGpgItemModel::updateNodeTrustColor(KGpgExpandableNode *node, const KgpgCore::KgpgKeyTrust &trust, const QColor &color)
{
for (int i = 0; i < node->getChildCount(); i++) {
KGpgNode *child = node->getChild(i);
if (child->getTrust() == trust)
emit dataChanged(createIndex(i, KEYCOLUMN_TRUST, child), createIndex(i, KEYCOLUMN_TRUST, child));
if (!child->hasChildren())
continue;
KGpgExpandableNode *echild = static_cast<KGpgExpandableNode *>(child);
if (echild->wasExpanded())
updateNodeTrustColor(echild, trust, color);
}
}
......@@ -13,6 +13,9 @@
#include "kgpgitemnode.h"
#include "keyinfodialog.h"
#include "kgpgkey.h"
class QColor;
class KGpgItemModel : public QAbstractItemModel
{
......@@ -55,12 +58,14 @@ public Q_SLOTS:
void refreshKeys(const QStringList &ids = QStringList());
void refreshGroups();
void invalidateIndexes(KGpgNode *nd);
void refreshTrust(const KgpgCore::KgpgKeyTrust &trust, const QColor &color);
protected:
int rowForNode(KGpgNode *node) const;
void refreshKeyIds(const QStringList &id, QList<KGpgNode *> &nodes);
bool isDefaultKey(const KGpgNode *node) const;
void fixPersistentIndexes();
void updateNodeTrustColor(KGpgExpandableNode *node, const KgpgCore::KgpgKeyTrust &trust, const QColor &color);
};
#endif
......@@ -376,25 +376,30 @@ void kgpgOptions::updateSettings()
gr.writeEntry("Server_List", currList);
if (keyUltimate != m_page3->kcfg_ColorUltimate->color())
emit refreshTrust(UltimateColor, m_page3->kcfg_ColorUltimate->color());
emit refreshTrust(TRUST_ULTIMATE, m_page3->kcfg_ColorUltimate->color());
if (keyGood != m_page3->kcfg_ColorGood->color())
emit refreshTrust(GoodColor, m_page3->kcfg_ColorGood->color());
emit refreshTrust(TRUST_FULL, m_page3->kcfg_ColorGood->color());
if (keyExpired != m_page3->kcfg_ColorExpired->color())
emit refreshTrust(ExpiredColor, m_page3->kcfg_ColorExpired->color());
emit refreshTrust(TRUST_EXPIRED, m_page3->kcfg_ColorExpired->color());
if (keyMarginal != m_page3->kcfg_ColorMarginal->color())
emit refreshTrust(MarginalColor, m_page3->kcfg_ColorMarginal->color());
emit refreshTrust(TRUST_MARGINAL, m_page3->kcfg_ColorMarginal->color());
if (keyBad != m_page3->kcfg_ColorBad->color())
emit refreshTrust(BadColor, m_page3->kcfg_ColorBad->color());
if (keyBad != m_page3->kcfg_ColorBad->color()) {
emit refreshTrust(TRUST_INVALID, m_page3->kcfg_ColorBad->color());
emit refreshTrust(TRUST_DISABLED, m_page3->kcfg_ColorBad->color());
}
if (keyUnknown != m_page3->kcfg_ColorUnknown->color())
emit refreshTrust(UnknownColor, m_page3->kcfg_ColorUnknown->color());
if (keyUnknown != m_page3->kcfg_ColorUnknown->color()) {
emit refreshTrust(TRUST_UNDEFINED, m_page3->kcfg_ColorUnknown->color());
emit refreshTrust(TRUST_NONE, m_page3->kcfg_ColorUnknown->color());
emit refreshTrust(TRUST_UNKNOWN, m_page3->kcfg_ColorUnknown->color());
}
if (keyRev != m_page3->kcfg_ColorRev->color())
emit refreshTrust(RevColor, m_page3->kcfg_ColorRev->color());
emit refreshTrust(TRUST_REVOKED, m_page3->kcfg_ColorRev->color());
m_showsystray = m_page7->kcfg_ShowSystray->isChecked();
KGpgSettings::setShowSystray(m_showsystray);
......
......@@ -21,14 +21,14 @@
#include <KConfigDialog>
#include "ui_conf_gpg.h"
#include "ui_conf_ui2.h"
#include "ui_conf_servers.h"
#include "ui_conf_misc.h"
#include "ui_conf_decryption.h"
class KConfig;
#include "kgpgkey.h"
class KFontChooser;
class KConfig;
......@@ -101,7 +101,7 @@ signals:
void settingsUpdated();
void changeFont(QFont);
void homeChanged();
void refreshTrust(int, QColor);
void refreshTrust(KgpgCore::KgpgKeyTrust, QColor);
private slots:
void slotChangeHome();
......
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