equal
deleted
inserted
replaced
23 #include "UiUtil.h" |
23 #include "UiUtil.h" |
24 |
24 |
25 #define GOOGLE_SEARCH_ENGINE "http://www.google.com/search?q=" |
25 #define GOOGLE_SEARCH_ENGINE "http://www.google.com/search?q=" |
26 |
26 |
27 namespace WRT { |
27 namespace WRT { |
|
28 |
|
29 |
|
30 QString UiUtil::removeScheme(const QString & str ) |
|
31 { |
|
32 |
|
33 QUrl url(str); |
|
34 QString scheme=url.scheme(); |
|
35 QString urlStr = str; |
|
36 |
|
37 if (scheme == "http" || scheme == "https") { |
|
38 urlStr.remove(0, scheme.length() + 3); //remove "scheme://" |
|
39 } |
|
40 return urlStr; |
|
41 |
|
42 } |
28 |
43 |
29 QString UiUtil::loadFiletoString(const QString &name) |
44 QString UiUtil::loadFiletoString(const QString &name) |
30 { |
45 { |
31 QFile file(name); |
46 QFile file(name); |
32 file.open(QFile::ReadOnly); |
47 file.open(QFile::ReadOnly); |
73 if(url.isValid()) |
88 if(url.isValid()) |
74 return url; |
89 return url; |
75 } |
90 } |
76 } |
91 } |
77 // Might be a file. |
92 // Might be a file. |
78 if (QFile::exists(urlStr)) |
93 if (hasSchema) { |
79 return QUrl::fromLocalFile(urlStr); |
94 if (QFile::exists(urlStr)) |
80 |
95 return QUrl::fromLocalFile(urlStr); |
|
96 } |
81 // Might be a shorturl - try to detect the schema. |
97 // Might be a shorturl - try to detect the schema. |
82 if (!hasSchema) { |
98 if (!hasSchema) { |
83 int dotIndex = urlStr.indexOf(QLatin1Char('.')); |
99 int dotIndex = urlStr.indexOf(QLatin1Char('.')); |
84 if (dotIndex != -1 && !hasSpaces) { |
100 if (dotIndex != -1 && !hasSpaces) { |
85 QUrl url; |
101 QUrl url; |
86 urlStr.endsWith(".") ? ( url.setUrl(QLatin1String("http://") + urlStr + QLatin1String("com"), QUrl::TolerantMode) ) : ( url.setUrl(QLatin1String("http://") + urlStr, QUrl::TolerantMode) ); |
102 urlStr.endsWith(".") ? ( url.setUrl(QLatin1String("http://") + urlStr + QLatin1String("com"), QUrl::TolerantMode) ) : ( url.setUrl(QLatin1String("http://") + urlStr, QUrl::TolerantMode) ); |
87 if (url.isValid()) |
103 if (url.isValid()){ |
88 return url; |
104 return url; |
|
105 } |
|
106 //--Condition for Character DOT(.)-- |
|
107 else { |
|
108 QUrl url(QLatin1String(GOOGLE_SEARCH_ENGINE) + urlStr, QUrl::TolerantMode); |
|
109 if(url.isValid()) |
|
110 return url; |
|
111 } |
89 } |
112 } |
90 //The string parameter is simple text and a search should be performed. |
113 //--The string parameter is simple text and a search should be performed. Like for Special Character :\ etc.-- |
91 else { |
114 else { |
92 QUrl url(QLatin1String(GOOGLE_SEARCH_ENGINE) + urlStr, QUrl::TolerantMode); |
115 QUrl url(QLatin1String(GOOGLE_SEARCH_ENGINE) + urlStr, QUrl::TolerantMode); |
93 if(url.isValid()) |
116 if(url.isValid()) |
94 return url; |
117 return url; |
95 } |
118 } |