| 1811 | |
| 1812 | |
| 1813 | void 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 | |
| 1834 | void NBrowserWindow::imageContextMenu(QString l, QString f) { |
| 1835 | editor->downloadAttachmentAction()->setEnabled(true); |
nothing calls this directly
no test coverage detected