From e36b30d13d1f89100fae656adfde2b52234d12b6 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 1 Feb 2013 17:25:43 -0600 Subject: Fix FTBFS --- parts/fileselector/kactionselector.cpp | 537 ------------------------------- parts/fileselector/kactionselector.h | 400 ----------------------- parts/fileselector/tdeactionselector.cpp | 537 +++++++++++++++++++++++++++++++ parts/fileselector/tdeactionselector.h | 400 +++++++++++++++++++++++ 4 files changed, 937 insertions(+), 937 deletions(-) delete mode 100644 parts/fileselector/kactionselector.cpp delete mode 100644 parts/fileselector/kactionselector.h create mode 100644 parts/fileselector/tdeactionselector.cpp create mode 100644 parts/fileselector/tdeactionselector.h (limited to 'parts/fileselector') diff --git a/parts/fileselector/kactionselector.cpp b/parts/fileselector/kactionselector.cpp deleted file mode 100644 index 0b5b3801..00000000 --- a/parts/fileselector/kactionselector.cpp +++ /dev/null @@ -1,537 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2002 Anders Lund - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - - -#include "kactionselector.h" - -#include -#include -#include // for spacingHint() -#include -#include - -#include -#include -#include -#include -#include -#include - -class TDEActionSelectorPrivate { - public: - TQListBox *availableListBox, *selectedListBox; - TQToolButton *btnAdd, *btnRemove, *btnUp, *btnDown; - TQLabel *lAvailable, *lSelected; - bool moveOnDoubleClick, keyboardEnabled; - TDEActionSelector::ButtonIconSize iconSize; - TQString addIcon, removeIcon, upIcon, downIcon; - TDEActionSelector::InsertionPolicy availableInsertionPolicy, selectedInsertionPolicy; - bool showUpDownButtons; -}; - -//BEGIN Constructor/destructor - -TDEActionSelector::TDEActionSelector( TQWidget *parent, const char *name ) - : TQWidget( parent, name ) -{ - d = new TDEActionSelectorPrivate(); - d->moveOnDoubleClick = true; - d->keyboardEnabled = true; - d->iconSize = SmallIcon; - d->addIcon = TQApplication::reverseLayout() ? "back" : "forward"; - d->removeIcon = TQApplication::reverseLayout() ? "forward" : "back"; - d->upIcon = "up"; - d->downIcon = "down"; - d->availableInsertionPolicy = Sorted; - d->selectedInsertionPolicy = BelowCurrent; - d->showUpDownButtons = true; - - //int isz = IconSize( KIcon::Small ); - - TQHBoxLayout *lo = new TQHBoxLayout( this ); - lo->setSpacing( KDialog::spacingHint() ); - - TQVBoxLayout *loAv = new TQVBoxLayout( lo ); - d->lAvailable = new TQLabel( i18n("&Available:"), this ); - loAv->addWidget( d->lAvailable ); - d->availableListBox = new TQListBox( this ); - loAv->addWidget( d->availableListBox ); - d->lAvailable->setBuddy( d->availableListBox ); - - TQVBoxLayout *loHBtns = new TQVBoxLayout( lo ); - loHBtns->addStretch( 1 ); - d->btnAdd = new TQToolButton( this ); - loHBtns->addWidget( d->btnAdd ); - d->btnRemove = new TQToolButton( this ); - loHBtns->addWidget( d->btnRemove ); - loHBtns->addStretch( 1 ); - - TQVBoxLayout *loS = new TQVBoxLayout( lo ); - d->lSelected = new TQLabel( i18n("&Selected:"), this ); - loS->addWidget( d->lSelected ); - d->selectedListBox = new TQListBox( this ); - loS->addWidget( d->selectedListBox ); - d->lSelected->setBuddy( d->selectedListBox ); - - TQVBoxLayout *loVBtns = new TQVBoxLayout( lo ); - loVBtns->addStretch( 1 ); - d->btnUp = new TQToolButton( this ); - loVBtns->addWidget( d->btnUp ); - d->btnDown = new TQToolButton( this ); - loVBtns->addWidget( d->btnDown ); - loVBtns->addStretch( 1 ); - - loadIcons(); - - connect( d->btnAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(buttonAddClicked()) ); - connect( d->btnRemove, TQT_SIGNAL(clicked()), this, TQT_SLOT(buttonRemoveClicked()) ); - connect( d->btnUp, TQT_SIGNAL(clicked()), this, TQT_SLOT(buttonUpClicked()) ); - connect( d->btnDown, TQT_SIGNAL(clicked()), this, TQT_SLOT(buttonDownClicked()) ); - connect( d->availableListBox, TQT_SIGNAL(doubleClicked(TQListBoxItem*)), - this, TQT_SLOT(itemDoubleClicked(TQListBoxItem*)) ); - connect( d->selectedListBox, TQT_SIGNAL(doubleClicked(TQListBoxItem*)), - this, TQT_SLOT(itemDoubleClicked(TQListBoxItem*)) ); - connect( d->availableListBox, TQT_SIGNAL(currentChanged(TQListBoxItem*)), - this, TQT_SLOT(slotCurrentChanged(TQListBoxItem *)) ); - connect( d->selectedListBox, TQT_SIGNAL(currentChanged(TQListBoxItem*)), - this, TQT_SLOT(slotCurrentChanged(TQListBoxItem *)) ); - - d->availableListBox->installEventFilter( this ); - d->selectedListBox->installEventFilter( this ); -} - -TDEActionSelector::~TDEActionSelector() -{ - delete d; -} - -//END Constructor/destroctor - -//BEGIN Public Methods - -TQListBox *TDEActionSelector::availableListBox() -{ - return d->availableListBox; -} - -TQListBox *TDEActionSelector::selectedListBox() -{ - return d->selectedListBox; -} - -void TDEActionSelector::setButtonIcon( const TQString &icon, MoveButton button ) -{ - switch ( button ) - { - case ButtonAdd: - d->addIcon = icon; - d->btnAdd->setIconSet( SmallIconSet( icon, d->iconSize ) ); - break; - case ButtonRemove: - d->removeIcon = icon; - d->btnRemove->setIconSet( SmallIconSet( icon, d->iconSize ) ); - break; - case ButtonUp: - d->upIcon = icon; - d->btnUp->setIconSet( SmallIconSet( icon, d->iconSize ) ); - break; - case ButtonDown: - d->downIcon = icon; - d->btnDown->setIconSet( SmallIconSet( icon, d->iconSize ) ); - break; - default: - kdDebug()<<"TDEActionSelector::setButtonIcon: DAINBREAD!"<btnAdd->setIconSet( iconset ); - break; - case ButtonRemove: - d->btnRemove->setIconSet( iconset ); - break; - case ButtonUp: - d->btnUp->setIconSet( iconset ); - break; - case ButtonDown: - d->btnDown->setIconSet( iconset ); - break; - default: - kdDebug()<<"TDEActionSelector::setButtonIconSet: DAINBREAD!"<btnAdd->setTextLabel( tip ); - break; - case ButtonRemove: - d->btnRemove->setTextLabel( tip ); - break; - case ButtonUp: - d->btnUp->setTextLabel( tip ); - break; - case ButtonDown: - d->btnDown->setTextLabel( tip ); - break; - default: - kdDebug()<<"TDEActionSelector::setButtonToolTip: DAINBREAD!"<btnAdd, text ); - break; - case ButtonRemove: - TQWhatsThis::add( d->btnRemove, text ); - break; - case ButtonUp: - TQWhatsThis::add( d->btnUp, text ); - break; - case ButtonDown: - TQWhatsThis::add( d->btnDown, text ); - break; - default: - kdDebug()<<"TDEActionSelector::setButtonWhatsThis: DAINBREAD!"<btnAdd->setEnabled( d->availableListBox->currentItem() > -1 ); - d->btnRemove->setEnabled( d->selectedListBox->currentItem() > -1 ); - d->btnUp->setEnabled( d->selectedListBox->currentItem() > 0 ); - d->btnDown->setEnabled( d->selectedListBox->currentItem() > -1 && - d->selectedListBox->currentItem() < (int)d->selectedListBox->count() - 1 ); -} - -//END Public Methods - -//BEGIN Properties - -bool TDEActionSelector::moveOnDoubleClick() const -{ - return d->moveOnDoubleClick; -} - -void TDEActionSelector::setMoveOnDoubleClick( bool b ) -{ - d->moveOnDoubleClick = b; -} - -bool TDEActionSelector::keyboardEnabled() const -{ - return d->keyboardEnabled; -} - -void TDEActionSelector::setKeyboardEnabled( bool b ) -{ - d->keyboardEnabled = b; -} - -TQString TDEActionSelector::availableLabel() const -{ - return d->lAvailable->text(); -} - -void TDEActionSelector::setAvailableLabel( const TQString &text ) -{ - d->lAvailable->setText( text ); -} - -TQString TDEActionSelector::selectedLabel() const -{ - return d->lSelected->text(); -} - -void TDEActionSelector::setSelectedLabel( const TQString &text ) -{ - d->lSelected->setText( text ); -} - -TDEActionSelector::ButtonIconSize TDEActionSelector::buttonIconSize() const -{ - return d->iconSize; -} - -void TDEActionSelector::setButtonIconSize( ButtonIconSize size ) -{ - d->iconSize = size; - // reload icons - loadIcons(); -} - -TDEActionSelector::InsertionPolicy TDEActionSelector::availableInsertionPolicy() const -{ - return d->availableInsertionPolicy; -} - -void TDEActionSelector::setAvailableInsertionPolicy( InsertionPolicy p ) -{ - d->availableInsertionPolicy = p; -} - -TDEActionSelector::InsertionPolicy TDEActionSelector::selectedInsertionPolicy() const -{ - return d->selectedInsertionPolicy; -} - -void TDEActionSelector::setSelectedInsertionPolicy( InsertionPolicy p ) -{ - d->selectedInsertionPolicy = p; -} - -bool TDEActionSelector::showUpDownButtons() const -{ - return d->showUpDownButtons; -} - -void TDEActionSelector::setShowUpDownButtons( bool show ) -{ - d->showUpDownButtons = show; - if ( show ) - { - d->btnUp->show(); - d->btnDown->show(); - } - else - { - d->btnUp->hide(); - d->btnDown->hide(); - } -} - -//END Properties - -//BEGIN Public Slots - -void TDEActionSelector::polish() -{ - setButtonsEnabled(); -} - -//END Public Slots - -//BEGIN Protected -void TDEActionSelector::keyPressEvent( TQKeyEvent *e ) -{ - if ( ! d->keyboardEnabled ) return; - if ( (e->state() & TQt::ControlButton) ) - { - switch ( e->key() ) - { - case Key_Right: - buttonAddClicked(); - break; - case Key_Left: - buttonRemoveClicked(); - break; - case Key_Up: - buttonUpClicked(); - break; - case Key_Down: - buttonDownClicked(); - break; - default: - e->ignore(); - return; - } - } -} - -bool TDEActionSelector::eventFilter( TQObject *o, TQEvent *e ) -{ - if ( d->keyboardEnabled && e->type() == TQEvent::KeyPress ) - { - if ( (((TQKeyEvent*)e)->state() & TQt::ControlButton) ) - { - switch ( ((TQKeyEvent*)e)->key() ) - { - case Key_Right: - buttonAddClicked(); - break; - case Key_Left: - buttonRemoveClicked(); - break; - case Key_Up: - buttonUpClicked(); - break; - case Key_Down: - buttonDownClicked(); - break; - default: - return TQWidget::eventFilter( o, e ); - break; - } - return true; - } - else if ( o->inherits( TQLISTBOX_OBJECT_NAME_STRING ) ) - { - switch ( ((TQKeyEvent*)e)->key() ) - { - case Key_Return: - case Key_Enter: - TQListBox *lb = (TQListBox*)o; - int index = lb->currentItem(); - if ( index < 0 ) break; - moveItem( lb->item( index ) ); - return true; - } - } - } - return TQWidget::eventFilter( o, e ); -} - -//END Protected - -//BEGIN Private Slots - -void TDEActionSelector::buttonAddClicked() -{ - // move all selected items from available to selected listbox - TQListBoxItem *item = d->availableListBox->firstItem(); - while ( item ) { - if ( item->isSelected() ) { - d->availableListBox->takeItem( item ); - d->selectedListBox->insertItem( item, insertionIndex( d->selectedListBox, d->selectedInsertionPolicy ) ); - d->selectedListBox->setCurrentItem( item ); - emit added( item ); - } - item = item->next(); - } - if ( d->selectedInsertionPolicy == Sorted ) - d->selectedListBox->sort(); - d->selectedListBox->setFocus(); -} - -void TDEActionSelector::buttonRemoveClicked() -{ - // move all selected items from selected to available listbox - TQListBoxItem *item = d->selectedListBox->firstItem(); - while ( item ) { - if ( item->isSelected() ) { - d->selectedListBox->takeItem( item ); - d->availableListBox->insertItem( item, insertionIndex( d->availableListBox, d->availableInsertionPolicy ) ); - d->availableListBox->setCurrentItem( item ); - emit removed( item ); - } - item = item->next(); - } - if ( d->availableInsertionPolicy == Sorted ) - d->availableListBox->sort(); - d->availableListBox->setFocus(); -} - -void TDEActionSelector::buttonUpClicked() -{ - int c = d->selectedListBox->currentItem(); - if ( c < 0 ) return; - TQListBoxItem *item = d->selectedListBox->item( c ); - d->selectedListBox->takeItem( item ); - d->selectedListBox->insertItem( item, c-1 ); - d->selectedListBox->setCurrentItem( item ); - emit movedUp( item ); -} - -void TDEActionSelector::buttonDownClicked() -{ - int c = d->selectedListBox->currentItem(); - if ( c < 0 ) return; - TQListBoxItem *item = d->selectedListBox->item( c ); - d->selectedListBox->takeItem( item ); - d->selectedListBox->insertItem( item, c+1 ); - d->selectedListBox->setCurrentItem( item ); - emit movedDown( item ); -} - -void TDEActionSelector::itemDoubleClicked( TQListBoxItem *item ) -{ - if ( d->moveOnDoubleClick ) - moveItem( item ); -} - -//END Private Slots - -//BEGIN Private Methods - -void TDEActionSelector::loadIcons() -{ - d->btnAdd->setIconSet( SmallIconSet( d->addIcon, d->iconSize ) ); - d->btnRemove->setIconSet( SmallIconSet( d->removeIcon, d->iconSize ) ); - d->btnUp->setIconSet( SmallIconSet( d->upIcon, d->iconSize ) ); - d->btnDown->setIconSet( SmallIconSet( d->downIcon, d->iconSize ) ); -} - -void TDEActionSelector::moveItem( TQListBoxItem *item ) -{ - TQListBox *lbFrom = item->listBox(); - TQListBox *lbTo; - if ( lbFrom == d->availableListBox ) - lbTo = d->selectedListBox; - else if ( lbFrom == d->selectedListBox ) - lbTo = d->availableListBox; - else //?! somewhat unlikely... - return; - - InsertionPolicy p = ( lbTo == d->availableListBox ) ? - d->availableInsertionPolicy : d->selectedInsertionPolicy; - - lbFrom->takeItem( item ); - lbTo->insertItem( item, insertionIndex( lbTo, p ) ); - lbTo->setFocus(); - lbTo->setCurrentItem( item ); - - if ( p == Sorted ) - lbTo->sort(); - if ( lbTo == d->selectedListBox ) - emit added( item ); - else - emit removed( item ); -} - -int TDEActionSelector::insertionIndex( TQListBox *lb, InsertionPolicy policy ) -{ - int index; - switch ( policy ) - { - case BelowCurrent: - index = lb->currentItem(); - if ( index > -1 ) index += 1; - break; - case AtTop: - index = 0; - break; - default: - index = -1; - } - return index; -} - -//END Private Methods -#include "kactionselector.moc" diff --git a/parts/fileselector/kactionselector.h b/parts/fileselector/kactionselector.h deleted file mode 100644 index a1c26394..00000000 --- a/parts/fileselector/kactionselector.h +++ /dev/null @@ -1,400 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2002 Anders Lund - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef _KACTION_SELECTOR_H_ -#define _KACTION_SELECTOR_H_ - -#include - -class TQListBox; -class TQListBoxItem; -class TQKeyEvent; -class TQEvent; -class TQIconSet; - -class TDEActionSelectorPrivate; - -/** - @short A widget for selecting and arranging actions/objects - This widget allows the user to select from a set of objects and arrange - the order of the selected ones using two list boxes labeled "Available" - and "Used" with horizontal arrows in between to move selected objects between - the two, and vertical arrows on the right to arrange the order of the selected - objects. - - The widget moves objects to the other listbox when doubleclicked if - the property moveOnDoubleClick is set to true (default). See moveOnDoubleClick() - and setMoveOnDoubleClick(). - - The user control the widget using the keyboard if enabled (default), - see keyboardEnabled. - - Note that this may conflist with keyboard selection in the selected list box, - if you set that to anything else than TQListBox::Single (which is the default). - - To use it, simply construct an instance and then add items to the two listboxes, - available through lbAvailable() and lbSelected(). Whenever you want, you can retrieve - the selected options using TQListBox methods on lbSelected(). - - This way, you can use your own TQListBoxItem class, allowing you to easily - store object data in those. - - When an item is moved to a listbox, it is placed below the current item - of that listbox. - - Standard arrow icons are used, but you can use icons of your own choice if desired, - see setButtonIcon(). It is also possible to set tooltips and whatsthis help - for the buttons. See setButtonTooltip() and setButtonWhatsThis(). - - To set whatsthis or tooltips for the listboxes, access them through - availableListbox() and selectedListBox(). - - All the moving buttons are automatically set enabled as expected. - - Signals are sent each time an item is moved, allowing you to follow the - users actions if you need to. See addedToSelection(), removedFromSelection(), - movedUp() and movedDown() - - @author Anders Lund -*/ - -class TDEActionSelector : public TQWidget { - Q_OBJECT - - TQ_ENUMS( ButtonIconSize InsertionPolicy ) - TQ_PROPERTY( bool moveOnDoubleClick READ moveOnDoubleClick WRITE setMoveOnDoubleClick ) - TQ_PROPERTY( bool keyboardEnabled READ keyboardEnabled WRITE setKeyboardEnabled ) - TQ_PROPERTY( TQString availableLabel READ availableLabel WRITE setAvailableLabel ) - TQ_PROPERTY( TQString selectedLabel READ selectedLabel WRITE setSelectedLabel ) - TQ_PROPERTY( ButtonIconSize buttonIconSize READ buttonIconSize WRITE setButtonIconSize ) - TQ_PROPERTY( InsertionPolicy availableInsertionPolicy READ availableInsertionPolicy WRITE setAvailableInsertionPolicy ) - TQ_PROPERTY( InsertionPolicy selectedInsertionPolicy READ selectedInsertionPolicy WRITE setSelectedInsertionPolicy ) - TQ_PROPERTY( bool showUpDownButtons READ showUpDownButtons WRITE setShowUpDownButtons ) - -public: - TDEActionSelector( TQWidget *parent=0, const char *name=0 ); - ~TDEActionSelector(); - - /** - @return The TQListBox holding the available actions - */ - TQListBox *availableListBox(); - - /** - @return The TQListBox holding the selected actions - */ - TQListBox *selectedListBox(); - - /** - This enum indentifies the moving buttons - */ - enum MoveButton { - ButtonAdd, - ButtonRemove, - ButtonUp, - ButtonDown - }; - - /** - This enum identifies the icon sizes, used for the move buttons. - The values correspond to the following pixel sizes: - @li SmallIcon - the return value of IconSize( KIcon::Small ), the user defined size - of a small icon in KDE. This is the default setting. - @li Small - 16px - @li Medium - 22px - @li Large - 32px - @li XLarge - 48px - */ - enum ButtonIconSize { - SmallIcon, - Small, - Medium, - Large, - XLarge - }; - - /** - This enum defines policies for where to insert moved items in a listbox. - The following policies are currently defined: - @li BelowCurrent - The item is inserted below the listbox' - currentItem() or at the end if there is no curent item. - @li Sorted - The listbox is sort()ed after one or more items are inserted. - @li AtTop - The item is inserted at index 0 in the listbox. - @li AtBottom - The item is inserted at the end of the listbox. - - @sa availableInsertionPolicy(), setAvailableInsertionPolicy(), - selectedInsertionPolicy(), setSelectedInsertionPolicy(). - */ - enum InsertionPolicy { - BelowCurrent, - Sorted, - AtTop, - AtBottom - }; - - /** - @return Wheather moveOnDoubleClcik is enabled. - - If enabled, an item in any listbox will be moved to the other one whenever - doubleclicked. - @sa setMoveOnDoubleClick() - */ - bool moveOnDoubleClick() const; - - /** - Sets moveOnDoubleClick to @p enable - @sa moveOnDoubleClick() - */ - void setMoveOnDoubleClick( bool enable ); - - /** - @return Weather keyboard control is enabled. - - When Keyboard control is enabled, the widget will react to - the following keyboard actions: - @li CTRL + Right - simulate clicking the add button - @li CTRL + Left - simulate clicking the remove button - @li CTRL + Up - simulate clicking the up button - @li CTRL + Down - simulate clicking the down button - - Additionally, pressing RETURN or ENTER on one of the list boxes - will cause the current item of that listbox to be moved to the other - listbox. - - The keyboard actions are enabled by default. - - @sa setKeyboardEnabled() - */ - bool keyboardEnabled() const; - - /** - Sets the keyboard enabled depending on @p enable. - @sa keyboardEnabled() - */ - void setKeyboardEnabled( bool enable ); - - /** - @return The text of the label for the available items listbox. - */ - TQString availableLabel() const; - - /** - Sets the label for the available items listbox to @p text. - Note that this label has the listbox as its @e buddy, so that - if you have a single ampersand in the text, the following character - will become the accellerator to focus te listbox. - */ - void setAvailableLabel( const TQString & text ); - - /** - @return the label of the selected items listbox. - */ - TQString selectedLabel() const; - - /** - Sets the label for the selected items listbox to @p text. - Note that this label has the listbox as its @e buddy, so that - if you have a single ampersand in the text, the following character - will become the accellerator to focus te listbox. - */ - void setSelectedLabel( const TQString & text ); - - /** - @return the current ButtonIconSize. - */ - ButtonIconSize buttonIconSize() const; - - /** - Sets the button icon size. - See ButtonIconSize for the possible values and their pixel meaning. - */ - void setButtonIconSize( ButtonIconSize size ); - - /** - @return The current insertion policy for the available listbox. - The default policy for the available listbox is Sorted. - See also InsertionPolicy, setAvailableInsertionPolicy(). - */ - InsertionPolicy availableInsertionPolicy() const; - - /** - Sets the insertion policy for the available listbox. - See also InsertionPolicy, availableInsertionPolicy(). - */ - void setAvailableInsertionPolicy( InsertionPolicy policy ); - - /** - @return The current insertion policy for the selected listbox. - The default policy for the selected listbox is BelowCurrent. - See also InsertionPolicy, setSelectedInsertionPolicy(). - */ - InsertionPolicy selectedInsertionPolicy() const; - - /** - Sets the insertion policy for the selected listbox. - See also InsertionPolicy, selectedInsertionPolicy(). - */ - void setSelectedInsertionPolicy( InsertionPolicy policy ); - - /** - @return wheather the Up and Down buttons should be displayed. - */ - bool showUpDownButtons() const; - - /** - Sets wheather the Up and Down buttons should be displayed - according to @p show - */ - void setShowUpDownButtons( bool show ); - - /** - Sets the pixmap of the button @p button to @p icon. - It calls SmallIconSet(pm) to generate the icon set. - */ - void setButtonIcon( const TQString &icon, MoveButton button ); - - /** - Sets the iconset for button @p button to @p iconset. - You can use this method to et a costum icon set. Either - created by @ref TQIconSet, or use the application instance of - @ref KIconLoader (recommended). - */ - void setButtonIconSet( const TQIconSet &iconset, MoveButton button ); - - /** - Sets the tooltip for the button @p button to @p tip. - */ - void setButtonTooltip( const TQString &tip, MoveButton button ); - - /** - Sets the whatsthis help for button @p button to @p text. - */ - void setButtonWhatsThis( const TQString &text, MoveButton button ); - - /** - Sets the enabled state of all moving buttons to reflect the current - options. - - Be sure to call this if you add or removes items to either listbox after the - widget is show()n - */ - void setButtonsEnabled(); - -signals: - /** - Emitted when an item is moved to the "selected" listbox. - */ - void added( TQListBoxItem *item ); - - /** - Emitted when an item is moved out of the "selected" listbox. - */ - void removed( TQListBoxItem *item ); - - /** - Emitted when an item is moved upwards in the "selected" listbox. - */ - void movedUp( TQListBoxItem *item ); - - /** - Emitted when an item is moved downwards in the "selected" listbox. - */ - void movedDown( TQListBoxItem *item ); - - /** - Emitted when an item is moved to the "selected" listbox. - */ -// void addedToSelection( TQListBoxItem *item ); - -public slots: - /** - Reimplemented for internal reasons. - (calls setButtonsEnabled()) - */ - void polish(); - -protected: - /** - Reimplamented for internal reasons. - */ - void keyPressEvent( TQKeyEvent * ); - - /** - Reimplemented for internal reasons. - */ - bool eventFilter( TQObject *, TQEvent * ); - -private slots: - /** - Move selected item from available box to the selected box - */ - void buttonAddClicked(); - - /** - Move selected item from selected box to available box - */ - void buttonRemoveClicked(); - - /** - Move selected item in selected box upwards - */ - void buttonUpClicked(); - - /** - Move seleted item in selected box downwards - */ - void buttonDownClicked(); - - /** - Moves the item @p item to the other listbox if moveOnDoubleClick is enabled. - */ - void itemDoubleClicked( TQListBoxItem *item ); - - /** - connected to both list boxes to set the buttons enabled - */ - void slotCurrentChanged( TQListBoxItem * ) { setButtonsEnabled(); }; - -private: - - /** - Move item @p item to the other listbox - */ - void moveItem( TQListBoxItem *item ); - - /** - loads the icons for the move buttons. - */ - void loadIcons(); - - /** - @return the index to insert an item into listbox @p lb, - given InsertionPolicy @p policy. - - Note that if policy is Sorted, this will return -1. - Sort the listbox after inserting the item in that case. - */ - int insertionIndex( TQListBox *lb, InsertionPolicy policy ); - - /** - Private data storage - */ - TDEActionSelectorPrivate *d; -}; - -#endif // _KACTION_SELECTOR_H_ diff --git a/parts/fileselector/tdeactionselector.cpp b/parts/fileselector/tdeactionselector.cpp new file mode 100644 index 00000000..0b5b3801 --- /dev/null +++ b/parts/fileselector/tdeactionselector.cpp @@ -0,0 +1,537 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#include "kactionselector.h" + +#include +#include +#include // for spacingHint() +#include +#include + +#include +#include +#include +#include +#include +#include + +class TDEActionSelectorPrivate { + public: + TQListBox *availableListBox, *selectedListBox; + TQToolButton *btnAdd, *btnRemove, *btnUp, *btnDown; + TQLabel *lAvailable, *lSelected; + bool moveOnDoubleClick, keyboardEnabled; + TDEActionSelector::ButtonIconSize iconSize; + TQString addIcon, removeIcon, upIcon, downIcon; + TDEActionSelector::InsertionPolicy availableInsertionPolicy, selectedInsertionPolicy; + bool showUpDownButtons; +}; + +//BEGIN Constructor/destructor + +TDEActionSelector::TDEActionSelector( TQWidget *parent, const char *name ) + : TQWidget( parent, name ) +{ + d = new TDEActionSelectorPrivate(); + d->moveOnDoubleClick = true; + d->keyboardEnabled = true; + d->iconSize = SmallIcon; + d->addIcon = TQApplication::reverseLayout() ? "back" : "forward"; + d->removeIcon = TQApplication::reverseLayout() ? "forward" : "back"; + d->upIcon = "up"; + d->downIcon = "down"; + d->availableInsertionPolicy = Sorted; + d->selectedInsertionPolicy = BelowCurrent; + d->showUpDownButtons = true; + + //int isz = IconSize( KIcon::Small ); + + TQHBoxLayout *lo = new TQHBoxLayout( this ); + lo->setSpacing( KDialog::spacingHint() ); + + TQVBoxLayout *loAv = new TQVBoxLayout( lo ); + d->lAvailable = new TQLabel( i18n("&Available:"), this ); + loAv->addWidget( d->lAvailable ); + d->availableListBox = new TQListBox( this ); + loAv->addWidget( d->availableListBox ); + d->lAvailable->setBuddy( d->availableListBox ); + + TQVBoxLayout *loHBtns = new TQVBoxLayout( lo ); + loHBtns->addStretch( 1 ); + d->btnAdd = new TQToolButton( this ); + loHBtns->addWidget( d->btnAdd ); + d->btnRemove = new TQToolButton( this ); + loHBtns->addWidget( d->btnRemove ); + loHBtns->addStretch( 1 ); + + TQVBoxLayout *loS = new TQVBoxLayout( lo ); + d->lSelected = new TQLabel( i18n("&Selected:"), this ); + loS->addWidget( d->lSelected ); + d->selectedListBox = new TQListBox( this ); + loS->addWidget( d->selectedListBox ); + d->lSelected->setBuddy( d->selectedListBox ); + + TQVBoxLayout *loVBtns = new TQVBoxLayout( lo ); + loVBtns->addStretch( 1 ); + d->btnUp = new TQToolButton( this ); + loVBtns->addWidget( d->btnUp ); + d->btnDown = new TQToolButton( this ); + loVBtns->addWidget( d->btnDown ); + loVBtns->addStretch( 1 ); + + loadIcons(); + + connect( d->btnAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(buttonAddClicked()) ); + connect( d->btnRemove, TQT_SIGNAL(clicked()), this, TQT_SLOT(buttonRemoveClicked()) ); + connect( d->btnUp, TQT_SIGNAL(clicked()), this, TQT_SLOT(buttonUpClicked()) ); + connect( d->btnDown, TQT_SIGNAL(clicked()), this, TQT_SLOT(buttonDownClicked()) ); + connect( d->availableListBox, TQT_SIGNAL(doubleClicked(TQListBoxItem*)), + this, TQT_SLOT(itemDoubleClicked(TQListBoxItem*)) ); + connect( d->selectedListBox, TQT_SIGNAL(doubleClicked(TQListBoxItem*)), + this, TQT_SLOT(itemDoubleClicked(TQListBoxItem*)) ); + connect( d->availableListBox, TQT_SIGNAL(currentChanged(TQListBoxItem*)), + this, TQT_SLOT(slotCurrentChanged(TQListBoxItem *)) ); + connect( d->selectedListBox, TQT_SIGNAL(currentChanged(TQListBoxItem*)), + this, TQT_SLOT(slotCurrentChanged(TQListBoxItem *)) ); + + d->availableListBox->installEventFilter( this ); + d->selectedListBox->installEventFilter( this ); +} + +TDEActionSelector::~TDEActionSelector() +{ + delete d; +} + +//END Constructor/destroctor + +//BEGIN Public Methods + +TQListBox *TDEActionSelector::availableListBox() +{ + return d->availableListBox; +} + +TQListBox *TDEActionSelector::selectedListBox() +{ + return d->selectedListBox; +} + +void TDEActionSelector::setButtonIcon( const TQString &icon, MoveButton button ) +{ + switch ( button ) + { + case ButtonAdd: + d->addIcon = icon; + d->btnAdd->setIconSet( SmallIconSet( icon, d->iconSize ) ); + break; + case ButtonRemove: + d->removeIcon = icon; + d->btnRemove->setIconSet( SmallIconSet( icon, d->iconSize ) ); + break; + case ButtonUp: + d->upIcon = icon; + d->btnUp->setIconSet( SmallIconSet( icon, d->iconSize ) ); + break; + case ButtonDown: + d->downIcon = icon; + d->btnDown->setIconSet( SmallIconSet( icon, d->iconSize ) ); + break; + default: + kdDebug()<<"TDEActionSelector::setButtonIcon: DAINBREAD!"<btnAdd->setIconSet( iconset ); + break; + case ButtonRemove: + d->btnRemove->setIconSet( iconset ); + break; + case ButtonUp: + d->btnUp->setIconSet( iconset ); + break; + case ButtonDown: + d->btnDown->setIconSet( iconset ); + break; + default: + kdDebug()<<"TDEActionSelector::setButtonIconSet: DAINBREAD!"<btnAdd->setTextLabel( tip ); + break; + case ButtonRemove: + d->btnRemove->setTextLabel( tip ); + break; + case ButtonUp: + d->btnUp->setTextLabel( tip ); + break; + case ButtonDown: + d->btnDown->setTextLabel( tip ); + break; + default: + kdDebug()<<"TDEActionSelector::setButtonToolTip: DAINBREAD!"<btnAdd, text ); + break; + case ButtonRemove: + TQWhatsThis::add( d->btnRemove, text ); + break; + case ButtonUp: + TQWhatsThis::add( d->btnUp, text ); + break; + case ButtonDown: + TQWhatsThis::add( d->btnDown, text ); + break; + default: + kdDebug()<<"TDEActionSelector::setButtonWhatsThis: DAINBREAD!"<btnAdd->setEnabled( d->availableListBox->currentItem() > -1 ); + d->btnRemove->setEnabled( d->selectedListBox->currentItem() > -1 ); + d->btnUp->setEnabled( d->selectedListBox->currentItem() > 0 ); + d->btnDown->setEnabled( d->selectedListBox->currentItem() > -1 && + d->selectedListBox->currentItem() < (int)d->selectedListBox->count() - 1 ); +} + +//END Public Methods + +//BEGIN Properties + +bool TDEActionSelector::moveOnDoubleClick() const +{ + return d->moveOnDoubleClick; +} + +void TDEActionSelector::setMoveOnDoubleClick( bool b ) +{ + d->moveOnDoubleClick = b; +} + +bool TDEActionSelector::keyboardEnabled() const +{ + return d->keyboardEnabled; +} + +void TDEActionSelector::setKeyboardEnabled( bool b ) +{ + d->keyboardEnabled = b; +} + +TQString TDEActionSelector::availableLabel() const +{ + return d->lAvailable->text(); +} + +void TDEActionSelector::setAvailableLabel( const TQString &text ) +{ + d->lAvailable->setText( text ); +} + +TQString TDEActionSelector::selectedLabel() const +{ + return d->lSelected->text(); +} + +void TDEActionSelector::setSelectedLabel( const TQString &text ) +{ + d->lSelected->setText( text ); +} + +TDEActionSelector::ButtonIconSize TDEActionSelector::buttonIconSize() const +{ + return d->iconSize; +} + +void TDEActionSelector::setButtonIconSize( ButtonIconSize size ) +{ + d->iconSize = size; + // reload icons + loadIcons(); +} + +TDEActionSelector::InsertionPolicy TDEActionSelector::availableInsertionPolicy() const +{ + return d->availableInsertionPolicy; +} + +void TDEActionSelector::setAvailableInsertionPolicy( InsertionPolicy p ) +{ + d->availableInsertionPolicy = p; +} + +TDEActionSelector::InsertionPolicy TDEActionSelector::selectedInsertionPolicy() const +{ + return d->selectedInsertionPolicy; +} + +void TDEActionSelector::setSelectedInsertionPolicy( InsertionPolicy p ) +{ + d->selectedInsertionPolicy = p; +} + +bool TDEActionSelector::showUpDownButtons() const +{ + return d->showUpDownButtons; +} + +void TDEActionSelector::setShowUpDownButtons( bool show ) +{ + d->showUpDownButtons = show; + if ( show ) + { + d->btnUp->show(); + d->btnDown->show(); + } + else + { + d->btnUp->hide(); + d->btnDown->hide(); + } +} + +//END Properties + +//BEGIN Public Slots + +void TDEActionSelector::polish() +{ + setButtonsEnabled(); +} + +//END Public Slots + +//BEGIN Protected +void TDEActionSelector::keyPressEvent( TQKeyEvent *e ) +{ + if ( ! d->keyboardEnabled ) return; + if ( (e->state() & TQt::ControlButton) ) + { + switch ( e->key() ) + { + case Key_Right: + buttonAddClicked(); + break; + case Key_Left: + buttonRemoveClicked(); + break; + case Key_Up: + buttonUpClicked(); + break; + case Key_Down: + buttonDownClicked(); + break; + default: + e->ignore(); + return; + } + } +} + +bool TDEActionSelector::eventFilter( TQObject *o, TQEvent *e ) +{ + if ( d->keyboardEnabled && e->type() == TQEvent::KeyPress ) + { + if ( (((TQKeyEvent*)e)->state() & TQt::ControlButton) ) + { + switch ( ((TQKeyEvent*)e)->key() ) + { + case Key_Right: + buttonAddClicked(); + break; + case Key_Left: + buttonRemoveClicked(); + break; + case Key_Up: + buttonUpClicked(); + break; + case Key_Down: + buttonDownClicked(); + break; + default: + return TQWidget::eventFilter( o, e ); + break; + } + return true; + } + else if ( o->inherits( TQLISTBOX_OBJECT_NAME_STRING ) ) + { + switch ( ((TQKeyEvent*)e)->key() ) + { + case Key_Return: + case Key_Enter: + TQListBox *lb = (TQListBox*)o; + int index = lb->currentItem(); + if ( index < 0 ) break; + moveItem( lb->item( index ) ); + return true; + } + } + } + return TQWidget::eventFilter( o, e ); +} + +//END Protected + +//BEGIN Private Slots + +void TDEActionSelector::buttonAddClicked() +{ + // move all selected items from available to selected listbox + TQListBoxItem *item = d->availableListBox->firstItem(); + while ( item ) { + if ( item->isSelected() ) { + d->availableListBox->takeItem( item ); + d->selectedListBox->insertItem( item, insertionIndex( d->selectedListBox, d->selectedInsertionPolicy ) ); + d->selectedListBox->setCurrentItem( item ); + emit added( item ); + } + item = item->next(); + } + if ( d->selectedInsertionPolicy == Sorted ) + d->selectedListBox->sort(); + d->selectedListBox->setFocus(); +} + +void TDEActionSelector::buttonRemoveClicked() +{ + // move all selected items from selected to available listbox + TQListBoxItem *item = d->selectedListBox->firstItem(); + while ( item ) { + if ( item->isSelected() ) { + d->selectedListBox->takeItem( item ); + d->availableListBox->insertItem( item, insertionIndex( d->availableListBox, d->availableInsertionPolicy ) ); + d->availableListBox->setCurrentItem( item ); + emit removed( item ); + } + item = item->next(); + } + if ( d->availableInsertionPolicy == Sorted ) + d->availableListBox->sort(); + d->availableListBox->setFocus(); +} + +void TDEActionSelector::buttonUpClicked() +{ + int c = d->selectedListBox->currentItem(); + if ( c < 0 ) return; + TQListBoxItem *item = d->selectedListBox->item( c ); + d->selectedListBox->takeItem( item ); + d->selectedListBox->insertItem( item, c-1 ); + d->selectedListBox->setCurrentItem( item ); + emit movedUp( item ); +} + +void TDEActionSelector::buttonDownClicked() +{ + int c = d->selectedListBox->currentItem(); + if ( c < 0 ) return; + TQListBoxItem *item = d->selectedListBox->item( c ); + d->selectedListBox->takeItem( item ); + d->selectedListBox->insertItem( item, c+1 ); + d->selectedListBox->setCurrentItem( item ); + emit movedDown( item ); +} + +void TDEActionSelector::itemDoubleClicked( TQListBoxItem *item ) +{ + if ( d->moveOnDoubleClick ) + moveItem( item ); +} + +//END Private Slots + +//BEGIN Private Methods + +void TDEActionSelector::loadIcons() +{ + d->btnAdd->setIconSet( SmallIconSet( d->addIcon, d->iconSize ) ); + d->btnRemove->setIconSet( SmallIconSet( d->removeIcon, d->iconSize ) ); + d->btnUp->setIconSet( SmallIconSet( d->upIcon, d->iconSize ) ); + d->btnDown->setIconSet( SmallIconSet( d->downIcon, d->iconSize ) ); +} + +void TDEActionSelector::moveItem( TQListBoxItem *item ) +{ + TQListBox *lbFrom = item->listBox(); + TQListBox *lbTo; + if ( lbFrom == d->availableListBox ) + lbTo = d->selectedListBox; + else if ( lbFrom == d->selectedListBox ) + lbTo = d->availableListBox; + else //?! somewhat unlikely... + return; + + InsertionPolicy p = ( lbTo == d->availableListBox ) ? + d->availableInsertionPolicy : d->selectedInsertionPolicy; + + lbFrom->takeItem( item ); + lbTo->insertItem( item, insertionIndex( lbTo, p ) ); + lbTo->setFocus(); + lbTo->setCurrentItem( item ); + + if ( p == Sorted ) + lbTo->sort(); + if ( lbTo == d->selectedListBox ) + emit added( item ); + else + emit removed( item ); +} + +int TDEActionSelector::insertionIndex( TQListBox *lb, InsertionPolicy policy ) +{ + int index; + switch ( policy ) + { + case BelowCurrent: + index = lb->currentItem(); + if ( index > -1 ) index += 1; + break; + case AtTop: + index = 0; + break; + default: + index = -1; + } + return index; +} + +//END Private Methods +#include "kactionselector.moc" diff --git a/parts/fileselector/tdeactionselector.h b/parts/fileselector/tdeactionselector.h new file mode 100644 index 00000000..a1c26394 --- /dev/null +++ b/parts/fileselector/tdeactionselector.h @@ -0,0 +1,400 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _KACTION_SELECTOR_H_ +#define _KACTION_SELECTOR_H_ + +#include + +class TQListBox; +class TQListBoxItem; +class TQKeyEvent; +class TQEvent; +class TQIconSet; + +class TDEActionSelectorPrivate; + +/** + @short A widget for selecting and arranging actions/objects + This widget allows the user to select from a set of objects and arrange + the order of the selected ones using two list boxes labeled "Available" + and "Used" with horizontal arrows in between to move selected objects between + the two, and vertical arrows on the right to arrange the order of the selected + objects. + + The widget moves objects to the other listbox when doubleclicked if + the property moveOnDoubleClick is set to true (default). See moveOnDoubleClick() + and setMoveOnDoubleClick(). + + The user control the widget using the keyboard if enabled (default), + see keyboardEnabled. + + Note that this may conflist with keyboard selection in the selected list box, + if you set that to anything else than TQListBox::Single (which is the default). + + To use it, simply construct an instance and then add items to the two listboxes, + available through lbAvailable() and lbSelected(). Whenever you want, you can retrieve + the selected options using TQListBox methods on lbSelected(). + + This way, you can use your own TQListBoxItem class, allowing you to easily + store object data in those. + + When an item is moved to a listbox, it is placed below the current item + of that listbox. + + Standard arrow icons are used, but you can use icons of your own choice if desired, + see setButtonIcon(). It is also possible to set tooltips and whatsthis help + for the buttons. See setButtonTooltip() and setButtonWhatsThis(). + + To set whatsthis or tooltips for the listboxes, access them through + availableListbox() and selectedListBox(). + + All the moving buttons are automatically set enabled as expected. + + Signals are sent each time an item is moved, allowing you to follow the + users actions if you need to. See addedToSelection(), removedFromSelection(), + movedUp() and movedDown() + + @author Anders Lund +*/ + +class TDEActionSelector : public TQWidget { + Q_OBJECT + + TQ_ENUMS( ButtonIconSize InsertionPolicy ) + TQ_PROPERTY( bool moveOnDoubleClick READ moveOnDoubleClick WRITE setMoveOnDoubleClick ) + TQ_PROPERTY( bool keyboardEnabled READ keyboardEnabled WRITE setKeyboardEnabled ) + TQ_PROPERTY( TQString availableLabel READ availableLabel WRITE setAvailableLabel ) + TQ_PROPERTY( TQString selectedLabel READ selectedLabel WRITE setSelectedLabel ) + TQ_PROPERTY( ButtonIconSize buttonIconSize READ buttonIconSize WRITE setButtonIconSize ) + TQ_PROPERTY( InsertionPolicy availableInsertionPolicy READ availableInsertionPolicy WRITE setAvailableInsertionPolicy ) + TQ_PROPERTY( InsertionPolicy selectedInsertionPolicy READ selectedInsertionPolicy WRITE setSelectedInsertionPolicy ) + TQ_PROPERTY( bool showUpDownButtons READ showUpDownButtons WRITE setShowUpDownButtons ) + +public: + TDEActionSelector( TQWidget *parent=0, const char *name=0 ); + ~TDEActionSelector(); + + /** + @return The TQListBox holding the available actions + */ + TQListBox *availableListBox(); + + /** + @return The TQListBox holding the selected actions + */ + TQListBox *selectedListBox(); + + /** + This enum indentifies the moving buttons + */ + enum MoveButton { + ButtonAdd, + ButtonRemove, + ButtonUp, + ButtonDown + }; + + /** + This enum identifies the icon sizes, used for the move buttons. + The values correspond to the following pixel sizes: + @li SmallIcon - the return value of IconSize( KIcon::Small ), the user defined size + of a small icon in KDE. This is the default setting. + @li Small - 16px + @li Medium - 22px + @li Large - 32px + @li XLarge - 48px + */ + enum ButtonIconSize { + SmallIcon, + Small, + Medium, + Large, + XLarge + }; + + /** + This enum defines policies for where to insert moved items in a listbox. + The following policies are currently defined: + @li BelowCurrent - The item is inserted below the listbox' + currentItem() or at the end if there is no curent item. + @li Sorted - The listbox is sort()ed after one or more items are inserted. + @li AtTop - The item is inserted at index 0 in the listbox. + @li AtBottom - The item is inserted at the end of the listbox. + + @sa availableInsertionPolicy(), setAvailableInsertionPolicy(), + selectedInsertionPolicy(), setSelectedInsertionPolicy(). + */ + enum InsertionPolicy { + BelowCurrent, + Sorted, + AtTop, + AtBottom + }; + + /** + @return Wheather moveOnDoubleClcik is enabled. + + If enabled, an item in any listbox will be moved to the other one whenever + doubleclicked. + @sa setMoveOnDoubleClick() + */ + bool moveOnDoubleClick() const; + + /** + Sets moveOnDoubleClick to @p enable + @sa moveOnDoubleClick() + */ + void setMoveOnDoubleClick( bool enable ); + + /** + @return Weather keyboard control is enabled. + + When Keyboard control is enabled, the widget will react to + the following keyboard actions: + @li CTRL + Right - simulate clicking the add button + @li CTRL + Left - simulate clicking the remove button + @li CTRL + Up - simulate clicking the up button + @li CTRL + Down - simulate clicking the down button + + Additionally, pressing RETURN or ENTER on one of the list boxes + will cause the current item of that listbox to be moved to the other + listbox. + + The keyboard actions are enabled by default. + + @sa setKeyboardEnabled() + */ + bool keyboardEnabled() const; + + /** + Sets the keyboard enabled depending on @p enable. + @sa keyboardEnabled() + */ + void setKeyboardEnabled( bool enable ); + + /** + @return The text of the label for the available items listbox. + */ + TQString availableLabel() const; + + /** + Sets the label for the available items listbox to @p text. + Note that this label has the listbox as its @e buddy, so that + if you have a single ampersand in the text, the following character + will become the accellerator to focus te listbox. + */ + void setAvailableLabel( const TQString & text ); + + /** + @return the label of the selected items listbox. + */ + TQString selectedLabel() const; + + /** + Sets the label for the selected items listbox to @p text. + Note that this label has the listbox as its @e buddy, so that + if you have a single ampersand in the text, the following character + will become the accellerator to focus te listbox. + */ + void setSelectedLabel( const TQString & text ); + + /** + @return the current ButtonIconSize. + */ + ButtonIconSize buttonIconSize() const; + + /** + Sets the button icon size. + See ButtonIconSize for the possible values and their pixel meaning. + */ + void setButtonIconSize( ButtonIconSize size ); + + /** + @return The current insertion policy for the available listbox. + The default policy for the available listbox is Sorted. + See also InsertionPolicy, setAvailableInsertionPolicy(). + */ + InsertionPolicy availableInsertionPolicy() const; + + /** + Sets the insertion policy for the available listbox. + See also InsertionPolicy, availableInsertionPolicy(). + */ + void setAvailableInsertionPolicy( InsertionPolicy policy ); + + /** + @return The current insertion policy for the selected listbox. + The default policy for the selected listbox is BelowCurrent. + See also InsertionPolicy, setSelectedInsertionPolicy(). + */ + InsertionPolicy selectedInsertionPolicy() const; + + /** + Sets the insertion policy for the selected listbox. + See also InsertionPolicy, selectedInsertionPolicy(). + */ + void setSelectedInsertionPolicy( InsertionPolicy policy ); + + /** + @return wheather the Up and Down buttons should be displayed. + */ + bool showUpDownButtons() const; + + /** + Sets wheather the Up and Down buttons should be displayed + according to @p show + */ + void setShowUpDownButtons( bool show ); + + /** + Sets the pixmap of the button @p button to @p icon. + It calls SmallIconSet(pm) to generate the icon set. + */ + void setButtonIcon( const TQString &icon, MoveButton button ); + + /** + Sets the iconset for button @p button to @p iconset. + You can use this method to et a costum icon set. Either + created by @ref TQIconSet, or use the application instance of + @ref KIconLoader (recommended). + */ + void setButtonIconSet( const TQIconSet &iconset, MoveButton button ); + + /** + Sets the tooltip for the button @p button to @p tip. + */ + void setButtonTooltip( const TQString &tip, MoveButton button ); + + /** + Sets the whatsthis help for button @p button to @p text. + */ + void setButtonWhatsThis( const TQString &text, MoveButton button ); + + /** + Sets the enabled state of all moving buttons to reflect the current + options. + + Be sure to call this if you add or removes items to either listbox after the + widget is show()n + */ + void setButtonsEnabled(); + +signals: + /** + Emitted when an item is moved to the "selected" listbox. + */ + void added( TQListBoxItem *item ); + + /** + Emitted when an item is moved out of the "selected" listbox. + */ + void removed( TQListBoxItem *item ); + + /** + Emitted when an item is moved upwards in the "selected" listbox. + */ + void movedUp( TQListBoxItem *item ); + + /** + Emitted when an item is moved downwards in the "selected" listbox. + */ + void movedDown( TQListBoxItem *item ); + + /** + Emitted when an item is moved to the "selected" listbox. + */ +// void addedToSelection( TQListBoxItem *item ); + +public slots: + /** + Reimplemented for internal reasons. + (calls setButtonsEnabled()) + */ + void polish(); + +protected: + /** + Reimplamented for internal reasons. + */ + void keyPressEvent( TQKeyEvent * ); + + /** + Reimplemented for internal reasons. + */ + bool eventFilter( TQObject *, TQEvent * ); + +private slots: + /** + Move selected item from available box to the selected box + */ + void buttonAddClicked(); + + /** + Move selected item from selected box to available box + */ + void buttonRemoveClicked(); + + /** + Move selected item in selected box upwards + */ + void buttonUpClicked(); + + /** + Move seleted item in selected box downwards + */ + void buttonDownClicked(); + + /** + Moves the item @p item to the other listbox if moveOnDoubleClick is enabled. + */ + void itemDoubleClicked( TQListBoxItem *item ); + + /** + connected to both list boxes to set the buttons enabled + */ + void slotCurrentChanged( TQListBoxItem * ) { setButtonsEnabled(); }; + +private: + + /** + Move item @p item to the other listbox + */ + void moveItem( TQListBoxItem *item ); + + /** + loads the icons for the move buttons. + */ + void loadIcons(); + + /** + @return the index to insert an item into listbox @p lb, + given InsertionPolicy @p policy. + + Note that if policy is Sorted, this will return -1. + Sort the listbox after inserting the item in that case. + */ + int insertionIndex( TQListBox *lb, InsertionPolicy policy ); + + /** + Private data storage + */ + TDEActionSelectorPrivate *d; +}; + +#endif // _KACTION_SELECTOR_H_ -- cgit v1.2.1