longscroll-qt  2.0.0
Create long scrollable widgets in Qt.
 All Classes Namespaces Functions Variables Properties
longscroll::ContentWidget Class Reference

Longscroll-qt's central widget. More...

Inheritance diagram for longscroll::ContentWidget:
[legend]

Public Slots

virtual void showingRect (QRect const &rect) override
 Reimplemented from NotifyableScrollContentWidget::showingRect. More...
 
void showNavigator (int itemIndex)
 Shows the navigatorWidget for the given item index. More...
 
void showNavigator (int row, int col)
 Shows the navigatorWidget for the given row and column. More...
 
virtual QSize sizeHint () const override
 Reimplemented from NotifyableScrollContentWidget::sizeHint. More...
 

Signals

void currentItemChanged (int itemIndex, int oldItemIndex)
 This signal is emitted whenever the current item changes. More...
 
void itemClicked (int row, int col, int itemIndex)
 This signal is emitted whenever an item is left-clicked. More...
 
void itemDoubleClicked (int row, int col, int itemIndex)
 This signal is emitted whenever an item is double clicked. More...
 
void itemPressed (int row, int col, int itemIndex)
 This signal is emitted whenever an item is pressed. More...
 
void itemReleased (int row, int col, int itemIndex)
 This signal is emitted whenever an item is released. More...
 
void scrollToRequest (int y)
 This signal is emitted when the widget wants to scroll somewhere. More...
 
void selectionChanged (QList< int > const &selection, QList< int > const &oldSelection)
 This signal is emitted whenever the selection changes. More...
 

Public Member Functions

 ContentWidget (QWidget *parent=0)
 Constructs a ContentWidget. More...
 
 ContentWidget (int rowHeight, int itemWidth=0, QWidget *parent=0)
 Constructs a ContentWidget. More...
 
int findRow (int itemIndex)
 Searches the row of a given item index. More...
 
void findRowCol (int &row, int &col, int itemIndex)
 Searches the row and column of a given item index. More...
 
bool getAllowOverfill () const
 
int getCurrentItem () const
 
bool getHandleMouseEvents () const
 
int getHorizontalSpacing () const
 
ContentWidgetItemFactorygetItemFactory ()
 
QList< ContentItemInfo > const & getItemInfos () const
 
uchar getItemTrackingScreenPositionPercentageX () const
 ContentWidget::getItemTrackingScreenPositionPercentageX. More...
 
uchar getItemTrackingScreenPositionPercentageY () const
 ContentWidget::getItemTrackingScreenPositionPercentageY. More...
 
int getItemWidth () const
 
int getNavigatorHeight () const
 
NavigatorWidgetgetNavigatorWidget ()
 
int getPrefetchRowsAfter () const
 
int getPrefetchRowsBefore () const
 
int getRowHeight () const
 
bool getScaleRows () const
 
QList< int > getSelectedItems () const
 
QAbstractItemView::SelectionMode getSelectionMode () const
 
bool getShowNavigatorOnClick () const
 
bool getStretchLastRow () const
 
bool getStretchRows () const
 
int getVerticalSpacing () const
 
bool isDragEnabled () const
 
bool isItemTrackingEnabled () const
 
void setAllowOverfill (bool allow)
 
void setCurrentItem (int index)
 
void setDragEnabled (bool enabled)
 
void setHandleMouseEvents (bool handle)
 
void setHorizontalSpacing (int spacing)
 
void setItemFactory (ContentWidgetItemFactory *factory)
 
void setItemInfos (QList< ContentItemInfo > const &infos)
 
void setItemTrackingEnabled (bool enabled)
 
void setItemTrackingScreenPositionPercentage (uchar percentX, uchar percentY)
 Sets the position where the tracking item is searched. More...
 
void setItemWidth (int width)
 
void setNavigatorHeight (int height)
 
void setNavigatorWidget (NavigatorWidget *nav)
 
void setPrefetchRowsAfter (int rows)
 
void setPrefetchRowsBefore (int rows)
 
void setRowHeight (int height)
 
void setScaleRows (bool scale)
 
void setSelectedItems (QList< int > const &indexes)
 
void setSelectionMode (QAbstractItemView::SelectionMode mode)
 
void setShowNavigatorOnClick (bool show)
 
void setStretchLastRow (bool stretch)
 
void setStretchRows (bool stretch)
 
void setVerticalSpacing (int spacing)
 
 ~ContentWidget ()
 Destroys the widget. More...
 
- Public Member Functions inherited from longscroll::NotifyableScrollContentWidget
virtual void showingRect (QRect const &visible)=0
 Called by NotifyingScrollArea whenever the visible region changes. More...
 
- Public Member Functions inherited from QFrame
QRect frameRect () const
 
Shadow frameShadow () const
 
Shape frameShape () const
 
int frameStyle () const
 
int frameWidth () const
 
int lineWidth () const
 
int midLineWidth () const
 
 QFrame (QWidget *parent, Qt::WindowFlags f)
 
void setFrameRect (const QRect &)
 
void setFrameShadow (Shadow)
 
void setFrameShape (Shape)
 
void setFrameStyle (int style)
 
void setLineWidth (int)
 
void setMidLineWidth (int)
 
virtual QSize sizeHint () const
 
- Public Member Functions inherited from QWidget
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 
void activateWindow ()
 
void addAction (QAction *action)
 
void addActions (QList< QAction * > actions)
 
void adjustSize ()
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 
QBackingStorebackingStore () const
 
QSize baseSize () const
 
QWidgetchildAt (int x, int y) const
 
QWidgetchildAt (const QPoint &p) const
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 
void clearMask ()
 
bool close ()
 
QMargins contentsMargins () const
 
QRect contentsRect () const
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
QCursor cursor () const
 
void customContextMenuRequested (const QPoint &pos)
 
WId effectiveWinId () const
 
void ensurePolished () const
 
Qt::FocusPolicy focusPolicy () const
 
QWidgetfocusProxy () const
 
QWidgetfocusWidget () const
 
const QFontfont () const
 
QFontInfo fontInfo () const
 
QFontMetrics fontMetrics () const
 
QPalette::ColorRole foregroundRole () const
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
QPixmap grab (const QRect &rectangle)
 
void grabGesture (Qt::GestureType gesture, Qt::GestureFlags flags)
 
void grabKeyboard ()
 
void grabMouse ()
 
void grabMouse (const QCursor &cursor)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context)
 
QGraphicsEffectgraphicsEffect () const
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 
bool hasEditFocus () const
 
bool hasFocus () const
 
virtual bool hasHeightForWidth () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int w) const
 
void hide ()
 
Qt::InputMethodHints inputMethodHints () const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
void insertAction (QAction *before, QAction *action)
 
void insertActions (QAction *before, QList< QAction * > actions)
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 
bool isEnabled () const
 
bool isEnabledTo (const QWidget *ancestor) const
 
bool isEnabledToTLW () const
 
bool isFullScreen () const
 
bool isHidden () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isTopLevel () const
 
bool isVisible () const
 
bool isVisibleTo (const QWidget *ancestor) const
 
bool isWindow () const
 
bool isWindowModified () const
 
QLayoutlayout () const
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
void lower ()
 
Qt::HANDLE macCGHandle () const
 
Qt::HANDLE macQDHandle () const
 
QPoint mapFrom (const QWidget *parent, const QPoint &pos) const
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapFromParent (const QPoint &pos) const
 
QPoint mapTo (const QWidget *parent, const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QPoint mapToParent (const QPoint &pos) const
 
QRegion mask () const
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
virtual QSize minimumSizeHint () const
 
int minimumWidth () const
 
void move (int x, int y)
 
void move (const QPoint &)
 
QWidgetnativeParentWidget () const
 
QWidgetnextInFocusChain () const
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags flags)
 
QPaintEnginepaintEngine () const
 
const QPalettepalette () const
 
QWidgetparentWidget () const
 
QPoint pos () const
 
QWidgetpreviousInFocusChain () const
 
 QWidget (QWidget *parent, Qt::WindowFlags f)
 
void raise ()
 
QRect rect () const
 
void releaseKeyboard ()
 
void releaseMouse ()
 
void releaseShortcut (int id)
 
void removeAction (QAction *action)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QFlags< QWidget::RenderFlag > renderFlags)
 
void render (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QFlags< QWidget::RenderFlag > renderFlags)
 
void repaint ()
 
void repaint (int x, int y, int w, int h)
 
void repaint (const QRect &rect)
 
void repaint (const QRegion &rgn)
 
void resize (int w, int h)
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 
QByteArray saveGeometry () const
 
void scroll (int dx, int dy, const QRect &r)
 
void scroll (int dx, int dy)
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute attribute, bool on)
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole role)
 
void setBaseSize (int basew, int baseh)
 
void setBaseSize (const QSize &)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContentsMargins (const QMargins &margins)
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setDisabled (bool disable)
 
void setEditFocus (bool enable)
 
void setEnabled (bool)
 
void setFixedHeight (int h)
 
void setFixedSize (const QSize &s)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFocus (Qt::FocusReason reason)
 
void setFocus ()
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *w)
 
void setFont (const QFont &)
 
void setForegroundRole (QPalette::ColorRole role)
 
void setGeometry (const QRect &)
 
void setGeometry (int x, int y, int w, int h)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
void setHidden (bool hidden)
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *layout)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &bitmap)
 
void setMask (const QRegion &region)
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (int maxw, int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 
void setShortcutAutoRepeat (int id, bool enable)
 
void setShortcutEnabled (int id, bool enable)
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *style)
 
void setStyleSheet (const QString &styleSheet)
 
void setToolTip (const QString &)
 
void setToolTipDuration (int msec)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 
virtual void setVisible (bool visible)
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowModified (bool)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &role)
 
void setWindowState (Qt::WindowStates windowState)
 
void setWindowTitle (const QString &)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
QSize size () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *w)
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute attribute) const
 
QString toolTip () const
 
int toolTipDuration () const
 
QWidgettopLevelWidget () const
 
bool underMouse () const
 
void ungrabGesture (Qt::GestureType gesture)
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update ()
 
void update (int x, int y, int w, int h)
 
void update (const QRect &rect)
 
void update (const QRegion &rgn)
 
void updateGeometry ()
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 
QString whatsThis () const
 
int width () const
 
QWidgetwindow () const
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 
QWindowwindowHandle () const
 
QIcon windowIcon () const
 
void windowIconChanged (const QIcon &icon)
 
QString windowIconText () const
 
void windowIconTextChanged (const QString &iconText)
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 
Qt::WindowStates windowState () const
 
QString windowTitle () const
 
void windowTitleChanged (const QString &title)
 
Qt::WindowType windowType () const
 
WId winId () const
 
int x () const
 
const QX11Info & x11Info () const
 
Qt::HANDLE x11PictureHandle () const
 
int y () const
 

Protected Member Functions

int colAt (int x, int row)
 This is an overloaded function. More...
 
int colAt (int x, RowInfo const &row)
 Calculates which column of a row a given x-coordinate belongs to. More...
 
virtual QWidgetcreateItemWidget (ContentItemInfo const &info, int itemIndex)
 Creates an item widget. More...
 
virtual void mouseDoubleClickEvent (QMouseEvent *event) override
 Reimplemented from NotifyableScrollContentWidget::mouseDoubleClickEvent. More...
 
virtual void mouseMoveEvent (QMouseEvent *event) override
 Reimplemented from NotifyableScrollContentWidget::mouseMoveEvent. More...
 
virtual void mousePressEvent (QMouseEvent *event) override
 Reimplemented from NotifyableScrollContentWidget::mousePressEvent. More...
 
virtual void mouseReleaseEvent (QMouseEvent *event) override
 Reimplemented from NotifyableScrollContentWidget::mouseReleaseEvent. More...
 
void nextImage (int &row, int &col)
 Takes a row and column and changes them to point at the next item. More...
 
void previousImage (int &row, int &col)
 Takes a row and column and changes them to point at the previous item. More...
 
int rowAt (int y, bool *onNavigator=0)
 Calculates which row a given y-coordinate belongs to. More...
 
virtual void startDrag (int row, int col, int itemIndex)
 Begins a drag operation. More...
 
- Protected Member Functions inherited from QFrame
virtual void changeEvent (QEvent *ev)
 
bool event (QEvent *e)
 
virtual void paintEvent (QPaintEvent *)
 
- Protected Member Functions inherited from QWidget
virtual void actionEvent (QActionEvent *event)
 
virtual void closeEvent (QCloseEvent *event)
 
virtual void contextMenuEvent (QContextMenuEvent *event)
 
void create (WId window, bool initializeWindow, bool destroyOldWindow)
 
void destroy (bool destroyWindow, bool destroySubWindows)
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual void enterEvent (QEvent *event)
 
bool event (QEvent *event)
 
virtual void focusInEvent (QFocusEvent *event)
 
bool focusNextChild ()
 
virtual bool focusNextPrevChild (bool next)
 
virtual void focusOutEvent (QFocusEvent *event)
 
bool focusPreviousChild ()
 
virtual void hideEvent (QHideEvent *event)
 
void initPainter (QPainter *painter) const
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void leaveEvent (QEvent *event)
 
int metric (PaintDeviceMetric m) const
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, long *result)
 
QPaintDeviceredirected (QPoint *offset) const
 
virtual void resizeEvent (QResizeEvent *event)
 
QPaintersharedPainter () const
 
virtual void showEvent (QShowEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
void updateMicroFocus ()
 
virtual void wheelEvent (QWheelEvent *event)
 

Properties

bool allowOverfill = true
 Allows the last item in a row to exceed the width of that row. More...
 
int currentItem
 Current item index. More...
 
bool dragEnabled = false
 Enables drag detection, requires handleMouseEvents to be set. More...
 
bool handleMouseEvents = true
 Handle mouse events. More...
 
int horizontalSpacing
 Horizontal spacing between items. More...
 
ContentWidgetItemFactory itemFactory
 ContentWidgetItemFactory used to create displaying widgets. More...
 
QList< ContentItemInfoitemInfos
 The list of ContentItemInfos being displayed. More...
 
bool itemTrackingEnabled = true
 Tries to keep one item at the same screen y-coordinate while resizing. More...
 
int itemWidth = 0
 Item base width. More...
 
int navigatorHeight = 400
 Navigator widget height. More...
 
NavigatorWidget navigatorWidget
 NavigatorWidget. More...
 
int prefetchRowsAfter
 Number of rows after the last visible row that should be kept ready for displaying. More...
 
int prefetchRowsBefore
 Number of rows before the first visible row that should be kept ready for displaying. More...
 
int rowHeight = 150
 Row base height. More...
 
bool scaleRows = false
 Scale rows to the actual widget's width, keeping the items' aspect ratio. More...
 
QList< int > selectedItems
 Selected item indexes. More...
 
QAbstractItemView::SelectionMode selectionMode = QAbstractItemView::NoSelection
 Selection mode. More...
 
bool showNavigatorOnClick
 Show the navigator widget on item click, requires handleMouseEvents to be set. More...
 
bool stretchLastRow
 Stretch last row. More...
 
bool stretchRows
 Stretch row widths to the actual widget's width. More...
 
int verticalSpacing
 Vertical spacing between items. More...
 
- Properties inherited from QFrame
 frameRect
 
 frameShadow
 
 frameShape
 
 frameWidth
 
 lineWidth
 
 midLineWidth
 
- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 toolTip
 
 toolTipDuration
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 

Friends

bool operator== (ContentWidget::ItemInfo const &lhs, ContentWidget::ItemInfo const &rhs)
 
bool operator== (ContentWidget::RowInfo const &lhs, ContentWidget::RowInfo const &rhs)
 

Additional Inherited Members

- Static Public Member Functions inherited from QWidget
QWidgetcreateWindowContainer (QWindow *window, QWidget *parent, Qt::WindowFlags flags)
 
QWidgetfind (WId id)
 
QWidgetkeyboardGrabber ()
 
QWidgetmouseGrabber ()
 
void setTabOrder (QWidget *first, QWidget *second)
 
- Public Attributes inherited from QWidget
typedef RenderFlags
 

Detailed Description

Longscroll-qt's central widget.

Note
You probably want to use LongscrollWidget instead of instantiating this class directly.

Implements a widget that can display a lot of items, similar to a QAbstractItemView, but allows dynamic item positions and uses real widgets to display the items, thus there is no MVC concept.

Items can be any kind of data and their number is not limited by this widget, however you may face other limits. For example, any QWidget can only have a size of QWIDGETSIZE_MAX pixels in each dimension. An item is visualized by a widget that is created when the item becomes visible and destroyed when it's hidden. This item widget determines how the item looks and what its data mean. The widget is created using the createItemWidget() function, which again calls ContentWidgetItemFactory::createItemWidget(). This can be customized by setting a different itemFactory or by overriding createItemWidget(), so that a custom widget is returned.

Items are always aligned in rows. The height of the rows can be fixed or dynamic, the width of the items inside a row can also be fixed or dynamic. That way different kind of layouts can be achieved: Tables, lists or Goolge-Image-like views. Set the properties to achieve a layout before seetting itemInfos, since each property change causes re-layouting. The following properties affect the layout: rowHeight, itemWidth, allowOverfill, stretchRows, stretchLastRow, scaleRows, horizontalSpacing, verticalSpacing, itemFactory, navigatorHeight.

layout1.png
layout2.png
layout3.png
layout4.png
layout5.png
layout6.png
Some possible layouts.

ContentWidget offers a so called navigator widget. The navigatorWidget represents a single item and is shown below the row the item is in. It always has a fixed height of navigatorHeight and the full width of this widget. The navigator widget can for example provide additional information about the selected item. By default the navigator widget is shown when an item is clicked, this can be disabled using showNavigatorOnClick.

Constructor & Destructor Documentation

longscroll::ContentWidget::ContentWidget ( QWidget parent = 0)

Constructs a ContentWidget.

Parameters
parent
longscroll::ContentWidget::ContentWidget ( int  rowHeight,
int  itemWidth = 0,
QWidget parent = 0 
)

Constructs a ContentWidget.

Parameters
rowHeight
itemWidth
parent
longscroll::ContentWidget::~ContentWidget ( )

Destroys the widget.

Member Function Documentation

int longscroll::ContentWidget::colAt ( int  x,
int  row 
)
protected

This is an overloaded function.

See Also
colAt(int x, const ContentWidget::RowInfo & row)
int longscroll::ContentWidget::colAt ( int  x,
RowInfo const &  row 
)
protected

Calculates which column of a row a given x-coordinate belongs to.

Since items can have different widths, a row is needed.

Parameters
xX-Coordinate.
rowRow.
Returns
Column.
See Also
rowAt
QWidget * longscroll::ContentWidget::createItemWidget ( ContentItemInfo const &  info,
int  itemIndex 
)
protectedvirtual

Creates an item widget.

This method creates a widget to visualize an item. These widgets are created when the respective item becomes close to the visible region and destroyed when it moves away. For fine control when the widget is created, use prefetchRowsBefore and prefetchRowsAfter. This widget takes ownership of the returned widget.

This method can be overridden. However, the same effect can be achieved by changing the itemFactory.

Parameters
infoThe item info to be displayed.
itemIndexList index of the item info.
Returns
The newly created widget.
See Also
itemFactory
prefetchBefore
prefetchAfter
longscroll::ContentWidget::currentItemChanged ( int  itemIndex,
int  oldItemIndex 
)
signal

This signal is emitted whenever the current item changes.

The previous model item index is replaced by the current index as the selection's current item.

Parameters
itemIndexCurrent item index.
oldItemIndexOld current item index.
int longscroll::ContentWidget::findRow ( int  itemIndex)

Searches the row of a given item index.

Uses binary search using std::lower_bound() to find the row. The itemIndex must be in the range of the item info list, this is not checked.

Parameters
itemIndex
Returns
row
See Also
itemInfos
findRowCol
void longscroll::ContentWidget::findRowCol ( int &  row,
int &  col,
int  itemIndex 
)

Searches the row and column of a given item index.

Uses binary search using std::lower_bound() to find the row, the column is calculated directly. The itemIndex must be in the range of the item info list, this is not checked.

Parameters
rowReturns the row.
colReturns the column.
itemIndex
See Also
itemInfos
findRow
bool longscroll::ContentWidget::getAllowOverfill ( ) const
See Also
allowOverfill
int longscroll::ContentWidget::getCurrentItem ( ) const
bool longscroll::ContentWidget::getHandleMouseEvents ( ) const
int longscroll::ContentWidget::getHorizontalSpacing ( ) const
ContentWidgetItemFactory * longscroll::ContentWidget::getItemFactory ( )
See Also
itemFactory
const QList< ContentItemInfo > & longscroll::ContentWidget::getItemInfos ( ) const
See Also
itemInfos
uchar longscroll::ContentWidget::getItemTrackingScreenPositionPercentageX ( ) const
uchar longscroll::ContentWidget::getItemTrackingScreenPositionPercentageY ( ) const
int longscroll::ContentWidget::getItemWidth ( ) const
See Also
itemWidth
int longscroll::ContentWidget::getNavigatorHeight ( ) const
See Also
navigatorWidget
NavigatorWidget * longscroll::ContentWidget::getNavigatorWidget ( )
See Also
navigatorWidget
int longscroll::ContentWidget::getPrefetchRowsAfter ( ) const
int longscroll::ContentWidget::getPrefetchRowsBefore ( ) const
int longscroll::ContentWidget::getRowHeight ( ) const
See Also
rowHeight
bool longscroll::ContentWidget::getScaleRows ( ) const
See Also
scaleRows
QList< int > longscroll::ContentWidget::getSelectedItems ( ) const
QAbstractItemView::SelectionMode longscroll::ContentWidget::getSelectionMode ( ) const
bool longscroll::ContentWidget::getShowNavigatorOnClick ( ) const
bool longscroll::ContentWidget::getStretchLastRow ( ) const
See Also
stretchLastRow
bool longscroll::ContentWidget::getStretchRows ( ) const
See Also
stretchRows
int longscroll::ContentWidget::getVerticalSpacing ( ) const
See Also
verticalSpacing
bool longscroll::ContentWidget::isDragEnabled ( ) const
bool longscroll::ContentWidget::isItemTrackingEnabled ( ) const
longscroll::ContentWidget::itemClicked ( int  row,
int  col,
int  itemIndex 
)
signal

This signal is emitted whenever an item is left-clicked.

The row, column and item inex specify is the item that was clicked.

Parameters
row
col
itemIndex
See Also
itemPressed
itemReleased
itemDoubleClicked
longscroll::ContentWidget::itemDoubleClicked ( int  row,
int  col,
int  itemIndex 
)
signal

This signal is emitted whenever an item is double clicked.

The row, column and item inex specify is the item that was double clicked.

Parameters
row
col
itemIndex
See Also
itemPressed
itemReleased
itemClicked
longscroll::ContentWidget::itemPressed ( int  row,
int  col,
int  itemIndex 
)
signal

This signal is emitted whenever an item is pressed.

The row, column and item inex specify is the item that was pressed. Use the QApplication::mouseButtons() function to get the state of the mouse buttons.

Parameters
row
col
itemIndex
See Also
itemReleased
itemClicked
itemDoubleClicked
QGuiApplication::mouseButtons()
longscroll::ContentWidget::itemReleased ( int  row,
int  col,
int  itemIndex 
)
signal

This signal is emitted whenever an item is released.

The row, column and item inex specify is the item that was released. Use the QApplication::mouseButtons() function to get the state of the mouse buttons.

Parameters
row
col
itemIndex
See Also
itemPressed
itemClicked
itemDoubleClicked
QGuiApplication::mouseButtons()
void longscroll::ContentWidget::mouseDoubleClickEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from NotifyableScrollContentWidget::mouseDoubleClickEvent.

Reimplemented from QWidget.

void longscroll::ContentWidget::mouseMoveEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from NotifyableScrollContentWidget::mouseMoveEvent.

Reimplemented from QWidget.

void longscroll::ContentWidget::mousePressEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from NotifyableScrollContentWidget::mousePressEvent.

Reimplemented from QWidget.

void longscroll::ContentWidget::mouseReleaseEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from NotifyableScrollContentWidget::mouseReleaseEvent.

Reimplemented from QWidget.

void longscroll::ContentWidget::nextImage ( int &  row,
int &  col 
)
protected

Takes a row and column and changes them to point at the next item.

The input row and column have to exist. If there is no next item, row and col will be -1.

Parameters
rowRow.
colColumn.
void longscroll::ContentWidget::previousImage ( int &  row,
int &  col 
)
protected

Takes a row and column and changes them to point at the previous item.

The input row and column have to exist. If there is no previous item, row and col will be -1.

Parameters
rowRow.
colColumn.
int longscroll::ContentWidget::rowAt ( int  y,
bool *  onNavigator = 0 
)
protected

Calculates which row a given y-coordinate belongs to.

If the navigator widget is shown and the y-coordinate is on the navigator, the returned row will be the number of the row above the navigator. The optional parameter onNavigator returns if the y-coordinate is on the navigator.

Parameters
yY-Coordinate.
onNavigatorReturns if y is on the navigator widget.
Returns
Row index.
longscroll::ContentWidget::scrollToRequest ( int  y)
signal

This signal is emitted when the widget wants to scroll somewhere.

This happens when the navigator switches a line to keep it steady on the screen, or when itemTrackingEnabled is enabled and the widget is resized and tries to keep one item at one y-coordinate. Can be connected to the setValue() signal of the vertical scroll bar of the containing scroll area.

Parameters
yThe y-coordiate the widget wants to be visible on the top edge.
longscroll::ContentWidget::selectionChanged ( QList< int > const &  selection,
QList< int > const &  oldSelection 
)
signal

This signal is emitted whenever the selection changes.

Parameters
selectionNew selection.
oldSelectionOld selection.
void longscroll::ContentWidget::setAllowOverfill ( bool  allow)
See Also
allowOverfill
void longscroll::ContentWidget::setCurrentItem ( int  index)
void longscroll::ContentWidget::setDragEnabled ( bool  enabled)
void longscroll::ContentWidget::setHandleMouseEvents ( bool  handle)
void longscroll::ContentWidget::setHorizontalSpacing ( int  spacing)
void longscroll::ContentWidget::setItemFactory ( ContentWidgetItemFactory factory)
See Also
itemFactory
void longscroll::ContentWidget::setItemInfos ( QList< ContentItemInfo > const &  infos)
See Also
itemInfos
void longscroll::ContentWidget::setItemTrackingEnabled ( bool  enabled)
void longscroll::ContentWidget::setItemTrackingScreenPositionPercentage ( uchar  percentX,
uchar  percentY 
)

Sets the position where the tracking item is searched.

If item tracking is enabled, the tracking item is the item that is found at this position of the visible region. The values are in percent. For example, (0, 0) is the item at the top left corner, (0, 100) is the item at the bottom left corner and (50, 50) is the item at the center.

Default Value
(0, 0)
Parameters
percentXX-coordinate percentage.
percentYY-coordinate percentage.
See Also
itemTrackingEnabled
getItemTrackingScreenPositionPercentageX
getItemTrackingScreenPositionPercentageY
void longscroll::ContentWidget::setItemWidth ( int  width)
See Also
itemWidth
void longscroll::ContentWidget::setNavigatorHeight ( int  height)
See Also
navigatorWidget
void longscroll::ContentWidget::setNavigatorWidget ( NavigatorWidget nav)
See Also
navigatorWidget
void longscroll::ContentWidget::setPrefetchRowsAfter ( int  rows)
void longscroll::ContentWidget::setPrefetchRowsBefore ( int  rows)
void longscroll::ContentWidget::setRowHeight ( int  height)
See Also
rowHeight
void longscroll::ContentWidget::setScaleRows ( bool  scale)
See Also
scaleRows
void longscroll::ContentWidget::setSelectedItems ( QList< int > const &  indexes)
void longscroll::ContentWidget::setSelectionMode ( QAbstractItemView::SelectionMode  mode)
void longscroll::ContentWidget::setShowNavigatorOnClick ( bool  show)
void longscroll::ContentWidget::setStretchLastRow ( bool  stretch)
See Also
stretchLastRow
void longscroll::ContentWidget::setStretchRows ( bool  stretch)
See Also
stretchRows
void longscroll::ContentWidget::setVerticalSpacing ( int  spacing)
See Also
verticalSpacing
void longscroll::ContentWidget::showingRect ( QRect const &  rect)
overridevirtualslot
void longscroll::ContentWidget::showNavigator ( int  itemIndex)
slot

Shows the navigatorWidget for the given item index.

The index must exist in the item info list.

Parameters
itemIndex
See Also
itemInfos
findRowCol
void longscroll::ContentWidget::showNavigator ( int  row,
int  col 
)
slot

Shows the navigatorWidget for the given row and column.

The row and column must exist.

Parameters
row
col
QSize longscroll::ContentWidget::sizeHint ( ) const
overridevirtualslot
void longscroll::ContentWidget::startDrag ( int  row,
int  col,
int  itemIndex 
)
protectedvirtual

Begins a drag operation.

If dragging is enabled (dragEnabled), and the user tries to drag an item, this method is called. If you wish to implement some kind of drag support, you have to override this moethod. The default implementation does nothing.

See Also
dragEnabled

Property Documentation

bool longscroll::ContentWidget::allowOverfill = true
readwrite

Allows the last item in a row to exceed the width of that row.

If allowOverfill is not set, a row is never wider than the widget.
If allowOverfill is set, the widget decides for the first item that does not fit inside a row anymore, if it adds the item to the row anyway or creates a new row. The item is added to the row if more than half of the item fits inside the row. This is usually used together with stretchRows or scaleRows.

Default Value
true
Accessors
getAllowOverfill(), setAllowOverfill()
See Also
stretchRows
scaleRows
longscroll::ContentWidget::currentItem
readwrite

Current item index.

Accessors
getcurrentItem(), setcurrentItem()
bool longscroll::ContentWidget::dragEnabled = false
readwrite

Enables drag detection, requires handleMouseEvents to be set.

If dragEnabled is set, the widget detects mouse dragging. If a drag was detected, startDrag is called. Any actual actions need to be implemented by overriding it.

Default Value
false
Accessors
isDragEnabled(), setDragEnabled()
See Also
handleMouseEvents
startDrag
bool longscroll::ContentWidget::handleMouseEvents = true
readwrite

Handle mouse events.

Handle press, release and move events to change the selection, start dragging, emit events or show navigator.

Default Value
true
Accessors
getHandleMouseEvents(), setHandleMouseEvents()
See Also
showNavigatorOnClick
selectionMode
dragEnabled
longscroll::ContentWidget::horizontalSpacing
readwrite

Horizontal spacing between items.

Default Value
5
Accessors
getHorizontalSpacing(), setHorizontalSpacing()
longscroll::ContentWidget::itemFactory
readwrite

ContentWidgetItemFactory used to create displaying widgets.

This ContentWidget takes ownership of the ContentWidgetItemFactory.

Accessors
getItemFactory(), setItemFactory()
Default Value
new ContentWidgetImageItemFactory(false, this)
See Also
ContentWidgetImageItemFactory
QList< ContentItemInfo > longscroll::ContentWidget::itemInfos
readwrite

The list of ContentItemInfos being displayed.

Accessors
getItemInfos(), setItemInfos()
bool longscroll::ContentWidget::itemTrackingEnabled = true
readwrite

Tries to keep one item at the same screen y-coordinate while resizing.

If item tracking is enabled, an item is memorized when the user scrolls the widget. When the widget is resized, it tries to keep that tracking item at the same screen y-coordinate.

Default Value
true
Accessors
isItemTrackingEnabled(), setItemTrackingEnabled()
See Also
setItemTrackingScreenPositionPercentage
int longscroll::ContentWidget::itemWidth = 0
readwrite

Item base width.

If itemWidth > 0, all items will have this width, unless stretchRows is set.
If itemWidth < 0, all items will have some large width. Only use this to gether with stretchRows and without scaleRows. That has the effect that one item takes exactly one row.
If itemWidth == 0, the items will have their size assigned by using item.widthForHeight(rowHeight), i.e. each item has the width that fits the rowHeight best.

Default Value
0
Accessors
getItemWidth(), setItemWidth()
See Also
stretchRows
int longscroll::ContentWidget::navigatorHeight = 400
readwrite

Navigator widget height.

The navigator widget always has a fixed height.

Default Value
400
Accessors
getNavigatorHeight(), setNavigatorHeight()
See Also
navigatorWidget
longscroll::ContentWidget::navigatorWidget
readwrite

NavigatorWidget.

Default Value
new ImageNavigatorWidget(this)
Accessors
getNavigatorWidget(), setNavigatorWidget()
See Also
navigatorHeight
ImageNavigatorWidget
longscroll::ContentWidget::prefetchRowsAfter
readwrite

Number of rows after the last visible row that should be kept ready for displaying.

These rows are not currently visible, but their widgets still or already exist anyway. This can be useful for example if a widget needs some time to load data from the disk or network.

Default Value
3
Accessors
getPrefetchRowsAfter(), setPrefetchRowsAfter()
longscroll::ContentWidget::prefetchRowsBefore
readwrite

Number of rows before the first visible row that should be kept ready for displaying.

These rows are not currently visible, but their widgets still or already exist anyway. This can be useful for example if a widget needs some time to load data from the disk or network.

Default Value
1
Accessors
getPrefetchRowsBefore(), setPrefetchRowsBefore()
int longscroll::ContentWidget::rowHeight = 150
readwrite

Row base height.

If scaleRows is not set, every row will have this height. If scaleRows is set, this will be the base value to calculate the actual size from. The value must be > 0.

Default Value
150
Accessors
getRowHeight(), setRowHeight()
See Also
scaleRows
bool longscroll::ContentWidget::scaleRows = false
readwrite

Scale rows to the actual widget's width, keeping the items' aspect ratio.

Similar to stretchRows, but keeps the aspect ratios of the items. Instead it changes the row height. If enabled, overrides stretchRows, but respects stretchLastRow. For (theoretically) better performance you should disable stretchRows when scaleRows is set.

Enabling scaleRows means that rows don't have fixed row heights anymore, which causes some operations to be a bit more complex. For maximum performance, this feature can be disabled completely by compiling the library with CONTENTWIDGET_VARIABLE_ROW_HEIGHT=0 defined. However I found the effective performance impact hardly mensurable.

Don't use scaleRows with itemWidth < 0.

Default Value
false
Accessors
getScaleRows(), setScaleRows()
See Also
stretchRows
stretchLastRow
longscroll::ContentWidget::selectedItems
readwrite

Selected item indexes.

Accessors
getSelectedItems(), setSelectedItems()
QAbstractItemView::SelectionMode longscroll::ContentWidget::selectionMode = QAbstractItemView::NoSelection
readwrite

Selection mode.

If selectionMode is set to QAbstractItemView::NoSelection, the selection is cleared and disabled. Requires handleMouseEvents for mouse selection to work.

Note that selection is not automatically displayed. The item widget has to visualize the selection. ImageItemWidget for example can be configured to visualize selections.

Currently only mouse selection is implemented.

Accessors
getSelectionMode(), setSelectionMode()
See Also
handleMouseEvents
longscroll::ContentWidget::showNavigatorOnClick
readwrite

Show the navigator widget on item click, requires handleMouseEvents to be set.

Default Value
true
Accessors
getShowNavigatorOnClick(), setShowNavigatorOnClick()
See Also
handleMouseEvents
longscroll::ContentWidget::stretchLastRow
readwrite

Stretch last row.

The last row can be stretched independently from the other rows. This is because the last row usually is not completely filled and stretching it looks strange.

Default Value
false
Accessors
getStretchLastRow(), setStretchLastRow()
See Also
stretchRows
longscroll::ContentWidget::stretchRows
readwrite

Stretch row widths to the actual widget's width.

If stretchRows is set, all rows will be stretched to the actual widget's width. This is done by stretching all items of a row proportionally to their widths. If stretchRows is not set, all items will have the size specified by itemWidth. This value does not affect the last row, which is controlled by stretchLastRow.

Default Value
true
Accessors
getStretchRows(), setStretchRows()
See Also
stretchLastRow
scaleRows
longscroll::ContentWidget::verticalSpacing
readwrite

Vertical spacing between items.

Default Value
5
Accessors
getVerticalSpacing(), setVerticalSpacing()

The documentation for this class was generated from the following files: