13 namespace swift::misc::network
21 : m_name(name), m_url(url), m_size(size)
26 if (!this->
hasName()) {
return {}; }
32 if (name.isEmpty()) {
return false; }
34 if (name.startsWith(this->getBaseName(), Qt::CaseInsensitive)) {
return true; }
35 if (this->
getBaseName().startsWith(name, Qt::CaseInsensitive)) {
return true; }
56 if (m_created < 1) {
return {}; }
57 const QDateTime dt = QDateTime::fromMSecsSinceEpoch(m_created);
58 return dt.toString(
"yyyy-MM-dd HH:mm:ss");
64 return "Name: " + m_name +
" description: " + m_description +
" size: " + QString::number(m_size) +
71 if (index.
isMyself()) {
return QVariant::fromValue(*
this); }
76 case IndexName:
return QVariant::fromValue(m_name);
77 case IndexDescription:
return QVariant::fromValue(m_description);
78 case IndexUrl:
return QVariant::fromValue(m_url);
79 case IndexSize:
return QVariant::fromValue(m_size);
99 case IndexName: this->
setName(variant.value<QString>());
break;
100 case IndexDescription: this->
setDescription(variant.value<QString>());
break;
102 case IndexSize: this->
setSize(variant.toInt());
break;
110 file.
setName(json.value(
"name").toString());
112 file.
setUrl(json.value(
"url").toString());
113 const qint64 size = json.value(
"size").toInt();
115 const qint64 created = json.value(
"tsCreated").toInt();
116 const qint64 lastUpdated = json.value(
"tsLastUpdated").toInt();
117 file.m_created = created;
static QString humanReadableFileSize(qint64 size)
Human readable (GB, MB, ..) file size.
static bool isExecutableFile(const QString &fileName)
Executable file (decided by appendix)
static bool isSwiftInstaller(const QString &fileName)
swift installer
Non-owning reference to a CPropertyIndex with a subset of its features.
Q_REQUIRED_RESULT CPropertyIndexRef copyFrontRemoved() const
Copy with first element removed.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QString getFormattedUtcTimestampYmdhms() const
As yyyy MM dd HH mm ss.
static bool canHandleIndex(CPropertyIndexRef index)
Can given index be handled.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void setMSecsSinceEpoch(qint64 mSecsSinceEpoch)
Timestamp as ms value.
ColumnIndex
Base class enums.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString convertToQString(bool i18n=false) const
Cast as QString.
QString getFormattedCreatedYmdhms() const
Created timestamp.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
bool matchesBaseName(const QString &baseName) const
Matching name?
bool isSwiftInstaller() const
swift installer
void setDescription(const QString &description)
Description.
QString getBaseName() const
Name with directory stripped.
CUrl getSmartUrl() const
Automatically concatenates the name if missing.
void setSize(qint64 size)
Set size.
bool isExecutableFile() const
Executable file (decided by appendix)
void setName(const QString &name)
Name.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
qint64 getSize() const
Get size.
QString getSizeHumanReadable() const
Human readable (GB, MB, ..) file size.
const CUrl & getUrl() const
Get URL.
bool hasName() const
Has name?
CRemoteFile()=default
Constructor.
bool hasUrl() const
Has an URL.
QString getBaseNameAndSize() const
Name + human readable size.
static CRemoteFile fromDatabaseJson(const QJsonObject &json)
Role from DB JSON.
void setUrl(const CUrl &url)
Set URL.
const QString & getName() const
Name.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
CUrl withAppendedPath(const QString &path) const
Append path.
QString getFullUrl(bool withQuery=true) const
Qualified name.
SWIFT_MISC_EXPORT bool caseInsensitiveStringCompare(const QString &c1, const QString &c2)
Case insensitive string compare.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.