Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
1d99e976
Commit
1d99e976
authored
Feb 10, 2012
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented auto-scrolling for ticket 499
parent
70a204a9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
5 deletions
+47
-5
UBDocumentThumbnailWidget.cpp
src/gui/UBDocumentThumbnailWidget.cpp
+42
-5
UBDocumentThumbnailWidget.h
src/gui/UBDocumentThumbnailWidget.h
+5
-0
No files found.
src/gui/UBDocumentThumbnailWidget.cpp
View file @
1d99e976
...
@@ -26,9 +26,10 @@ UBDocumentThumbnailWidget::UBDocumentThumbnailWidget(QWidget* parent)
...
@@ -26,9 +26,10 @@ UBDocumentThumbnailWidget::UBDocumentThumbnailWidget(QWidget* parent)
:
UBThumbnailWidget
(
parent
)
:
UBThumbnailWidget
(
parent
)
,
mDropCaretRectItem
(
0
)
,
mDropCaretRectItem
(
0
)
,
mClosestDropItem
(
0
)
,
mClosestDropItem
(
0
)
,
mDragEnabled
(
true
)
,
mDragEnabled
(
true
),
mScrollMagnitude
(
0
)
{
{
// NOOP
mScrollTimer
=
new
QTimer
(
this
);
connect
(
mScrollTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
autoScroll
()));
}
}
...
@@ -96,13 +97,43 @@ void UBDocumentThumbnailWidget::dragEnterEvent(QDragEnterEvent *event)
...
@@ -96,13 +97,43 @@ void UBDocumentThumbnailWidget::dragEnterEvent(QDragEnterEvent *event)
void
UBDocumentThumbnailWidget
::
dragLeaveEvent
(
QDragLeaveEvent
*
event
)
void
UBDocumentThumbnailWidget
::
dragLeaveEvent
(
QDragLeaveEvent
*
event
)
{
{
Q_UNUSED
(
event
);
Q_UNUSED
(
event
);
if
(
mScrollTimer
->
isActive
())
{
mScrollMagnitude
=
0
;
mScrollTimer
->
stop
();
}
deleteDropCaret
();
deleteDropCaret
();
}
}
void
UBDocumentThumbnailWidget
::
autoScroll
()
{
this
->
verticalScrollBar
()
->
setValue
(
this
->
verticalScrollBar
()
->
value
()
+
mScrollMagnitude
);
}
void
UBDocumentThumbnailWidget
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
void
UBDocumentThumbnailWidget
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
{
{
QRect
boundingFrame
=
frameRect
();
//setting up automatic scrolling
const
int
SCROLL_DISTANCE
=
16
;
int
bottomDist
=
boundingFrame
.
bottom
()
-
event
->
pos
().
y
(),
topDist
=
boundingFrame
.
top
()
-
event
->
pos
().
y
();
if
(
qAbs
(
bottomDist
)
<=
SCROLL_DISTANCE
)
{
mScrollMagnitude
=
(
SCROLL_DISTANCE
-
bottomDist
)
*
4
;
if
(
verticalScrollBar
()
->
isVisible
()
&&
!
mScrollTimer
->
isActive
())
mScrollTimer
->
start
(
100
);
}
else
if
(
qAbs
(
topDist
)
<=
SCROLL_DISTANCE
)
{
mScrollMagnitude
=
(
-
SCROLL_DISTANCE
-
topDist
)
*
4
;
if
(
verticalScrollBar
()
->
isVisible
()
&&
!
mScrollTimer
->
isActive
())
mScrollTimer
->
start
(
100
);
}
else
{
mScrollMagnitude
=
0
;
mScrollTimer
->
stop
();
}
QList
<
UBSceneThumbnailPixmap
*>
pixmapItems
;
QList
<
UBSceneThumbnailPixmap
*>
pixmapItems
;
foreach
(
QGraphicsItem
*
item
,
scene
()
->
items
(
mapToScene
(
frameRect
()
)))
foreach
(
QGraphicsItem
*
item
,
scene
()
->
items
(
mapToScene
(
boundingFrame
)))
{
{
UBSceneThumbnailPixmap
*
sceneItem
=
dynamic_cast
<
UBSceneThumbnailPixmap
*>
(
item
);
UBSceneThumbnailPixmap
*
sceneItem
=
dynamic_cast
<
UBSceneThumbnailPixmap
*>
(
item
);
if
(
sceneItem
)
if
(
sceneItem
)
...
@@ -161,8 +192,14 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
...
@@ -161,8 +192,14 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
event
->
acceptProposedAction
();
event
->
acceptProposedAction
();
}
}
void
UBDocumentThumbnailWidget
::
dropEvent
(
QDropEvent
*
event
)
void
UBDocumentThumbnailWidget
::
dropEvent
(
QDropEvent
*
event
)
{
{
if
(
mScrollTimer
->
isActive
())
{
mScrollMagnitude
=
0
;
mScrollTimer
->
stop
();
}
deleteDropCaret
();
deleteDropCaret
();
if
(
mClosestDropItem
)
if
(
mClosestDropItem
)
...
...
src/gui/UBDocumentThumbnailWidget.h
View file @
1d99e976
...
@@ -41,6 +41,9 @@ class UBDocumentThumbnailWidget: public UBThumbnailWidget
...
@@ -41,6 +41,9 @@ class UBDocumentThumbnailWidget: public UBThumbnailWidget
signals
:
signals
:
void
sceneDropped
(
UBDocumentProxy
*
proxy
,
int
source
,
int
target
);
void
sceneDropped
(
UBDocumentProxy
*
proxy
,
int
source
,
int
target
);
private
slots
:
void
autoScroll
();
protected
:
protected
:
virtual
void
mouseMoveEvent
(
QMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QMouseEvent
*
event
);
...
@@ -57,6 +60,8 @@ class UBDocumentThumbnailWidget: public UBThumbnailWidget
...
@@ -57,6 +60,8 @@ class UBDocumentThumbnailWidget: public UBThumbnailWidget
UBSceneThumbnailPixmap
*
mClosestDropItem
;
UBSceneThumbnailPixmap
*
mClosestDropItem
;
bool
mDropIsRight
;
bool
mDropIsRight
;
bool
mDragEnabled
;
bool
mDragEnabled
;
QTimer
*
mScrollTimer
;
int
mScrollMagnitude
;
};
};
#endif
/* UBDOCUMENTTHUMBNAILWIDGET_H_ */
#endif
/* UBDOCUMENTTHUMBNAILWIDGET_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment