Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
PhraseView Class Reference

#include <phraseview.h>

+ Inheritance diagram for PhraseView:
+ Collaboration diagram for PhraseView:

Public Slots

void toggleGuessing ()
 
void update ()
 
int getMaxCandidates () const
 
void setMaxCandidates (const int max)
 
static int getDefaultMaxCandidates ()
 
void moreGuesses ()
 
void fewerGuesses ()
 
void resetNumGuesses ()
 
- Public Slots inherited from QTreeView
void hideColumn (int column)
 Hides the column given.
 
void showColumn (int column)
 Shows the given column in the tree view.
 
void expand (const QModelIndex &index)
 Expands the model item specified by the index.
 
void collapse (const QModelIndex &index)
 Collapses the model item specified by the index.
 
void resizeColumnToContents (int column)
 Resizes the column given to the size of its contents.
 
void sortByColumn (int column, Qt::SortOrder order)
 Sorts the model by the values in the given column and order.
 
void expandAll ()
 Expands all expandable items.
 
void expandRecursively (const QModelIndex &index, int depth=-1)
 
void collapseAll ()
 Collapses all expanded items.
 
void expandToDepth (int depth)
 Expands all expandable items to the given depth.
 
- Public Slots inherited from QAbstractItemView
void edit (const QModelIndex &index)
 Starts editing the item corresponding to the given index if it is editable.
 
void clearSelection ()
 Deselects all selected items.
 
void setCurrentIndex (const QModelIndex &index)
 Sets the current item to be the item at index.
 
void scrollToTop ()
 Scrolls the view to the top.
 
void scrollToBottom ()
 Scrolls the view to the bottom.
 
void update (const QModelIndex &index)
 Updates the area occupied by the given index.
 

Signals

void phraseSelected (int latestModel, const QString &phrase)
 
void showFewerGuessesAvailable (bool canShow)
 
void setCurrentMessageFromGuess (int modelIndex, const Candidate &cand)
 
- Signals inherited from QTreeView
void expanded (const QModelIndex &index)
 This signal is emitted when the item specified by index is expanded.
 
void collapsed (const QModelIndex &index)
 This signal is emitted when the item specified by index is collapsed.
 
- Signals inherited from QAbstractItemView
void pressed (const QModelIndex &index)
 This signal is emitted when a mouse button is pressed.
 
void clicked (const QModelIndex &index)
 This signal is emitted when a mouse button is left-clicked.
 
void doubleClicked (const QModelIndex &index)
 This signal is emitted when a mouse button is double-clicked.
 
void activated (const QModelIndex &index)
 This signal is emitted when the item specified by index is activated by the user.
 
void entered (const QModelIndex &index)
 This signal is emitted when the mouse cursor enters the item specified by index.
 
void viewportEntered ()
 This signal is emitted when the mouse cursor enters the viewport.
 
void iconSizeChanged (const QSize &size)
 

Public Member Functions

 PhraseView (MultiDataModel *model, QList< QHash< QString, QList< Phrase * > > > *phraseDict, QWidget *parent=0)
 
 ~PhraseView ()
 
void setSourceText (int model, const QString &sourceText)
 
- Public Member Functions inherited from QTreeView
 QTreeView (QWidget *parent=nullptr)
 Constructs a tree view with a parent to represent a model's data.
 
 ~QTreeView ()
 Destroys the tree view.
 
void setModel (QAbstractItemModel *model) override
 \reimp
 
void setRootIndex (const QModelIndex &index) override
 \reimp
 
void setSelectionModel (QItemSelectionModel *selectionModel) override
 \reimp
 
QHeaderViewheader () const
 Returns the header for the tree view.
 
void setHeader (QHeaderView *header)
 Sets the header for the tree view, to the given header.
 
int autoExpandDelay () const
 
void setAutoExpandDelay (int delay)
 
int indentation () const
 
void setIndentation (int i)
 
void resetIndentation ()
 
bool rootIsDecorated () const
 
void setRootIsDecorated (bool show)
 
bool uniformRowHeights () const
 
void setUniformRowHeights (bool uniform)
 
bool itemsExpandable () const
 
void setItemsExpandable (bool enable)
 
bool expandsOnDoubleClick () const
 
void setExpandsOnDoubleClick (bool enable)
 
int columnViewportPosition (int column) const
 Returns the horizontal position of the column in the viewport.
 
int columnWidth (int column) const
 Returns the width of the column.
 
void setColumnWidth (int column, int width)
 Sets the width of the given column to the width specified.
 
int columnAt (int x) const
 Returns the column in the tree view whose header covers the x coordinate given.
 
bool isColumnHidden (int column) const
 Returns true if the column is hidden; otherwise returns false.
 
void setColumnHidden (int column, bool hide)
 If hide is true the column is hidden, otherwise the column is shown.
 
bool isHeaderHidden () const
 
void setHeaderHidden (bool hide)
 
bool isRowHidden (int row, const QModelIndex &parent) const
 Returns true if the item in the given row of the parent is hidden; otherwise returns false.
 
void setRowHidden (int row, const QModelIndex &parent, bool hide)
 If hide is true the row with the given parent is hidden, otherwise the row is shown.
 
bool isFirstColumnSpanned (int row, const QModelIndex &parent) const
 Returns true if the item in first column in the given row of the parent is spanning all the columns; otherwise returns false.
 
void setFirstColumnSpanned (int row, const QModelIndex &parent, bool span)
 If span is true the item in the first column in the row with the given parent is set to span all columns, otherwise all items on the row are shown.
 
bool isExpanded (const QModelIndex &index) const
 Returns true if the model item index is expanded; otherwise returns false.
 
void setExpanded (const QModelIndex &index, bool expand)
 Sets the item referred to by index to either collapse or expanded, depending on the value of expanded.
 
void setSortingEnabled (bool enable)
 
bool isSortingEnabled () const
 
void setAnimated (bool enable)
 
bool isAnimated () const
 
void setAllColumnsShowFocus (bool enable)
 
bool allColumnsShowFocus () const
 
void setWordWrap (bool on)
 
bool wordWrap () const
 
void setTreePosition (int logicalIndex)
 
int treePosition () const
 
void keyboardSearch (const QString &search) override
 \reimp
 
QRect visualRect (const QModelIndex &index) const override
 Returns the rectangle on the viewport occupied by the item at index.
 
void scrollTo (const QModelIndex &index, ScrollHint hint=EnsureVisible) override
 Scroll the contents of the tree view until the given model item index is visible.
 
QModelIndex indexAt (const QPoint &p) const override
 \reimp
 
QModelIndex indexAbove (const QModelIndex &index) const
 Returns the model index of the item above index.
 
QModelIndex indexBelow (const QModelIndex &index) const
 Returns the model index of the item below index.
 
void doItemsLayout () override
 
void reset () override
 \reimp
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >()) override
 \reimp
 
void selectAll () override
 \reimp
 
- Public Member Functions inherited from QAbstractItemView
 QAbstractItemView (QWidget *parent=nullptr)
 Constructs an abstract item view with the given parent.
 
 ~QAbstractItemView ()
 Destroys the view.
 
QAbstractItemModelmodel () const
 Returns the model that this view is presenting.
 
QItemSelectionModelselectionModel () const
 Returns the current selection model.
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 Sets the item delegate for this view and its model to delegate.
 
QAbstractItemDelegateitemDelegate () const
 Returns the item delegate used by this view and model.
 
void setSelectionMode (QAbstractItemView::SelectionMode mode)
 
QAbstractItemView::SelectionMode selectionMode () const
 
void setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior)
 
QAbstractItemView::SelectionBehavior selectionBehavior () const
 
QModelIndex currentIndex () const
 Returns the model index of the current item.
 
QModelIndex rootIndex () const
 Returns the model index of the model's root item.
 
void setEditTriggers (EditTriggers triggers)
 
EditTriggers editTriggers () const
 
void setVerticalScrollMode (ScrollMode mode)
 
ScrollMode verticalScrollMode () const
 
void resetVerticalScrollMode ()
 
void setHorizontalScrollMode (ScrollMode mode)
 
ScrollMode horizontalScrollMode () const
 
void resetHorizontalScrollMode ()
 
void setAutoScroll (bool enable)
 
bool hasAutoScroll () const
 
void setAutoScrollMargin (int margin)
 
int autoScrollMargin () const
 
void setTabKeyNavigation (bool enable)
 
bool tabKeyNavigation () const
 
void setAlternatingRowColors (bool enable)
 
bool alternatingRowColors () const
 
void setIconSize (const QSize &size)
 
QSize iconSize () const
 
void setTextElideMode (Qt::TextElideMode mode)
 
Qt::TextElideMode textElideMode () const
 
QSize sizeHintForIndex (const QModelIndex &index) const
 Returns the size hint for the item with the specified index or an invalid size for invalid indexes.
 
virtual int sizeHintForRow (int row) const
 Returns the height size hint for the specified row or -1 if there is no model.
 
uint32_t updateThreshold () const
 
void setUpdateThreshold (uint32_t threshold)
 
void openPersistentEditor (const QModelIndex &index)
 Opens a persistent editor on the item at the given index.
 
void closePersistentEditor (const QModelIndex &index)
 Closes the persistent editor for the item at the given index.
 
bool isPersistentEditorOpen (const QModelIndex &index) const
 
void setIndexWidget (const QModelIndex &index, QWidget *widget)
 Sets the given widget on the item at the given index, passing the ownership of the widget to the viewport.
 
QWidgetindexWidget (const QModelIndex &index) const
 Returns the widget for the item at the given index.
 
void setItemDelegateForRow (int row, QAbstractItemDelegate *delegate)
 Sets the given item delegate used by this view and model for the given row.
 
QAbstractItemDelegateitemDelegateForRow (int row) const
 Returns the item delegate used by this view and model for the given row, or \nullptr if no delegate has been assigned.
 
void setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate)
 Sets the given item delegate used by this view and model for the given column.
 
QAbstractItemDelegateitemDelegateForColumn (int column) const
 Returns the item delegate used by this view and model for the given column.
 
virtual QAbstractItemDelegateitemDelegateForIndex (const QModelIndex &index) const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const override
 \reimp
 

Protected Member Functions

void contextMenuEvent (QContextMenuEvent *event) override
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 
- Protected Member Functions inherited from QTreeView
 QTreeView (QTreeViewPrivate &dd, QWidget *parent=nullptr)
 
void scrollContentsBy (int dx, int dy) override
 Scrolls the contents of the tree view by (dx, dy).
 
void rowsInserted (const QModelIndex &parent, int start, int end) override
 Informs the view that the rows from the start row to the end row inclusive have been inserted into the parent model item.
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end) override
 Informs the view that the rows from the start row to the end row inclusive are about to removed from the given parent model item.
 
QModelIndex moveCursor (CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
 Move the cursor in the way described by cursorAction, using the information provided by the button modifiers.
 
int horizontalOffset () const override
 Returns the horizontal offset of the items in the treeview.
 
int verticalOffset () const override
 Returns the vertical offset of the items in the tree view.
 
void setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags command) override
 Applies the selection command to the items in or touched by the rectangle, rect.
 
QRegion visualRegionForSelection (const QItemSelection &selection) const override
 Returns the rectangle from the viewport of the items in the given selection.
 
QModelIndexList selectedIndexes () const override
 \reimp
 
void changeEvent (QEvent *event) override
 \reimp
 
void timerEvent (QTimerEvent *event) override
 \reimp
 
void paintEvent (QPaintEvent *event) override
 \reimp
 
void drawTree (QPainter *painter, const QRegion &region) const
 Draws the part of the tree intersecting the given region using the specified painter.
 
virtual void drawRow (QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const
 Draws the row in the tree view that contains the model item index, using the painter given.
 
virtual void drawBranches (QPainter *painter, const QRect &rect, const QModelIndex &index) const
 Draws the branches in the tree view on the same row as the model item index, using the painter given.
 
void mousePressEvent (QMouseEvent *event) override
 \reimp
 
void mouseReleaseEvent (QMouseEvent *event) override
 \reimp
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 \reimp
 
void mouseMoveEvent (QMouseEvent *event) override
 \reimp
 
void keyPressEvent (QKeyEvent *event) override
 \reimp
 
bool viewportEvent (QEvent *event) override
 \reimp
 
void updateGeometries () override
 \reimp
 
QSize viewportSizeHint () const override
 \reimp
 
int sizeHintForColumn (int column) const override
 Returns the size hint for the column's width or -1 if there is no model.
 
int indexRowSizeHint (const QModelIndex &index) const
 Returns the size hint for the row indicated by index.
 
int rowHeight (const QModelIndex &index) const
 Returns the height of the row indicated by the given index.
 
void horizontalScrollbarAction (int action) override
 
bool isIndexHidden (const QModelIndex &index) const override
 \reimp
 
void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) override
 \reimp
 
void currentChanged (const QModelIndex &current, const QModelIndex &previous) override
 \reimp
 
- Protected Member Functions inherited from QAbstractItemView
 QAbstractItemView (QAbstractItemViewPrivate &, QWidget *parent=nullptr)
 
virtual bool edit (const QModelIndex &index, EditTrigger trigger, QEvent *event)
 Starts editing the item at index, creating an editor if necessary, and returns true if the view's \l{State} is now EditingState; otherwise returns false.
 
virtual QItemSelectionModel::SelectionFlags selectionCommand (const QModelIndex &index, const QEvent *event=nullptr) const
 Returns the SelectionFlags to be used when updating a selection model for the specified index.
 
virtual void initViewItemOption (QStyleOptionViewItem *option) const
 
State state () const
 Returns the item view's state.
 
void setState (State state)
 Sets the item view's state to the given state.
 
void scheduleDelayedItemsLayout ()
 Schedules a layout of the items in the view to be executed when the event processing starts.
 
void executeDelayedItemsLayout ()
 Executes the scheduled layouts without waiting for the event processing to begin.
 
void setDirtyRegion (const QRegion &region)
 Marks the given region as dirty and schedules it to be updated.
 
void scrollDirtyRegion (int dx, int dy)
 Prepares the view for scrolling by ({dx},{dy}) pixels by moving the dirty regions in the opposite direction.
 
QPoint dirtyRegionOffset () const
 Returns the offset of the dirty regions in the view.
 
void startAutoScroll ()
 
void stopAutoScroll ()
 
void doAutoScroll ()
 
bool focusNextPrevChild (bool next) override
 \reimp
 
bool event (QEvent *event) override
 \reimp
 
bool viewportEvent (QEvent *event) override
 This function is used to handle tool tips, and What's This? mode, if the given event is a QEvent::ToolTip,or a QEvent::WhatsThis.
 
void mousePressEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is pressed while the cursor is inside the widget.
 
void mouseMoveEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse move event is sent to the widget.
 
void mouseReleaseEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is released, after a mouse press event on the widget.
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is double clicked inside the widget.
 
void focusInEvent (QFocusEvent *event) override
 This function is called with the given event when the widget obtains the focus.
 
void focusOutEvent (QFocusEvent *event) override
 This function is called with the given event when the widget loses the focus.
 
void keyPressEvent (QKeyEvent *event) override
 This function is called with the given event when a key event is sent to the widget.
 
void resizeEvent (QResizeEvent *event) override
 This function is called with the given event when a resize event is sent to the widget.
 
void timerEvent (QTimerEvent *event) override
 This function is called with the given event when a timer event is sent to the widget.
 
void inputMethodEvent (QInputMethodEvent *event) override
 \reimp
 
bool eventFilter (QObject *object, QEvent *event) override
 \reimp
 
QSize viewportSizeHint () const override
 

Additional Inherited Members

- Public Types inherited from QAbstractItemView
enum  SelectionMode {
  NoSelection , SingleSelection , MultiSelection , ExtendedSelection ,
  ContiguousSelection
}
 This enum indicates how the view responds to user selections: More...
 
enum  SelectionBehavior { SelectItems , SelectRows , SelectColumns }
 \value SelectItems Selecting single items. More...
 
enum  ScrollHint { EnsureVisible , PositionAtTop , PositionAtBottom , PositionAtCenter }
 \value EnsureVisible Scroll to ensure that the item is visible. More...
 
enum  EditTrigger {
  NoEditTriggers = 0 , CurrentChanged = 1 , DoubleClicked = 2 , SelectedClicked = 4 ,
  EditKeyPressed = 8 , AnyKeyPressed = 16 , AllEditTriggers = 31
}
 This enum describes actions which will initiate item editing. More...
 
enum  ScrollMode { ScrollPerItem , ScrollPerPixel }
 Describes how the scrollbar should behave. More...
 
- Protected Types inherited from QAbstractItemView
enum  CursorAction {
  MoveUp , MoveDown , MoveLeft , MoveRight ,
  MoveHome , MoveEnd , MovePageUp , MovePageDown ,
  MoveNext , MovePrevious
}
 This enum describes the different ways to navigate between items,. More...
 
enum  State {
  NoState , DraggingState , DragSelectingState , EditingState ,
  ExpandingState , CollapsingState , AnimatingState
}
 Describes the different states the view can be in. More...
 
- Protected Slots inherited from QTreeView
void columnResized (int column, int oldSize, int newSize)
 This function is called whenever {column}'s size is changed in the header.
 
void columnCountChanged (int oldCount, int newCount)
 Informs the tree view that the number of columns in the tree view has changed from oldCount to newCount.
 
void columnMoved ()
 This slot is called whenever a column has been moved.
 
void reexpand ()
 
void rowsRemoved (const QModelIndex &parent, int first, int last)
 Informs the view that the rows from the start row to the end row inclusive have been removed from the given parent model item.
 
void verticalScrollbarValueChanged (int value) override
 
- Protected Slots inherited from QAbstractItemView
virtual void updateEditorData ()
 
virtual void updateEditorGeometries ()
 
virtual void verticalScrollbarAction (int action)
 
virtual void verticalScrollbarValueChanged (int value)
 
virtual void horizontalScrollbarValueChanged (int value)
 
virtual void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 Closes the given editor, and releases it.
 
virtual void commitData (QWidget *editor)
 Commit the data in the editor to the model.
 
virtual void editorDestroyed (QObject *editor)
 This function is called when the given editor has been destroyed.
 
- Properties inherited from QTreeView
int autoExpandDelay
 The delay time before items in a tree are opened during a drag and drop operation.
 
int indentation
 indentation of the items in the tree view.
 
bool rootIsDecorated
 whether to show controls for expanding and collapsing top-level items
 
bool uniformRowHeights
 whether all items in the treeview have the same height
 
bool itemsExpandable
 whether the items are expandable by the user.
 
bool sortingEnabled
 whether sorting is enabled
 
bool animated
 whether animations are enabled
 
bool allColumnsShowFocus
 whether items should show keyboard focus using all columns
 
bool wordWrap
 the item text word-wrapping policy
 
bool headerHidden
 whether the header is shown or not.
 
bool expandsOnDoubleClick
 whether the items can be expanded by double-clicking.
 
- Properties inherited from QAbstractItemView
bool autoScroll
 whether autoscrolling in drag move events is enabled
 
int autoScrollMargin
 the size of the area when auto scrolling is triggered
 
EditTriggers editTriggers
 which actions will initiate item editing
 
bool tabKeyNavigation
 whether item navigation with tab and backtab is enabled.
 
bool alternatingRowColors
 whether to draw the background using alternating colors
 
SelectionMode selectionMode
 which selection mode the view operates in
 
SelectionBehavior selectionBehavior
 which selection behavior the view uses
 
QSize iconSize
 the size of items' icons
 
Qt::TextElideMode textElideMode
 the position of the "..." in elided text.
 
ScrollMode verticalScrollMode
 how the view scrolls its contents in the vertical direction
 
ScrollMode horizontalScrollMode
 how the view scrolls its contents in the horizontal direction
 
uint32_t updateThreshold
 

Detailed Description

Definition at line 18 of file phraseview.h.

Constructor & Destructor Documentation

◆ PhraseView()

PhraseView::PhraseView ( MultiDataModel * model,
QList< QHash< QString, QList< Phrase * > > > * phraseDict,
QWidget * parent = 0 )

Definition at line 28 of file phraseview.cpp.

◆ ~PhraseView()

PhraseView::~PhraseView ( )

Definition at line 61 of file phraseview.cpp.

Member Function Documentation

◆ contextMenuEvent()

void PhraseView::contextMenuEvent ( QContextMenuEvent * event)
overrideprotected

Definition at line 79 of file phraseview.cpp.

◆ fewerGuesses

void PhraseView::fewerGuesses ( )
slot

Definition at line 163 of file phraseview.cpp.

References DefaultMaxCandidates, and setMaxCandidates().

+ Here is the call graph for this function:

◆ getDefaultMaxCandidates

static int PhraseView::getDefaultMaxCandidates ( )
inlinestaticslot

Definition at line 32 of file phraseview.h.

References DefaultMaxCandidates.

◆ getMaxCandidates

int PhraseView::getMaxCandidates ( ) const
inlineslot

Definition at line 30 of file phraseview.h.

◆ moreGuesses

void PhraseView::moreGuesses ( )
slot

Definition at line 157 of file phraseview.cpp.

References DefaultMaxCandidates, and setMaxCandidates().

+ Here is the call graph for this function:

◆ mouseDoubleClickEvent()

void PhraseView::mouseDoubleClickEvent ( QMouseEvent * event)
overrideprotected

Definition at line 110 of file phraseview.cpp.

◆ phraseSelected

void PhraseView::phraseSelected ( int latestModel,
const QString & phrase )
signal

◆ resetNumGuesses

void PhraseView::resetNumGuesses ( )
slot

Definition at line 169 of file phraseview.cpp.

References DefaultMaxCandidates, and setMaxCandidates().

+ Here is the call graph for this function:

◆ setCurrentMessageFromGuess

void PhraseView::setCurrentMessageFromGuess ( int modelIndex,
const Candidate & cand )
signal

◆ setMaxCandidates

void PhraseView::setMaxCandidates ( const int max)
slot

Definition at line 151 of file phraseview.cpp.

Referenced by fewerGuesses(), moreGuesses(), and resetNumGuesses().

+ Here is the caller graph for this function:

◆ setSourceText()

void PhraseView::setSourceText ( int model,
const QString & sourceText )

Definition at line 223 of file phraseview.cpp.

◆ showFewerGuessesAvailable

void PhraseView::showFewerGuessesAvailable ( bool canShow)
signal

◆ toggleGuessing

void PhraseView::toggleGuessing ( )
slot

Definition at line 67 of file phraseview.cpp.

References update().

+ Here is the call graph for this function:

◆ update

void PhraseView::update ( )
slot

Definition at line 73 of file phraseview.cpp.

Referenced by toggleGuessing().

+ Here is the caller graph for this function:

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