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

Class PathMappingModel

kdevplatform/debugger/util/pathmappings.cpp:66–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65
66class PathMappingModel : public QAbstractTableModel
67{
68 Q_OBJECT
69public:
70 int columnCount(const QModelIndex& parent = QModelIndex()) const override
71 {
72 if (parent.isValid()) return 0;
73 return 2;
74 }
75
76 int rowCount(const QModelIndex& parent = QModelIndex()) const override
77 {
78 if (parent.isValid()) return 0;
79 return m_paths.count() + 1;
80 }
81
82 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override
83 {
84 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
85 if (section == 0) {
86 return i18n("Remote Path");
87 } else if (section == 1) {
88 return i18n("Local Path");
89 }
90 }
91 return QAbstractTableModel::headerData(section, orientation, role);
92 }
93
94 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override
95 {
96 if (!index.isValid()) return QVariant();
97 if (index.parent().isValid()) return QVariant();
98 if (index.column() > 1) return QVariant();
99 if (index.row() > m_paths.count()) return QVariant();
100 if (role == Qt::DisplayRole || role == Qt::EditRole) {
101 if (index.row() == m_paths.count()) return QString();
102 if (index.column() == 0) {
103 return m_paths[index.row()].remote.toDisplayString(QUrl::PreferLocalFile);
104 } else if (index.column() == 1) {
105 return m_paths[index.row()].local.toDisplayString(QUrl::PreferLocalFile);
106 }
107 }
108 return QVariant();
109 }
110
111 Qt::ItemFlags flags(const QModelIndex& index) const override
112 {
113 if (index.parent().isValid()) return Qt::NoItemFlags;
114 if (!index.isValid()) return Qt::NoItemFlags;
115 return ( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
116
117 }
118
119 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override
120 {
121 if (!index.isValid()) return false;
122 if (index.parent().isValid()) return false;
123 if (index.column() > 1) return false;

Callers

nothing calls this directly

Calls 2

QModelIndexClass · 0.50
isValidMethod · 0.45

Tested by

no test coverage detected