Changeset View
Changeset View
Standalone View
Standalone View
plugins/custom-definesandincludes/kcm_widget/projectpathsmodel.cpp
Show All 39 Lines | 39 | { | |||
---|---|---|---|---|---|
40 | if( !index.isValid() || index.row() < 0 || index.row() >= rowCount() || index.column() != 0 ) { | 40 | if( !index.isValid() || index.row() < 0 || index.row() >= rowCount() || index.column() != 0 ) { | ||
41 | return QVariant(); | 41 | return QVariant(); | ||
42 | } | 42 | } | ||
43 | 43 | | |||
44 | const ConfigEntry& pathConfig = projectPaths.at( index.row() ); | 44 | const ConfigEntry& pathConfig = projectPaths.at( index.row() ); | ||
45 | switch( role ) { | 45 | switch( role ) { | ||
46 | case IncludesDataRole: | 46 | case IncludesDataRole: | ||
47 | return pathConfig.includes; | 47 | return pathConfig.includes; | ||
48 | break; | | |||
49 | case DefinesDataRole: | 48 | case DefinesDataRole: | ||
50 | return QVariant::fromValue(pathConfig.defines); | 49 | return QVariant::fromValue(pathConfig.defines); | ||
51 | break; | | |||
52 | case Qt::EditRole: | 50 | case Qt::EditRole: | ||
53 | return sanitizePath( pathConfig.path, true, false ); | 51 | return sanitizePath( pathConfig.path, true, false ); | ||
54 | break; | | |||
55 | case Qt::DisplayRole: { | 52 | case Qt::DisplayRole: { | ||
56 | const QString& path = pathConfig.path; | 53 | const QString& path = pathConfig.path; | ||
57 | return (path == QLatin1String(".")) ? QStringLiteral("(project root)") : path; | 54 | return (path == QLatin1String(".")) ? QStringLiteral("(project root)") : path; | ||
58 | break; | | |||
59 | } | 55 | } | ||
60 | case FullUrlDataRole: | 56 | case FullUrlDataRole: | ||
61 | return QVariant::fromValue(QUrl::fromUserInput( sanitizePath( pathConfig.path, true, false ) )); | 57 | return QVariant::fromValue(QUrl::fromUserInput( sanitizePath( pathConfig.path, true, false ) )); | ||
62 | break; | | |||
63 | case CompilerDataRole: | 58 | case CompilerDataRole: | ||
64 | return QVariant::fromValue(pathConfig.compiler); | 59 | return QVariant::fromValue(pathConfig.compiler); | ||
65 | break; | | |||
66 | case ParserArgumentsRole: | 60 | case ParserArgumentsRole: | ||
67 | return QVariant::fromValue(pathConfig.parserArguments); | 61 | return QVariant::fromValue(pathConfig.parserArguments); | ||
68 | break; | | |||
69 | default: | 62 | default: | ||
70 | break; | 63 | break; | ||
71 | } | 64 | } | ||
72 | return QVariant(); | 65 | return QVariant(); | ||
73 | } | 66 | } | ||
74 | 67 | | |||
75 | int ProjectPathsModel::rowCount( const QModelIndex& parent ) const | 68 | int ProjectPathsModel::rowCount( const QModelIndex& parent ) const | ||
76 | { | 69 | { | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 77 | { | |||
121 | case CompilerDataRole: | 114 | case CompilerDataRole: | ||
122 | pathConfig.compiler = value.value<CompilerPointer>(); | 115 | pathConfig.compiler = value.value<CompilerPointer>(); | ||
123 | break; | 116 | break; | ||
124 | case ParserArgumentsRole: | 117 | case ParserArgumentsRole: | ||
125 | pathConfig.parserArguments = value.value<ParserArguments>(); | 118 | pathConfig.parserArguments = value.value<ParserArguments>(); | ||
126 | break; | 119 | break; | ||
127 | default: | 120 | default: | ||
128 | return false; | 121 | return false; | ||
129 | break; | | |||
130 | } | 122 | } | ||
131 | emit dataChanged( index, index ); | 123 | emit dataChanged( index, index ); | ||
132 | return true; | 124 | return true; | ||
133 | } | 125 | } | ||
134 | 126 | | |||
135 | Qt::ItemFlags ProjectPathsModel::flags( const QModelIndex& index ) const | 127 | Qt::ItemFlags ProjectPathsModel::flags( const QModelIndex& index ) const | ||
136 | { | 128 | { | ||
137 | if( !index.isValid() ) { | 129 | if( !index.isValid() ) { | ||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |