diff --git a/vcs/CMakeLists.txt b/vcs/CMakeLists.txt --- a/vcs/CMakeLists.txt +++ b/vcs/CMakeLists.txt @@ -37,8 +37,6 @@ dvcs/dvcsplugin.cpp dvcs/ui/dvcsimportmetadatawidget.cpp dvcs/ui/branchmanager.cpp - dvcs/ui/revhistory/commitView.cpp - dvcs/ui/revhistory/commitlogmodel.cpp interfaces/ibasicversioncontrol.cpp interfaces/icontentawareversioncontrol.cpp interfaces/ipatchdocument.cpp diff --git a/vcs/dvcs/dvcsplugin.h b/vcs/dvcs/dvcsplugin.h --- a/vcs/dvcs/dvcsplugin.h +++ b/vcs/dvcs/dvcsplugin.h @@ -89,7 +89,6 @@ public Q_SLOTS: //slots for context menu void ctxBranchManager(); - void ctxRevHistory(); protected: /** Checks if dirPath is located in DVCS repository */ diff --git a/vcs/dvcs/dvcsplugin.cpp b/vcs/dvcs/dvcsplugin.cpp --- a/vcs/dvcs/dvcsplugin.cpp +++ b/vcs/dvcs/dvcsplugin.cpp @@ -48,8 +48,6 @@ #include "dvcsjob.h" #include "ui/dvcsimportmetadatawidget.h" #include "ui/branchmanager.h" -#include "ui/revhistory/commitlogmodel.h" -#include "ui/revhistory/commitView.h" #include #include @@ -112,7 +110,6 @@ QMenu * menu = d->m_common->commonActions(); menu->addSeparator(); menu->addAction(i18n("Branches..."), this, SLOT(ctxBranchManager()))->setEnabled(ctxUrlList.count()==1); - menu->addAction(i18n("Revision Graph..."), this, SLOT(ctxRevHistory()))->setEnabled(ctxUrlList.count()==1); additionalMenuEntries(menu, ctxUrlList); ContextMenuExtension menuExt; @@ -143,30 +140,6 @@ branchManager.exec(); } -// This is redundant with the normal VCS "history" action -void DistributedVersionControlPlugin::ctxRevHistory() -{ - QList const & ctxUrlList = d->m_common->contextUrlList(); - Q_ASSERT(!ctxUrlList.isEmpty()); - - QDialog d; - QVBoxLayout* layout = new QVBoxLayout(&d); - d.setLayout(layout); - - CommitLogModel* model = new CommitLogModel(this, ctxUrlList.first().toLocalFile(), &d); - CommitView *revTree = new CommitView(&d); - revTree->setModel(model); - layout->addWidget(revTree); - - QDialogButtonBox* dbox = new QDialogButtonBox(&d); - dbox->setStandardButtons(QDialogButtonBox::Close); - connect(dbox, &QDialogButtonBox::accepted, &d, &QDialog::accept); - connect(dbox, &QDialogButtonBox::rejected, &d, &QDialog::reject); - layout->addWidget(dbox); - - d.exec(); -} - } #endif diff --git a/vcs/dvcs/ui/revhistory/commitView.h b/vcs/dvcs/ui/revhistory/commitView.h deleted file mode 100644 --- a/vcs/dvcs/ui/revhistory/commitView.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * Copyright 2008 Evgeniy Ivanov * - * * - * 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) version 3 or any later version * - * accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy * - * defined in Section 14 of version 3 of the license. * - * * - * 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, see . * - ***************************************************************************/ - -#ifndef KDEVPLATFORM_COMMIT_VIEW_H -#define KDEVPLATFORM_COMMIT_VIEW_H - -#include -#include - -enum ViewColumns { - GRAPH_COLUMN = 0, - SLOG_COLUMN = 1, - AUTHOR_COLUMN = 2, - DATE_COLUMN = 3 -}; - -class CommitView : public QTreeView -{ - Q_OBJECT -public: - explicit CommitView(QWidget *parent = nullptr); - ~CommitView() override {}; -// void setLineHeight(int h) { lineHeight = h; } - int getLineHeight(const QModelIndex & index) {return rowHeight(index);} -private: -// int lineHeight; -}; - -class CommitViewDelegate : public QItemDelegate { - Q_OBJECT -public: - CommitViewDelegate(CommitView* _view, QObject* parent); - - void paint(QPainter* p, const QStyleOptionViewItem& o, const QModelIndex &i) const override; - -private: - void paintGraph(QPainter* p, const QStyleOptionViewItem& o, const QModelIndex &i) const; - void paintGraphLane(QPainter* p, int type, int x1, int x2, const int height, const QColor& col, const QBrush& back) const; - -private: - CommitView* view; - -}; - -#endif diff --git a/vcs/dvcs/ui/revhistory/commitView.cpp b/vcs/dvcs/ui/revhistory/commitView.cpp deleted file mode 100644 --- a/vcs/dvcs/ui/revhistory/commitView.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/*************************************************************************** - * class CommitViewDelegate was partly taken from QGit * - * (Author: Marco Costalba (C) 2005-2007) * - * * - * Copyright 2008 Evgeniy Ivanov * - * * - * 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) version 3 or any later version * - * accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy * - * defined in Section 14 of version 3 of the license. * - * * - * 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, see . * - ***************************************************************************/ - -#include "commitView.h" -#include "../../../debug.h" - -#include - -#include "../../../vcsrevision.h" -#include "commitlogmodel.h" - - enum LaneType { -// EMPTY, -// ACTIVE, -// NOT_ACTIVE, -// MERGE_FORK, -// MERGE_FORK_R, -// MERGE_FORK_L, -// JOIN, -// JOIN_R, -// JOIN_L, -// HEAD, -// HEAD_R, -// HEAD_L, -// TAIL, -// TAIL_R, -// TAIL_L, -// CROSS, -// CROSS_EMPTY, -// INITIAL, - BRANCH/*,*/ -// UNAPPLIED, -// APPLIED, -// BOUNDARY, -// BOUNDARY_C, // corresponds to MERGE_FORK -// BOUNDARY_R, // corresponds to MERGE_FORK_R -// BOUNDARY_L, // corresponds to MERGE_FORK_L -// -// LANE_TYPES_NUM - }; - -CommitView::CommitView(QWidget *parent) - : QTreeView(parent) -{ -// setLineHeight(fontMetrics().height()); - CommitViewDelegate* delegate = new CommitViewDelegate(this, this); - setItemDelegate(delegate); -// setupGeometry(); -} - -/*===============================================================================================*/ - -CommitViewDelegate::CommitViewDelegate(CommitView* _view, QObject* p) - : QItemDelegate(p) -{ - view = _view; -} - -void CommitViewDelegate::paint(QPainter* p, const QStyleOptionViewItem& opt, - const QModelIndex& index) const -{ - p->setRenderHints(QPainter::Antialiasing); - - if (index.column() == GRAPH_COLUMN) - return paintGraph(p, opt, index); - - return QItemDelegate::paint(p, opt, index); -} - -void CommitViewDelegate::paintGraph(QPainter* p, const QStyleOptionViewItem& opt, - const QModelIndex& index) const { - - static const QColor colors[/*COLORS_NUM*/8] = { Qt::black, Qt::red, Qt::darkGreen /*DARK_GREEN*/, - Qt::blue, Qt::darkGray, /*BROWN*/Qt::darkYellow, - Qt::magenta, Qt::yellow /*ORANGE*/ }; - if (opt.state & QStyle::State_Selected) - p->fillRect(opt.rect, opt.palette.highlight()); - else - p->fillRect(opt.rect, opt.palette.base()); - - QAbstractItemModel* model = view->model(); - -/* const Rev* r = revLookup(i.row(), &fh);*/ -// if (!r) -// return; - - p->save(); - p->translate(QPoint(opt.rect.left(), opt.rect.top())); - -// // calculate lanes -// if (r->lanes.count() == 0) -// git->setLane(r->sha(), fh); - - QBrush back = opt.palette.base(); -// const QVector& lanes(r->lanes); -// uint laneNum = model->rowCount(); - uint branchNum = (dynamic_cast(model))->branchCount(index.row()); - - int x1 = 0; int x2 = 0; - -// int maxWidth = opt.rect.right(); - int lw = 12; //TODO: count it with laneWidth(), it depends on font - for(uint curBr = 0; curBr < branchNum; curBr++) - { - x1 = x2; - x2 += lw; - paintGraphLane(p, (dynamic_cast(model))->getProperties(index.row())[curBr], - x1, x2, view->getLineHeight(index), colors[curBr % 8], back); - } - p->restore(); -} - - -void CommitViewDelegate::paintGraphLane(QPainter* p, int type, int x1, int x2, const int height, - const QColor& col, const QBrush& back) const -{ - Q_UNUSED(back); - - int h = height / 2; //TODO: laneHeight! - int m = (x1 + x2) / 2; - int r = (x2 - x1) / 3; - int d = 2 * r; - - #define P_CENTER m , h - #define P_0 x2, h - #define P_90 m , 0 - #define P_180 x1, h - #define P_270 m , 2 * h - #define R_CENTER m - r, h - r, d, d - - static QPen myPen(Qt::black, 2); // fast path here - myPen.setColor(col); - p->setPen(myPen); - - switch(type) - { - case DVcsEvent::INITIAL: - p->drawLine(P_90, P_CENTER); - break; - case DVcsEvent::HEAD: - p->drawLine(P_270, P_CENTER); - break; - case DVcsEvent::BRANCH: - case DVcsEvent::MERGE: - case DVcsEvent::CROSS: - p->drawLine(P_90, P_270); - break; - case DVcsEvent::HCROSS: - p->drawLine(P_0, P_180); - break; - case DVcsEvent::MERGE_RIGHT: - { - p->drawLine(P_180, P_CENTER); - p->drawLine(P_CENTER, P_90); - break; - } - } - - -// // horizontal line -// switch (type) { -// case MERGE_FORK: -// case JOIN: -// case HEAD: -// case TAIL: -// case CROSS: -// case CROSS_EMPTY: -// case BOUNDARY_C: -// p->drawLine(P_180, P_0); -// break; -// case MERGE_FORK_R: -// case JOIN_R: -// case HEAD_R: -// case TAIL_R: -// case BOUNDARY_R: -// p->drawLine(P_180, P_CENTER); -// break; -// case MERGE_FORK_L: -// case JOIN_L: -// case HEAD_L: -// case TAIL_L: -// case BOUNDARY_L: -// p->drawLine(P_CENTER, P_0); -// break; -// default: -// break; -// } - - // center symbol, e.g. rect or ellipse - switch (type) { - case DVcsEvent::INITIAL: - case DVcsEvent::BRANCH: - case DVcsEvent::HEAD: - { - p->setPen(Qt::NoPen); - p->setBrush(col); - p->drawEllipse(R_CENTER); - break; - } - //we always have parent branch at the right - case DVcsEvent::MERGE: - { - qCDebug(VCS) << "MERGE!"; - p->setPen(Qt::NoPen); - p->setBrush(col); - p->drawLine(P_CENTER, x1, 0); - p->drawRect(R_CENTER); - break; - } - } - - #undef P_CENTER - #undef P_0 - #undef P_90 - #undef P_180 - #undef P_270 - #undef R_CENTER -} diff --git a/vcs/dvcs/ui/revhistory/commitlogmodel.h b/vcs/dvcs/ui/revhistory/commitlogmodel.h deleted file mode 100644 --- a/vcs/dvcs/ui/revhistory/commitlogmodel.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright 2008 Evgeniy Ivanov * - * * - * 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) version 3 or any later version * - * accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy * - * defined in Section 14 of version 3 of the license. * - * * - * 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, see . * - ***************************************************************************/ - -#ifndef KDEVPLATFORM_COMMITLOGMODEL_H -#define KDEVPLATFORM_COMMITLOGMODEL_H - -#include -#include -#include -#include - -namespace KDevelop -{ - class DistributedVersionControlPlugin; -} - -class QStringList; - -class CommitLogModel : public QAbstractItemModel -{ - Q_OBJECT - -public: - CommitLogModel(KDevelop::DistributedVersionControlPlugin* plugin, const QString& repo, QObject* parent = nullptr); - ~CommitLogModel() override {}; - - QVariant data(const QModelIndex &index, int role) const override; - Qt::ItemFlags flags(const QModelIndex& index) const override; - QVariant headerData(int s, Qt::Orientation o, int role = Qt::DisplayRole) const override; - QModelIndex index(int r, int c, const QModelIndex& par = QModelIndex()) const override; - QModelIndex parent(const QModelIndex& index) const override; - int rowCount(const QModelIndex& par = QModelIndex()) const override; - int columnCount(const QModelIndex&) const override; - int branchCount(const int) const {return branchCnt;} - QList getProperties(const int i) const {return revs[i].getProperties();} - -private slots: - void initializeModel(); - -private: - QStringList headerInfo; - QList revs; - - int branchCnt; - - QString m_repo; - KDevelop::DistributedVersionControlPlugin* m_plugin; -}; - -#endif diff --git a/vcs/dvcs/ui/revhistory/commitlogmodel.cpp b/vcs/dvcs/ui/revhistory/commitlogmodel.cpp deleted file mode 100644 --- a/vcs/dvcs/ui/revhistory/commitlogmodel.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/*************************************************************************** - * Copyright 2008 Evgeniy Ivanov * - * * - * 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) version 3 or any later version * - * accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy * - * defined in Section 14 of version 3 of the license. * - * * - * 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, see . * - ***************************************************************************/ - -#include "commitlogmodel.h" - -#include - -#include "commitView.h" -#include - -CommitLogModel::CommitLogModel(KDevelop::DistributedVersionControlPlugin* plugin, const QString& repo, QObject* parent) - : QAbstractItemModel(parent), m_repo(repo), m_plugin(plugin) -{ - headerInfo << QStringLiteral("Graph") << QStringLiteral("Short Log") << QStringLiteral("Author") << QStringLiteral("Date"); - QMetaObject::invokeMethod(this, "initializeModel", Qt::QueuedConnection); -} - -void CommitLogModel::initializeModel() -{ - beginResetModel(); - revs = m_plugin->getAllCommits(m_repo); - if (!revs.isEmpty() ) - branchCnt = revs.last().getProperties().count(); //num of branch (size of properties of initial commit) - endResetModel(); -} - -Qt::ItemFlags CommitLogModel::flags(const QModelIndex&) const -{ - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; // read only -} - -QVariant CommitLogModel::headerData(int section, Qt::Orientation orientation, int role) const { - - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - return headerInfo.at(section); - - return QVariant(); -} - -QModelIndex CommitLogModel::index(int row, int column, const QModelIndex&) const -{ - if (row < 0 || row >= rowCount()) - return QModelIndex(); - - return createIndex(row, column); -} - -QVariant CommitLogModel::data(const QModelIndex& index, int role) const -{ - if (!index.isValid() || role != Qt::DisplayRole) - return QVariant(); - - const DVcsEvent &revision = revs.at(index.row()); - - int column = index.column(); - - if (column == SLOG_COLUMN) - return revision.getLog().split('\n')[0]; - - if (column == AUTHOR_COLUMN) - return revision.getAuthor(); - - if (column == DATE_COLUMN) { - return revision.getDate(); - } - return QVariant(); -} - -QModelIndex CommitLogModel::parent(const QModelIndex& index) const -{ - Q_UNUSED(index) - return QModelIndex(); -} - -int CommitLogModel::rowCount(const QModelIndex& parent) const -{ - return (!parent.isValid() ? revs.size() : 0); -} - -int CommitLogModel::columnCount(const QModelIndex&) const -{ - return 4; -}