Commit 896bbc2b authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Tag deletion is functionnal

parent d5606f51
......@@ -33,7 +33,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() ) );
connect( ui->addTagsButton, SIGNAL( clicked() ), this, SLOT( addTagsRequired() ) );
connect( ui->deleteTagsButton, SIGNAL( clicked() ), this, SLOT( removeTagsRequired() ) );
}
MediaProperty::~MediaProperty()
......@@ -62,7 +63,7 @@ void MediaProperty::apply()
m_media->setMetaTags( model->stringList() );
}
void MediaProperty::addTagRequired()
void MediaProperty::addTagsRequired()
{
bool ok;
QString newTags = QInputDialog::getText( this, tr( "New tags edition" ),
......@@ -79,3 +80,20 @@ void MediaProperty::addTagRequired()
model->setStringList( list );
}
}
void MediaProperty::removeTagsRequired()
{
QStringListModel* model = dynamic_cast<QStringListModel*>( ui->metaTagsView->model() );
if ( model == NULL )
return ;
QItemSelectionModel* selected = ui->metaTagsView->selectionModel();
QModelIndexList listSelected = selected->selectedIndexes();
QStringList list = model->stringList();
while ( listSelected.empty() == false )
{
QVariant elem = model->data( listSelected.first(), Qt::DisplayRole );
list.removeOne( elem.toString() );
listSelected.removeFirst();
}
model->setStringList( list );
}
......@@ -43,7 +43,8 @@ protected:
private slots:
void apply();
void addTagRequired();
void addTagsRequired();
void removeTagsRequired();
private:
Ui::MediaProperty* ui;
......
......@@ -14,7 +14,7 @@
<string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<item row="0" column="0" colspan="4">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
......@@ -57,7 +57,7 @@
</layout>
</widget>
</item>
<item row="0" column="3">
<item row="0" column="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -70,7 +70,7 @@
</property>
</spacer>
</item>
<item row="0" column="4" colspan="2">
<item row="0" column="5" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
......@@ -166,10 +166,14 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="6">
<widget class="QListView" name="metaTagsView"/>
<item row="2" column="0" colspan="7">
<widget class="QListView" name="metaTagsView">
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item row="3" column="4">
<item row="3" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -182,7 +186,7 @@
</property>
</spacer>
</item>
<item row="3" column="5">
<item row="3" column="6">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
......@@ -205,7 +209,14 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="addTagButton">
<widget class="QToolButton" name="addTagsButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="deleteTagsButton">
<property name="text">
<string>...</string>
</property>
......
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