The user clicked a link in the note
| 2099 | |
| 2100 | // The user clicked a link in the note |
| 2101 | void NBrowserWindow::linkClicked(const QUrl url) { |
| 2102 | if (url.toString().startsWith("latex:///", Qt::CaseInsensitive)) { |
| 2103 | editLatex(url.toString().mid(9)); |
| 2104 | return; |
| 2105 | } |
| 2106 | if (url.toString().startsWith("evernote:/view/", Qt::CaseInsensitive) || |
| 2107 | url.toString().startsWith("evernote:///view/", Qt::CaseInsensitive)) { |
| 2108 | |
| 2109 | QStringList tokens; |
| 2110 | if (url.toString().startsWith("evernote:/view/", Qt::CaseInsensitive)) |
| 2111 | tokens = url.toString().replace("evernote:/view/", "").split("/", QString::SkipEmptyParts); |
| 2112 | else |
| 2113 | tokens = url.toString().replace("evernote:///view/", "").split("/", QString::SkipEmptyParts); |
| 2114 | QString oguid =tokens[2]; |
| 2115 | QString eguid = tokens[3]; |
| 2116 | NoteTable ntable(global.db); |
| 2117 | qint32 newlid = ntable.getLid(eguid); |
| 2118 | if (newlid <= 0) |
| 2119 | newlid = ntable.getLid(oguid); |
| 2120 | if (newlid <= 0) |
| 2121 | return; |
| 2122 | |
| 2123 | bool newExternalWindow = false; |
| 2124 | bool newTab = false; |
| 2125 | if (QApplication::keyboardModifiers() & Qt::ShiftModifier) { |
| 2126 | if (global.getMiddleClickAction() == MOUSE_MIDDLE_CLICK_NEW_WINDOW) |
| 2127 | newExternalWindow = true; |
| 2128 | else |
| 2129 | newTab = true; |
| 2130 | } else { |
| 2131 | // Setup a new filter |
| 2132 | FilterCriteria *criteria = new FilterCriteria(); |
| 2133 | global.filterCriteria[global.filterPosition]->duplicate(*criteria); |
| 2134 | criteria->unsetSelectedNotes(); |
| 2135 | criteria->unsetLid(); |
| 2136 | criteria->setLid(newlid); |
| 2137 | global.appendFilter(criteria); |
| 2138 | global.filterPosition++; |
| 2139 | } |
| 2140 | emit(evernoteLinkClicked(newlid, newTab, newExternalWindow)); |
| 2141 | |
| 2142 | return; |
| 2143 | } |
| 2144 | if (url.toString().startsWith("nnres:", Qt::CaseInsensitive)) { |
| 2145 | if (url.toString().endsWith("/vnd.evernote.ink")) { |
| 2146 | QMessageBox::information(this, tr("Unable Open"), QString(tr("This is an ink note.\nInk notes are not supported since Evernote has not\n published any specifications on them\nand I'm too lazy to figure them out by myself."))); |
| 2147 | return; |
| 2148 | } |
| 2149 | QString filepath = global.fileManager.getDbaDirPath(); |
| 2150 | // Windows check |
| 2151 | #ifdef _WIN32 |
| 2152 | filepath = filepath.replace("\\", "/"); |
| 2153 | #endif // End windows check |
| 2154 | QString fullName = url.toString().mid(6).replace(filepath,""); |
| 2155 | filepath = filepath.replace("\\", "/"); |
| 2156 | QLOG_DEBUG() << global.fileManager.getDbaDirPath(); |
| 2157 | int index = fullName.lastIndexOf("."); |
| 2158 | QString guid = ""; |
nothing calls this directly
no test coverage detected