Changeset View
Changeset View
Standalone View
Standalone View
app/galleryhistory.cpp
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
46 | static QString entryData(const FileTreeBranch *branch, const QString &relPath) | 46 | static QString entryData(const FileTreeBranch *branch, const QString &relPath) | ||
47 | { | 47 | { | ||
48 | return (branch->name() + GALLERY_PATH_SEP + relPath); | 48 | return (branch->name() + GALLERY_PATH_SEP + relPath); | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | // Data for display - what the user sees | 51 | // Data for display - what the user sees | ||
52 | static QString entryName(const FileTreeBranch *branch, const QString &relPath) | 52 | static QString entryName(const FileTreeBranch *branch, const QString &relPath) | ||
53 | { | 53 | { | ||
54 | QString name = QString::null; | 54 | QString name; | ||
mlaurent: it's not necessary to initialize to QString() when we create QString directly | |||||
55 | 55 | | |||
56 | FileTreeView *view = static_cast<FileTreeView *>(branch->root()->treeWidget()); | 56 | FileTreeView *view = static_cast<FileTreeView *>(branch->root()->treeWidget()); | ||
57 | if (view == nullptr) { | 57 | if (view == nullptr) { | ||
58 | return (relPath); // get view that this belongs to | 58 | return (relPath); // get view that this belongs to | ||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | if (view->branches().count() > 1 || relPath == "/") { // multiple galleries, or | 61 | if (view->branches().count() > 1 || relPath == "/") { // multiple galleries, or | ||
62 | // at the branch root | 62 | // at the branch root | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 102 | } else { // if not already present, | |||
105 | setCurrentIndex(0); | 105 | setCurrentIndex(0); | ||
106 | } | 106 | } | ||
107 | 107 | | |||
108 | setEnabled(true); // now have at least 1 item | 108 | setEnabled(true); // now have at least 1 item | ||
109 | } | 109 | } | ||
110 | 110 | | |||
111 | void GalleryHistory::slotActivated(int idx) | 111 | void GalleryHistory::slotActivated(int idx) | ||
112 | { | 112 | { | ||
113 | QString branchName = QString::null; | 113 | QString branchName; | ||
114 | 114 | | |||
115 | QString relPath = itemData(idx).toString(); | 115 | QString relPath = itemData(idx).toString(); | ||
116 | int ix = relPath.indexOf(GALLERY_PATH_SEP); // is the separator present? | 116 | int ix = relPath.indexOf(GALLERY_PATH_SEP); // is the separator present? | ||
117 | if (ix > 0) { // (multiple gallery roots) | 117 | if (ix > 0) { // (multiple gallery roots) | ||
118 | branchName = relPath.left(ix); // split into root and path | 118 | branchName = relPath.left(ix); // split into root and path | ||
119 | relPath = relPath.mid(ix + 3); | 119 | relPath = relPath.mid(ix + 3); | ||
120 | } | 120 | } | ||
121 | 121 | | |||
122 | if (!relPath.endsWith("/")) { | 122 | if (!relPath.endsWith("/")) { | ||
123 | relPath = "/"; // it's the root | 123 | relPath = "/"; // it's the root | ||
124 | } | 124 | } | ||
125 | emit pathSelected(branchName, relPath); | 125 | emit pathSelected(branchName, relPath); | ||
126 | } | 126 | } |
it's not necessary to initialize to QString() when we create QString directly