Commit 3773971a authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Tags can now be added

parent 2399aee5
......@@ -2,6 +2,7 @@
#include <QTime>
#include <QPushButton>
#include <QStringListModel>
#include <QInputDialog>
#include "MediaProperty.h"
#include "ui_MediaProperty.h"
......@@ -31,6 +32,8 @@ MediaProperty::MediaProperty( Media* media, QWidget *parent ) :
QStringListModel* model = new QStringListModel( media->getMetaTags(), this );
ui->metaTagsView->setModel( model );
connect( ui->addTagButton, SIGNAL( clicked() ), this, SLOT( addTagRequired() ) );
}
MediaProperty::~MediaProperty()
......@@ -54,5 +57,26 @@ void MediaProperty::changeEvent( QEvent *e )
void MediaProperty::apply()
{
QStringListModel* model = dynamic_cast<QStringListModel*>( ui->metaTagsView->model() );
if ( model == NULL )
return ;
m_media->setMetaTags( model->stringList() );
}
void MediaProperty::addTagRequired()
{
bool ok;
QString newTags = QInputDialog::getText( this, tr( "New tags edition" ),
tr( "Enter tags (you can enter multiple tags, separated by a comma)" ),
QLineEdit::Normal, "", &ok );
if ( ok == true && newTags.length() > 0 )
{
QStringListModel* model = dynamic_cast<QStringListModel*>( ui->metaTagsView->model() );
if ( model == NULL )
return ;
QStringList list = model->stringList();
QStringList toAdd = newTags.split( ",", QString::SkipEmptyParts );
list.append( toAdd );
model->setStringList( list );
ui->metaTagsView->update( QModelIndex() );
}
}
......@@ -43,6 +43,7 @@ protected:
private slots:
void apply();
void addTagRequired();
private:
Ui::MediaProperty* ui;
......
......@@ -14,7 +14,7 @@
<string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<item row="0" column="0" colspan="3">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
......@@ -57,30 +57,8 @@
</layout>
</widget>
</item>
<item row="4" column="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="2">
<spacer name="horizontalSpacer">
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
......@@ -92,7 +70,7 @@
</property>
</spacer>
</item>
<item row="0" column="2" colspan="2">
<item row="0" column="4" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
......@@ -181,8 +159,18 @@
</layout>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Metatags :</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="6">
<widget class="QListView" name="metaTagsView"/>
</item>
<item row="3" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
......@@ -194,13 +182,32 @@
</property>
</spacer>
</item>
<item row="3" column="0" colspan="6">
<widget class="QListView" name="metaTagsView"/>
<item row="3" column="5">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<item row="1" column="1">
<widget class="QToolButton" name="addTagButton">
<property name="text">
<string>Metatags :</string>
<string>...</string>
</property>
</widget>
</item>
......
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