mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: convert divesite strings to std::string
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3394ce7931
commit
160f06db8d
38 changed files with 181 additions and 222 deletions
|
|
@ -76,7 +76,7 @@ AddDiveSite::AddDiveSite(const QString &name)
|
|||
{
|
||||
setText(Command::Base::tr("add dive site"));
|
||||
sitesToAdd.push_back(std::make_unique<dive_site>());
|
||||
sitesToAdd.back()->name = copy_qstring(name);
|
||||
sitesToAdd.back()->name = name.toStdString();
|
||||
}
|
||||
|
||||
bool AddDiveSite::workToBeDone()
|
||||
|
|
@ -175,24 +175,15 @@ void PurgeUnusedDiveSites::undo()
|
|||
sitesToRemove = addDiveSites(sitesToAdd);
|
||||
}
|
||||
|
||||
// Helper function: swap C and Qt string
|
||||
static void swap(char *&c, QString &q)
|
||||
{
|
||||
QString s = c;
|
||||
free(c);
|
||||
c = copy_qstring(q);
|
||||
q = s;
|
||||
}
|
||||
|
||||
EditDiveSiteName::EditDiveSiteName(dive_site *dsIn, const QString &name) : ds(dsIn),
|
||||
value(name)
|
||||
value(name.toStdString())
|
||||
{
|
||||
setText(Command::Base::tr("Edit dive site name"));
|
||||
}
|
||||
|
||||
bool EditDiveSiteName::workToBeDone()
|
||||
{
|
||||
return value != QString(ds->name);
|
||||
return value != ds->name;
|
||||
}
|
||||
|
||||
void EditDiveSiteName::redo()
|
||||
|
|
@ -208,14 +199,14 @@ void EditDiveSiteName::undo()
|
|||
}
|
||||
|
||||
EditDiveSiteDescription::EditDiveSiteDescription(dive_site *dsIn, const QString &description) : ds(dsIn),
|
||||
value(description)
|
||||
value(description.toStdString())
|
||||
{
|
||||
setText(Command::Base::tr("Edit dive site description"));
|
||||
}
|
||||
|
||||
bool EditDiveSiteDescription::workToBeDone()
|
||||
{
|
||||
return value != QString(ds->description);
|
||||
return value != ds->description;
|
||||
}
|
||||
|
||||
void EditDiveSiteDescription::redo()
|
||||
|
|
@ -231,14 +222,14 @@ void EditDiveSiteDescription::undo()
|
|||
}
|
||||
|
||||
EditDiveSiteNotes::EditDiveSiteNotes(dive_site *dsIn, const QString ¬es) : ds(dsIn),
|
||||
value(notes)
|
||||
value(notes.toStdString())
|
||||
{
|
||||
setText(Command::Base::tr("Edit dive site notes"));
|
||||
}
|
||||
|
||||
bool EditDiveSiteNotes::workToBeDone()
|
||||
{
|
||||
return value != QString(ds->notes);
|
||||
return value != ds->notes;
|
||||
}
|
||||
|
||||
void EditDiveSiteNotes::redo()
|
||||
|
|
@ -400,7 +391,7 @@ ApplyGPSFixes::ApplyGPSFixes(const std::vector<DiveAndLocation> &fixes)
|
|||
siteLocations.push_back({ ds, dl.location });
|
||||
}
|
||||
} else {
|
||||
ds = create_dive_site(qPrintable(dl.name), divelog.sites);
|
||||
ds = create_dive_site(dl.name.toStdString(), divelog.sites);
|
||||
ds->location = dl.location;
|
||||
add_dive_to_dive_site(dl.d, ds);
|
||||
dl.d->dive_site = nullptr; // This will be set on redo()
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ private:
|
|||
void redo() override;
|
||||
|
||||
dive_site *ds;
|
||||
QString value; // Value to be set
|
||||
std::string value; // Value to be set
|
||||
};
|
||||
|
||||
class EditDiveSiteDescription : public Base {
|
||||
|
|
@ -101,7 +101,7 @@ private:
|
|||
void redo() override;
|
||||
|
||||
dive_site *ds;
|
||||
QString value; // Value to be set
|
||||
std::string value; // Value to be set
|
||||
};
|
||||
|
||||
class EditDiveSiteNotes : public Base {
|
||||
|
|
@ -113,7 +113,7 @@ private:
|
|||
void redo() override;
|
||||
|
||||
dive_site *ds;
|
||||
QString value; // Value to be set
|
||||
std::string value; // Value to be set
|
||||
};
|
||||
|
||||
class EditDiveSiteCountry : public Base {
|
||||
|
|
|
|||
|
|
@ -374,14 +374,11 @@ void EditDiveSite::redo()
|
|||
EditDiveSite::undo(); // Undo and redo do the same
|
||||
}
|
||||
|
||||
static struct dive_site *createDiveSite(const QString &name)
|
||||
static struct dive_site *createDiveSite(const std::string &name)
|
||||
{
|
||||
struct dive_site *ds = new dive_site;
|
||||
struct dive_site *old = current_dive ? current_dive->dive_site : nullptr;
|
||||
if (old) {
|
||||
copy_dive_site(old, ds);
|
||||
free(ds->name); // Free name, as we will overwrite it with our own version
|
||||
}
|
||||
if (current_dive && current_dive->dive_site)
|
||||
*ds = *current_dive->dive_site;
|
||||
|
||||
// If the current dive has a location, use that as location for the new dive site
|
||||
if (current_dive) {
|
||||
|
|
@ -390,12 +387,12 @@ static struct dive_site *createDiveSite(const QString &name)
|
|||
ds->location = loc;
|
||||
}
|
||||
|
||||
ds->name = copy_qstring(name);
|
||||
ds->name = name;
|
||||
return ds;
|
||||
}
|
||||
|
||||
EditDiveSiteNew::EditDiveSiteNew(const QString &newName, bool currentDiveOnly) :
|
||||
EditDiveSite(createDiveSite(newName), currentDiveOnly),
|
||||
EditDiveSite(createDiveSite(newName.toStdString()), currentDiveOnly),
|
||||
diveSiteToAdd(value),
|
||||
diveSiteToRemove(nullptr)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue