Basic openoffice.org control, and listening for new presentation documents, still...
[kworship.git] / unipresent / kpresenter1 / UpKpr1Presentation.cpp
blob105600743c87d4f4241e1bfc2f4a8b092116eb13
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 /**
21 * @file UpKpr1Presentation.cpp
22 * @brief KPresenter 1 presentation.
23 * @author James Hogan <james@albanarts.com>
26 #include "UpKpr1Presentation.h"
27 #include "UpKpr1Slide.h"
28 #include "UpKpr1Backend.h"
31 * Constructors + destructor
34 /// Primary constructor.
35 UpKpr1Presentation::UpKpr1Presentation(const UpKpr1PresentationDcop& dcop, const UpKpr1ViewDcop& dcopView, UpKpr1Backend* parent)
36 : UpPresentation(parent, parent)
37 , m_dcop(dcop)
38 , m_dcopView(dcopView)
39 , m_url(dcop.url())
41 Q_ASSERT(m_dcopView.isValid());
44 /// Destructor.
45 UpKpr1Presentation::~UpKpr1Presentation()
50 * Main interface
53 void UpKpr1Presentation::close()
57 QUrl UpKpr1Presentation::url() const
59 return m_url;
63 * Custom slideshows
66 QString UpKpr1Presentation::currentSlideshow()
68 return "All slides";
71 QStringList UpKpr1Presentation::slideshows()
73 return QStringList() << "All slides";
76 void UpKpr1Presentation::setSlideshow(QString slideshow)
80 int UpKpr1Presentation::numSlides()
82 return m_dcop.numPages();
85 UpSlide* UpKpr1Presentation::slide(int index)
87 return new UpKpr1Slide(this, m_dcop.slide(index), index);
91 * Slideshow accessors
94 bool UpKpr1Presentation::isSlideshowRunning()
96 return m_dcopView.getCurrentPresPage() != -1;
99 int UpKpr1Presentation::numSlidesInSlideshow()
101 return m_dcopView.getNumPresPages();
104 int UpKpr1Presentation::currentSlideshowSlide()
106 return m_dcopView.getCurrentPresPage() - 1;
109 int UpKpr1Presentation::stepsInCurrentSlideshowSlide()
111 return m_dcopView.getPresStepsOfPage();
114 int UpKpr1Presentation::currentSlideshowStep()
116 return m_dcopView.getCurrentPresStep();
120 * Slideshow control
123 void UpKpr1Presentation::startSlideshow()
125 m_dcopView.screenStartFromFirst();
126 slideshowStarted(m_dcopView.getNumPresPages());
127 signalChangedSlide();
130 void UpKpr1Presentation::stopSlideshow()
132 m_dcopView.screenStop();
133 slideshowStopped();
136 void UpKpr1Presentation::goToSlide(int index)
138 m_dcopView.gotoPresPage(index+1);
139 signalChangedSlide();
142 void UpKpr1Presentation::previousSlide()
144 int newPage = m_dcopView.getCurrentPresPage() - 1;
145 if (newPage > 0)
147 m_dcopView.gotoPresPage(newPage);
148 signalChangedSlide();
152 void UpKpr1Presentation::nextSlide()
154 int presPages = m_dcopView.getNumPresPages();
155 int newPage = m_dcopView.getCurrentPresPage() + 1;
156 if (newPage <= presPages)
158 m_dcopView.gotoPresPage(newPage);
159 signalChangedSlide(newPage);
163 void UpKpr1Presentation::previousStep()
165 int slide = m_dcopView.getCurrentPresPage();
166 m_dcopView.screenPrev();
167 int newSlide = m_dcopView.getCurrentPresPage();
168 if (slide != newSlide)
170 signalChangedSlide(newSlide);
172 else
174 signalChangedStep();
178 void UpKpr1Presentation::nextStep()
180 // don't go past the end of the slideshow
181 bool operate = true;
182 int steps = m_dcopView.getPresStepsOfPage();
183 int step = m_dcopView.getCurrentPresStep();
184 int page = -1;
185 if (step == steps - 1)
187 int pages = m_dcopView.getNumPresPages();
188 page = m_dcopView.getCurrentPresPage();
189 if (page == pages)
191 operate = false;
194 if (operate)
196 m_dcopView.screenNext();
197 int newSlide = m_dcopView.getCurrentPresPage();
198 if (page != newSlide)
200 signalChangedSlide(newSlide);
202 else
204 signalChangedStep();
210 * Backend specific interface.
213 /// Get the dcop interface.
214 UpKpr1PresentationDcop UpKpr1Presentation::dcop() const
216 return m_dcop;
219 /// Get the dcop view interface.
220 UpKpr1ViewDcop UpKpr1Presentation::dcopView() const
222 return m_dcopView;
226 * Helpers
229 /// Signal that the slide has changed.
230 void UpKpr1Presentation::signalChangedSlide(int slide, int step)
232 if (slide < 0)
234 slide = m_dcopView.getCurrentPresPage();
236 slideshowSlideChanged(slide - 1, m_dcopView.getPresStepsOfPage());
237 signalChangedStep(step);
240 /// Signal that the step has changed.
241 void UpKpr1Presentation::signalChangedStep(int step)
243 if (step < 0)
245 step = m_dcopView.getCurrentPresStep();
247 slideshowStepChanged(step);
251 #include "UpKpr1Presentation.moc"