summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views/colorlistbox.cpp
authorzautrix <zautrix>2005-04-02 12:16:34 (UTC)
committer zautrix <zautrix>2005-04-02 12:16:34 (UTC)
commit997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe (patch) (side-by-side diff)
treef788b37459574b5cea0d2ab874882c6a396c240d /kaddressbook/views/colorlistbox.cpp
parente0d51120d2f0c178115746e0c1357af40f95bc77 (diff)
downloadkdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.zip
kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.gz
kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.bz2
more fixes
Diffstat (limited to 'kaddressbook/views/colorlistbox.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/colorlistbox.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/kaddressbook/views/colorlistbox.cpp b/kaddressbook/views/colorlistbox.cpp
index c243fa0..7386207 100644
--- a/kaddressbook/views/colorlistbox.cpp
+++ b/kaddressbook/views/colorlistbox.cpp
@@ -11,91 +11,96 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <qpainter.h>
#include <kcolordialog.h>
#ifndef KAB_EMBEDDED
#include <kcolordrag.h>
#endif //KAB_EMBEDDED
#include "colorlistbox.h"
ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f )
:KListBox( parent, name, f ), mCurrentOnDragEnter(-1)
{
connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) );
+ connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) );
setAcceptDrops( true);
}
void ColorListBox::setEnabled( bool state )
{
if( state == isEnabled() )
{
return;
}
QListBox::setEnabled( state );
for( uint i=0; i<count(); i++ )
{
updateItem( i );
}
}
void ColorListBox::setColor( uint index, const QColor &color )
{
if( index < count() )
{
ColorListItem *colorItem = (ColorListItem*)item(index);
colorItem->setColor(color);
updateItem( colorItem );
}
}
QColor ColorListBox::color( uint index ) const
{
if( index < count() )
{
ColorListItem *colorItem = (ColorListItem*)item(index);
return( colorItem->color() );
}
else
{
return( black );
}
}
-
+void ColorListBox::slotNewColor(QListBoxItem * i)
+{
+ if ( i )
+ newColor( index( i ) );
+}
void ColorListBox::newColor( int index )
{
if( isEnabled() == false )
{
return;
}
if( (uint)index < count() )
{
QColor c = color( index );
#ifndef KAB_EMBEDDED
if( KColorDialog::getColor( c, this ) != QDialog::Rejected )
{
setColor( index, c );
}
#else //KAB_EMBEDDED
KColorDialog* k = new KColorDialog( this );
k->setColor( c );
int res = k->exec();
if ( res ) {
setColor( index, k->getColor() );
}
delete k;