|
1 #include "GridView.h" |
|
2 #include "ScreenSize.h" |
|
3 #include <qgridlayout.h> |
|
4 #include <qpushbutton.h> |
|
5 #include <qdebug.h> |
|
6 |
|
7 GridView::GridView() |
|
8 { |
|
9 |
|
10 } |
|
11 GridView::~GridView() |
|
12 { |
|
13 |
|
14 } |
|
15 void GridView::CreateGridView(QStringList aIconPath, QStringList names) |
|
16 { |
|
17 qDebug()<<"Inside GridView::CreateGridView()"; |
|
18 qDebug()<<"aIconPath count = "<<aIconPath.count(); |
|
19 qDebug()<<"names count = "<<names.count(); |
|
20 |
|
21 int row; |
|
22 int col; |
|
23 QWidget* widget = new QWidget(); |
|
24 QGridLayout* GridLayout = new QGridLayout(widget); |
|
25 if((6 == aIconPath.count()) || (5 == aIconPath.count())) |
|
26 { |
|
27 row = 3; |
|
28 col = 2; |
|
29 } |
|
30 else if((4 == aIconPath.count()) || (3 == aIconPath.count())) |
|
31 { |
|
32 row = col = 2; |
|
33 } |
|
34 else if((2 == aIconPath.count()) || (1 == aIconPath.count())) |
|
35 { |
|
36 row = 1; |
|
37 col = 2; |
|
38 } |
|
39 else if(0 == aIconPath.count()) |
|
40 { |
|
41 row = col = 0; |
|
42 } |
|
43 |
|
44 int rowSpace = (ScreenSize::GetScreenRect().height() - (KHeadNameHeight+ToolbarIconHeight+2*KWidgetGapFactor))/row; |
|
45 int colSpace = (ScreenSize::GetScreenRect().width() - 2*KWidgetGapFactor )/col; |
|
46 |
|
47 int index = 0; |
|
48 for(int i=0;i<row;i++) |
|
49 { |
|
50 for(int j=0;j<col;j++) |
|
51 { |
|
52 QPushButton *pushBtn = new QPushButton(); |
|
53 qDebug()<<"name = "<<names[index]; |
|
54 //pushBtn-> |
|
55 pushBtn->setGeometry(i*colSpace,(j*rowSpace + KWidgetGapFactor),colSpace,rowSpace); |
|
56 pushBtn->setIconSize(QSize(colSpace,colSpace)); |
|
57 qDebug()<<"icon = "<<aIconPath[index]; |
|
58 pushBtn->setIcon(QIcon(aIconPath[index])); |
|
59 GridLayout->addWidget(pushBtn,i,j); |
|
60 pushBtn->show(); |
|
61 |
|
62 index++; |
|
63 if(index == names.count()) |
|
64 { |
|
65 qDebug()<<"Count became same so exiting"; |
|
66 break; |
|
67 } |
|
68 } |
|
69 if(index == names.count()) |
|
70 { |
|
71 qDebug()<<"Count became same so exiting"; |
|
72 break; |
|
73 } |
|
74 } |
|
75 //return widget; |
|
76 |
|
77 } |