2015-06-27 10:22:46 +12:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#--!-- coding: utf8 --!--
|
|
|
|
|
|
|
|
from qt import *
|
|
|
|
from enums import *
|
|
|
|
from functions import *
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
def infoForRef(ref):
|
|
|
|
match = re.fullmatch("::(\w):(\d+?)::", ref)
|
|
|
|
if match:
|
|
|
|
_type = match.group(1)
|
|
|
|
_ref = match.group(2)
|
|
|
|
|
|
|
|
if _type == "T":
|
|
|
|
m = mainWindow().mdlOutline
|
|
|
|
idx = m.getIndexByID(_ref)
|
|
|
|
|
|
|
|
if not idx.isValid():
|
|
|
|
return qApp.translate("references", "Unknown reference: {}.").format(ref)
|
|
|
|
|
|
|
|
item = idx.internalPointer()
|
|
|
|
|
|
|
|
text = "<h1>{}</h1>".format(item.title())
|
|
|
|
text += "<b>Path:</b> {}<br>".format(item.path())
|
|
|
|
ss = item.data(Outline.summarySentance.value)
|
|
|
|
if ss:
|
|
|
|
text += "\n<b>Short summary:</b> {}<br>".format(ss)
|
|
|
|
|
|
|
|
ls = item.data(Outline.summaryFull.value)
|
|
|
|
if ls:
|
|
|
|
text += "\n<b>Long summary:</b> {}<br>".format(ls)
|
|
|
|
|
|
|
|
return text
|
|
|
|
|
|
|
|
elif _type == "C":
|
|
|
|
m = mainWindow().mdlPersos
|
|
|
|
name = m.item(int(_ref), Perso.name.value).text()
|
|
|
|
return "<h1>{}</h1>".format(name)
|
|
|
|
|
|
|
|
else:
|
2015-06-27 22:20:05 +12:00
|
|
|
return qApp.translate("references", "Unknown reference: {}.").format(ref)
|
|
|
|
|
|
|
|
|
|
|
|
def openReference(ref):
|
|
|
|
match = re.fullmatch("::(\w):(\d+?)::", ref)
|
|
|
|
if match:
|
|
|
|
_type = match.group(1)
|
|
|
|
_ref = match.group(2)
|
|
|
|
|
|
|
|
if _type == "C":
|
|
|
|
mw = mainWindow()
|
|
|
|
|
|
|
|
for i in range(mw.mdlPersos.rowCount()):
|
2015-06-29 20:22:18 +12:00
|
|
|
if mw.mdlPersos.ID(i) == _ref:
|
2015-06-27 22:20:05 +12:00
|
|
|
mw.tabMain.setCurrentIndex(2)
|
2015-06-29 20:22:18 +12:00
|
|
|
item = mw.lstPersos.getItemByID(_ref)
|
|
|
|
mw.lstPersos.setCurrentItem(item)
|
2015-06-27 22:20:05 +12:00
|
|
|
return True
|
|
|
|
|
|
|
|
print("Ref not found")
|
|
|
|
return False
|
|
|
|
|
|
|
|
elif _type == "T":
|
|
|
|
|
|
|
|
mw = mainWindow()
|
|
|
|
index = mw.mdlOutline.getIndexByID(_ref)
|
|
|
|
|
|
|
|
if index.isValid():
|
2015-06-30 00:21:57 +12:00
|
|
|
mw.mainEditor.setCurrentModelIndex(index, newTab=True)
|
2015-06-27 22:20:05 +12:00
|
|
|
return True
|
|
|
|
else:
|
|
|
|
print("Ref not found")
|
|
|
|
return False
|
|
|
|
|
|
|
|
print("Ref not implemented")
|
|
|
|
return False
|