File indexing completed on 2024-05-05 04:35:31

0001 /***************************************************************************
0002  *   Copyright 2011 Andrey Batyiev <batyiev@gmail.com>                     *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or         *
0005  *   modify it under the terms of the GNU General Public License as        *
0006  *   published by the Free Software Foundation; either version 2 of        *
0007  *   the License or (at your option) version 3 or any later version        *
0008  *   accepted by the membership of KDE e.V. (or its successor approved     *
0009  *   by the membership of KDE e.V.), which shall act as a proxy            *
0010  *   defined in Section 14 of version 3 of the license.                    *
0011  *                                                                         *
0012  *   This program is distributed in the hope that it will be useful,       *
0013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0015  *   GNU General Public License for more details.                          *
0016  *                                                                         *
0017  *   You should have received a copy of the GNU General Public License     *
0018  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
0019  ***************************************************************************/
0020 
0021 #include "mercurialqueuesmanager.h"
0022 #include "ui_mercurialqueuesmanager.h"
0023 #include <models/mercurialqueueseriesmodel.h>
0024 #include <vcs/vcsjob.h>
0025 #include <mercurialplugin.h>
0026 
0027 using namespace KDevelop;
0028 
0029 MercurialQueuesManager::MercurialQueuesManager(MercurialPlugin *plugin, const QUrl &localLocation)
0030     : QWidget(), m_plugin(plugin), repoLocation(localLocation), m_ui(new Ui::MercurialManagerWidget)
0031 {
0032     m_ui->setupUi(this);
0033     m_model = new MercurialQueueSeriesModel(m_plugin, repoLocation, m_ui->patchesListView);
0034     m_ui->patchesListView->setModel(m_model);
0035 
0036     connect(m_ui->pushPushButton, &QPushButton::clicked, this, &MercurialQueuesManager::executePush);
0037     connect(m_ui->pushAllPushButton, &QPushButton::clicked, this, &MercurialQueuesManager::executePushAll);
0038     connect(m_ui->popPushButton, &QPushButton::clicked, this, &MercurialQueuesManager::executePop);
0039     connect(m_ui->popAllPushButton, &QPushButton::clicked, this, &MercurialQueuesManager::executePopAll);
0040 }
0041 
0042 void MercurialQueuesManager::executePush()
0043 {
0044     QScopedPointer<VcsJob> job(m_plugin->mqPush(repoLocation));
0045     job->exec();
0046     m_model->update();
0047 }
0048 
0049 void MercurialQueuesManager::executePushAll()
0050 {
0051     QScopedPointer<VcsJob> job(m_plugin->mqPushAll(repoLocation));
0052     job->exec();
0053     m_model->update();
0054 }
0055 
0056 void MercurialQueuesManager::executePop()
0057 {
0058     QScopedPointer<VcsJob> job(m_plugin->mqPop(repoLocation));
0059     job->exec();
0060     m_model->update();
0061 }
0062 
0063 void MercurialQueuesManager::executePopAll()
0064 {
0065     QScopedPointer<VcsJob> job(m_plugin->mqPopAll(repoLocation));
0066     job->exec();
0067     m_model->update();
0068 }