Merge branch 'central-widget'
[krunner.git] / raptorsliderviewgroup.cpp
blobfe8d95eebdb2e5e289605cc79d5e4535bee8141d
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 *scene)
20 d->currentLayer = new RaptorSlide();
21 d->mode = RaptorSlide::Grid; // Default is 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 = scene;
27 d->currentViewId = 0;
28 d->slideTimer = new QTimer(this);
31 RaptorSliderViewGroup::~RaptorSliderViewGroup()
33 delete d;
36 void RaptorSliderViewGroup::setMode(RaptorSlide::Direction m)
38 d->mode = m;
41 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();
49 d->currentLayer->setDirection(d->mode);
50 d->slideLayer[++d->slideCount] = d->currentLayer;
51 d->currentLayer->addItem(item);
52 canvas->addItem(item);
53 item->hide();
58 void RaptorSliderViewGroup::clearItems()
60 while (d->slideCount == 0) {
61 delete d->slideLayer[d->slideCount];
62 d->slideCount--;
66 QGraphicsItem* RaptorSliderViewGroup::find(const QString& key)
70 int RaptorSliderViewGroup::slideCount()
72 return d->slideCount;
75 void RaptorSliderViewGroup::view(int id)
77 // we want to hide quick for now..
78 // TODO : add phase animation integration.here
79 for (int i = 0; i < d->slideLayer.count(); i++) {
80 // Plasma::Phase().animateItem(d->slideLayer[i],Plasma::Phase::Disappear);
81 // Plasma::Phase().moveItem(d->slideLayer[i],Plasma::Phase::SlideOut,QPoint(400,400));
82 d->slideLayer[i]->hide();
84 if (d->slideLayer[id]) {
85 d->slideLayer[id]->show();
87 d->currentViewId= id;
89 //protected
91 void RaptorSliderViewGroup::swapNext()
93 if ((d->currentViewId ) < d->slideCount)
95 d->currentViewId = d->currentViewId + 1;
96 this->view(d->currentViewId);
98 qDebug("Now Swapping");
101 void RaptorSliderViewGroup::swapPrevious()
103 if ( d->currentViewId -1 >= 0) {
104 this->view(--d->currentViewId);
108 void RaptorSliderViewGroup::move(float x , float y)
110 for (int i = 0; i < d->slideLayer.count(); i++) {
111 d->slideLayer[i]->move(x,y);
115 float RaptorSliderViewGroup::height()
117 return d->currentLayer->height();
120 #include "raptorsliderviewgroup.moc"