# # # add_file "guitone/src/view/dialogs/FileDiff.cpp" # content [95ae7962a58d4777ca532b469600df7e20a2bb28] # # add_file "guitone/src/view/dialogs/FileDiff.h" # content [7852d0b3128d22c478938f84e419683b46801eee] # ============================================================ --- guitone/src/view/dialogs/FileDiff.cpp 95ae7962a58d4777ca532b469600df7e20a2bb28 +++ guitone/src/view/dialogs/FileDiff.cpp 95ae7962a58d4777ca532b469600df7e20a2bb28 @@ -0,0 +1,78 @@ +/*************************************************************************** + * Copyright (C) 2006 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "FileDiff.h" +#include "../../monotone/Monotone.h" + +FileDiff::FileDiff(QWidget* parent) + : QDialog(parent) +{ + setupUi(this); +} + +FileDiff::FileDiff(QWidget* parent, QString fileName) + : QDialog(parent) +{ + setupUi(this); + init(fileName); +} + +void FileDiff::init(QString fileName) +{ + file = fileName; + + fileModel = new GetFile(this); + fileModel->readFileByName(fileName); + + diffView->setModel(fileModel); + + connect( + fileModel, SIGNAL(fileRead()), + this, SLOT(dataRead()) + ); + + diffModel = new ContentDiff(this); + diffModel->readDiff(fileName); + + connect( + diffModel, SIGNAL(diffRead()), + this, SLOT(dataRead()) + ); +} + +FileDiff::~FileDiff() {} + +void FileDiff::dataRead() +{ + // we don't care about the actual order in which the data + // are signaled to be read, we just assume that we're notified two + // times and in the second round we have all data available we need + static bool dataRead = false; + + if (!dataRead) + { + dataRead = true; + return; + } + + // file seems to be read, now apply the diff + fileModel->applyDiff(diffModel->getDiff(file), GetFile::Both); +} + ============================================================ --- guitone/src/view/dialogs/FileDiff.h 7852d0b3128d22c478938f84e419683b46801eee +++ guitone/src/view/dialogs/FileDiff.h 7852d0b3128d22c478938f84e419683b46801eee @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2006 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FILE_DIFF_H +#define FILE_DIFF_H + +#include "ui_file_diff.h" +#include "../../model/ContentDiff.h" +#include "../../model/GetFile.h" + +class FileDiff : public QDialog, private Ui::FileDiffDialog +{ + Q_OBJECT + +public: + FileDiff(QWidget*); + FileDiff(QWidget*, QString); + void init(QString); + + ~FileDiff(); + +private slots: + void dataRead(); + +private: + ContentDiff * diffModel; + GetFile * fileModel; + QString file; +}; + +#endif