MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / updateImageHash

Method updateImageHash

gui/nbrowserwindow.cpp:1813–1832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1811
1812
1813void NBrowserWindow::updateImageHash(QByteArray newhash) {
1814 QString content = editor->page()->mainFrame()->toHtml();
1815 int pos = content.indexOf("<img ");
1816 for (; pos != -1; pos=content.indexOf("<img ", pos+1) ) {
1817 int endPos = content.indexOf(">", pos);
1818 QString section = content.mid(pos, endPos-pos);
1819 if (section.contains("lid=\"" +QString::number(selectedFileLid) + "\"")) {
1820 ResourceTable rtable(global.db);
1821 QString oldhash = section.mid(section.indexOf("hash=\"")+6);
1822 oldhash = oldhash.mid(0,oldhash.indexOf("\""));
1823 section.replace(oldhash, newhash.toHex());
1824 QString newcontent = content.mid(0,pos) +section +content.mid(endPos);
1825 QByteArray c;
1826 c.append(newcontent);
1827 editor->page()->mainFrame()->setContent(c);
1828 rtable.updateResourceHash(selectedFileLid, newhash);
1829 return;
1830 }
1831 }
1832}
1833
1834void NBrowserWindow::imageContextMenu(QString l, QString f) {
1835 editor->downloadAttachmentAction()->setEnabled(true);

Callers

nothing calls this directly

Calls 2

setContentMethod · 0.45
updateResourceHashMethod · 0.45

Tested by

no test coverage detected