from sfa.util.record import SfaRecord, SliceRecord, AuthorityRecord
from sface.config import config
+from sface.sfidata import SfiData
NAME_COLUMN = 0
MEMBERSHIP_STATUS_COLUMN = 1
node_index = model.index(current.row(), 0, current.parent())
node_data = node_index.data().toString()
+MODE_AUTHORITY_SLICES = 1
+MODE_USER_SLICES = 2
+
class SliceModel(QStandardItemModel):
- def __init__(self, rows=0, columns=4, parent=None):
+ def __init__(self, rows=0, columns=4, parent=None, mode=MODE_AUTHORITY_SLICES):
QStandardItemModel.__init__(self, rows, columns, parent)
+ self.mode = mode
def updateModel(self):
self.clear()
- slice_names = []
-
- i=0
- while (os.path.exists(config.getAuthorityListFile(i))):
- rec = self.readSliceRecord(i)
- if rec:
- name = str(rec.get_name())
- if (rec.get_type() == "slice"):
- slice_names.append(name)
- i=i+1
+ if (self.mode == MODE_AUTHORITY_SLICES):
+ slice_names = SfiData().getAuthorityHrns(type="slice")
+ else: # MODE_USER_SLICES
+ slice_names = SfiData().getUserSliceHrns()
rootItem = self.invisibleRootItem()
return slices
- def readSliceRecord(self, i):
- rec_file = config.getAuthorityListFile(i)
- if os.path.exists(rec_file):
- xml = open(rec_file).read()
- rec = SliceRecord()
- rec.load_from_string(xml)
- return rec
- return None
-