Added alternative added(), removed(), renamed() variants.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/147/head
Mavridis Philippe 3 years ago committed by TDE Gitea
parent 88413aaa75
commit fa49e53a23

@ -175,11 +175,13 @@ void KEditListBox::typedSomething(const TQString& text)
// but TT disagree with me on this one (it's been that way since ages ... grrr)
bool block = m_listBox->signalsBlocked();
const TQString& oldText = currentText();
int item = currentItem();
m_listBox->blockSignals( true );
m_listBox->changeItem(text, currentItem());
m_listBox->changeItem(text, item);
m_listBox->blockSignals( block );
emit changed();
emit renamed(oldText, text);
emit renamed(item, oldText, text);
}
}
@ -280,7 +282,8 @@ void KEditListBox::addItem()
m_lineEdit->clear();
m_lineEdit->blockSignals(block);
m_listBox->setSelected(currentItem(), false);
int item = currentItem();
m_listBox->setSelected(item, false);
if (!alreadyInList)
{
@ -290,6 +293,7 @@ void KEditListBox::addItem()
m_listBox->blockSignals( block );
emit changed();
emit added( currentTextLE );
emit added( item, currentTextLE );
}
}
@ -302,18 +306,19 @@ int KEditListBox::currentItem() const
void KEditListBox::removeItem()
{
int selected = m_listBox->currentItem();
int item = m_listBox->currentItem();
if ( selected >= 0 )
if ( item >= 0 )
{
TQString removedText = m_listBox->currentText();
m_listBox->removeItem( selected );
m_listBox->removeItem( item );
if ( count() > 0 )
m_listBox->setSelected( TQMIN( selected, count() - 1 ), true );
m_listBox->setSelected( TQMIN( item, count() - 1 ), true );
emit changed();
emit removed( removedText );
emit removed( item, removedText );
}
if ( servRemoveButton && m_listBox->currentItem() == -1 )

@ -33,7 +33,7 @@ class KEditListBoxPrivate;
/**
* An editable listbox
*
* This class provides a editable listbox ;-), this means
* This class provides an editable listbox ;-), this means
* a listbox which is accompanied by a line edit to enter new
* items into the listbox and pushbuttons to add and remove
* items from the listbox and two buttons to move items up and down.
@ -199,25 +199,58 @@ public:
void changed();
/**
* This signal is emitted when the user adds a new string to the list,
* the parameter is the added string.
* This signal is emitted when the user adds a new string to the list.
* @param text is the added string.
* @since 3.2
* @see added( int item, const TQString & text )
*/
void added( const TQString & text );
/**
* This signal is emitted when the user removes a string from the list,
* the parameter is the removed string.
* This signal is emitted when the user adds a new string to the list.
* @param item is the added item's position in the list.
* @param text is the added string.
* @since R14.1.0
* @see added( const TQString & text )
*/
void added( int item, const TQString & text );
/**
* This signal is emitted when the user removes a string from the list.
* @param text is the removed string.
* @since 3.2
* @see removed( int item, const TQString & text )
*/
void removed( const TQString & text );
/**
* This signal is emitted when the user removes a string from the list.
* @param item is the removed item's position in the list.
* @param text is the removed string.
* @since R14.1.0
* @see removed( const TQString & text )
*/
void removed( int item, const TQString & text );
/**
* This signal is emitted when the user renames a list item.
* @param from is the original item's text.
* @param to is the new text of the item.
* @since R14.1.0
* @see renamed( int item, const TQString &from, const TQString &to )
*/
void renamed( const TQString &from, const TQString &to );
/**
* This signal is emitted when the user renames a list item.
* @param item is the renamed item's position in the list.
* @param from is the original item's text.
* @param to is the new text of the item.
* @since R14.1.0
* @see renamed( const TQString &from, const TQString &to )
*/
void renamed( int item, const TQString &from, const TQString &to );
protected slots:
//the names should be self-explaining
void moveItemUp();

Loading…
Cancel
Save