Initial commit
[raptor.git] / launcher / raptorsliderviewgroup.cpp
blob3fba9bcea356ef784bc8b1cad9eae3b6bd184f42
1 #include "raptorsliderviewgroup.h"
2 #include <QTimer>
3 #include <plasma/phase.h>
5 class RaptorSliderViewGroup::Private
7 public:
8 Private(){}
9 ~Private(){}
10 stackHash slideLayer;
11 int slideCount;
12 RaptorSlide * currentLayer;
13 int currentViewId;
14 QTimer * slideTimer;
15 RaptorSlide::Direction mode;
18 RaptorSliderViewGroup::RaptorSliderViewGroup(QGraphicsScene * parent):QObject(),d(new Private)
20 d->currentLayer = new RaptorSlide();
21 d->mode = RaptorSlide::Grid;
22 d->currentLayer->setDirection(d->mode);
23 d->currentLayer->move(10.0,0.0);
24 d->slideCount = 0;
25 d->slideLayer[0] = d->currentLayer;
26 canvas = parent;
27 d->currentViewId=0;
28 d->slideTimer = new QTimer(this);
31 RaptorSliderViewGroup::~RaptorSliderViewGroup()
33 delete d;
34 delete canvas;
36 void RaptorSliderViewGroup::setMode(RaptorSlide::Direction m)
38 d->mode = m;
40 bool RaptorSliderViewGroup::addItem(RaptorClaw * item)
43 if (!d->currentLayer->isFull()) {
44 d->currentLayer->addItem((RaptorClaw*)item);
45 canvas->addItem(item);
46 item->hide();
47 } else {
48 d->currentLayer = new RaptorSlide();
50 d->currentLayer->setDirection(d->mode);
51 d->slideLayer[++d->slideCount] = d->currentLayer;
52 d->currentLayer->addItem((RaptorClaw*)item);
53 canvas->addItem(item);
54 item->hide();
59 bool RaptorSliderViewGroup::deleteItem(QGraphicsItem * item)
63 QGraphicsItem * RaptorSliderViewGroup::find (const QString& key)
67 int RaptorSliderViewGroup::slideCount()
69 return d->slideCount;
72 void RaptorSliderViewGroup::view(int id)
74 //we want to hide quick for now..
75 //TODO : add phase animation integration.here
76 for (int i = 0; i < d->slideLayer.count(); i++) {
77 //Plasma::Phase().animateItem(d->slideLayer[i],Plasma::Phase::Disappear);
78 // Plasma::Phase().moveItem(d->slideLayer[i],Plasma::Phase::SlideOut,QPoint(400,400));
79 d->slideLayer[i]->hide();
81 if (d->slideLayer[id]) {
82 d->slideLayer[id]->show();
84 d->currentViewId= id;
86 //protected
88 void RaptorSliderViewGroup::swapNext()
90 if ((d->currentViewId ) < d->slideCount)
92 d->currentViewId = d->currentViewId + 1;
93 this->view(d->currentViewId);
95 qDebug("Now Swaping");
98 void RaptorSliderViewGroup::swapPrevious()
100 if ( d->currentViewId -1 >= 0) {
101 this->view(--d->currentViewId);
105 void RaptorSliderViewGroup::move(float x , float y)
107 for (int i = 0; i < d->slideLayer.count(); i++) {
108 d->slideLayer[i]->move(x,y);
113 float RaptorSliderViewGroup::height()
115 return d->currentLayer->height();
118 #include "raptorsliderviewgroup.moc"