# # # patch "guitone/src/model/GetFile.cpp" # from [c92f6cf00400806ebfedb2045d83ad8b502ea72e] # to [0117818744e4fe5b21736b6455f8907891cf5207] # # patch "guitone/src/model/GetFile.h" # from [f5b57cf148d9ca611caabcf3f57a77a650e74916] # to [c0eef19054f57b96eeb9bc989be39e972f4c0697] # ============================================================ --- guitone/src/model/GetFile.cpp c92f6cf00400806ebfedb2045d83ad8b502ea72e +++ guitone/src/model/GetFile.cpp 0117818744e4fe5b21736b6455f8907891cf5207 @@ -72,7 +72,11 @@ void GetFile::parseOutput(AutomateComman return; } - fileContents = AutomateCommand::data.split("/[\\r\\n]+/"); + QStringList lines(AutomateCommand::data.split("/[\\r\\n]+/")); + for (int i=0, s=lines.size(); i= fileContents.size()) return QVariant(); + + ContentLine line = fileContents.at(row); - return QVariant(fileContents.at(row)); + if (role == Qt::DisplayRole) + { + switch (index.column()) + { + case 0: return QVariant(row + 1); + case 1: return QVariant(line.content); + default: Q_ASSERT(false); + } + } + else + if (role == Qt::BackgroundRole) + { + if (line.marker == ContentLine::Changed) + { + // FIXME: define brush color global + return QVariant(QBrush(Qt::yellow)); + } + } + + return QVariant(); } Qt::ItemFlags GetFile::flags(const QModelIndex &index) const @@ -107,7 +127,14 @@ QVariant GetFile::headerData(int section QVariant GetFile::headerData(int section, Qt::Orientation orientation, int role) const { - return QVariant(); + if (role != Qt::DisplayRole) return QVariant(); + + switch (section) + { + case 0: return QVariant(tr("Line")); + case 1: return QVariant(tr("Content")); + } + return QVariant(); } int GetFile::rowCount(const QModelIndex& parent) const ============================================================ --- guitone/src/model/GetFile.h f5b57cf148d9ca611caabcf3f57a77a650e74916 +++ guitone/src/model/GetFile.h c0eef19054f57b96eeb9bc989be39e972f4c0697 @@ -25,6 +25,15 @@ #include "AutomateCommand.h" +struct ContentLine { + QString content; + enum Marker {Changed, Unchanged} marker; + ContentLine() {} + ContentLine(QString c, Marker m) : content(c), marker(m) {} +}; + +typedef QVector Content; + class GetFile : public AutomateCommand { Q_OBJECT @@ -51,7 +60,7 @@ private: private: bool readFile(QStringList, QStringList); void parseOutput(AutomateCommand*); - QStringList fileContents; + Content fileContents; }; #endif