-
-
Notifications
You must be signed in to change notification settings - Fork 321
QskTreeView #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rick-vogel
wants to merge
5
commits into
uwerat:master
Choose a base branch
from
rick-vogel:qsktreeview
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
QskTreeView #310
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /****************************************************************************** | ||
| * QSkinny - Copyright (C) 2016 Uwe Rathmann | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| *****************************************************************************/ | ||
|
|
||
| #include "ListBox.h" | ||
| #include <QskFunctions.h> | ||
|
|
||
| ListBox::ListBox( QQuickItem* parent ) | ||
| : Inherited( parent ) | ||
| { | ||
| setAlternatingRowColors( true ); | ||
|
|
||
| // increasing the padding of each row: usually the job of the skin ! | ||
| setPaddingHint( Cell, QMargins( 10, 20, 10, 20 ) ); | ||
|
|
||
| populate(); | ||
|
|
||
| setSelectedRow( 5 ); | ||
| } | ||
|
|
||
| void ListBox::populate() | ||
| { | ||
| const int count = 10000; | ||
|
|
||
| const QString format( "Row %1: The quick brown fox jumps over the lazy dog" ); | ||
|
|
||
| QStringList entries; | ||
| entries.reserve( count ); | ||
|
|
||
| for ( int i = 0; i < count; i++ ) | ||
| { | ||
| entries += format.arg( i + 1 ); | ||
| } | ||
|
|
||
| // we know, that the last entry is the longest one and | ||
| // can prevent the list box from having to find it out | ||
| // the expensive way. | ||
|
|
||
| const qreal maxWidth = qskHorizontalAdvance( effectiveFont( Cell ), entries.last() ); | ||
| setColumnWidthHint( 0, maxWidth ); | ||
|
|
||
| append( entries ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /****************************************************************************** | ||
| * QSkinny - Copyright (C) 2016 Uwe Rathmann | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| *****************************************************************************/ | ||
|
|
||
| #include <QskSimpleListBox.h> | ||
|
|
||
| class ListBox : public QskSimpleListBox | ||
| { | ||
| using Inherited = QskSimpleListBox; | ||
|
|
||
| public: | ||
| explicit ListBox( QQuickItem* parent = nullptr ); | ||
|
|
||
| private: | ||
| void populate(); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /****************************************************************************** | ||
| * QSkinny - Copyright (C) 2016 Uwe Rathmann | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| *****************************************************************************/ | ||
|
|
||
| #include "TreeBox.h" | ||
|
|
||
| QSK_SUBCONTROL( TreeBox, FirstRow ) | ||
| QSK_SUBCONTROL( TreeBox, SecondRow ) | ||
|
|
||
| TreeBox::TreeBox( QQuickItem* const parent ) | ||
| : Inherited( parent ) | ||
| { | ||
| setAlternatingRowColors( true ); | ||
| setPaddingHint( Cell, QMargins( 10, 20, 10, 20 ) ); | ||
|
|
||
| setAlternatingRowColors( true ); | ||
| setColor( FirstRow, Qt::white ); | ||
| setColor( SecondRow, color( Panel ) ); | ||
| updateScrollableSize(); | ||
| }; | ||
|
|
||
| QskAspect::Subcontrol TreeBox::rowSubControl( int row ) const noexcept | ||
| { | ||
| if ( alternatingRowColors() ) | ||
| { | ||
| if ( row == selectedRow() ) | ||
| { | ||
| return Cell; | ||
| } | ||
| return row % 2 == 0 ? Cell : QskAspect::NoSubcontrol; | ||
| } | ||
| return QskAspect::NoSubcontrol; | ||
| } | ||
|
|
||
| int TreeBox::rowCount() const | ||
| { | ||
| return 100000; | ||
| } | ||
|
|
||
| int TreeBox::columnCount() const | ||
| { | ||
| return 2; | ||
| } | ||
|
|
||
| qreal TreeBox::columnWidth( int col ) const | ||
| { | ||
| return col == 0 ? 100 : 350; | ||
| } | ||
|
|
||
| qreal TreeBox::rowHeight() const | ||
| { | ||
| const auto hint = strutSizeHint( Cell ); | ||
| const auto padding = paddingHint( Cell ); | ||
|
|
||
| qreal h = effectiveFontHeight( Text ); | ||
| h += padding.top() + padding.bottom(); | ||
|
|
||
| return qMax( h, hint.height() ); | ||
| } | ||
|
|
||
| Q_INVOKABLE QVariant TreeBox::valueAt( int row, int col ) const | ||
| { | ||
| if ( col == 0 ) | ||
| { | ||
| return QString::number( row ); | ||
| } | ||
| return QStringLiteral( "The quick brown fox jumps over the lazy dog" ); | ||
| } | ||
|
|
||
| qreal TreeBox::rowOffset( int row ) const | ||
| { | ||
| return ( row % 4 ) * 10; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a real scenerio the user must provide usefull offsets for a valid tree structure |
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /****************************************************************************** | ||
| * QSkinny - Copyright (C) 2016 Uwe Rathmann | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| *****************************************************************************/ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <QskTreeView.h> | ||
|
|
||
| class TreeBox final : public QskTreeView | ||
| { | ||
| using Inherited = QskTreeView; | ||
|
|
||
| public: | ||
| QSK_SUBCONTROLS( FirstRow, SecondRow ) | ||
|
|
||
| explicit TreeBox( QQuickItem* parent = nullptr ); | ||
| QskAspect::Subcontrol rowSubControl( int row ) const noexcept override; | ||
| int rowCount() const override; | ||
| int columnCount() const override; | ||
| qreal columnWidth( int col ) const override; | ||
| qreal rowHeight() const override; | ||
| Q_INVOKABLE QVariant valueAt( int row, int col ) const override; | ||
| qreal rowOffset( int row ) const override; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.