[KPhotoAlbum] Updated "remove multiple tags" patch

Robert L Krawitz rlk at alum.mit.edu
Thu Mar 16 12:23:13 GMT 2006


Here's an update to that patch -- it hides the second checkbox when in
search mode.  I guess eventually that could become a "NOT" checkbox or
the like.

Index: AnnotationDialog/ListSelect.h
===================================================================
--- AnnotationDialog/ListSelect.h       (revision 519155)
+++ 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 519155)
+++ 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 519155)
+++ 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();
@@ -308,9 +338,13 @@
        _checkBox->setText( i18n("AND") );
        // OR is a better default choice (the browser can do AND but not OR)
        _checkBox->setChecked( false );
+       _removeCheckBox->hide();
     } else {
        _checkBox->setText( i18n("Merge") );
        _checkBox->setChecked( true );
+       _removeCheckBox->setText( i18n("Remove") );
+       _removeCheckBox->setChecked( false );
+       _removeCheckBox->show();
     }
 }
 
Index: imageinfo.cpp
===================================================================
--- imageinfo.cpp       (revision 519155)
+++ 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 519155)
+++ 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