1 #include "raptorslide.h"
5 class RaptorSlide::Private
10 // ItemList m_itemList; //Hash of ponters indexed with integer key
11 int m_index
;//integer index for the slide
12 int m_count
;//current itemcount
13 int m_max
; // Max number of this slide.
14 QString m_name
;//name of the slide
21 RaptorSlide::Direction m_SlideLayout
;
26 typedef QHash
<int,QPoint
> GridHash
;
30 RaptorSlide::RaptorSlide(QGraphicsItem
*parent
)
31 : QGraphicsItemGroup(parent
)
39 d
->m_slideLength
= 0.0;
40 d
->m_SlideLayout
= Verticle
;
45 d
->hideTimer
= new QTimer(this);
46 connect(d
->hideTimer
,SIGNAL(timeout()),this,SLOT(animate()));
52 RaptorSlide::~RaptorSlide()
58 QMap<RaptorClaw*,RaptorSlide*>& RaptorSlide::groupMap()
60 static GroupMap *group = 0;
69 QString
RaptorSlide::name()
74 void RaptorSlide::setName(const QString
&name
)
79 bool RaptorSlide::addItem(RaptorClaw
*item
)
82 kDebug() << "Null Item not added" << endl
;
91 void RaptorSlide::setDirection(RaptorSlide::Direction layout
)
93 d
->m_SlideLayout
= layout
;
97 RaptorSlide::Direction
RaptorSlide::direction()
99 return d
->m_SlideLayout
;
102 void RaptorSlide::doLayoutShift()
104 float len
= (direction() == Horizontal
)?this->d
->x
:this->d
->y
;
106 if (direction() == Grid
) {
107 //Calcaulate Gird values.
110 int totalHeight
= itemHeight
;
111 int totalWidth
= itemWidth
;
113 for (int i
= 0 ; i
< items
.size();i
++) {
114 itemWidth
= items
.at(i
)->boundingRect().width();
115 itemHeight
= items
.at(i
)->boundingRect().height();
116 totalWidth
+=itemWidth
;
117 totalHeight
+=itemHeight
;
124 kDebug() << "item height , width" << totalWidth
<< totalHeight
;
126 for (int i
=-0; i
< items
.size(); i
++ ) {
131 d
->ghash
[i
] = QPoint(x
,y
);
132 items
.at(i
)->setPos(d
->ghash
[i
]);
140 for (int i
= 0; i
< items
.size(); ++i
) {
141 if (direction() == Horizontal
) {
142 items
.at(i
)->setPos(len
/2,items
.at(0)->y());
143 len
+= items
.at(i
)->boundingRect().width();
145 //item at zero to avoice starecase effect
146 items
.at(i
)->setPos(items
.at(0)->x(),len
/2);
147 len
+= items
.at(i
)->boundingRect().height();
153 bool RaptorSlide::deleteItem(RaptorClaw
*item
)
155 removeFromGroup(item
);
161 RaptorClaw
* RaptorSlide::find(const QString
&key
)
165 void RaptorSlide::show()
167 for (int i
= 0; i
< items
.size(); ++i
)
169 kDebug() << "Showing:"<< items
.at(i
)->name();
171 items
.at(i
)->setOpacity(1.0);
172 items
.at(i
)->update();
178 void RaptorSlide::move(float x
, float y
, float z
)
183 if (items
.count() >= 1) {
184 items
.at(0)->setPos(x
,y
);
190 bool RaptorSlide::isFull()
192 if (d
->m_max
== d
->m_count
) {
198 void RaptorSlide::hide()
200 // d->hideTimer->start(100);
201 for (int i
= 0; i
< items
.size(); ++i
)
205 this->d
->m_visible
= false;
208 bool RaptorSlide::isVisible()
213 int RaptorSlide::height()
218 void RaptorSlide::animate()
223 #include "raptorslide.moc"