MCPcopy Create free account
hub / github.com/KDE/kdevelop / data

Method data

plugins/projectfilter/filtermodel.cpp:86–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86QVariant FilterModel::data(const QModelIndex& index, int role) const
87{
88 if (!index.isValid()) {
89 return QVariant();
90 }
91 Q_ASSERT(!index.parent().isValid());
92 Q_ASSERT(index.row() >= 0 && index.row() < m_filters.size());
93 Q_ASSERT(index.column() >= 0 && index.column() < NUM_COLUMNS);
94
95 if (role != Qt::DisplayRole && role != Qt::DecorationRole
96 && role != Qt::EditRole && role != Qt::ToolTipRole)
97 {
98 return QVariant();
99 }
100
101 const SerializedFilter& filter = m_filters.at(index.row());
102 const int column = index.column();
103
104 if (column == Pattern) {
105 if (role == Qt::DecorationRole) {
106 return QVariant();
107 } else if (role == Qt::ToolTipRole) {
108 return i18n(
109 "The wildcard pattern defines whether a file or folder is included in a project or not.<br />"
110 "The pattern is matched case-sensitively against the items relative path to the project root. "
111 "The relative path starts with a forward slash, trailing slashes of folders are removed.<br />"
112 "Patterns ending on <code>\"/\"</code> are implicitly considered to match against folders only.<br />"
113 "Patterns which do not explicitly start with either <code>\"/\"</code> or <code>\"*\"</code> implicitly get <code>\"*/\"</code> prepended and thus match any item with a relative path ending on the given pattern."
114 );
115 }
116 return filter.pattern;
117 } else if (column == Targets) {
118 if (role == Qt::EditRole) {
119 return static_cast<int>(filter.targets);
120 } else if (role == Qt::ToolTipRole) {
121 return i18n("The target defines what type of item the filter is matched against.<br />Filters either apply only to files, only to folders or to both.");
122 }
123 if (filter.targets & Filter::Files && filter.targets & Filter::Folders) {
124 if (role == Qt::DecorationRole) {
125 return QIcon::fromTheme(QStringLiteral("document-open"));
126 }
127 return i18nc("@item", "Files and Folders");
128 } else if (filter.targets & Filter::Folders) {
129 if (role == Qt::DecorationRole) {
130 return QIcon::fromTheme(QStringLiteral("folder"));
131 }
132 return i18nc("@item", "Folders");
133 } else {
134 if (role == Qt::DecorationRole) {
135 return QIcon::fromTheme(QStringLiteral("text-plain"));
136 }
137 return i18nc("@item", "Files");
138 }
139 } else if (column == Inclusive) {
140 if (role == Qt::EditRole) {
141 return static_cast<int>(filter.type);
142 } else if (role == Qt::ToolTipRole) {
143 return i18n("Filters by default exclude items from the project. Inclusive patterns can be used to include items which where matched by previous exclusive patterns.<br />E.g. to only include files ending on <code>\".cpp\"</code> in your project, you could exclude all files via <code>\"*\"</code> and then apply an inclusive <code>\"*.cpp\"</code> pattern.");

Callers 15

addHighlightingMethod · 0.45
forceUpdateMethod · 0.45
updateKompareModelMethod · 0.45
closeReviewMethod · 0.45
setPatchMethod · 0.45
documentSavedMethod · 0.45
updateStateMethod · 0.45
setFileInfoMethod · 0.45
GetLocalPatchSourceMethod · 0.45
openMethod · 0.45

Calls 7

QVariantClass · 0.50
isValidMethod · 0.45
parentMethod · 0.45
rowMethod · 0.45
sizeMethod · 0.45
columnMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected