mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Use std::vector<string> instead of QStringList in main()
In an effort to convert core to C++ structures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
c6cd10a43f
commit
4af2ec88bd
8 changed files with 80 additions and 58 deletions
|
@ -13,6 +13,7 @@
|
|||
#include "core/qt-gui.h"
|
||||
#include "core/qthelper.h"
|
||||
#include "core/subsurfacestartup.h"
|
||||
#include "core/subsurface-string.h"
|
||||
#include "core/settings/qPref.h"
|
||||
#include "core/tag.h"
|
||||
#include "desktop-widgets/mainwindow.h"
|
||||
|
@ -37,23 +38,22 @@ int main(int argc, char **argv)
|
|||
if (verbose) /* print the version if the Win32 console_init() code enabled verbose. */
|
||||
print_version();
|
||||
|
||||
int i;
|
||||
bool no_filenames = true;
|
||||
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
||||
std::unique_ptr<QApplication> app(new QApplication(argc, argv));
|
||||
QStringList files;
|
||||
QStringList importedFiles;
|
||||
std::vector<std::string> files;
|
||||
std::vector<std::string> importedFiles;
|
||||
QStringList arguments = QCoreApplication::arguments();
|
||||
|
||||
const char *default_directory = system_default_directory();
|
||||
subsurface_mkdir(default_directory);
|
||||
|
||||
for (i = 1; i < arguments.length(); i++) {
|
||||
QString a = arguments.at(i);
|
||||
if (a.isEmpty())
|
||||
for (int i = 1; i < arguments.length(); i++) {
|
||||
std::string a = arguments[i].toStdString();
|
||||
if (a.empty())
|
||||
continue;
|
||||
if (a.at(0) == '-') {
|
||||
parse_argument(qPrintable(a));
|
||||
if (a[0] == '-') {
|
||||
parse_argument(a.c_str());
|
||||
continue;
|
||||
}
|
||||
if (imported) {
|
||||
|
@ -85,21 +85,20 @@ int main(int argc, char **argv)
|
|||
init_ui();
|
||||
if (no_filenames) {
|
||||
if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) {
|
||||
QString defaultFile(prefs.default_filename);
|
||||
if (!defaultFile.isEmpty())
|
||||
files.push_back(QString(prefs.default_filename));
|
||||
if (!empty_string(prefs.default_filename))
|
||||
files.emplace_back(prefs.default_filename ? prefs.default_filename : "");
|
||||
} else if (prefs.default_file_behavior == CLOUD_DEFAULT_FILE) {
|
||||
auto cloudURL = getCloudURL();
|
||||
if (cloudURL)
|
||||
files.push_back(QString::fromStdString(*cloudURL));
|
||||
files.push_back(*cloudURL);
|
||||
}
|
||||
}
|
||||
MainWindow *m = MainWindow::instance();
|
||||
if (verbose && !files.isEmpty())
|
||||
qDebug() << "loading dive data from" << files;
|
||||
if (verbose && !files.empty())
|
||||
report_info("loading dive data from: %s", join(files, std::string(", ")).c_str());
|
||||
m->loadFiles(files);
|
||||
if (verbose && !importedFiles.isEmpty())
|
||||
qDebug() << "importing dive data from" << importedFiles;
|
||||
if (verbose && !importedFiles.empty())
|
||||
report_info("importing dive data from %s", join(importedFiles, std::string(", ")).c_str());
|
||||
m->importFiles(importedFiles);
|
||||
|
||||
if (verbose > 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue