[KPhotoAlbum] Updated "remove multiple tags" patch

Jesper K. Pedersen blackie at blackie.dk
Mon Mar 20 01:43:41 GMT 2006


I did close for features, you know ;-)
And I dont really like the current solution, it is kind of clumsy (just like 
the merge checkbox is), however, I know very well that this feature has been 
on my TODO list for years, so it made it in.

Thanks for the patch.

And now, SVN is closed for anything but bugfixes :-)

Cheers
Jesper.

On Thursday 16 March 2006 07:23, Robert L Krawitz wrote:
| 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;

-- 
Jesper K. Pedersen          |  Klarälvdalens Datakonsult
Senior Software Engineer    |  www.klaralvdalens-datakonsult.se
Prinsensgade 4a st.         |
9800 Hjørring               |  Platform-independent
Denmark                     |  software solutions




More information about the Kphotoalbum mailing list