Changeset View
Changeset View
Standalone View
Standalone View
src/main.cpp
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Line(s) | 56 | #endif | |||
---|---|---|---|---|---|
134 | 134 | | |||
135 | const QStringList args = parser.positionalArguments(); | 135 | const QStringList args = parser.positionalArguments(); | ||
136 | QList<QUrl> urls = Dolphin::validateUris(args); | 136 | QList<QUrl> urls = Dolphin::validateUris(args); | ||
137 | 137 | | |||
138 | if (urls.isEmpty()) { | 138 | if (urls.isEmpty()) { | ||
139 | // We need at least one URL to open Dolphin | 139 | // We need at least one URL to open Dolphin | ||
140 | urls.append(Dolphin::homeUrl()); | 140 | urls.append(Dolphin::homeUrl()); | ||
141 | } | 141 | } | ||
142 | QList<QUrl> urlDirectories = QList<QUrl>(); | ||||
apol: No need to initialize with an empty list, it will be filled by default.
Just leave `QList<QUrl>… | |||||
143 | QList<QUrl> urlRegularFiles = QList<QUrl>(); | ||||
144 | | ||||
Please make url a const reference. We should also prevent a possible detaching by using qAsConst(urls): for (const QUrl &url : qAsConst(urls)) elvisangelaccio: Please make `url` a const reference. We should also prevent a possible detaching by using… | |||||
145 | for (QUrl url: urls) { | ||||
146 | if (QFileInfo(url.path()).isDir()) { | ||||
pino: toLocalFile() instead of path(), otherwise it breaks on Windows | |||||
147 | urlDirectories.append(url); | ||||
148 | } else { | ||||
149 | urlRegularFiles.append(url); | ||||
150 | } | ||||
151 | } | ||||
142 | 152 | | |||
143 | const bool splitView = parser.isSet(QStringLiteral("split")) || GeneralSettings::splitView(); | 153 | const bool splitView = parser.isSet(QStringLiteral("split")) || GeneralSettings::splitView(); | ||
144 | if (splitView && urls.size() < 2) { | 154 | if (splitView && urls.size() < 2) { | ||
145 | // Split view does only make sense if we have at least 2 URLs | 155 | // Split view does only make sense if we have at least 2 URLs | ||
146 | urls.append(urls.last()); | 156 | urls.append(urls.last()); | ||
147 | } | 157 | } | ||
148 | 158 | | |||
149 | DolphinMainWindow* mainWindow = new DolphinMainWindow(); | 159 | DolphinMainWindow* mainWindow = new DolphinMainWindow(); | ||
150 | 160 | | |||
151 | if (parser.isSet(QStringLiteral("select"))) { | 161 | if (parser.isSet(QStringLiteral("select"))) { | ||
152 | mainWindow->openFiles(urls, splitView); | 162 | mainWindow->openFiles(urls, splitView); | ||
153 | } else { | 163 | } else { | ||
154 | mainWindow->openDirectories(urls, splitView); | 164 | if (urlDirectories.size()>0) { | ||
apol: Use `!urlDirectories.isEmpty()`, it's a bit more direct. | |||||
165 | mainWindow->openDirectories(urlDirectories, splitView); | ||||
166 | } | ||||
167 | if (urlRegularFiles.size()>0) { | ||||
168 | mainWindow->openFiles(urlRegularFiles, splitView); | ||||
169 | } | ||||
155 | } | 170 | } | ||
156 | 171 | | |||
157 | mainWindow->show(); | 172 | mainWindow->show(); | ||
158 | 173 | | |||
159 | if (app.isSessionRestored()) { | 174 | if (app.isSessionRestored()) { | ||
160 | const QString className = KXmlGuiWindow::classNameOfToplevel(1); | 175 | const QString className = KXmlGuiWindow::classNameOfToplevel(1); | ||
161 | if (className == QLatin1String("DolphinMainWindow")) { | 176 | if (className == QLatin1String("DolphinMainWindow")) { | ||
162 | mainWindow->restore(1); | 177 | mainWindow->restore(1); | ||
163 | } else { | 178 | } else { | ||
164 | qCWarning(DolphinDebug) << "Unknown class " << className << " in session saved data!"; | 179 | qCWarning(DolphinDebug) << "Unknown class " << className << " in session saved data!"; | ||
165 | } | 180 | } | ||
166 | } | 181 | } | ||
167 | 182 | | |||
168 | return app.exec(); // krazy:exclude=crash; | 183 | return app.exec(); // krazy:exclude=crash; | ||
169 | } | 184 | } |
No need to initialize with an empty list, it will be filled by default.
Just leave QList<QUrl> urlDirectories;