# # # patch "src/model/GetBranchLog.cpp" # from [2fd72e38075643a2b197a8462639223dc28a90c2] # to [f166e4acdc755a7364eba01eb120ecc865f775e6] # # patch "src/model/GetBranchLog.h" # from [523153146959d08cbcfb93db65ab09970f99789c] # to [e35442cb15dcf7ea81b68e25172c8e6283081420] # ============================================================ --- src/model/GetBranchLog.cpp 2fd72e38075643a2b197a8462639223dc28a90c2 +++ src/model/GetBranchLog.cpp f166e4acdc755a7364eba01eb120ecc865f775e6 @@ -20,58 +20,68 @@ #include "GetBranchLog.h" -GetBranchLog::GetBranchLog(QString branch, QObject *parent) : QObject(parent) +GetBranchLog::GetBranchLog(QObject * parent, const QString & db, const QString & b) + : QObject(parent), branch(b) { - this->branch = branch; - selectModel = new Select(this); - revSortModel = new Toposort(this); - ancestorModel = new Ancestors(this); - revSortModel->setSourceModel(ancestorModel); - connect(selectModel, SIGNAL(selectionRead()), - this, SLOT(selectionReady())); - connect(revSortModel, SIGNAL(sortingFinished()), - this, SLOT(revisionsReady())); - connect(this, SIGNAL(commandDone(GetBranchLog *)), - parent, SLOT(branchLogRead(GetBranchLog *))); - selectModel->readSelection("h:" + branch); + selectModel = new Select(this, db); + revSortModel = new Toposort(this, db); + ancestorModel = new Ancestors(this, db); + revSortModel->setSourceModel(ancestorModel); + + connect( + selectModel, SIGNAL(selectionRead()), + this, SLOT(selectionReady()) + ); + + connect( + revSortModel, SIGNAL(sortingFinished()), + this, SLOT(revisionsReady()) + ); + + selectModel->readSelection("h:" + branch); } GetBranchLog::~GetBranchLog() { - delete selectModel; - delete revSortModel; - delete ancestorModel; + delete selectModel; + delete revSortModel; + delete ancestorModel; } -QString GetBranchLog::getBranch() -{ - return branch; -} - -QStringList GetBranchLog::getRevisions() -{ - return revisions; -} - void GetBranchLog::selectionReady() { - QStringList heads; - int count = selectModel->rowCount(QModelIndex()); - for(int i = 0; i < count; i++) - { - heads << selectModel->data(selectModel->index(i, 0, QModelIndex()), Qt::DisplayRole).toString(); - } - revisions << heads; - ancestorModel->readAncestors(heads); + QStringList heads; + int count = selectModel->rowCount(QModelIndex()); + + for (int i = 0; i < count; i++) + { + heads.append( + selectModel->data( + selectModel->index(i, 0, QModelIndex()), + Qt::DisplayRole + ).toString() + ); + } + revisions += heads; + ancestorModel->readAncestors(heads); } void GetBranchLog::revisionsReady() { - int count = revSortModel->rowCount(QModelIndex()); - for(int i = 0; i < count; i++) - { - revSortModel->sort(0, Qt::DescendingOrder); - revisions << revSortModel->QSortFilterProxyModel::data(revSortModel->index(i, 0, QModelIndex()), Qt::DisplayRole).toString(); - } - emit commandDone(this); + int count = revSortModel->rowCount(QModelIndex()); + for (int i = 0; i < count; i++) + { + revSortModel->sort(0, Qt::DescendingOrder); + revisions.append( + revSortModel->QSortFilterProxyModel::data( + revSortModel->index( + i, 0, + QModelIndex() + ), + Qt::DisplayRole + ).toString() + ); + } + emit branchLogRead(branch, revisions); } + ============================================================ --- src/model/GetBranchLog.h 523153146959d08cbcfb93db65ab09970f99789c +++ src/model/GetBranchLog.h e35442cb15dcf7ea81b68e25172c8e6283081420 @@ -25,32 +25,27 @@ #include "Select.h" #include "Toposort.h" -#include - - class GetBranchLog : public QObject { Q_OBJECT public: - GetBranchLog(QString branch, QObject *parent); - ~GetBranchLog(); + GetBranchLog(QObject *, const QString &, const QString &); + ~GetBranchLog(); - QStringList getRevisions(); - QString getBranch(); - signals: - void commandDone(GetBranchLog *); + void branchLogRead(const QString &, const QStringList &); private: - QString branch; - QStringList revisions; - Select * selectModel; - Toposort * revSortModel; - Ancestors * ancestorModel; + QString branch; + QStringList revisions; + Select * selectModel; + Toposort * revSortModel; + Ancestors * ancestorModel; private slots: - void selectionReady(); - void revisionsReady(); + void selectionReady(); + void revisionsReady(); }; +#endif + -#endif //GETBRANCHLOG_H