Warning, file /sdk/cervisia/watchersdialog.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  Copyright (c) 2003-2007 Christian Loose <christian.loose@kdemail.net>
0003  *
0004  * This program is free software; you can redistribute it and/or modify
0005  * it under the terms of the GNU General Public License as published by
0006  * the Free Software Foundation; either version 2 of the License, or
0007  * (at your option) any later version.
0008  *
0009  * This program is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  * GNU General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU General Public License
0015  * along with this program; if not, write to the Free Software
0016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0017  */
0018 
0019 #include "watchersdialog.h"
0020 
0021 #include <QDialogButtonBox>
0022 #include <QHeaderView>
0023 #include <QPushButton>
0024 #include <QTableView>
0025 #include <QVBoxLayout>
0026 
0027 #include <KConfig>
0028 #include <KConfigGroup>
0029 #include <KLocalizedString>
0030 
0031 #include "cvsserviceinterface.h"
0032 #include "progressdialog.h"
0033 #include "watchersmodel.h"
0034 
0035 WatchersDialog::WatchersDialog(KConfig &cfg, QWidget *parent)
0036     : QDialog(parent)
0037     , partConfig(cfg)
0038 {
0039     auto mainLayout = new QVBoxLayout;
0040     setLayout(mainLayout);
0041 
0042     auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
0043     connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
0044     connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
0045 
0046     m_tableView = new QTableView;
0047     mainLayout->addWidget(m_tableView);
0048     m_tableView->setSelectionMode(QAbstractItemView::NoSelection);
0049     m_tableView->setSortingEnabled(true);
0050     m_tableView->verticalHeader()->setVisible(false);
0051 
0052     mainLayout->addWidget(buttonBox);
0053 
0054     setAttribute(Qt::WA_DeleteOnClose, true);
0055 
0056     KConfigGroup cg(&partConfig, "WatchersDialog");
0057     restoreGeometry(cg.readEntry<QByteArray>("geometry", QByteArray()));
0058 }
0059 
0060 WatchersDialog::~WatchersDialog()
0061 {
0062     KConfigGroup cg(&partConfig, "WatchersDialog");
0063     cg.writeEntry("geometry", saveGeometry());
0064 }
0065 
0066 bool WatchersDialog::parseWatchers(OrgKdeCervisia5CvsserviceCvsserviceInterface *cvsService, const QStringList &files)
0067 {
0068     setWindowTitle(i18n("CVS Watchers"));
0069 
0070     QDBusReply<QDBusObjectPath> job = cvsService->watchers(files);
0071     if (!job.isValid())
0072         return false;
0073 
0074     ProgressDialog dlg(this, "Watchers", cvsService->service(), job, "watchers", i18n("CVS Watchers"));
0075     if (!dlg.execute())
0076         return false;
0077 
0078     auto proxyModel = new WatchersSortModel(this);
0079     proxyModel->setSourceModel(new WatchersModel(dlg.getOutput()));
0080     m_tableView->setModel(proxyModel);
0081     m_tableView->sortByColumn(0, Qt::AscendingOrder);
0082 
0083     return true;
0084 }