File indexing completed on 2024-04-21 05:50:37
0001 /* 0002 SPDX-FileCopyrightText: 2008-2022 Rolf Eike Beer <kde@opensource.sf-tec.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 #include "KGpgSignableNode.h" 0007 0008 #include <KLocalizedString> 0009 0010 KGpgSignableNode::KGpgSignableNode(KGpgExpandableNode *parent) 0011 : KGpgExpandableNode(parent) 0012 { 0013 } 0014 0015 KGpgSignNode::List 0016 KGpgSignableNode::getSignatures(void) const 0017 { 0018 KGpgSignNode::List ret; 0019 0020 for (KGpgNode *kn : children) { 0021 if (kn->getType() == KgpgCore::ITYPE_SIGN) 0022 ret << kn->toSignNode(); 0023 } 0024 0025 return ret; 0026 } 0027 0028 QString 0029 KGpgSignableNode::getSignCount() const 0030 { 0031 return i18np("1 signature", "%1 signatures", children.count()); 0032 } 0033 0034 bool 0035 KGpgSignableNode::operator<(const KGpgSignableNode &other) const 0036 { 0037 return operator<(&other); 0038 } 0039 0040 bool 0041 KGpgSignableNode::operator<(const KGpgSignableNode *other) const 0042 { 0043 switch (getType()) { 0044 case KgpgCore::ITYPE_PUBLIC: 0045 case KgpgCore::ITYPE_PAIR: { 0046 const QString myid(getId()); 0047 0048 switch (other->getType()) { 0049 case KgpgCore::ITYPE_PUBLIC: 0050 case KgpgCore::ITYPE_PAIR: 0051 return (myid < other->getId()); 0052 default: { 0053 const QString otherid(other->getParentKeyNode()->getId()); 0054 0055 if (myid == otherid) 0056 return true; 0057 return (myid < otherid); 0058 } 0059 } 0060 } 0061 default: { 0062 const QString myp(getParentKeyNode()->getId()); 0063 0064 switch (other->getType()) { 0065 case KgpgCore::ITYPE_PAIR: 0066 case KgpgCore::ITYPE_PUBLIC: 0067 return (myp < other->getId()); 0068 default: { 0069 const QString otherp(other->getParentKeyNode()->getId()); 0070 0071 if (otherp == myp) 0072 return (getId().toInt() < other->getId().toInt()); 0073 0074 return (myp < otherp); 0075 } 0076 } 0077 } 0078 } 0079 }