MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / data

Method data

Plugins/WebBrowser/History/HistoryModel.cpp:55–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55QVariant CHistoryModel::data(const QModelIndex &index, int role) const
56{
57
58 if (!index.isValid() || index.row() >= m_historyItems.count())
59 return QVariant();
60
61 if(!m_pDatabase) {
62 qCritical(log) << "The m_pDatabase is nullptr";
63 return QVariant();
64 }
65
66 const HistoryItem &item = m_historyItems.at(index.row());
67
68 switch (role) {
69 case Qt::DisplayRole:
70 switch (index.column()) {
71 case ColumnTitle:
72 return item.title.isEmpty() ? tr("Untitled") : item.title;
73 case ColumnUrl:
74 return item.url;
75 case ColumnVisitTime:
76 return item.visitTime.toString(QLocale::system().dateFormat());
77 }
78 break;
79
80 case Qt::DecorationRole:
81 if (index.column() == ColumnTitle) {
82 return item.icon;
83 }
84 break;
85
86 case Qt::ToolTipRole:
87 return QString(tr("Title: %1\nUrl: %2\nVisit Time: %3")
88 .arg(item.title)
89 .arg(item.url)
90 .arg(item.visitTime.toString(QLocale::system().dateFormat())));
91
92 case Qt::UserRole:
93 return item.url; // 返回URL用于导航
94 }
95
96 return QVariant();
97}
98
99void CHistoryModel::refresh()
100{

Callers 15

CDlgScreenCaptureMethod · 0.45
onItemClickedMethod · 0.45
on_pbAdd_clickedMethod · 0.45
onAddBookmarkMethod · 0.45
onAddFolderMethod · 0.45
onEditBookmarkMethod · 0.45
onDeleteBookmarkMethod · 0.45
onSetFavoriteMethod · 0.45
onCustomContextMenuMethod · 0.45

Calls 2

isValidMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected