Changeset View
Changeset View
Standalone View
Standalone View
kwrite/main.cpp
Show All 33 Lines | |||||
34 | #include <KCrash> | 34 | #include <KCrash> | ||
35 | #endif // KCrash >= 5.15 | 35 | #endif // KCrash >= 5.15 | ||
36 | 36 | | |||
37 | #include <QCommandLineParser> | 37 | #include <QCommandLineParser> | ||
38 | #include <QApplication> | 38 | #include <QApplication> | ||
39 | #include <QTextCodec> | 39 | #include <QTextCodec> | ||
40 | #include <QFileInfo> | 40 | #include <QFileInfo> | ||
41 | #include <QDir> | 41 | #include <QDir> | ||
42 | #include <QUrlQuery> | ||||
42 | 43 | | |||
43 | #include "../urlinfo.h" | 44 | #include "../urlinfo.h" | ||
44 | 45 | | |||
45 | #ifndef Q_OS_WIN | 46 | #ifndef Q_OS_WIN | ||
46 | #include <unistd.h> | 47 | #include <unistd.h> | ||
47 | #endif | 48 | #endif | ||
48 | #include <iostream> | 49 | #include <iostream> | ||
49 | 50 | | |||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Line(s) | 262 | if (codec) { | |||
262 | t->view()->document()->setEncoding(QString::fromLatin1(codec->name())); | 263 | t->view()->document()->setEncoding(QString::fromLatin1(codec->name())); | ||
263 | } | 264 | } | ||
264 | 265 | | |||
265 | t->loadURL(info.url); | 266 | t->loadURL(info.url); | ||
266 | 267 | | |||
267 | if (info.cursor.isValid()) { | 268 | if (info.cursor.isValid()) { | ||
268 | t->view()->setCursorPosition(info.cursor); | 269 | t->view()->setCursorPosition(info.cursor); | ||
269 | } | 270 | } | ||
271 | else if (info.url.hasQuery()) { | ||||
272 | QUrlQuery q(info.url); | ||||
273 | QString lineStr = q.queryItemValue(QStringLiteral("line")); | ||||
274 | QString columnStr = q.queryItemValue(QStringLiteral("column")); | ||||
275 | | ||||
276 | line = lineStr.toInt(); | ||||
277 | if (line > 0) | ||||
278 | line--; | ||||
279 | | ||||
280 | column = columnStr.toInt(); | ||||
281 | if (column > 0) | ||||
282 | column--; | ||||
283 | | ||||
284 | t->view()->setCursorPosition(KTextEditor::Cursor(line, column)); | ||||
285 | } | ||||
270 | } else { | 286 | } else { | ||
271 | KMessageBox::sorry(nullptr, i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", info.url.toString())); | 287 | KMessageBox::sorry(nullptr, i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", info.url.toString())); | ||
272 | } | 288 | } | ||
273 | } | 289 | } | ||
274 | if (!docs_opened) { | 290 | if (!docs_opened) { | ||
275 | ::exit(1); // see http://bugs.kde.org/show_bug.cgi?id=124708 | 291 | ::exit(1); // see http://bugs.kde.org/show_bug.cgi?id=124708 | ||
276 | } | 292 | } | ||
277 | } | 293 | } | ||
Show All 18 Lines |