Changeset View
Changeset View
Standalone View
Standalone View
src/urifilters/ikws/kuriikwsfiltereng.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 66 | if ( pos > -1 ) | |||
---|---|---|---|---|---|
67 | key = typedString.left(pos).toLower(); // #169801 | 67 | key = typedString.left(pos).toLower(); // #169801 | ||
68 | else if ( !typedString.isEmpty() && m_cKeywordDelimiter == ' ') | 68 | else if ( !typedString.isEmpty() && m_cKeywordDelimiter == ' ') | ||
69 | key = typedString; | 69 | key = typedString; | ||
70 | 70 | | |||
71 | qCDebug(category) << "m_cKeywordDelimiter=" << QString(QChar(m_cKeywordDelimiter)) << "pos=" << pos << "key=" << key; | 71 | qCDebug(category) << "m_cKeywordDelimiter=" << QString(QChar(m_cKeywordDelimiter)) << "pos=" << pos << "key=" << key; | ||
72 | 72 | | |||
73 | if (!key.isEmpty() && !KProtocolInfo::isKnownProtocol(key)) | 73 | if (!key.isEmpty() && !KProtocolInfo::isKnownProtocol(key)) | ||
74 | { | 74 | { | ||
75 | provider = SearchProvider::findByKey(key); | 75 | provider = m_registry.findByKey(key); | ||
76 | if (provider) | 76 | if (provider) | ||
77 | { | 77 | { | ||
78 | if (!m_bUseOnlyPreferredWebShortcuts || m_preferredWebShortcuts.contains(provider->desktopEntryName())) { | 78 | if (!m_bUseOnlyPreferredWebShortcuts || m_preferredWebShortcuts.contains(provider->desktopEntryName())) { | ||
79 | searchTerm = typedString.mid(pos+1); | 79 | searchTerm = typedString.mid(pos+1); | ||
80 | qCDebug(category) << "found provider" << provider->desktopEntryName() << "searchTerm=" << searchTerm; | 80 | qCDebug(category) << "found provider" << provider->desktopEntryName() << "searchTerm=" << searchTerm; | ||
81 | } else { | 81 | } else { | ||
82 | delete provider; | | |||
83 | provider = nullptr; | 82 | provider = nullptr; | ||
84 | } | 83 | } | ||
85 | } | 84 | } | ||
86 | } | 85 | } | ||
87 | } | 86 | } | ||
88 | 87 | | |||
89 | return provider; | 88 | return provider; | ||
90 | } | 89 | } | ||
91 | 90 | | |||
92 | 91 | | |||
93 | SearchProvider* KURISearchFilterEngine::autoWebSearchQuery(const QString& typedString, const QString &defaultShortcut) const | 92 | SearchProvider* KURISearchFilterEngine::autoWebSearchQuery(const QString& typedString, const QString &defaultShortcut) const | ||
94 | { | 93 | { | ||
95 | SearchProvider *provider = nullptr; | 94 | SearchProvider *provider = nullptr; | ||
96 | const QString defaultSearchProvider = (m_defaultWebShortcut.isEmpty() ? defaultShortcut : m_defaultWebShortcut); | 95 | const QString defaultSearchProvider = (m_defaultWebShortcut.isEmpty() ? defaultShortcut : m_defaultWebShortcut); | ||
97 | 96 | | |||
98 | if (m_bWebShortcutsEnabled && !defaultSearchProvider.isEmpty()) | 97 | if (m_bWebShortcutsEnabled && !defaultSearchProvider.isEmpty()) | ||
99 | { | 98 | { | ||
100 | // Make sure we ignore supported protocols, e.g. "smb:", "http:" | 99 | // Make sure we ignore supported protocols, e.g. "smb:", "http:" | ||
101 | const int pos = typedString.indexOf(':'); | 100 | const int pos = typedString.indexOf(':'); | ||
102 | 101 | | |||
103 | if (pos == -1 || !KProtocolInfo::isKnownProtocol(typedString.left(pos))) | 102 | if (pos == -1 || !KProtocolInfo::isKnownProtocol(typedString.left(pos))) { | ||
104 | provider = SearchProvider::findByDesktopName(defaultSearchProvider); | 103 | provider = m_registry.findByDesktopName(defaultSearchProvider); | ||
104 | } | ||||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | return provider; | 107 | return provider; | ||
108 | } | 108 | } | ||
109 | 109 | | |||
110 | QByteArray KURISearchFilterEngine::name() const | 110 | QByteArray KURISearchFilterEngine::name() const | ||
111 | { | 111 | { | ||
112 | return "kuriikwsfilter"; | 112 | return "kuriikwsfilter"; | ||
▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Line(s) | 420 | { | |||
437 | // Use either a white space or a : as the keyword delimiter... | 437 | // Use either a white space or a : as the keyword delimiter... | ||
438 | if (strchr (" :", m_cKeywordDelimiter) == nullptr) | 438 | if (strchr (" :", m_cKeywordDelimiter) == nullptr) | ||
439 | m_cKeywordDelimiter = ':'; | 439 | m_cKeywordDelimiter = ':'; | ||
440 | 440 | | |||
441 | qCDebug(category) << "Web Shortcuts Enabled: " << m_bWebShortcutsEnabled; | 441 | qCDebug(category) << "Web Shortcuts Enabled: " << m_bWebShortcutsEnabled; | ||
442 | qCDebug(category) << "Default Shortcut: " << m_defaultWebShortcut; | 442 | qCDebug(category) << "Default Shortcut: " << m_defaultWebShortcut; | ||
443 | qCDebug(category) << "Keyword Delimiter: " << m_cKeywordDelimiter; | 443 | qCDebug(category) << "Keyword Delimiter: " << m_cKeywordDelimiter; | ||
444 | } | 444 | } | ||
445 | | ||||
446 | SearchProviderRegistry * KURISearchFilterEngine::registry() | ||||
447 | { | ||||
448 | return &m_registry; | ||||
449 | } |