/***************************************************************************
 *   Copyright (C) 2004 by Trenton Carr                                    *
 *   trenton.carr@gmail.com                                                *
 *                                                                         *
 *   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 of the License, 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.                          *
 *                                                                         *
 *   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.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/

#include "startwidgetview.h"

#include <qtabwidget.h>
#include <qwidget.h>

#include <kdebug.h>
#include <klibloader.h>
#include <klocale.h>
#include <ktrader.h>

#include "parts/kmathbase_part.h"

StartWidgetView::StartWidgetView(QWidget* parent, const char* name, WFlags fl)
        : StartWidgetD(parent,name,fl)
{
    KTrader::OfferList parts = KTrader::self()->query( QString::fromLatin1( "KMathtool/MathBasePart" ) );
//    kDebug() << "# of parts: " << parts.size() << endl;

    for ( KTrader::OfferListIterator it = parts.begin(); it != parts.end(); ++it )
    {
        KService::Ptr ptr = (*it);
        KLibFactory *factory = KLibLoader::self()->factory( ptr->library() );
        if ( factory )
        {
            KMathBasePart* part = static_cast<KMathBasePart *>( factory->create( this, ptr->name(), "KMathBasePart" ) );
            if ( part )
            {
                tabWidget->insertTab( part->widget(), ptr->comment() );
                kDebug() << "part: " << ptr->library() << " - OK" << endl;
            }
        }
    }

}

StartWidgetView::~StartWidgetView()
{}


#include "startwidgetview.moc"
