#
#
# patch "res/forms/file_diff.ui"
# from [9b8103ba53247d189bb0e6ef1205bceeb45d7c13]
# to [243551f9851e8129ce736dd81ca5b4049347c14d]
#
# patch "res/i18n/guitone_de.ts"
# from [a3c83e0fb2e5622a249408067c37ff640584c920]
# to [f97a54ec58da7eec984b6fbaa85993e65ca85340]
#
# patch "src/model/GetFile.cpp"
# from [0416604eb10e3a6e93a4ddb990dc078c5550085c]
# to [54bfdc61b73d50418793fca0b86bc05f434ee311]
#
# patch "src/model/GetFile.h"
# from [4d33901d2eba3e5f57b453101c5245cd075e0a2f]
# to [341b069c5778068d50bbf01cd34557a04b639db3]
#
# patch "src/view/dialogs/FileDiff.cpp"
# from [8f186d00a2f425b1f13f3089486832a4dea35007]
# to [0df18f51a4020c5a2a36495b8da49fc5348c53c5]
#
# patch "src/view/dialogs/FileDiff.h"
# from [4992d27618b9504b8f042b545afb13d374bc0e73]
# to [c254fa1cdec0a6fe6545adcf784e5cbcb5ca1573]
#
============================================================
--- res/forms/file_diff.ui 9b8103ba53247d189bb0e6ef1205bceeb45d7c13
+++ res/forms/file_diff.ui 243551f9851e8129ce736dd81ca5b4049347c14d
@@ -5,8 +5,8 @@
0
0
- 553
- 436
+ 676
+ 491
@@ -47,6 +47,68 @@
-
+
+
+ Show
+
+
+
+ 9
+
+
+ 6
+
+
-
+
+
+ 0
+
+
+ 6
+
+
-
+
+
+ first (%1)
+
+
+
+ -
+
+
+ second (%2)
+
+
+
+ -
+
+
+ both
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+
+
+ -
0
@@ -55,47 +117,6 @@
6
-
-
-
- Show
-
-
-
- -
-
-
- 0
-
-
- 6
-
-
-
-
-
- first (%1)
-
-
-
- -
-
-
- second (%2)
-
-
-
- -
-
-
- both
-
-
- true
-
-
-
-
-
- -
Qt::Horizontal
@@ -109,6 +130,20 @@
-
+
+
+ Prev
+
+
+
+ -
+
+
+ Next
+
+
+
+ -
Close
============================================================
--- res/i18n/guitone_de.ts a3c83e0fb2e5622a249408067c37ff640584c920
+++ res/i18n/guitone_de.ts f97a54ec58da7eec984b6fbaa85993e65ca85340
@@ -559,12 +559,12 @@ In jedem Fall sollte der derzeitige Arbe
Arbeitsbereichrevision
-
+
Datei wurde nicht geändert
-
+
Die Datei wurde zwischen diesen Revisionen nicht geändert.
@@ -597,30 +597,40 @@ In jedem Fall sollte der derzeitige Arbe
beide
-
+
SchlieÃen
-
+
Zeige
-
+
erste (%1)
-
+
zweite (%2)
-
+
beide
+
+
+
+ Vorherige
+
+
+
+
+ Nächste
+
FileExporter
@@ -762,12 +772,12 @@ In jedem Fall sollte der derzeitige Arbe
GetFile
-
+
Zeile
-
+
Inhalt
============================================================
--- src/model/GetFile.cpp 0416604eb10e3a6e93a4ddb990dc078c5550085c
+++ src/model/GetFile.cpp 54bfdc61b73d50418793fca0b86bc05f434ee311
@@ -132,6 +132,75 @@ void GetFile::applyDiff(Diff * diff)
reset();
}
+QModelIndex GetFile::getNextGroup(const QModelIndex & base, bool recurse)
+{
+ int startRow = 0;
+ ContentLine::Marker lastMarker = ContentLine::Unchanged;
+ if (base.isValid() && base.row() < fileContents.size())
+ {
+ startRow = base.row();
+ lastMarker = fileContents.at(startRow)->marker;
+ }
+
+ for (int i=startRow, j=fileContents.size(); imarker != lastMarker && line->marker != ContentLine::Unchanged)
+ {
+ return index(i, 0, QModelIndex());
+ }
+ lastMarker = line->marker;
+ }
+
+ // if we already recursed, stop here
+ if (recurse) return QModelIndex();
+ // try to get the first group
+ return getNextGroup(QModelIndex(), true);
+}
+
+QModelIndex GetFile::getPrevGroup(const QModelIndex & base, bool recurse)
+{
+ int startRow = fileContents.size() - 1;
+ ContentLine::Marker lastMarker = ContentLine::Unchanged;
+ if (base.isValid() && base.row() < fileContents.size())
+ {
+ startRow = base.row();
+ lastMarker = fileContents.at(startRow)->marker;
+ }
+
+ bool foundLast = false;
+ for (int i=startRow; i>=0; i--)
+ {
+ ContentLine * line = fileContents.at(i);
+
+ // did we already found the last line of a group of similar lines?
+ if (!foundLast)
+ {
+ if (line->marker != lastMarker && line->marker != ContentLine::Unchanged)
+ {
+ foundLast = true;
+ }
+ lastMarker = line->marker;
+ continue;
+ }
+
+ if (foundLast)
+ {
+ // if the marker just changed, the previous line was our
+ // first line
+ if (line->marker != lastMarker)
+ {
+ return index(i + 1, 0, QModelIndex());
+ }
+ }
+ }
+
+ // if we've already recursed, stop here
+ if (recurse) return QModelIndex();
+ // try to get the last group
+ return getPrevGroup(QModelIndex(), true);
+}
+
int GetFile::columnCount(const QModelIndex &parent) const
{
return 2;
============================================================
--- src/model/GetFile.h 4d33901d2eba3e5f57b453101c5245cd075e0a2f
+++ src/model/GetFile.h 341b069c5778068d50bbf01cd34557a04b639db3
@@ -53,6 +53,8 @@ public:
QModelIndex parent(const QModelIndex&) const;
int rowCount(const QModelIndex&) const;
int columnCount(const QModelIndex&) const;
+ QModelIndex getNextGroup(const QModelIndex &, bool recurse = false);
+ QModelIndex getPrevGroup(const QModelIndex &, bool recurse = false);
public slots:
bool readFileById(const QString &);
============================================================
--- src/view/dialogs/FileDiff.cpp 8f186d00a2f425b1f13f3089486832a4dea35007
+++ src/view/dialogs/FileDiff.cpp 0df18f51a4020c5a2a36495b8da49fc5348c53c5
@@ -49,7 +49,7 @@ void FileDiff::init(
QString title = windowTitle();
setWindowTitle(title.arg(fileName));
- if (base.isEmpty())
+ if (base.isNull() || base.isEmpty())
{
firstRevision->setText(tr("workspace parent"));
}
@@ -60,7 +60,7 @@ void FileDiff::init(
);
}
- if (target.isEmpty())
+ if (target.isNull() || target.isEmpty())
{
secondRevision->setText(tr("workspace revision"));
}
@@ -107,6 +107,16 @@ void FileDiff::init(
this, SLOT(applyDiff())
);
+ connect(
+ scrollToNext, SIGNAL(clicked()),
+ this, SLOT(getNextGroup())
+ );
+
+ connect(
+ scrollToPrev, SIGNAL(clicked()),
+ this, SLOT(getPrevGroup())
+ );
+
fileModel->readFileByName(fileName, base);
diffModel->readDiff(fileName, base, target);
}
@@ -150,3 +160,36 @@ void FileDiff::versionToggled(bool dummy
diffStatusView->update();
}
+void FileDiff::scrollToGroup(bool forward)
+{
+ if (!currentIndex.isValid()) return;
+ QModelIndex proxyIndex = fileProxyModel->mapFromSource(currentIndex);
+
+ // recursion: if the queried group is not valid in the view because it
+ // has been filtered out, get the next group and try again
+ if (!proxyIndex.isValid())
+ {
+ if (forward)
+ {
+ getNextGroup();
+ return;
+ }
+ getPrevGroup();
+ return;
+ }
+
+ diffView->scrollTo(proxyIndex, QAbstractItemView::PositionAtTop);
+}
+
+void FileDiff::getPrevGroup()
+{
+ currentIndex = fileModel->getPrevGroup(currentIndex);
+ scrollToGroup(false);
+}
+
+void FileDiff::getNextGroup()
+{
+ currentIndex = fileModel->getNextGroup(currentIndex);
+ scrollToGroup(true);
+}
+
============================================================
--- src/view/dialogs/FileDiff.h 4992d27618b9504b8f042b545afb13d374bc0e73
+++ src/view/dialogs/FileDiff.h c254fa1cdec0a6fe6545adcf784e5cbcb5ca1573
@@ -41,11 +41,15 @@ private slots:
private slots:
void applyDiff();
void versionToggled(bool);
+ void scrollToGroup(bool);
+ void getPrevGroup();
+ void getNextGroup();
private:
ContentDiff * diffModel;
GetFile * fileModel;
GetFileProxyModel * fileProxyModel;
+ QModelIndex currentIndex;
QString file;
bool loaded;
};