11#include " sectionalsubtitlesview.hpp"
2- #include " customlineitem .hpp"
2+ #include " subtitledividerlineitem .hpp"
33
44#include < QtWidgets>
55
@@ -8,14 +8,14 @@ class SectionalSubtitlesView::SectionalSubtitlesViewPrivate
88public:
99 SectionalSubtitlesViewPrivate (QWidget *parent)
1010 : q_ptr(parent)
11- , line1Ptr(new CustomLineItem )
12- , line2Ptr(new CustomLineItem )
11+ , line1Ptr(new SubtitleDividerLineItem )
12+ , line2Ptr(new SubtitleDividerLineItem )
1313 {}
1414 ~SectionalSubtitlesViewPrivate () {}
1515
1616 QWidget *q_ptr;
17- QScopedPointer<CustomLineItem> line1Ptr;
18- QScopedPointer<CustomLineItem> line2Ptr;
17+ SubtitleDividerLineItemPtr line1Ptr;
18+ SubtitleDividerLineItemPtr line2Ptr;
1919};
2020
2121SectionalSubtitlesView::SectionalSubtitlesView (QWidget *parent)
@@ -31,10 +31,10 @@ void SectionalSubtitlesView::setImageAfter()
3131{
3232 auto rect = sceneRect ();
3333 auto y = rect.height () / 5.0 * 4 ;
34- d_ptr->line1Ptr ->setLine (QLineF (1 , y, rect.width () - 1 , y));
35- d_ptr->line2Ptr ->setLine (QLineF (1 , rect.height () - 2 , rect.width () - 1 , rect.height () - 2 ));
3634 scene ()->addItem (d_ptr->line1Ptr .data ());
3735 scene ()->addItem (d_ptr->line2Ptr .data ());
36+ d_ptr->line1Ptr ->setLine (QLineF (1 , y, rect.width () - 1 , y));
37+ d_ptr->line2Ptr ->setLine (QLineF (1 , rect.height () - 1 , rect.width () - 1 , rect.height () - 1 ));
3838}
3939
4040auto SectionalSubtitlesView::clipImage () const -> QImage
@@ -64,7 +64,7 @@ auto SectionalSubtitlesView::info() const -> StitchingImageInfo
6464
6565auto SectionalSubtitlesView::line1RatioOfHeight () const -> double
6666{
67- return (d_ptr->line1Ptr ->line ().y1 () / pixmap ().size ().height ());
67+ return (static_cast < int >( d_ptr->line1Ptr ->line ().y1 ()) * 1.0 / pixmap ().size ().height ());
6868}
6969
7070void SectionalSubtitlesView::setLine1RatioOfHeight (double value)
@@ -76,7 +76,7 @@ void SectionalSubtitlesView::setLine1RatioOfHeight(double value)
7676
7777auto SectionalSubtitlesView::line2RatioOfHeight () const -> double
7878{
79- return (d_ptr->line2Ptr ->line ().y1 () / pixmap ().size ().height ());
79+ return (static_cast < int >( d_ptr->line2Ptr ->line ().y1 ()) * 1.0 / pixmap ().size ().height ());
8080}
8181
8282void SectionalSubtitlesView::setLine2RatioOfHeight (double value)
@@ -89,11 +89,11 @@ void SectionalSubtitlesView::setLine2RatioOfHeight(double value)
8989void SectionalSubtitlesView::buildConnect ()
9090{
9191 connect (d_ptr->line1Ptr .data (),
92- &CustomLineItem ::lineChanged,
92+ &SubtitleDividerLineItem ::lineChanged,
9393 this ,
9494 &SectionalSubtitlesView::line1Changed);
9595 connect (d_ptr->line2Ptr .data (),
96- &CustomLineItem ::lineChanged,
96+ &SubtitleDividerLineItem ::lineChanged,
9797 this ,
9898 &SectionalSubtitlesView::line2Changed);
9999}
0 commit comments