PhotoStripView::PhotoStripView(PhotoStrip *controller) : MWidgetView(controller), controller(controller), viewport(new Viewport), mainLayout(new QGraphicsLinearLayout(Qt::Horizontal)), pannedWidget(new QGraphicsWidget), focusedWidget(-1), _isPositionChanged(false), isModelRowChanged(false), currentModel(0), mode(PhotoStripView::OnNormal) { /* controller initial setting */ controller->setContentsMargins(0, 0, 0, 0); controller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); /* pannable viewport initial setting */ viewport->setObjectName("PhotoStripDetailsViewport"); viewport->setPanDirection(Qt::Horizontal); viewport->setContentsMargins(0, 0, 0, 0); viewport->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); viewport->setAutoRange(false); /* the layout of viewport initial setting */ mainLayout->setSpacing(0); mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->addItem(viewport); controller->setLayout(mainLayout); /* pannedWidget initial setting */ pannedWidget->setContentsMargins(0, 0, 0, 0); pannedWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); /* pannedLayout initial setting */ pannedLayout = new PhotoStripLayout(); pannedWidget->setLayout(pannedLayout); pannedLayout->setSpacing(ITEM_SPACING); pannedLayout->setContentsMargins(0, 0, 0, 0); connect(viewport, SIGNAL(sizePosChanged(const QSizeF &, const QRectF &, const QPointF &)), this, SLOT(sizePosChanged(const QSizeF &, const QRectF &, const QPointF &))); viewport->setWidget(pannedWidget); viewport->positionIndicator()->hide(); physics = new PhotoStripPhysics(this); connect(physics, SIGNAL(snapIndexChanged(int)), this, SLOT(snapIndexChanged(int))); viewport->setPhysics(physics); connect(viewport, SIGNAL(panningStopped()), this, SLOT(panningStopped())); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(showNextImage())); timer->setInterval(SLIDESHOW_INTERVAL); connect(viewport, SIGNAL(mousePress()), this, SLOT(mousePress())); }
void MList::updateData(const QList<const char *>& modifications) { const char *member; for (int i = 0; i < modifications.count(); i++) { member = modifications[i]; if (member == MListModel::ListIsMoving) { model()->listIsMoving() ? emit panningStarted() : emit panningStopped(); } } }
void Ut_PagedPanning::performIntegration(PagedPanning* pagedPanning) { Ut_MPhysics2DPanning physicsDriver(pagedPanning); QSignalSpy stopSpy(pagedPanning, SIGNAL(panningStopped())); int i = 0; do { physicsDriver.advancePhysicsCalculation(); i++; } while (stopSpy.count() == 0 && i < 100000); }
void Ut_PagedPanning::testWhenRangeChangesWhileActivelyPanningThenPanningStoppedSignalGetsEmitted() { Ut_MPhysics2DPanning physicsDriver(m_subject); // Start panning m_subject->pointerPress(QPointF(0.0, 0.0)); physicsDriver.advancePhysicsCalculation(); QSignalSpy panningStoppedSpy(m_subject, SIGNAL(panningStopped())); m_subject->setRange(QRectF(0.0, 0.0, (DEFAULT_NUM_PAGES - 1) * (DEFAULT_PAGE_WIDTH * 1.5), 0.0)); physicsDriver.advancePhysicsCalculation(); QCOMPARE(panningStoppedSpy.count(), 1); }
void MPhysics2DPanning::stop() { Q_D(MPhysics2DPanning); // Checking if the viewport is currently dragged beyond its borders and the integration should // continue. bool inRangeX = (d->panDirection.testFlag(Qt::Horizontal) == false) || (d->posX >= d->range.left() && d->posX <= d->range.right()); bool inRangeY = (d->panDirection.testFlag(Qt::Vertical) == false) || (d->posY >= d->range.top() && d->posY <= d->range.bottom()); if (inRangeX && inRangeY) { d->panningAnimation->stop(); emit panningStopped(); } }
DynamicAlbumList::DynamicAlbumList(MWidget *parent) : DynamicMList(parent, MContentItem::IconAndTwoTextLabels, 1), albumListDeleteConfirm(NULL) { connect(this, SIGNAL(panningStopped()), this, SLOT(doTasklet())); connect(AppWindow::instance(), SIGNAL(orientationChanged(M::Orientation)), this, SLOT(onOrientationChanged(M::Orientation))); MPListModel *albumListModel = new MPListModel(this, "", MPListModel::Album); albumTasklet = new PhotosTasklet(parent); setItemModel(albumListModel); setTasklet(albumTasklet); MContentItemCreator *albumThumbnailCreator = dynamic_cast<MContentItemCreator *>(cellCreator()); albumThumbnailCreator->setCellProcessor(new AlbumThumbnailsCellProcessor(this)); onOrientationChanged(AppWindow::instance()->orientation()); setColumns(2); setObjectName("albumList"); connect(this, SIGNAL(itemClicked(const QModelIndex&)), this, SLOT(onClick(const QModelIndex&))); QPixmapCache::setCacheLimit (4096); QTimer::singleShot(1500, this, SLOT(doTasklet())); }
void Ut_PagedPanning::testWhenPhysicsDisabledWhileActivelyPanningThenPositionIsPannedToNearestPage() { Ut_MPhysics2DPanning physicsDriver(m_subject); // Start panning m_subject->pointerPress(QPointF(0.0, 0.0)); for (int i = 0; i < DEFAULT_PAGE_WIDTH; i++) { m_subject->pointerMove(QPointF(-i * 2.2, 0)); physicsDriver.advancePhysicsCalculation(); } int currentPage = m_subject->currentPage; // Disable while being panned m_subject->setEnabled(false); QSignalSpy panningStoppedSpy(m_subject, SIGNAL(panningStopped())); performIntegration(m_subject); QCOMPARE(m_subject->position().x(), currentPage * DEFAULT_PAGE_WIDTH); QCOMPARE(panningStoppedSpy.count(), 2); }
void MPhysics2DPanning::pointerRelease() { Q_D(MPhysics2DPanning); // Disables the pointer spring d->pointerPressed = false; if (d->enabled == false) { //The physics engine is not working, emitting panning stopped now. emit panningStopped(); } // Resolve new velocity only if we have enough samples if (d->positions.count() > 1) { // Get the current velocity QPointF v = d->getVelocity(); // Limit the velocity d->velX = qBound(-d->maxVel, v.x(), d->maxVel); d->velY = qBound(-d->maxVel, v.y(), d->maxVel); d->positions.clear(); } emit pointerReleased(); }
DynamicAlbumList::~DynamicAlbumList() { //The base class's destructor takes care of the model and the tasklet disconnect(this, SIGNAL(panningStopped()), this, SLOT(doTasklet())); }
OpenDialog::OpenDialog(QGraphicsWidget*, const QString ¤tFileName) { MWidget *centralWidget = new MWidget; MLayout *layout = new MLayout(); layout->setContentsMargins(0,0,0,0); MLinearLayoutPolicy* landscapePolicy = new MLinearLayoutPolicy(layout, Qt::Vertical); MLinearLayoutPolicy* portraitPolicy = new MLinearLayoutPolicy(layout, Qt::Vertical); // m_itemSize.setWidth(100); // m_itemSize.setHeight(100); m_columnsPortrait = 4; m_columnsLandscape = 5; m_columnsLandscapeSlider = 0; m_columnsPortraitSlider = 0; list = new MList(this); list->setObjectName("list"); landscapePolicy->addItem(list); portraitPolicy->addItem(list); landscapePolicy->setContentsMargins(20, 12, 20, 0); portraitPolicy->setContentsMargins(20, 24, 20, 0); layout->setLandscapePolicy(landscapePolicy); layout->setPortraitPolicy(portraitPolicy); //int initialWidth = MApplication::activeWindow()->visibleSceneSize().width(); /* if(MApplication::activeWindow()->orientation() == M::Portrait) { list->setColumns(m_columnsPortrait); m_itemSize.setWidth(initialWidth / m_columnsPortrait); m_itemSize.setHeight(m_itemSize.width()); } else { list->setColumns(m_columnsLandscape); m_itemSize.setWidth(initialWidth / m_columnsLandscape); m_itemSize.setHeight(m_itemSize.width()); }*/ m_itemSize.setWidth(110); m_itemSize.setHeight(110); ContentItemCreator *cellCreator = new ContentItemCreator(this); list->setCellCreator(cellCreator); QStringList mediaDirs; mediaDirs << APP_CATALOG; model = new OpenDialogModel(this, m_itemSize.toSize(), mediaDirs, currentFileName); model->setObjectName("gridModel"); list->setItemModel(model); connect(list, SIGNAL(itemClicked(QModelIndex)), this, SLOT(itemClicked(QModelIndex))); connect(list, SIGNAL(panningStarted()), this, SLOT(pauseLoaders())); connect(list, SIGNAL(panningStopped()), this, SLOT(resumeLoaders())); centralWidget->setLayout(layout); this->setTitle("Choose an image"); this->setModal(true); this->setCentralWidget(centralWidget); }