diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-14 13:25:44 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-14 14:35:19 +0100 |
commit | fd7cff5da4b33be1e7606c516f7dda00397600b8 (patch) | |
tree | a8664dbed85bca9399189f91e9ed7bad68894c4b /examples/imapresource/imapserverproxy.h | |
parent | bcbde00d40d618eabba263f28bb88c713cbffb5e (diff) | |
download | sink-fd7cff5da4b33be1e7606c516f7dda00397600b8.tar.gz sink-fd7cff5da4b33be1e7606c516f7dda00397600b8.zip |
Made the use of the folder struct a bit more expressive
Diffstat (limited to 'examples/imapresource/imapserverproxy.h')
-rw-r--r-- | examples/imapresource/imapserverproxy.h | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h index 6e6626e..22527c0 100644 --- a/examples/imapresource/imapserverproxy.h +++ b/examples/imapresource/imapserverproxy.h | |||
@@ -59,35 +59,64 @@ struct Message { | |||
59 | 59 | ||
60 | struct Folder { | 60 | struct Folder { |
61 | Folder() = default; | 61 | Folder() = default; |
62 | Folder(QList<QString> pathParts_, const QString &path_, const QChar &separator_, bool noselect_) | 62 | Folder(const QString &path, const QChar &separator, bool noselect_) |
63 | : pathParts(pathParts_), | 63 | : noselect(noselect_), |
64 | path(path_), | 64 | mPath(path), |
65 | separator(separator_), | 65 | pathParts(path.split(separator)), |
66 | noselect(noselect_) | 66 | mSeparator(separator) |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | Folder(const QString &path_) | 70 | Folder(const QString &path_) |
71 | : path(path_) | 71 | : mPath(path_) |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | QString normalizedPath() const | 75 | QString normalizedPath() const |
76 | { | 76 | { |
77 | return pathParts.join('/'); | 77 | return path('/'); |
78 | } | ||
79 | |||
80 | QString path(const QChar &s) const | ||
81 | { | ||
82 | Q_ASSERT(!s.isNull()); | ||
83 | return pathParts.join(s); | ||
84 | } | ||
85 | |||
86 | QString path() const | ||
87 | { | ||
88 | Q_ASSERT(!mPath.isEmpty()); | ||
89 | return mPath; | ||
78 | } | 90 | } |
79 | 91 | ||
80 | QString parentPath() const | 92 | QString parentPath() const |
81 | { | 93 | { |
94 | Q_ASSERT(!mSeparator.isNull()); | ||
82 | auto parts = pathParts; | 95 | auto parts = pathParts; |
83 | parts.removeLast(); | 96 | parts.removeLast(); |
84 | return parts.join(separator); | 97 | return parts.join(mSeparator); |
98 | } | ||
99 | |||
100 | QString normalizedParentPath() const | ||
101 | { | ||
102 | Q_ASSERT(!pathParts.isEmpty()); | ||
103 | auto parts = pathParts; | ||
104 | parts.removeLast(); | ||
105 | return parts.join('/'); | ||
106 | } | ||
107 | |||
108 | QString name() const | ||
109 | { | ||
110 | Q_ASSERT(!pathParts.isEmpty()); | ||
111 | return pathParts.last(); | ||
85 | } | 112 | } |
86 | 113 | ||
87 | QList<QString> pathParts; | ||
88 | QString path; | ||
89 | QChar separator; | ||
90 | bool noselect = false; | 114 | bool noselect = false; |
115 | |||
116 | private: | ||
117 | QString mPath; | ||
118 | QList<QString> pathParts; | ||
119 | QChar mSeparator; | ||
91 | }; | 120 | }; |
92 | 121 | ||
93 | struct SelectResult { | 122 | struct SelectResult { |