kwave  18.07.70
Kwave::FileInfo Class Reference

#include <FileInfo.h>

Inheritance diagram for Kwave::FileInfo:
Inheritance graph
Collaboration diagram for Kwave::FileInfo:
Collaboration graph

Classes

class  PropertyTypesMap
 

Public Types

enum  Flag {
  FP_NONE = 0, FP_INTERNAL = 1, FP_READONLY = 2, FP_NO_LOAD_SAVE = 4,
  FP_FORMAT_NUMERIC = 8
}
 

Public Member Functions

 FileInfo ()
 
 FileInfo (const Kwave::MetaDataList &meta_data_list)
 
virtual ~FileInfo () Q_DECL_OVERRIDE
 
sample_index_t length () const
 
void setLength (sample_index_t length)
 
double rate () const
 
void setRate (double rate)
 
unsigned int bits () const
 
void setBits (unsigned int bits)
 
unsigned int tracks () const
 
void setTracks (unsigned int tracks)
 
bool contains (const FileProperty property) const
 
void set (FileProperty key, const QVariant &value)
 
QVariant get (FileProperty key) const
 
Flags flags (FileProperty key) const
 
bool isInternal (FileProperty key) const
 
bool canLoadSave (FileProperty key) const
 
QString name (FileProperty key) const
 
QString description (FileProperty key) const
 
FileProperty fromName (const QString &name) const
 
const QMap< FileProperty, QVariant > properties () const
 
QList< FilePropertyallKnownProperties () const
 
virtual void dump () const Q_DECL_OVERRIDE
 

Static Public Member Functions

static QString metaDataType ()
 

Private Attributes

PropertyTypesMap m_property_map
 

Additional Inherited Members

Detailed Description

Holds various properties of a file.

Definition at line 113 of file FileInfo.h.

Member Enumeration Documentation

◆ Flag

flags additional meta information about file info entries

Enumerator
FP_NONE 

no flags

FP_INTERNAL 

for internal usage only, do not show to the user

FP_READONLY 

readonly, cannot be modified by the user

FP_NO_LOAD_SAVE 

available for the GUI, but not for loading/saving

FP_FORMAT_NUMERIC 

represents a numeric value, otherwise handled as a string

Definition at line 120 of file FileInfo.h.

Constructor & Destructor Documentation

◆ FileInfo() [1/2]

Kwave::FileInfo::FileInfo ( )

Default constructor, creates an empty file info object

Definition at line 317 of file FileInfo.cpp.

References metaDataType(), Kwave::MetaData::setProperty(), and Kwave::MetaData::STDPROP_TYPE.

320 {
322 }
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
static const QString STDPROP_TYPE
Definition: MetaData.h:41
void setProperty(const QString &p, const QVariant &value)
Definition: MetaData.cpp:93
static QString metaDataType()
Definition: FileInfo.h:154
Here is the call graph for this function:

◆ FileInfo() [2/2]

Kwave::FileInfo::FileInfo ( const Kwave::MetaDataList meta_data_list)
explicit

Constructor, filters out all file global data from a list of meta data objects.

Parameters
meta_data_lista meta data list to copy from

Definition at line 325 of file FileInfo.cpp.

References FILE_INFO_PROPERTY_PREFIX, Kwave::MetaData::hasProperty(), Kwave::TypesMap< IDX, DATA >::keys(), m_property_map, metaDataType(), Kwave::TypesMap< IDX, DATA >::name(), name(), Kwave::MetaData::setProperty(), and Kwave::MetaData::STDPROP_TYPE.

327  (meta_data_list.selectByType(metaDataType()).isEmpty()) ?
329  meta_data_list.selectByType(metaDataType()).values().first()
330  ),
332 {
333  setProperty(Kwave::MetaData::STDPROP_TYPE, metaDataType());
334 
335  foreach (const Kwave::MetaData &meta_data, meta_data_list) {
336  foreach (Kwave::FileProperty key, m_property_map.keys()) {
337  QString name = FILE_INFO_PROPERTY_PREFIX +
338  m_property_map.name(key);
339  if (meta_data.hasProperty(name)) {
340  // take over each supported property
341  QVariant value = meta_data[name];
342  setProperty(name, value);
343  }
344  }
345  }
346 }
bool hasProperty(const QString &p) const
Definition: MetaData.cpp:104
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
virtual QString name() const
Definition: Plugin.cpp:196
#define FILE_INFO_PROPERTY_PREFIX
Definition: FileInfo.cpp:26
virtual MetaDataList selectByType(const QString &type) const
static const QString STDPROP_TYPE
Definition: MetaData.h:41
static QString metaDataType()
Definition: FileInfo.h:154
FileProperty
Definition: FileInfo.h:45
Here is the call graph for this function:

◆ ~FileInfo()

Kwave::FileInfo::~FileInfo ( )
virtual

Destructor

Definition at line 349 of file FileInfo.cpp.

350 {
351 }

Member Function Documentation

◆ allKnownProperties()

QList< Kwave::FileProperty > Kwave::FileInfo::allKnownProperties ( ) const

Returns a list of all known non-standard properties

Definition at line 383 of file FileInfo.cpp.

References Kwave::FileInfo::PropertyTypesMap::all(), and m_property_map.

Referenced by Kwave::SignalManager::executeCommand(), Kwave::AsciiDecoder::open(), and Kwave::AsciiEncoder::supportedProperties().

384 {
385  return m_property_map.all();
386 }
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
virtual QList< FileProperty > all() const
Definition: FileInfo.cpp:310
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bits()

unsigned int Kwave::FileInfo::bits ( ) const

returns the number of bits per sample

Definition at line 430 of file FileInfo.cpp.

References Kwave::INF_BITS_PER_SAMPLE.

Referenced by Kwave::SignalManager::bits(), dump(), Kwave::AsciiEncoder::encode(), Kwave::WavEncoder::encode(), Kwave::MP3Encoder::encode(), Kwave::FlacEncoder::encode(), Kwave::SignalManager::loadFile(), Kwave::TopWidget::metaDataChanged(), Kwave::AudiofileDecoder::open(), Kwave::OpusEncoder::open(), Kwave::SignalManager::save(), setBits(), Kwave::FileInfoDialog::setupFileInfoTab(), and Kwave::FlacDecoder::write_callback().

431 {
432  QVariant value = get(Kwave::INF_BITS_PER_SAMPLE);
433  bool ok = false;
434  unsigned int bits = value.toUInt(&ok);
435  return (ok) ? bits : 0;
436 }
unsigned int bits() const
Definition: FileInfo.cpp:430
Here is the caller graph for this function:

◆ canLoadSave()

bool Kwave::FileInfo::canLoadSave ( FileProperty  key) const
inline

Returns true if a property is intended to be saved into or loaded from a file.

Definition at line 220 of file FileInfo.h.

Referenced by Kwave::AsciiEncoder::encode(), and Kwave::Encoder::unsupportedProperties().

220  {
221  return !(flags(key) & FP_NO_LOAD_SAVE);
222  }
Flags flags(FileProperty key) const
Definition: FileInfo.h:205
Here is the caller graph for this function:

◆ contains()

bool Kwave::FileInfo::contains ( const FileProperty  property) const

Returns true if the given property exists

Definition at line 354 of file FileInfo.cpp.

References FILE_INFO_PROPERTY_PREFIX, Kwave::MetaData::hasProperty(), Kwave::TypesMap< IDX, DATA >::keys(), m_property_map, Kwave::TypesMap< IDX, DATA >::name(), and name().

Referenced by Kwave::FileInfoDialog::accept(), Kwave::FileInfoDialog::acceptEdit(), Kwave::VorbisDecoder::close(), Kwave::FileInfoDialog::compressionChanged(), dump(), Kwave::OggEncoder::encode(), Kwave::WavEncoder::encode(), Kwave::MP3Encoder::encode(), Kwave::MP3Encoder::encodeID3Tags(), Kwave::FlacEncoder::encodeMetaData(), Kwave::VorbisEncoder::encodeProperties(), Kwave::WavEncoder::fixAudiofileBrokenHeaderBug(), Kwave::SignalManager::loadFile(), Kwave::FileInfoDialog::mpegLayerChanged(), Kwave::AsciiDecoder::open(), Kwave::VorbisEncoder::open(), Kwave::VorbisDecoder::open(), Kwave::PlayBackPulseAudio::open(), Kwave::OpusDecoder::parseComment(), Kwave::MP3Decoder::parseID3Tags(), Kwave::FlacDecoder::parseVorbisComments(), properties(), Kwave::SignalManager::save(), Kwave::OpusEncoder::setupBitrate(), Kwave::FileInfoDialog::setupCompressionTab(), Kwave::FileInfoDialog::setupContentTab(), Kwave::OpusEncoder::setupEncoder(), Kwave::FileInfoDialog::setupFileInfoTab(), Kwave::FileInfoDialog::setupMiscellaneousTab(), Kwave::FileInfoDialog::setupMpegTab(), Kwave::FileInfoDialog::setupSourceTab(), and Kwave::OpusEncoder::writeOpusTags().

355 {
356  if (!m_property_map.keys().contains(key))
357  return false;
359  return hasProperty(name);
360 }
bool hasProperty(const QString &p) const
Definition: MetaData.cpp:104
QString name(FileProperty key) const
Definition: FileInfo.h:227
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
#define FILE_INFO_PROPERTY_PREFIX
Definition: FileInfo.cpp:26
QList< IDX > keys() const
Definition: TypesMap.h:150
QString name(IDX type) const
Definition: TypesMap.h:117
Here is the call graph for this function:
Here is the caller graph for this function:

◆ description()

QString Kwave::FileInfo::description ( FileProperty  key) const
inline

Returns the localized description of a property.

Definition at line 234 of file FileInfo.h.

Referenced by Kwave::FileInfoDialog::initInfo(), Kwave::CompressionWidget::initInfo(), and Kwave::FileInfoDialog::setupMiscellaneousTab().

234  {
235  return m_property_map.description(key, false);
236  }
QString description(IDX type, bool localized) const
Definition: TypesMap.h:128
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
Here is the caller graph for this function:

◆ dump()

void Kwave::FileInfo::dump ( ) const
virtual

dumps all properties to stdout, useful for debugging

Reimplemented from Kwave::MetaData.

Definition at line 460 of file FileInfo.cpp.

References bits(), contains(), DBG, Kwave::TypesMap< IDX, DATA >::keys(), length(), m_property_map, Kwave::TypesMap< IDX, DATA >::name(), name(), rate(), and tracks().

Referenced by Kwave::FileInfoDialog::accept(), and Kwave::OpusDecoder::open().

461 {
462  qDebug("--- dump of file info ---");
463  qDebug(" id = #%s", DBG(id()));
464  qDebug("default properties:");
465  qDebug(" length = %lu samples", static_cast<unsigned long int>(length()));
466  qDebug(" rate = %0.1f Hz", rate());
467  qDebug(" bits = %u", bits());
468  qDebug(" tracks = %u", tracks());
469 
470 // qDebug("labels:");
471 // foreach (Kwave::Label label, m_labels) {
472 // qDebug(" [%10lu] = '%s'", static_cast<unsigned long int>(label.pos()),
473 // DBG(label.name()));
474 // }
475 
476  qDebug("other properties:");
477  QMap<Kwave::FileProperty, QVariant>::Iterator it;
478  foreach (Kwave::FileProperty key, m_property_map.keys()) {
479  if (!contains(key)) continue;
480  QVariant val = get(key);
481  QString name = m_property_map.name(key);
482  qDebug(" '%s' = '%s'", DBG(name), DBG(val.toString()));
483 
484 // for updating the list of properties in the appendix of the handbook:
485 // QString name = m_property_map.name(key);
486 // QString descr = m_property_map.description(key, false);
487 // qDebug("\t <row>");
488 // qDebug("\t\t<entry colname='c1'>&no-i18n-tag;%s</entry>", DBG(name));
489 // qDebug("\t\t<entry colname='c2'>");
490 // qDebug("\t\t %s", DBG(descr.replace(_("\n"), _("\n\t\t "))));
491 // qDebug("\t\t</entry>");
492 // qDebug("\t </row>");
493  }
494  qDebug("-------------------------");
495 }
bool contains(const FileProperty property) const
Definition: FileInfo.cpp:354
double rate() const
Definition: FileInfo.cpp:415
QString name(FileProperty key) const
Definition: FileInfo.h:227
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
QList< IDX > keys() const
Definition: TypesMap.h:150
sample_index_t length() const
Definition: FileInfo.cpp:400
unsigned int tracks() const
Definition: FileInfo.cpp:445
QString name(IDX type) const
Definition: TypesMap.h:117
#define DBG(qs)
Definition: String.h:55
unsigned int bits() const
Definition: FileInfo.cpp:430
FileProperty
Definition: FileInfo.h:45
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flags()

Flags Kwave::FileInfo::flags ( FileProperty  key) const
inline

returns the flags of a property (meta data)

Definition at line 205 of file FileInfo.h.

Referenced by Kwave::SaveBlocksPlugin::createFileName().

205  {
206  return m_property_map.data(key);
207  }
DATA data(IDX type) const
Definition: TypesMap.h:110
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
Here is the caller graph for this function:

◆ fromName()

FileProperty Kwave::FileInfo::fromName ( const QString &  name) const
inline

Returns a file property key from a property name

Definition at line 241 of file FileInfo.h.

Referenced by Kwave::SaveBlocksPlugin::createFileName().

241  {
243  }
QString name(FileProperty key) const
Definition: FileInfo.h:227
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
IDX findFromName(const QString &name) const
Definition: TypesMap.h:101
Here is the caller graph for this function:

◆ get()

QVariant Kwave::FileInfo::get ( Kwave::FileProperty  key) const

Returns the value of a property. If the property does not exist, an empty value will be returned.

Parameters
keyidentifies the property
Returns
value of the property or empty if not found

Definition at line 372 of file FileInfo.cpp.

References FILE_INFO_PROPERTY_PREFIX, Kwave::MetaData::hasProperty(), Kwave::TypesMap< IDX, DATA >::keys(), m_property_map, Kwave::TypesMap< IDX, DATA >::name(), name(), and Kwave::MetaData::property().

Referenced by Kwave::FileInfoDialog::compressionChanged(), Kwave::SaveBlocksPlugin::createFileName(), Kwave::OggEncoder::encode(), Kwave::WavEncoder::encode(), Kwave::MP3Encoder::encode(), Kwave::MP3Encoder::encodeID3Tags(), Kwave::FlacEncoder::encodeMetaData(), Kwave::VorbisEncoder::encodeProperties(), Kwave::WavEncoder::fixAudiofileBrokenHeaderBug(), Kwave::MainWidget::fullZoom(), Kwave::FileInfoDialog::initInfoText(), Kwave::FileInfoDialog::mpegLayerChanged(), Kwave::AsciiDecoder::open(), Kwave::VorbisEncoder::open(), Kwave::VorbisDecoder::open(), Kwave::PlayBackPulseAudio::open(), Kwave::OpusDecoder::parseComment(), Kwave::MP3Decoder::parseID3Tags(), Kwave::FlacDecoder::parseVorbisComments(), Kwave::K3BExportPlugin::saveDocumentData(), Kwave::SaveBlocksPlugin::scanBlocksToSave(), Kwave::K3BExportPlugin::scanBlocksToSave(), Kwave::OpusEncoder::setupBitrate(), Kwave::OpusEncoder::setupBitrateMode(), Kwave::FileInfoDialog::setupCompressionTab(), Kwave::FileInfoDialog::setupContentTab(), Kwave::OpusEncoder::setupEncoder(), Kwave::FileInfoDialog::setupFileInfoTab(), Kwave::FileInfoDialog::setupMiscellaneousTab(), Kwave::FileInfoDialog::setupMpegTab(), Kwave::FileInfoDialog::setupSourceTab(), Kwave::SaveBlocksPlugin::start(), Kwave::FileInfoDialog::updateAvailableCompressions(), and Kwave::OpusEncoder::writeOpusTags().

373 {
374  if (!m_property_map.keys().contains(key))
375  return QVariant();
377 
378  if (!hasProperty(name)) return QVariant();
379  return property(name);
380 }
bool hasProperty(const QString &p) const
Definition: MetaData.cpp:104
QString name(FileProperty key) const
Definition: FileInfo.h:227
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
#define FILE_INFO_PROPERTY_PREFIX
Definition: FileInfo.cpp:26
QList< IDX > keys() const
Definition: TypesMap.h:150
QString name(IDX type) const
Definition: TypesMap.h:117
QVariant property(const QString &p) const
Definition: MetaData.cpp:110
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInternal()

bool Kwave::FileInfo::isInternal ( FileProperty  key) const
inline

Returns true if a property is only internal.

Definition at line 212 of file FileInfo.h.

212  {
213  return (flags(key) & FP_INTERNAL);
214  }
Flags flags(FileProperty key) const
Definition: FileInfo.h:205

◆ length()

◆ metaDataType()

static QString Kwave::FileInfo::metaDataType ( )
inlinestatic

returns the identifier of the "type" of this meta data object

Definition at line 154 of file FileInfo.h.

Referenced by Kwave::MimeData::decode(), and FileInfo().

154  {
155  return QString::fromLatin1("FILE INFO");
156  }
Here is the caller graph for this function:

◆ name()

QString Kwave::FileInfo::name ( FileProperty  key) const
inline

◆ properties()

const QMap< Kwave::FileProperty, QVariant > Kwave::FileInfo::properties ( ) const

Returns a list with all properties

Definition at line 389 of file FileInfo.cpp.

References contains(), Kwave::TypesMap< IDX, DATA >::keys(), and m_property_map.

Referenced by Kwave::AsciiEncoder::encode(), Kwave::MP3Encoder::encodeID3Tags(), Kwave::SignalManager::save(), Kwave::K3BExportPlugin::saveBlocks(), Kwave::SaveBlocksPlugin::start(), and Kwave::WavEncoder::writeInfoChunk().

390 {
391  QMap<Kwave::FileProperty, QVariant> map;
392  foreach (Kwave::FileProperty key, m_property_map.keys()) {
393  if (!contains(key)) continue;
394  map[key] = get(key);
395  }
396  return map;
397 }
bool contains(const FileProperty property) const
Definition: FileInfo.cpp:354
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
QList< IDX > keys() const
Definition: TypesMap.h:150
FileProperty
Definition: FileInfo.h:45
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rate()

◆ set()

void Kwave::FileInfo::set ( Kwave::FileProperty  key,
const QVariant &  value 
)

Sets a property to a new value. If the property does not already exist, a new one will be added to the info. If an empty value is passed, the property will be removed if exists.

Parameters
keyidentifies the property
valuea QVariant with the new value

Definition at line 363 of file FileInfo.cpp.

References FILE_INFO_PROPERTY_PREFIX, Kwave::TypesMap< IDX, DATA >::keys(), m_property_map, Kwave::TypesMap< IDX, DATA >::name(), name(), and Kwave::MetaData::setProperty().

Referenced by Kwave::FileInfoDialog::accept(), Kwave::FileInfoDialog::acceptEdit(), Kwave::VorbisDecoder::close(), Kwave::OpusDecoder::close(), Kwave::WavEncoder::encode(), Kwave::MimeData::encode(), Kwave::SignalManager::executeCommand(), Kwave::SignalManager::loadFile(), Kwave::AudiofileDecoder::open(), Kwave::AsciiDecoder::open(), Kwave::MP3Decoder::open(), Kwave::FlacDecoder::open(), Kwave::WavDecoder::open(), Kwave::VorbisDecoder::open(), Kwave::OpusDecoder::open(), Kwave::OpusDecoder::parseComment(), Kwave::OggDecoder::parseHeader(), Kwave::MP3Decoder::parseID3Tags(), Kwave::MP3Decoder::parseMp3Header(), Kwave::OpusDecoder::parseOpusHead(), Kwave::VorbisDecoder::parseTag(), Kwave::FlacDecoder::parseVorbisComments(), Kwave::SignalManager::save(), Kwave::K3BExportPlugin::saveBlocks(), Kwave::FileContext::saveFileAs(), Kwave::FileInfoDialog::setupFileInfoTab(), Kwave::SaveBlocksPlugin::start(), Kwave::RecordPlugin::startRecording(), and Kwave::MP3EncoderDialog::testSettings().

364 {
365  if (!m_property_map.keys().contains(key))
366  return;
368  setProperty(name, value);
369 }
QString name(FileProperty key) const
Definition: FileInfo.h:227
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
#define FILE_INFO_PROPERTY_PREFIX
Definition: FileInfo.cpp:26
QList< IDX > keys() const
Definition: TypesMap.h:150
void setProperty(const QString &p, const QVariant &value)
Definition: MetaData.cpp:93
QString name(IDX type) const
Definition: TypesMap.h:117
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBits()

void Kwave::FileInfo::setBits ( unsigned int  bits)

◆ setLength()

◆ setRate()

◆ setTracks()

◆ tracks()

Member Data Documentation

◆ m_property_map

PropertyTypesMap Kwave::FileInfo::m_property_map
private

map with properties and their names and descriptions

Definition at line 277 of file FileInfo.h.

Referenced by allKnownProperties(), contains(), dump(), FileInfo(), get(), properties(), and set().


The documentation for this class was generated from the following files: