Skip to content

Commit

Permalink
QtCommon v3.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosier committed Jun 25, 2024
1 parent bed5a2f commit 78a9a00
Show file tree
Hide file tree
Showing 12 changed files with 1,110 additions and 429 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(QtCommon)

# Define version information
set(QTCOMMON_MAJOR_VERSION 3)
set(QTCOMMON_MINOR_VERSION 13)
set(QTCOMMON_MINOR_VERSION 14)
if (NOT QTCOMMON_PATCH_NUMBER)
set(QTCOMMON_PATCH_NUMBER 0)
endif ()
Expand Down Expand Up @@ -40,4 +40,3 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
else ()
set(CPACK_ARCHIVE_GUITEST_FILE_NAME "QtCommon_GuiTest_${QTCOMMON_MAJOR_VERSION}.${QTCOMMON_MINOR_VERSION}.${QTCOMMON_PATCH_NUMBER}.${QTCOMMON_BUILD_NUMBER}")
endif ()

4 changes: 3 additions & 1 deletion _clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Language: Cpp
AccessModifierOffset: -4
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
Expand Down Expand Up @@ -37,7 +38,8 @@ AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: false
ReflowComments: false
SortIncludes: false
SortIncludes: true
IncludeBlocks: Preserve
SortUsingDeclarations: false
BinPackArguments: false
BinPackParameters: false
Expand Down
4 changes: 0 additions & 4 deletions source/qt_common/custom_widgets/navigation_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ NavigationBar::NavigationBar(QWidget* parent)
{
layout_.setAlignment(Qt::AlignCenter);
layout_.setSpacing(10);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
layout_.setMargin(20);
#else
layout_.setContentsMargins(20, 20, 20, 20);
#endif

browse_back_button_.setStyleSheet(kNavigationButtonStyle_);
EnableBackButton(false);
Expand Down
453 changes: 274 additions & 179 deletions source/qt_common/custom_widgets/shared_isa_item_delegate.cpp

Large diffs are not rendered by default.

62 changes: 46 additions & 16 deletions source/qt_common/custom_widgets/shared_isa_item_delegate.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//=============================================================================
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
/// @author AMD Developer Tools Team
/// @file
/// @brief Declaration for a shared isa item delegate.
Expand All @@ -10,10 +10,11 @@

#include <QModelIndex>
#include <QPainter>
#include <QStyledItemDelegate>
#include <QStyleOptionViewItem>
#include <QStyledItemDelegate>

#include "shared_isa_item_model.h"
#include "shared_isa_proxy_model.h"
#include "shared_isa_tree_view.h"

/// @brief SharedIsaItemDelegate is a styled delegate to be used with the SharedIsaTreeView.
Expand Down Expand Up @@ -58,30 +59,32 @@ class SharedIsaItemDelegate : public QStyledItemDelegate
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const Q_DECL_OVERRIDE;

protected:
/// @brief Determines if the current model index is at the top the corresponding tree and is an instruction.
/// @brief Determines if the source model index is at the top of its corresponding tree viewport and is a child row.
///
/// If the current index is at the top and is an instruction, the parent code block label will be pinned there instead in the op code column.
/// If the index is at the top and is a child, the parent label will be pinned there instead.
///
/// @param [in] source_model_index The source model index.
/// @param [in] proxy_model_index The proxy model index.
/// @param [in] proxy_index_y_position The y position of the proxy model index.
/// @param [out] pinned_code_block_op_code_column Flag set if the index is on top and is an instruction, but it is the op code column.
/// @param [in] source_model_index The source model index.
/// @param [in] proxy_model_index The proxy model index.
/// @param [in] proxy_index_y_position The y position of the proxy model index.
/// @param [out] pinned_label_line_number_column true if the index is at the top of its tree, is a child index, and is the line number column.
///
/// @return true if there is an instruction at the top of the corresponding tree view, false if not, or if the current column is the op code column where the code block label will be pinned.
/// @return true if the index is a child index and at the top of the corresponding tree view, false if not.
bool CodeBlockLabelPinnedToTop(const QModelIndex& source_model_index,
const QModelIndex& proxy_model_index,
int& proxy_index_y_position,
bool& pinned_code_block_op_code_column) const;

/// @brief Paint a 1 pixel gray vertical line at the right edge of the provided rectangle.
///
/// @param [in] painter The painter to use.
/// @param [in] rectangle The rectangle to use.
void PaintColumnSeparator(QPainter* painter, const QRect& rectangle) const;
bool& pinned_label_line_number_column) const;

SharedIsaTreeView* view_; ///< The corresponding tree view.

private:
/// @brief Help navigating from labels to branches by accomodating for column span when calculating x position relative to a column.
///
/// @param [in] index The view index to check.
/// @param [in] proxy The proxy model.
/// @param [out] source_index The source index to check; will be changed to the op code source index if the given index spans columns.
/// @param [out] local_x_position The x position of a mouse event; will be changed if the given index spans columns to be relative to the op code column.
void AdjustXPositionForSpannedColumns(const QModelIndex& index, const QSortFilterProxyModel* proxy, QModelIndex& source_index, int& local_x_position);

/// @brief Helper function to help determine if a selectable token is under the mouse.
///
/// @param [in] source_index The source model index that the mouse move event occurred under.
Expand Down Expand Up @@ -119,6 +122,33 @@ class SharedIsaItemDelegate : public QStyledItemDelegate
int instruction_index,
int token_index) const;

/// @brief Helper function to paint the text of a list of isa tokens or isa comments.
///
/// @param [in] painter The QPainter that will be used for painting.
/// @param [in] option The style option for determining font metrics.
/// @param [in] index The model index of the token.
/// @param [in] token_rectangle The rectangle where the token text will be drawn.
/// @param [in] tokens The list of tokens to be painted.
/// @param [in] token_index The starting index of the token in the double vector of tokens. Zero if there is only a singe vector.
/// @param [in] is_comment true if painting comment text, false if painting an instruction's tokens.
///
/// @return A pair of the final token index and text rectangle for when painting a double vector of tokens.
std::pair<int, QRect> PaintText(QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index,
QRect token_rectangle,
std::vector<SharedIsaItemModel::Token> tokens,
int token_index,
bool is_comment) const;

/// @brief Helper function to paint an isa opcode or isa comments in a spanned column.
///
/// @param [in] painter The QPainter that will be used for painting.
/// @param [in] option The style option for determining font metrics.
/// @param [in] source_index The source index where the data to be painted is.
/// @param [in] proxy_index The proxy index of where the painting should occur if it is not a comment.
void PaintSpanned(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& source_index, QModelIndex proxy_index) const;

SharedIsaItemModel::Token mouse_over_isa_token_; ///< Track the token that the mouse is over.
SharedIsaItemModel::Token selected_isa_token_; ///< Track the selected token.

Expand Down
Loading

0 comments on commit 78a9a00

Please sign in to comment.