File: watchersdialog.cpp

package info (click to toggle)
cervisia 4:17.08.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 7,548 kB
  • sloc: cpp: 14,364; xml: 393; makefile: 3; sh: 3
file content (90 lines) | stat: -rw-r--r-- 2,854 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 *  Copyright (c) 2003-2007 Christian Loose <christian.loose@kdemail.net>
 *
 * 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) any later version.
 *
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */


#include "watchersdialog.h"

#include <QHeaderView>
#include <QTableView>
#include <QVBoxLayout>
#include <QBoxLayout>
#include <QLineEdit>
#include <QDialogButtonBox>
#include <QPushButton>

#include <KConfig>
#include <KConfigGroup>
#include <KLocalizedString>

#include "cvsserviceinterface.h"
#include "progressdialog.h"
#include "watchersmodel.h"


WatchersDialog::WatchersDialog(KConfig& cfg, QWidget* parent)
    : QDialog(parent), partConfig(cfg)
{
    QVBoxLayout *mainLayout = new QVBoxLayout;
    setLayout(mainLayout);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    m_tableView = new QTableView;
    mainLayout->addWidget(m_tableView);
    m_tableView->setSelectionMode(QAbstractItemView::NoSelection);
    m_tableView->setSortingEnabled(true);
    m_tableView->verticalHeader()->setVisible(false);

    mainLayout->addWidget(buttonBox);

    setAttribute(Qt::WA_DeleteOnClose, true);

    KConfigGroup cg(&partConfig, "WatchersDialog");
    restoreGeometry(cg.readEntry<QByteArray>("geometry", QByteArray()));
}


WatchersDialog::~WatchersDialog()
{
    KConfigGroup cg(&partConfig, "WatchersDialog");
    cg.writeEntry("geometry", saveGeometry());
}


bool WatchersDialog::parseWatchers(OrgKdeCervisia5CvsserviceCvsserviceInterface* cvsService,
                                   const QStringList& files)
{
    setWindowTitle(i18n("CVS Watchers"));

    QDBusReply<QDBusObjectPath> job = cvsService->watchers(files);
    if( !job.isValid() )
        return false;

    ProgressDialog dlg(this, "Watchers",cvsService->service(), job, "watchers", i18n("CVS Watchers"));
    if( !dlg.execute() )
        return false;

    WatchersSortModel* proxyModel = new WatchersSortModel(this);
    proxyModel->setSourceModel(new WatchersModel(dlg.getOutput()));
    m_tableView->setModel(proxyModel);
    m_tableView->sortByColumn(0, Qt::AscendingOrder);

    return true;
}