Changeset View
Changeset View
Standalone View
Standalone View
src/gdriveurl.cpp
Show All 15 Lines | |||||
16 | * You should have received a copy of the GNU General Public License along | 16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | 17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | * | 19 | * | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include "gdriveurl.h" | 22 | #include "gdriveurl.h" | ||
23 | 23 | | |||
24 | #include <KLocalizedString> | ||||
25 | | ||||
24 | const QString GDriveUrl::Scheme = QStringLiteral("gdrive"); | 26 | const QString GDriveUrl::Scheme = QStringLiteral("gdrive"); | ||
27 | const QString GDriveUrl::SharedDrivesDir = i18n("Shared Drives"); | ||||
elvisangelaccio: "Shared Drives" should be translated if possible. | |||||
Sorry, this makes gdriveurl depend on ki18n (e.g. when building urltest). We should call i18n() directly in KIOGDrive::fetchSharedDrivesRootEntry() imho. BTW: does this translation even works? Isn't "Shared Drives" part of the path provided by Google? If we translate it on our side, how can we be sure that Google "understands" our translation? elvisangelaccio: Sorry, this makes gdriveurl depend on ki18n (e.g. when building `urltest`). We should call i18n… | |||||
I moved the translating to kio_gdrive.cpp, using it only for UDS_DISPLAY_NAME. All operations on Shared Drives are done by id, this string or its path is practically only user facing. barchiesi: I moved the translating to kio_gdrive.cpp, using it only for `UDS_DISPLAY_NAME`. All operations… | |||||
25 | const QString GDriveUrl::TrashDir = QStringLiteral("trash"); | 28 | const QString GDriveUrl::TrashDir = QStringLiteral("trash"); | ||
26 | 29 | | |||
27 | GDriveUrl::GDriveUrl(const QUrl &url) | 30 | GDriveUrl::GDriveUrl(const QUrl &url) | ||
28 | : m_url(url) | 31 | : m_url(url) | ||
29 | { | 32 | { | ||
30 | const auto path = url.adjusted(QUrl::StripTrailingSlash).path(); | 33 | const auto path = url.adjusted(QUrl::StripTrailingSlash).path(); | ||
31 | m_components = path.split(QLatin1Char('/'), QString::SkipEmptyParts); | 34 | m_components = path.split(QLatin1Char('/'), QString::SkipEmptyParts); | ||
32 | } | 35 | } | ||
Show All 26 Lines | 61 | { | |||
59 | return m_components.length() == 1; | 62 | return m_components.length() == 1; | ||
60 | } | 63 | } | ||
61 | 64 | | |||
62 | bool GDriveUrl::isTopLevel() const | 65 | bool GDriveUrl::isTopLevel() const | ||
63 | { | 66 | { | ||
64 | return m_components.length() == 2; | 67 | return m_components.length() == 2; | ||
65 | } | 68 | } | ||
66 | 69 | | |||
70 | bool GDriveUrl::isSharedDrivesRoot() const | ||||
71 | { | ||||
72 | return m_components.length() == 2 && m_components.at(1) == SharedDrivesDir; | ||||
73 | } | ||||
74 | | ||||
75 | bool GDriveUrl::isSharedDrive() const | ||||
76 | { | ||||
77 | return m_components.length() == 3 && m_components.at(1) == SharedDrivesDir; | ||||
78 | } | ||||
79 | | ||||
67 | bool GDriveUrl::isTrashDir() const | 80 | bool GDriveUrl::isTrashDir() const | ||
68 | { | 81 | { | ||
69 | return m_components.length() == 2 && m_components.at(1) == TrashDir; | 82 | return m_components.length() == 2 && m_components.at(1) == TrashDir; | ||
70 | } | 83 | } | ||
71 | 84 | | |||
72 | bool GDriveUrl::isTrashed() const | 85 | bool GDriveUrl::isTrashed() const | ||
73 | { | 86 | { | ||
74 | return m_components.length() > 2 && m_components.at(1) == TrashDir; | 87 | return m_components.length() > 2 && m_components.at(1) == TrashDir; | ||
Show All 23 Lines |
"Shared Drives" should be translated if possible.