Fluent-Qt

集合檢視

Timeline 時間軸

依時間順序顯示事件與狀態節點。

範例

Timeline 時間軸: 由模型提供節點

用法

由模型提供節點

透過 DescriptionRole、TimestampRole 與 StatusRole 傳入節點說明、時間標籤及狀態;更新 StatusRole 會重新整理節點圖示。

#include <FluentQt/Collections.h>
using namespace fluent::collections;

auto* timeline = new Timeline(this);
auto* model = new QStandardItemModel(3, 1, this);
for (int i = 0; i < 3; ++i) {
    model->setData(model->index(i, 0), QString("Node %1").arg(i + 1));
    model->setData(model->index(i, 0), "Optional supporting content supplied by the application.", Timeline::DescriptionRole);
    model->setData(model->index(i, 0), QString("Time label %1").arg(i + 1), Timeline::TimestampRole);
}
model->setData(model->index(1, 0), Timeline::Active, Timeline::StatusRole);
timeline->setModel(model);
connect(changeState, &Button::clicked, model, [model] {
    const auto index = model->index(1, 0);
    model->setData(index, model->data(index, Timeline::StatusRole).toInt() == Timeline::Active
        ? Timeline::Success : Timeline::Active, Timeline::StatusRole);
});

fluent::collections::Timeline

繼承自 ListView

由模型支援的時間軸檢視,依時間順序顯示事件節點與狀態;透過 DisplayRole 讀取標題、DecorationRole 讀取選用圖示,以及 DataRole 讀取詳細資訊。

建構函式

解構函式

列舉

enum NodeAlignment

時間軸軌道與節點所放置的一側。

  • Leading
  • Trailing
  • Alternate
enum Status

時間軸節點的視覺狀態色調。

  • Neutral
  • Active
  • Success
  • Warning
  • Error
enum DataRole

描述文字、時間戳記標籤與節點狀態的可選模型角色(預設為 Neutral)。

  • DescriptionRole = Qt::UserRole + 1
  • TimestampRole
  • StatusRole

方法

void setModel(QAbstractItemModel* model) override

設定時間軸模型(仍由呼叫端管理)。

屬性

NodeAlignment nodeAlignment
讀取 nodeAlignment()設定 setNodeAlignment()變更訊號 nodeAlignmentChanged()
bool animationEnabled
讀取 isAnimationEnabled()設定 setAnimationEnabled()變更訊號 animationEnabledChanged()

訊號

PySide6 擴充

受保護成員

方法

繼承自 fluent::collections::ListView

列舉

方法

Flow flow() const

項目排列方向(縱向 TopToBottom 或橫向 LeftToRight)。

void setFlow(Flow flow)

項目排列方向(縱向 TopToBottom 或橫向 LeftToRight)。

SelectionMode selectionMode() const

集合檢視使用的選取模式。

void setSelectionMode(SelectionMode mode)

集合檢視使用的選取模式。

Typography::FontRole fontRole() const

用於文字繪製的 Fluent 排版角色。

void setFontRole(Typography::FontRole role)

用於文字繪製的 Fluent 排版角色。

int trailingTextRole() const

尾端次要文字的可選模型角色;-1 表示隱藏。

void setTrailingTextRole(int role)

設定預設委派用於尾端文字的角色;自訂委派需自行處理版面配置。

bool borderVisible() const

是否繪製控制項外框邊線。

void setBorderVisible(bool visible)

是否繪製控制項外框邊線。

bool backgroundVisible() const

是否繪製控制項背景。

void setBackgroundVisible(bool visible)

是否繪製控制項背景。

QWidget* header() const

承載於 ListView 頁首區域的自訂控制項。

void setHeader(QWidget* widget)

承載於 ListView 頁首區域的自訂控制項。

QString headerText() const

顯示於頁首區域的便利文字。

void setHeaderText(const QString& text)

顯示於頁首區域的便利文字。

QString placeholderText() const

模型沒有項目時顯示的預留文字。

void setPlaceholderText(const QString& text)

模型沒有項目時顯示的預留文字。

bool viewportHovered() const

檢視區目前是否處於懸停狀態。

bool canReorderItems() const

是否啟用拖曳重新排序。

void setCanReorderItems(bool enabled)

是否啟用拖曳重新排序。

bool isScrollChainingEnabled() const

邊界處的滾輪輸入是否可繼續傳遞至外層捲動容器。

void setScrollChainingEnabled(bool enabled)

邊界處的滾輪輸入是否可繼續傳遞至外層捲動容器。

bool sectionEnabled() const

是否透過區段鍵回呼將相鄰項目歸組於區段標題下。

void setSectionEnabled(bool enabled)

是否透過區段鍵回呼將相鄰項目歸組於區段標題下。

void setSectionKeyFunction(SectionKeyFunc func)

設定針對每列傳回區段鍵的回呼函式;具有相同鍵的相鄰列會共用一個區段標題。

qreal selectedIndicatorProgress() const

已選項目指示器的動畫進度。

IndicatorMotionDirection selectedIndicatorMotionDirection() const

已選取指示器動態效果使用的方向。

bool selectedIndicatorAnimationEnabled() const

是否啟用選取指示器轉場動畫;停用後切換選取項目會立即移至目標位置。

bool selectionIndicatorVisible() const

是否繪製選取項目指示器。

void setSelectionIndicatorVisible(bool visible)

顯示或隱藏選取指示器,而不影響選取行為。

QRectF selectedIndicatorRect() const

傳回目前選取指示器在視口座標中的矩形區域;若無可見項目則傳回空矩形。

QRectF selectedIndicatorRect(qreal progress) const

傳回正規化動畫進度 [0, 1] 處的選取指示器矩形。

QRectF selectedIndicatorRectForRow(int row) const

傳回指定列的選取指示器矩形(用於多選模式)。

void refreshFluentScrollChrome()

隱藏原生捲軸並重新整理 Fluent 覆蓋式捲軸(若在 QComboBox 彈出視窗等場景於 show 後被平台樣式還原,可再次呼叫)。

屬性

SelectionMode selectionMode

集合檢視使用的選取模式。

讀取 selectionMode()設定 setSelectionMode()變更訊號 selectionModeChanged()
Typography::FontRole fontRole

用於文字繪製的 Fluent 排版角色。

讀取 fontRole()設定 setFontRole()變更訊號 fontRoleChanged()
int trailingTextRole

尾端次要文字的可選模型角色;-1 表示隱藏。

讀取 trailingTextRole()設定 setTrailingTextRole()變更訊號 trailingTextRoleChanged()
bool viewportHovered

檢視區目前是否處於懸停狀態。

讀取 viewportHovered()變更訊號 viewportHoveredChanged()
Flow flow

項目排列方向(縱向 TopToBottom 或橫向 LeftToRight)。

讀取 flow()設定 setFlow()變更訊號 flowChanged()
qreal selectedIndicatorProgress

已選項目指示器的動畫進度。

讀取 selectedIndicatorProgress()變更訊號 selectedIndicatorProgressChanged()
IndicatorMotionDirection selectedIndicatorMotionDirection

已選取指示器動態效果使用的方向。

讀取 selectedIndicatorMotionDirection()變更訊號 selectedIndicatorMotionDirectionChanged()
bool selectedIndicatorAnimationEnabled

是否啟用選取指示器動畫。

讀取 selectedIndicatorAnimationEnabled()設定 setSelectedIndicatorAnimationEnabled()變更訊號 selectedIndicatorAnimationEnabledChanged()
bool selectionIndicatorVisible

是否繪製選取項目指示器。

讀取 selectionIndicatorVisible()設定 setSelectionIndicatorVisible()變更訊號 selectionIndicatorVisibleChanged()
bool borderVisible

是否繪製控制項外框邊線。

讀取 borderVisible()設定 setBorderVisible()變更訊號 borderVisibleChanged()
bool backgroundVisible

是否繪製控制項背景。

讀取 backgroundVisible()設定 setBackgroundVisible()變更訊號 backgroundVisibleChanged()
QWidget* header

承載於 ListView 頁首區域的自訂控制項。

讀取 header()設定 setHeader()變更訊號 headerChanged()
QString headerText

顯示於頁首區域的便利文字。

讀取 headerText()設定 setHeaderText()變更訊號 headerTextChanged()
QString placeholderText

模型沒有項目時顯示的預留文字。

讀取 placeholderText()設定 setPlaceholderText()變更訊號 placeholderTextChanged()
bool canReorderItems

是否啟用拖曳重新排序。

讀取 canReorderItems()設定 setCanReorderItems()變更訊號 canReorderItemsChanged()
bool scrollChainingEnabled

邊界處的滾輪輸入是否可繼續傳遞至外層捲動容器。

讀取 isScrollChainingEnabled()設定 setScrollChainingEnabled()變更訊號 scrollChainingEnabledChanged()
bool sectionEnabled

是否透過區段鍵回呼將相鄰項目歸組於區段標題下。

讀取 sectionEnabled()設定 setSectionEnabled()變更訊號 sectionEnabledChanged()

訊號

void selectionModeChanged()

集合檢視使用的選取模式。

void fontRoleChanged()

用於文字繪製的 Fluent 排版角色。

void trailingTextRoleChanged()

尾端次要文字的可選模型角色;-1 表示隱藏。

void viewportHoveredChanged()

檢視區目前是否處於懸停狀態。

void flowChanged()

項目排列方向(縱向 TopToBottom 或橫向 LeftToRight)。

void borderVisibleChanged()

是否繪製控制項外框邊線。

void backgroundVisibleChanged()

是否繪製控制項背景。

void headerChanged()

承載於 ListView 頁首區域的自訂控制項。

void headerTextChanged()

顯示於頁首區域的便利文字。

void placeholderTextChanged()

模型沒有項目時顯示的預留文字。

void canReorderItemsChanged()

是否啟用拖曳重新排序。

void scrollChainingEnabledChanged()

邊界處的滾輪輸入是否可繼續傳遞至外層捲動容器。

void sectionEnabledChanged()

是否透過區段鍵回呼將相鄰項目歸組於區段標題下。

void selectedIndicatorProgressChanged()

已選項目指示器的動畫進度。

void selectedIndicatorMotionDirectionChanged()

已選取指示器動態效果使用的方向。

void selectedIndicatorAnimationEnabledChanged()

是否啟用選取指示器動畫。

void selectionIndicatorVisibleChanged()

是否繪製選取項目指示器。

void itemClicked(int index)

與 QAbstractItemView::clicked() 一同發出並傳遞所點擊列索引的便利訊號。

型別與別名

繼承自 fluent::FluentElement

列舉

enum Theme

解析設計 token 時使用的全域視覺佈景主題。

  • Light = 0
  • Dark = 1
  • HighContrast = 2

方法

static void setTheme(Theme theme)

更新全域主題,並通知使用中的 FluentElement 執行個體。

static void setThemeDeferred(Theme theme)

排程以可見元素優先的批次主題重新整理,避免阻斷目前的互動。

static Theme currentTheme()

傳回目前生效的全域主題。

static bool themeUsesDarkAppearance(Theme theme)

傳回主題是否使用深色底的視窗框架與材質 token。

static void refreshTheme()

在設計 token 變更後重新廣播目前佈景主題以觸發重繪。

static int themeGeneration()

每次主題變更時遞增的單調計數器,用於過期檢查。

Theme effectiveTheme() const

解析此元素所使用的佈景主題,並遵循繼承的 QWidget 覆寫。

bool effectiveThemeUsesDarkAppearance() const

傳回此元素的實際主題是否使用深色底 chrome。

bool setThemeOverrides(const QJsonObject& overrides)

取代此元素的稀疏色彩、圓角與字型 token 覆寫。

QJsonObject themeOverrides() const

傳回此元素的覆寫設定。

void clearThemeOverrides()

將全部 token 欄位還原為全域主題預設值。

const Colors& themeColorsRef() const

對目前使用中色組的不複製存取(適用於繪製熱路徑)。

Material::AcrylicToken themeAcrylic() const

材質、高度層級與自適應版面配置 token。

QColor themeBackdrop(bool active) const

指定啟用狀態下的視窗 chrome 背景色。

virtual void onThemeUpdated()

在全域主題變更後呼叫。

型別與別名

struct Colors

傳回給元件使用的設計 token 快照。

繼承自 fluent::QMLPlus

方法

AnchorLayout::Anchors* anchors()

傳回 QWidget 宿主的可變錨點。

void setState(const QString& name)

依名稱套用已註冊的狀態,或在 @p name 為空時還原為預設狀態。未知名稱會被忽略,離開該狀態後原有的繫結會恢復同步。

void addState(const QMLState& state)

註冊或取代具名狀態定義;若取代目前啟用中的狀態則會立即套用。

void evaluateStates()

依註冊順序重新評估狀態條件並啟用第一個符合的狀態,若無符合項目則恢復為預設狀態。相依屬性發出通知時也會自動執行;使用 extend 的衍生狀態會繼承上層變更,除非發生循環或缺失。

QMLPlusRuntime* runtime()

傳回由此宿主延遲建立並擁有的狀態觀察器。

void setAnchors(const AnchorLayout::Anchors& anchors)

取代所有宿主錨點,並使父層版面配置失效。

void resetAnchors()

清除所有宿主錨點,並使父版面配置失效。

void bind(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction dir = PropertyBinder::OneWay)

透過 PropertyBinder::bind() 將 @p source 上的 @p sourceProp 繫結至此 QWidget 宿主上的 @p targetProp。

void addTransition(const StateTransition& transition)

依優先順序註冊狀態轉場。

void setBehavior(const char* propertyName, const PropertyAnimation& animation)

設定透過 writeProperty() 或繫結寫入 @p propertyName 時使用的預設動畫。明確的 StateTransition 規則優先;直接呼叫 C++ setter 不會有動畫。

void clearBehavior(const char* propertyName)

移除後續受管理寫入所使用的預設動畫。

bool writeProperty(const char* propertyName, const QVariant& value)

透過 Behavior 寫入宿主屬性,且不移除該屬性的繫結。

Qt 基底類別文件:QListView