[KPhotoAlbum] Mass-removal of tags
Robert L Krawitz
rlk at alum.mit.edu
Thu Mar 16 03:13:03 GMT 2006
I finally got sufficiently tired of not having a way to remove tags
from multiple images that I hacked up a prototype.
Index: AnnotationDialog/ListSelect.h
===================================================================
--- AnnotationDialog/ListSelect.h (revision 519053)
+++ AnnotationDialog/ListSelect.h (working copy)
@@ -44,7 +44,9 @@
void setSelection( const QStringList& list );
QStringList selection();
void setShowMergeCheckbox( bool b );
+ void setShowRemoveCheckbox( bool b );
bool doMerge() const;
+ bool doRemove() const;
bool isAND() const;
enum Mode {INPUT, SEARCH};
@@ -61,16 +63,20 @@
void setViewSortType( Options::ViewSortType );
void slotSortDate();
void slotSortAlpha();
+ void checkBoxStateChanged( int state );
+ void removeCheckBoxStateChanged( int state );
protected:
virtual bool eventFilter( QObject* object, QEvent* event );
private:
+
QLabel* _label;
QString _category;
CompletableLineEdit* _lineEdit;
QListBox* _listBox;
QCheckBox* _checkBox;
+ QCheckBox* _removeCheckBox;
Mode _mode;
QListBoxItem* _none;
QToolButton* _alphaSort;
Index: AnnotationDialog/AnnotationDialog.cpp
===================================================================
--- AnnotationDialog/AnnotationDialog.cpp (revision 519053)
+++ AnnotationDialog/AnnotationDialog.cpp (working copy)
@@ -314,6 +314,8 @@
if ( (*it)->selection().count() != 0 ) {
if ( (*it)->doMerge() )
info->addOption( (*it)->category(), (*it)->selection() );
+ else if ( (*it)->doRemove() )
+ info->removeOption( (*it)->category(), (*it)->selection() );
else
info->setOption( (*it)->category(), (*it)->selection() );
}
Index: AnnotationDialog/ListSelect.cpp
===================================================================
--- AnnotationDialog/ListSelect.cpp (revision 519053)
+++ AnnotationDialog/ListSelect.cpp (working copy)
@@ -156,7 +156,18 @@
return 0;
}
+void ListSelect::checkBoxStateChanged( int )
+{
+ if (_checkBox->isChecked() && _removeCheckBox->isChecked())
+ _removeCheckBox->setChecked(false);
+}
+void ListSelect::removeCheckBoxStateChanged( int )
+{
+ if (_checkBox->isChecked() && _removeCheckBox->isChecked())
+ _checkBox->setChecked(false);
+}
+
ListSelect::ListSelect( const QString& category, QWidget* parent, const char* name )
: QWidget( parent, name ), _category( category )
{
@@ -180,9 +191,18 @@
// Merge CheckBox
QHBoxLayout* lay2 = new QHBoxLayout( layout, 6 );
_checkBox = new QCheckBox( QString(), this );
+ connect( _checkBox, SIGNAL( stateChanged( int ) ), this,
+ SLOT(checkBoxStateChanged(int) ) );
lay2->addWidget( _checkBox );
lay2->addStretch(1);
+ // Merge CheckBox
+ _removeCheckBox = new QCheckBox( QString(), this );
+ connect( _removeCheckBox, SIGNAL( stateChanged( int ) ), this,
+ SLOT(removeCheckBoxStateChanged(int) ) );
+ lay2->addWidget( _removeCheckBox );
+ lay2->addStretch(1);
+
// Sorting tool button
QButtonGroup* grp = new QButtonGroup( this );
grp->setExclusive( true );
@@ -288,11 +308,21 @@
_checkBox->setEnabled( b );
}
+void ListSelect::setShowRemoveCheckbox( bool b )
+{
+ _removeCheckBox->setEnabled( b );
+}
+
bool ListSelect::doMerge() const
{
return _checkBox->isChecked();
}
+bool ListSelect::doRemove() const
+{
+ return _removeCheckBox->isChecked();
+}
+
bool ListSelect::isAND() const
{
return _checkBox->isChecked();
@@ -311,6 +341,8 @@
} else {
_checkBox->setText( i18n("Merge") );
_checkBox->setChecked( true );
+ _removeCheckBox->setText( i18n("Remove") );
+ _removeCheckBox->setChecked( false );
}
}
Index: imageinfo.cpp
===================================================================
--- imageinfo.cpp (revision 519053)
+++ imageinfo.cpp (working copy)
@@ -96,6 +96,14 @@
}
}
+void ImageInfo::removeOption( const QString& key, const QStringList& value )
+{
+ for( QStringList::ConstIterator it = value.begin(); it != value.end(); ++it ) {
+ if ( _options[key].contains( *it ) )
+ _options[key].remove(*it);
+ }
+}
+
bool ImageInfo::hasOption( const QString& key, const QString& value )
{
return _options[key].contains(value);
Index: imageinfo.h
===================================================================
--- imageinfo.h (revision 519053)
+++ imageinfo.h (working copy)
@@ -80,6 +80,7 @@
void setOption( const QString& key, const QStringList& value );
void addOption( const QString& key, const QStringList& value );
+ void removeOption( const QString& key, const QStringList& value );
void removeOption( const QString& key, const QString& value );
bool hasOption( const QString& key, const QString& value );
QStringList availableCategories() const;
More information about the Kphotoalbum
mailing list