Tests/DemoGUI/GridView.cpp
author cgandhi
Mon, 11 Oct 2010 21:59:54 +0530
changeset 26 83d6a149c755
permissions -rw-r--r--
Submitting following changes - AuthApps for Last.fm and Twitter added API for checking ServiceAuthorization added for SMFCredMgrClient API added for forcefully removing credential details from SMFCredMgr Extra argument checks in SMfClient APIs APIs for service login and logout from SMFClient Redundant members removed from SmfServerSymbian DSM bug fixes Test Apps included

#include "GridView.h"
#include "ScreenSize.h"
#include <qgridlayout.h>
#include <qpushbutton.h>
#include <qdebug.h>

GridView::GridView()
{

}
GridView::~GridView()
{

}
void GridView::CreateGridView(QStringList aIconPath, QStringList names)
{
	qDebug()<<"Inside GridView::CreateGridView()";
	qDebug()<<"aIconPath count = "<<aIconPath.count();
	qDebug()<<"names count = "<<names.count();

    int row;
    int col;
    QWidget* widget = new QWidget();
    QGridLayout* GridLayout = new QGridLayout(widget);
    if((6 == aIconPath.count()) || (5 == aIconPath.count()))
    {
        row = 3;
        col = 2;
    }
    else if((4 == aIconPath.count()) || (3 == aIconPath.count()))
    {
        row = col = 2;
    }
    else if((2 == aIconPath.count()) || (1 == aIconPath.count()))
    {
        row = 1;
        col = 2;
    }
    else if(0 == aIconPath.count())
    {
        row = col = 0;
    }

    int rowSpace = (ScreenSize::GetScreenRect().height() - (KHeadNameHeight+ToolbarIconHeight+2*KWidgetGapFactor))/row;
    int colSpace = (ScreenSize::GetScreenRect().width() - 2*KWidgetGapFactor )/col;

    int index = 0;
    for(int i=0;i<row;i++)
    {
        for(int j=0;j<col;j++)
        {
        QPushButton *pushBtn = new QPushButton();
        qDebug()<<"name = "<<names[index];
        //pushBtn->
        pushBtn->setGeometry(i*colSpace,(j*rowSpace + KWidgetGapFactor),colSpace,rowSpace);
        pushBtn->setIconSize(QSize(colSpace,colSpace));
        qDebug()<<"icon = "<<aIconPath[index];
        pushBtn->setIcon(QIcon(aIconPath[index]));
        GridLayout->addWidget(pushBtn,i,j);
        pushBtn->show();
        
        index++;
        if(index == names.count())
        	{
        	qDebug()<<"Count became same so exiting";
			break;
        	}
        }
	if(index == names.count())
		{
		qDebug()<<"Count became same so exiting";
		break;
		}
    }
	//return widget;

}