Commit fbcb447a authored by Urs Fleisch's avatar Urs Fleisch
Browse files

QML: Make missing scripting functions available from QML.

parent 3165dc6c
......@@ -179,6 +179,8 @@ Kid3Application::Kid3Application(ICorePlatformTools* platformTools,
connect(m_selection, SIGNAL(singleFileChanged()),
this, SLOT(updateCoverArtImageId()));
connect(m_selection, SIGNAL(fileNameModified()),
this, SIGNAL(selectedFilesUpdated()));
initPlugins();
m_batchImporter->setImporters(m_importers, m_trackDataModel);
......@@ -2732,7 +2734,7 @@ void Kid3Application::convertToId3v23()
* @param name name of frame (e.g. "Artist")
*/
QString Kid3Application::getFrame(Frame::TagVersion tagMask,
const QString& name)
const QString& name) const
{
QString frameName(name);
QString dataFileName;
......@@ -2775,6 +2777,26 @@ QString Kid3Application::getFrame(Frame::TagVersion tagMask,
}
}
/**
* Get names and values of all frames.
*
* @param tagMask tag bit (1 for tag 1, 2 for tag 2)
*
* @return map containing frame values.
*/
QVariantMap Kid3Application::getAllFrames(Frame::TagVersion tagMask) const
{
QVariantMap map;
FrameTableModel* ft = (tagMask & Frame::TagV2) ? m_framesV2Model :
m_framesV1Model;
for (FrameCollection::const_iterator it = ft->frames().begin();
it != ft->frames().end();
++it) {
map.insert(it->getName(), it->getValue());
}
return map;
}
/**
* Set value of frame.
* For tag 2 (@a tagMask 2), if no frame with @a name exists, a new frame
......
......@@ -513,8 +513,20 @@ public:
*
* @param tagMask tag bit (1 for tag 1, 2 for tag 2)
* @param name name of frame (e.g. "artist")
*
* @return value of frame.
*/
Q_INVOKABLE QString getFrame(Frame::TagVersion tagMask,
const QString& name) const;
/**
* Get names and values of all frames.
*
* @param tagMask tag bit (1 for tag 1, 2 for tag 2)
*
* @return map containing frame values.
*/
QString getFrame(Frame::TagVersion tagMask, const QString& name);
Q_INVOKABLE QVariantMap getAllFrames(Frame::TagVersion tagMask) const;
/**
* Set value of frame.
......@@ -527,8 +539,8 @@ public:
* @param name name of frame (e.g. "artist")
* @param value value of frame
*/
bool setFrame(Frame::TagVersion tagMask, const QString& name,
const QString& value);
Q_INVOKABLE bool setFrame(Frame::TagVersion tagMask, const QString& name,
const QString& value);
/**
* Format a filename if format while editing is switched on.
......
......@@ -198,8 +198,10 @@ QString TaggedFileSelection::getFilename() const
*/
void TaggedFileSelection::setFilename(const QString& fn)
{
if (m_state.m_singleFile && !fn.isEmpty()) {
if (m_state.m_singleFile && !fn.isEmpty() &&
m_state.m_singleFile->getFilename() != fn) {
m_state.m_singleFile->setFilename(fn);
emit fileNameModified();
}
}
......
......@@ -220,6 +220,11 @@ signals:
*/
void singleFileChanged();
/**
* Emitted when the file name is modified.
*/
void fileNameModified();
private:
struct State {
State() : m_singleFile(0), m_tagV1SupportedCount(0), m_fileCount(0),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment