diff --git a/vcs/CMakeLists.txt b/vcs/CMakeLists.txt index 137c31897..89867da5e 100644 --- a/vcs/CMakeLists.txt +++ b/vcs/CMakeLists.txt @@ -1,113 +1,111 @@ add_definitions(-DTRANSLATION_DOMAIN=\"kdevplatform\") add_subdirectory(dvcs/tests) add_subdirectory(models/tests) set(KDevPlatformVcs_UIS widgets/vcscommitdialog.ui widgets/vcseventwidget.ui widgets/vcsdiffwidget.ui dvcs/ui/dvcsimportmetadatawidget.ui dvcs/ui/branchmanager.ui ) set(KDevPlatformVcs_LIB_SRCS vcsjob.cpp vcsrevision.cpp vcsannotation.cpp vcspluginhelper.cpp vcslocation.cpp vcsdiff.cpp vcsevent.cpp vcsstatusinfo.cpp debug.cpp widgets/vcsimportmetadatawidget.cpp widgets/vcseventwidget.cpp widgets/vcsdiffwidget.cpp widgets/vcscommitdialog.cpp widgets/vcsdiffpatchsources.cpp widgets/vcslocationwidget.cpp widgets/standardvcslocationwidget.cpp models/vcsannotationmodel.cpp models/vcseventmodel.cpp models/vcsfilechangesmodel.cpp models/vcsitemeventmodel.cpp models/brancheslistmodel.cpp dvcs/dvcsjob.cpp 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 interfaces/ipatchsource.cpp ) ki18n_wrap_ui(KDevPlatformVcs_LIB_SRCS ${KDevPlatformVcs_UIS}) kdevplatform_add_library(KDevPlatformVcs SOURCES ${KDevPlatformVcs_LIB_SRCS}) target_link_libraries(KDevPlatformVcs LINK_PUBLIC KDev::OutputView KDev::Interfaces LINK_PRIVATE KF5::KIOWidgets KF5::Parts KDev::Util ) install(FILES vcsjob.h vcsrevision.h vcsannotation.h vcsdiff.h vcspluginhelper.h vcsevent.h vcsstatusinfo.h vcslocation.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/vcs COMPONENT Devel ) install(FILES widgets/vcsimportmetadatawidget.h widgets/vcseventwidget.h widgets/vcsdiffwidget.h widgets/vcscommitdialog.h widgets/vcslocationwidget.h widgets/standardvcslocationwidget.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/vcs/widgets COMPONENT Devel ) install(FILES models/vcsannotationmodel.h models/vcseventmodel.h models/vcsfilechangesmodel.h models/vcsitemeventmodel.h models/brancheslistmodel.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/vcs/models COMPONENT Devel ) install(FILES interfaces/ibasicversioncontrol.h interfaces/icentralizedversioncontrol.h interfaces/idistributedversioncontrol.h interfaces/ibranchingversioncontrol.h interfaces/ibrowsableversioncontrol.h interfaces/irepositoryversioncontrol.h interfaces/ipatchdocument.h interfaces/ipatchsource.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/vcs/interfaces COMPONENT Devel ) install(FILES dvcs/dvcsjob.h dvcs/dvcsplugin.h dvcs/dvcsevent.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/vcs/dvcs COMPONENT Devel ) install(FILES dvcs/ui/dvcsimportmetadatawidget.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/vcs/dvcs/ui COMPONENT Devel ) diff --git a/vcs/dvcs/dvcsplugin.cpp b/vcs/dvcs/dvcsplugin.cpp index 3b1ca023b..9296957cf 100644 --- a/vcs/dvcs/dvcsplugin.cpp +++ b/vcs/dvcs/dvcsplugin.cpp @@ -1,172 +1,145 @@ /*************************************************************************** * This file was partly taken from KDevelop's cvs plugin * * Copyright 2007 Robert Gruber * * * * Adapted for DVCS (added templates) * * 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 DVCS_PLUGIN_CC #define DVCS_PLUGIN_CC #include "dvcsplugin.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dvcsjob.h" #include "ui/dvcsimportmetadatawidget.h" #include "ui/branchmanager.h" -#include "ui/revhistory/commitlogmodel.h" -#include "ui/revhistory/commitView.h" #include #include namespace KDevelop { struct DistributedVersionControlPluginPrivate { explicit DistributedVersionControlPluginPrivate(DistributedVersionControlPlugin * pThis) : m_common(new VcsPluginHelper(pThis, pThis)) {} ~DistributedVersionControlPluginPrivate() { delete m_common; } VcsPluginHelper* m_common; }; //class DistributedVersionControlPlugin DistributedVersionControlPlugin::DistributedVersionControlPlugin(QObject *parent, const QString& componentName) : IPlugin(componentName, parent) , d(new DistributedVersionControlPluginPrivate(this)) {} DistributedVersionControlPlugin::~DistributedVersionControlPlugin() { //TODO: Find out why this crashes on the svn tests delete d->m_factory; delete d; } // End: KDevelop::IBasicVersionControl // Begin: KDevelop::IDistributedVersionControl // End: KDevelop::IDistributedVersionControl KDevelop::VcsImportMetadataWidget* DistributedVersionControlPlugin::createImportMetadataWidget(QWidget* parent) { return new DvcsImportMetadataWidget(parent); } KDevelop::ContextMenuExtension DistributedVersionControlPlugin::contextMenuExtension(Context* context) { d->m_common->setupFromContext(context); QList const & ctxUrlList = d->m_common->contextUrlList(); bool isWorkingDirectory = false; foreach(const QUrl &url, ctxUrlList) { if (isValidDirectory(url)) { isWorkingDirectory = true; break; } } if (!isWorkingDirectory) { // Not part of a repository return ContextMenuExtension(); } 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; menuExt.addAction(ContextMenuExtension::VcsGroup, menu->menuAction()); return menuExt; } void DistributedVersionControlPlugin::additionalMenuEntries(QMenu* /*menu*/, const QList& /*urls*/) {} static QString stripPathToDir(const QString &path) { QFileInfo info = QFileInfo(path); return info.isDir() ? info.absoluteFilePath() : info.absolutePath(); } void DistributedVersionControlPlugin::ctxBranchManager() { QList const & ctxUrlList = d->m_common->contextUrlList(); Q_ASSERT(!ctxUrlList.isEmpty()); ICore::self()->documentController()->saveAllDocuments(); BranchManager branchManager(stripPathToDir(ctxUrlList.front().toLocalFile()), this, core()->uiController()->activeMainWindow()); 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/dvcsplugin.h b/vcs/dvcs/dvcsplugin.h index d2e2e56a9..42b8a2115 100644 --- a/vcs/dvcs/dvcsplugin.h +++ b/vcs/dvcs/dvcsplugin.h @@ -1,104 +1,103 @@ /*************************************************************************** * 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_DVCS_PLUGIN_H #define KDEVPLATFORM_DVCS_PLUGIN_H #include #include #include #include #include "dvcsevent.h" #include #include #include class QMenu; namespace KDevelop { struct DistributedVersionControlPluginPrivate; class DVcsJob; /** * DistributedVersionControlPlugin is a base class for git/hg/bzr plugins. This class implements * KDevelop::IBasicVersionControl, KDevelop::IDistributedVersionControl and KDevelop::IPlugin (contextMenuExtension). * DistributedVersionControlPlugin class uses IDVCSexecutor to get all jobs * from real DVCS plugins like Git. It is based on KDevelop's CVS plugin (also looks like svn plugin is it's relative too). * @note Create only special items in contextMenuExtension, all standard menu items are created in vcscommon plugin! */ class KDEVPLATFORMVCS_EXPORT DistributedVersionControlPlugin : public IPlugin, public IDistributedVersionControl, public IBranchingVersionControl { Q_OBJECT Q_INTERFACES(KDevelop::IBasicVersionControl KDevelop::IDistributedVersionControl KDevelop::IBranchingVersionControl) public: DistributedVersionControlPlugin(QObject *parent, const QString& componentName); ~DistributedVersionControlPlugin() override; // Begin: KDevelop::IBasicVersionControl /** Used in KDevelop's appwizardplugin (creates import widget) */ VcsImportMetadataWidget* createImportMetadataWidget(QWidget* parent) override; // From KDevelop::IPlugin /** Creates context menu * @note Create only special items here (like checkout), all standard menu items are created in vcscommon plugin! */ ContextMenuExtension contextMenuExtension(Context*) override; /** * Parses the output generated by a @code dvcs log @endcode command and * fills the given QList with all commits infos found in the given output. * @param job The finished job of a @code dvcs log @endcode call * @param revisions Will be filled with all revision infos found in @p jobOutput * TODO: Change it to pass the results in @code job->getResults() @endcode */ virtual void parseLogOutput(const DVcsJob * job, QList& revisions) const = 0; /** Returns the list of all commits (in all branches). * @see CommitView and CommitViewDelegate to see how this list is used. */ virtual QList getAllCommits(const QString &repo) = 0; /** * When a plugin wants to add elements to the vcs menu, this method can be * overridden. */ virtual void additionalMenuEntries(QMenu* menu, const QList& urls); public Q_SLOTS: //slots for context menu void ctxBranchManager(); - void ctxRevHistory(); protected: /** Checks if dirPath is located in DVCS repository */ virtual bool isValidDirectory(const QUrl &dirPath) = 0; private: DistributedVersionControlPluginPrivate * const d; }; } #endif diff --git a/vcs/dvcs/ui/revhistory/commitView.cpp b/vcs/dvcs/ui/revhistory/commitView.cpp deleted file mode 100644 index a58f3b130..000000000 --- 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/commitView.h b/vcs/dvcs/ui/revhistory/commitView.h deleted file mode 100644 index fee9ccc1e..000000000 --- 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/commitlogmodel.cpp b/vcs/dvcs/ui/revhistory/commitlogmodel.cpp deleted file mode 100644 index cb19bbd24..000000000 --- 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; -} diff --git a/vcs/dvcs/ui/revhistory/commitlogmodel.h b/vcs/dvcs/ui/revhistory/commitlogmodel.h deleted file mode 100644 index 7a2ad97f8..000000000 --- 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