void PolarChartLogValueAxisRadial::handleBaseChanged(qreal base) { Q_UNUSED(base); QGraphicsLayoutItem::updateGeometry(); if (presenter()) presenter()->layout()->invalidate(); }
void PolarChartLogValueAxisRadial::handleLabelFormatChanged(const QString &format) { Q_UNUSED(format); QGraphicsLayoutItem::updateGeometry(); if (presenter()) presenter()->layout()->invalidate(); }
void PolarChartValueAxisAngular::handleMinorTickCountChanged(int tick) { Q_UNUSED(tick); QGraphicsLayoutItem::updateGeometry(); if (presenter()) presenter()->layout()->invalidate(); }
TEST(MapTreeViewPresenterTest, AddItem) { Models::MapCollection mapCollection; MockMapTreeView view; MapTreeViewPresenter<MockMapTreeView> presenter(mapCollection, view); { presenter.MapTreeView_ItemAdded(view, 0); const Models::MapCollection::ChildIds& childIds = mapCollection.GetChildIds(0); ASSERT_EQ(1u, childIds.size()); ASSERT_EQ("AddItem", view.calledMethod); int newChildId = *(childIds.begin()); ASSERT_EQ(newChildId, view.intValues["id"]); ASSERT_EQ(0, view.intValues["parentId"]); ASSERT_EQ("", view.stringValues["name"]); } { presenter.MapTreeView_ItemAdded(view, 2); const Models::MapCollection::ChildIds& childIds = mapCollection.GetChildIds(2); ASSERT_EQ(1u, childIds.size()); ASSERT_EQ("AddItem", view.calledMethod); int newChildId = *(childIds.begin()); ASSERT_EQ(newChildId, view.intValues["id"]); ASSERT_EQ(2, view.intValues["parentId"]); ASSERT_EQ("", view.stringValues["name"]); } }
TEST(chatpresenter, test_incomingMessages) { Poco::SharedPtr<MockChatService> m(new MockChatService); Mvp::Presenter::TextChatPresenter presenter(m.get()); Poco::SharedPtr<MockChatView> v(new MockChatView()); EXPECT_CALL(*v, initialize()); ON_CALL(*m, getParticipants()) .WillByDefault(Return(contacts)); ON_CALL(*m, messageHistory(_)) .WillByDefault(Return(messages)); EXPECT_CALL(*m, chatName()); EXPECT_CALL(*v, setChatTitle(_)); EXPECT_CALL(*m, messageHistory(_)); EXPECT_CALL(*m, isConsumer()); EXPECT_CALL(*v, enableControls(_)); EXPECT_CALL(*v, showLeaveAction(_)); EXPECT_CALL(*m, getParticipants()); EXPECT_CALL(*v, setParticipants(_)); presenter.setView(v.get()); EXPECT_CALL(*v, showView()); presenter.showView(); EXPECT_CALL(*v, addMessage(_)); m->triggerIncomingMessage(); }
TEST(MapTreeViewPresenterTest, Reset) { Models::MapCollection mapCollection; MockMapTreeView view; MapTreeViewPresenter<MockMapTreeView> presenter(mapCollection, view); ASSERT_EQ("Reset", view.calledMethod); ASSERT_EQ(&mapCollection, view.mapCollectionValues["mapCollection"]); }
void StateView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (event->buttons() & Qt::MiddleButton) { if (auto si = dynamic_cast<Scenario::ScenarioInterface*>( presenter().model().parent())) { auto obj = copySelectedElementsToJson( *const_cast<ScenarioInterface*>(si), score::IDocument::documentContext(*m_presenter.model().parent())); if (!obj.empty()) { QDrag d{this}; auto m = new QMimeData; QJsonDocument doc{obj}; ; m->setData( score::mime::scenariodata(), doc.toJson(QJsonDocument::Indented)); d.setMimeData(m); d.exec(); } } } if (m_moving || (event->buttonDownScreenPos(Qt::LeftButton) - event->screenPos()) .manhattanLength() > QApplication::startDragDistance()) { m_moving = true; m_presenter.moved(event->scenePos()); } event->accept(); }
void DoGraphPresenterTest(TestCode t) { QCustomPlot plot; SignalData data; PlotInfo info; QScrollBar rangeScrollBar; GraphPresenter presenter(&plot, &rangeScrollBar, data, info); t(presenter, plot, data); }
int main() { rinle::model::Model model; rinle::view::Window window(model); rinle::presenter::Presenter presenter(model, window); presenter.setCurrent(rinle::File(__FILE__)); rinle::view::run(); return 0; }
/*---------------------------------------------------------------------------*/ bool HttpRecognizer::showDetails( IConnection* connection ) { Q_ASSERT (connection); Q_ASSERT (mConnections.contains( connection->networkInfo() )); const HttpConnection con = mConnections.value( connection->networkInfo() ); HttpPresenter presenter( mConnections, con ); presenter.exec(); return true; }
TEST(MapTreeViewPresenterTest, RemoveItem) { Models::MapCollection mapCollection; MockMapTreeView view; MapTreeViewPresenter<MockMapTreeView> presenter(mapCollection, view); presenter.MapTreeView_ItemAdded(view, 0); const Models::MapCollection::ChildIds& childIds = mapCollection.GetChildIds(0); int newChildId = *(childIds.begin()); presenter.MapTreeView_ItemRemoved(view, newChildId); ASSERT_EQ("RemoveItem", view.calledMethod); ASSERT_EQ(newChildId, view.intValues["id"]); }
optional<SlotPath> itemToIntervalFromHeader(const QGraphicsItem* pressedItem) const { auto handle = static_cast<const SlotHeader*>(pressedItem); const auto& cst = handle->presenter().model(); if (cst.parent() == &this->m_palette.model()) { auto fv = isInFullView(cst) ? Slot::FullView : Slot::SmallView; return SlotPath{cst, handle->slotIndex(), fv}; } else { return ossia::none; } }
Q_DECL_EXPORT int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); Model model("Hello World!"); Presenter presenter(model, new View, &app); presenter.showView(); model.setText("It works!"); // Generate output if model changes. { QObject::connect(&model, &Model::textChanged, [=](const QString &value) { qDebug() << "Model { text:" << value << "}"; }); } return app.exec(); }
TEST(MapTreeViewPresenterTest, UpdateItem) { Models::MapCollection mapCollection; MockMapTreeView view; MapTreeViewPresenter<MockMapTreeView> presenter(mapCollection, view); presenter.MapTreeView_ItemAdded(view, 0); const Models::MapCollection::ChildIds& childIds = mapCollection.GetChildIds(0); int newChildId = *(childIds.begin()); Models::Map& map = mapCollection.GetMap(newChildId); presenter.MapTreeView_ItemUpdated(view, newChildId, "foo"); ASSERT_EQ("foo", map.GetName()); ASSERT_EQ("UpdateItem", view.calledMethod); ASSERT_EQ("foo", view.stringValues["text"]); presenter.MapTreeView_ItemUpdated(view, newChildId, "bar"); ASSERT_EQ("bar", map.GetName()); ASSERT_EQ("UpdateItem", view.calledMethod); ASSERT_EQ("bar", view.stringValues["text"]); }
TEST(chatpresenter, test_postingsms) { Poco::SharedPtr<MockChatService> m(new MockChatService); Mvp::Presenter::TextChatPresenter presenter(m.get()); Poco::SharedPtr<MockChatView> v(new MockChatView()); EXPECT_CALL(*v, initialize()); ON_CALL(*m, getParticipants()) .WillByDefault(Return(contacts)); ON_CALL(*m, messageHistory(_)) .WillByDefault(Return(messages)); EXPECT_CALL(*m, chatName()); EXPECT_CALL(*v, setChatTitle(_)); EXPECT_CALL(*m, messageHistory(_)); EXPECT_CALL(*m, isConsumer()); EXPECT_CALL(*v, enableControls(_)); EXPECT_CALL(*v, showLeaveAction(_)); EXPECT_CALL(*m, getParticipants()); EXPECT_CALL(*v, setParticipants(_)); presenter.setView(v.get()); EXPECT_CALL(*v, showView()); presenter.showView(); EXPECT_CALL(*v, setSmsMode(true)); v->triggerToggleMode(); EXPECT_CALL(*m, postSMS(_)); v->triggerPostMessage(); EXPECT_CALL(*v, reportMessageStatus( Mvp::View::AbstractChatView::SmsDelivered, _)); m->triggerSmsDelivered(); EXPECT_CALL(*v, reportMessageStatus( Mvp::View::AbstractChatView::MiscError, _)); m->triggerSmsError(); }
void TemporalConstraintView::paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { qreal min_w = minWidth(); qreal max_w = maxWidth(); qreal def_w = defaultWidth(); qreal play_w = playWidth(); // Draw the stuff present if there is a rack *in the model* ? if(presenter().rack()) { // Background auto rect = boundingRect(); rect.adjust(0,15,0,-10); rect.setWidth(this->defaultWidth()); painter->fillRect(rect, m_bgColor); // Fake timenode continuation auto color = ScenarioStyle::instance().RackSideBorder; QPen pen{color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; painter->setPen(pen); painter->drawLine(rect.topLeft(), rect.bottomLeft()); painter->drawLine(rect.topRight(), rect.bottomRight()); } QPainterPath solidPath, dashedPath, leftBrace, rightBrace; // Paths if(infinite()) { if(min_w != 0.) { solidPath.lineTo(min_w, 0); leftBrace.moveTo(min_w, -10); leftBrace.arcTo(min_w - 10, -10, 20, 20, 90, 180); } // TODO end state should be hidden dashedPath.moveTo(min_w, 0); dashedPath.lineTo(def_w, 0); } else if(min_w == max_w) // TODO rigid() { solidPath.lineTo(def_w, 0); } else { if(min_w != 0.) solidPath.lineTo(min_w, 0); dashedPath.moveTo(min_w, 0); dashedPath.lineTo(max_w, 0); leftBrace.moveTo(min_w + 10, -10); leftBrace.arcTo(min_w, -10, 20, 20, 90, 180); leftBrace.closeSubpath(); rightBrace.moveTo(max_w, 10); rightBrace.arcTo(max_w - 10, -10, 20, 20, 270, 180); rightBrace.closeSubpath(); rightBrace.translate(-10, 0); // TODO bleh. } QPainterPath playedPath; if(play_w != 0.) { playedPath.lineTo(play_w, 0); } // Colors QColor constraintColor; // TODO make a switch instead if(isSelected()) { constraintColor = ScenarioStyle::instance().ConstraintSelected; } else if(warning()) { constraintColor = ScenarioStyle::instance().ConstraintWarning; } else { constraintColor = ScenarioStyle::instance().ConstraintBase; } if(! isValid()) { constraintColor = ScenarioStyle::instance().ConstraintInvalid; this->setZValue(this->zValue()+ 1); } else { this->setZValue(parentObject()->zValue() + 3); } m_solidPen.setColor(constraintColor); m_dashPen.setColor(constraintColor); // Drawing painter->setPen(m_solidPen); if(!solidPath.isEmpty()) painter->drawPath(solidPath); if(!leftBrace.isEmpty()) painter->drawPath(leftBrace); if(!rightBrace.isEmpty()) painter->drawPath(rightBrace); painter->setPen(m_dashPen); if(!dashedPath.isEmpty()) painter->drawPath(dashedPath); leftBrace.closeSubpath(); rightBrace.closeSubpath(); QPen anotherPen(Qt::transparent, 4); painter->setPen(anotherPen); QColor blueish = m_solidPen.color().lighter(); blueish.setAlphaF(0.3); painter->setBrush(blueish); painter->drawPath(leftBrace); painter->drawPath(rightBrace); static const QPen playedPen{ QBrush{ScenarioStyle::instance().ConstraintPlayFill}, 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin }; painter->setPen(playedPen); if(!playedPath.isEmpty()) painter->drawPath(playedPath); static const int fontSize = 12; QRectF labelRect{0,0, defaultWidth(), (-fontSize - 2.)}; auto f = ProcessFonts::Sans(); f.setPointSize(fontSize); painter->setFont(f); painter->setPen(m_labelColor); painter->drawText(labelRect, Qt::AlignCenter, m_label); #if defined(ISCORE_SCENARIO_DEBUG_RECTS) painter->setPen(Qt::darkRed); painter->setBrush(Qt::NoBrush); painter->drawRect(boundingRect()); #endif }
void TemporalConstraintView::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { // Draw the rack bg if(auto rack = presenter().rack()) { auto rackRect = rack->view().boundingRect(); painter->fillRect(rackRect, QColor::fromRgba(qRgba(0, 127, 229, 76))); auto color = qApp->palette("ScenarioPalette").base().color(); QPen pen{color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; painter->setPen(pen); painter->drawLine(rackRect.topLeft(), rackRect.bottomLeft()); painter->drawLine(rackRect.topRight(), rackRect.bottomRight()); } QPainterPath solidPath, dashedPath, leftBrace, rightBrace; // m_endState->setPos(defaultWidth(), 0); // Paths if(infinite()) { if(minWidth() != 0) { solidPath.lineTo(minWidth(), 0); leftBrace.moveTo(minWidth(), -10); leftBrace.arcTo(minWidth() - 10, -10, 20, 20, 90, 180); } // TODO end state should be hidden dashedPath.moveTo(minWidth(), 0); dashedPath.lineTo(defaultWidth(), 0); } else if(minWidth() == maxWidth()) // TODO rigid() { solidPath.lineTo(defaultWidth(), 0); } else { if(minWidth() != 0) solidPath.lineTo(minWidth(), 0); dashedPath.moveTo(minWidth(), 0); dashedPath.lineTo(maxWidth(), 0); leftBrace.moveTo(minWidth(), -10); leftBrace.arcTo(minWidth() - 10, -10, 20, 20, 90, 180); rightBrace.moveTo(maxWidth(), 10); rightBrace.arcTo(maxWidth() - 10, -10, 20, 20, 270, 180); } QPainterPath playedPath; if(playWidth() != 0) { playedPath.lineTo(playWidth(), 0); } // Colors QColor constraintColor; if(isSelected()) { constraintColor = QColor::fromRgbF(0.188235, 0.54902, 0.776471); } else { constraintColor = qApp->palette("ScenarioPalette").base().color(); } if(warning()) { constraintColor = QColor{200,150,0}; } if(! isValid()) { constraintColor = Qt::red; } m_solidPen.setColor(constraintColor); m_dashPen.setColor(constraintColor); // Drawing painter->setPen(m_solidPen); if(!solidPath.isEmpty()) painter->drawPath(solidPath); if(!leftBrace.isEmpty()) painter->drawPath(leftBrace); if(!rightBrace.isEmpty()) painter->drawPath(rightBrace); painter->setPen(m_dashPen); if(!dashedPath.isEmpty()) painter->drawPath(dashedPath); leftBrace.closeSubpath(); rightBrace.closeSubpath(); QPen anotherPen(Qt::transparent, 4); painter->setPen(anotherPen); QColor blueish = m_solidPen.color().lighter(); blueish.setAlphaF(0.3); painter->setBrush(blueish); painter->drawPath(leftBrace); painter->drawPath(rightBrace); static const QPen playedPen{ QBrush{Qt::green}, 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin }; static const QPen dashedPlayedPen{ QBrush{Qt::green}, 4, Qt::DashLine, Qt::RoundCap, Qt::RoundJoin }; painter->setPen(playedPen); if(!playedPath.isEmpty()) painter->drawPath(playedPath); int fontSize = 12; QRectF labelRect{0,0, defaultWidth(), (-fontSize - 2.)}; QFont f("Ubuntu"); f.setPixelSize(fontSize); painter->setFont(f); painter->setPen(m_labelColor); painter->drawText(labelRect, Qt::AlignCenter, m_label); /* painter->setPen(Qt::darkRed); painter->setBrush(Qt::NoBrush); painter->drawRect(boundingRect()); */ }
int main(int argc, char** argv){ setlocale( LC_ALL, ""); bindtextdomain( "gpc", LOCALEDIR); textdomain( "gpc" ); Gtk::Main app(argc, argv); Glib::thread_init(); GrubEnv env; GPC presenter(env); GrublistCfg listcfg(env); GrublistCfgDlgGtk listCfgView; SettingsManagerDataStore settings(env); SettingsManagerDataStore settingsOnDisk(env); GrubInstaller installer(env); GrubInstallDlgGtk installDlg; ScriptAddDlgGtk scriptAddDlg; MountTable mountTable; PartitionChooserGtk partitionChooser; GrublistCfg savedListCfg(env); FbResolutionsGetter fbResolutionsGetter; GrubSettingsDlgGtk settingsDlg; DeviceDataList deviceDataList; AboutDialogGtk aboutDialog; GlibMutex listCfgMutex1; GlibMutex listCfgMutex2; GlibThreadController threadC(presenter); presenter.setListCfg(listcfg); presenter.setListCfgDlg(listCfgView); presenter.setSettingsDialog(settingsDlg); presenter.setSettingsManager(settings); presenter.setSettingsBuffer(settingsOnDisk); presenter.setInstaller(installer); presenter.setInstallDlg(installDlg); presenter.setScriptAddDlg(scriptAddDlg); presenter.setPartitionChooser(partitionChooser); presenter.setSavedListCfg(savedListCfg); presenter.setFbResolutionsGetter(fbResolutionsGetter); presenter.setDeviceDataList(deviceDataList); presenter.setMountTable(mountTable); presenter.setAboutDialog(aboutDialog); presenter.setThreadController(threadC); EventListener evt(presenter); listCfgView.setEventListener(evt); installDlg.setEventListener(evt); scriptAddDlg.setEventListener(evt); settingsDlg.setEventListener(evt); partitionChooser.setEventListener(evt); listcfg.setEventListener(evt); installer.setEventListener(evt); fbResolutionsGetter.setEventListener(evt); StreamLogger logger(std::cout); presenter.setLogger(logger); listcfg.setLogger(logger); listCfgView.setLogger(logger); settings.setLogger(logger); settingsOnDisk.setLogger(logger); installer.setLogger(logger); installDlg.setLogger(logger); scriptAddDlg.setLogger(logger); mountTable.setLogger(logger); partitionChooser.setLogger(logger); savedListCfg.setLogger(logger); fbResolutionsGetter.setLogger(logger); settingsDlg.setLogger(logger); deviceDataList.setLogger(logger); aboutDialog.setLogger(logger); listCfgMutex1.setLogger(logger); listCfgMutex2.setLogger(logger); threadC.setLogger(logger); env.setLogger(logger); listcfg.setMutex(listCfgMutex1); savedListCfg.setMutex(listCfgMutex2); presenter.init(); app.run(); }
void TemporalConstraintView::paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { auto& skin = ScenarioStyle::instance(); qreal min_w = minWidth(); qreal max_w = maxWidth(); qreal def_w = defaultWidth(); qreal play_w = playWidth(); m_labelItem->setPos(def_w / 2. - m_labelItem->boundingRect().width() / 2., -17); m_counterItem->setPos(def_w - m_counterItem->boundingRect().width() - 5, 5); m_leftBrace->setX(min_w); m_rightBrace->setX(max_w); // Draw the stuff present if there is a rack *in the model* ? if(presenter().rack()) { // Background auto rect = boundingRect(); rect.adjust(0,4,0,-10); rect.setWidth(this->defaultWidth()); QColor bgColor = m_bgColor.getColor(); bgColor.setAlpha(m_hasFocus ? 84 : 76); painter->fillRect(rect, bgColor); // Fake timenode continuation auto color = skin.RackSideBorder.getColor(); QPen pen{color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; painter->setPen(pen); painter->drawLine(rect.topLeft(), rect.bottomLeft()); painter->drawLine(rect.topRight(), rect.bottomRight()); } QPainterPath solidPath, dashedPath, leftBrace, rightBrace; // Paths if(infinite()) { if(min_w != 0.) { solidPath.lineTo(min_w, 0); m_leftBrace->show(); } m_rightBrace->hide(); // TODO end state should be hidden dashedPath.moveTo(min_w, 0); dashedPath.lineTo(def_w, 0); } else if(min_w == max_w) // TODO rigid() { solidPath.lineTo(def_w, 0); m_leftBrace->hide(); m_rightBrace->hide(); } else { if(min_w != 0.) solidPath.lineTo(min_w, 0); dashedPath.moveTo(min_w, 0); dashedPath.lineTo(max_w, 0); m_leftBrace->show(); m_rightBrace->show(); } QPainterPath playedPath; if(play_w != 0.) { playedPath.lineTo(std::min(play_w, std::max(def_w, max_w)), 0); } // Colors QColor constraintColor; // TODO make a switch instead if(isSelected()) { constraintColor = skin.ConstraintSelected.getColor(); } else if(warning()) { constraintColor = skin.ConstraintWarning.getColor(); } else { constraintColor = skin.ConstraintBase.getColor(); } if(! isValid() || m_state == ConstraintExecutionState::Disabled) { constraintColor = skin.ConstraintInvalid.getColor(); } m_solidPen.setColor(constraintColor); m_dashPen.setColor(constraintColor); // Drawing painter->setPen(m_solidPen); if(!solidPath.isEmpty()) painter->drawPath(solidPath); painter->setPen(m_dashPen); if(!dashedPath.isEmpty()) painter->drawPath(dashedPath); leftBrace.closeSubpath(); rightBrace.closeSubpath(); QPen anotherPen(Qt::transparent, 4); painter->setPen(anotherPen); QColor blueish = m_solidPen.color().lighter(); blueish.setAlphaF(0.3); painter->setBrush(blueish); const QPen playedPen{ skin.ConstraintPlayFill.getColor(), 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin }; painter->setPen(playedPen); if(!playedPath.isEmpty()) painter->drawPath(playedPath); { auto& dur = presenter().model().duration; auto progress = dur.defaultDuration() * dur.playPercentage(); if(!progress.isZero()) { QString percent = progress.toString(); m_counterItem->setText(percent); } } #if defined(ISCORE_SCENARIO_DEBUG_RECTS) painter->setPen(Qt::darkRed); painter->setBrush(Qt::NoBrush); painter->drawRect(boundingRect()); #endif }
int NotificationCenter::checkPermission() { if (!presenter() || !scriptExecutionContext()) return NotificationPresenter::PermissionDenied; return m_notificationPresenter->checkPermission(scriptExecutionContext()); }
void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback) { if (!presenter() || !scriptExecutionContext()) return; m_notificationPresenter->requestPermission(scriptExecutionContext(), callback); }