/* ============================================================
 *
 * This file is a part of digiKam project
 * http://www.digikam.org
 *
 * Date        : 2008-03-14
 * Description : a widget to host settings as expander box in exclusive mode
 *
 * Copyright (C) 2008-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
 * Copyright (C) 2008-2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 * Copyright (C) 2010      by Manuel Viet    <contact at 13zenrv dot fr>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 *
 * This program 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 General Public License for more details.
 *
 * ============================================================ */

#include "rexpanderboxexclusive.moc"

namespace Digikam
{

RExpanderBoxExclusive::RExpanderBoxExclusive(QWidget* parent)
                     : KDcrawIface::RExpanderBox(parent)
{
    setIsToolBox(true);
}

RExpanderBoxExclusive::~RExpanderBoxExclusive()
{
}

void RExpanderBoxExclusive::slotItemExpanded(bool b)
{
    KDcrawIface::RLabelExpander* exp = dynamic_cast<KDcrawIface::RLabelExpander*>(sender());
    if (!exp) return;

    if (isToolBox() && b)
    {
        int item = 0;

        while (item < count())
        {
            if (isItemExpanded(item) && item != indexOf(exp))
            {
                setItemExpanded(item, false);
            }
            item++;
        }
    }
    emit signalItemExpanded(indexOf(exp), b);
}

void RExpanderBoxExclusive::setIsToolBox(bool b)
{
    m_toolbox = b;
}

bool RExpanderBoxExclusive::isToolBox() const
{
    return (m_toolbox);
}

} // namespace Digikam 
