mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
media: add small C++ helper describing a picture struct
By using a std::string instead of a C-string, memory management becomes so much simpler! This class will be used for keeping track of deleted/added pictures in the undo system. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
6f8cc5aafe
commit
fe82cb32b9
4 changed files with 56 additions and 0 deletions
27
core/pictureobj.cpp
Normal file
27
core/pictureobj.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "pictureobj.h"
|
||||
#include "qthelper.h"
|
||||
|
||||
PictureObj::PictureObj() : offset({ 0 }), location({ 0 })
|
||||
{
|
||||
}
|
||||
|
||||
PictureObj::PictureObj(const picture &pic) : filename(pic.filename), offset(pic.offset), location(pic.location)
|
||||
{
|
||||
}
|
||||
|
||||
picture PictureObj::toCore() const
|
||||
{
|
||||
return picture {
|
||||
strdup(filename.c_str()),
|
||||
offset,
|
||||
location
|
||||
};
|
||||
}
|
||||
|
||||
bool PictureObj::operator<(const PictureObj &p2) const
|
||||
{
|
||||
if (offset.seconds != p2.offset.seconds)
|
||||
return offset.seconds < p2.offset.seconds;
|
||||
return strcmp(filename.c_str(), p2.filename.c_str()) < 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue