comparison filestatuswidget.cpp @ 88:c5e34ed5b791

* Start work on new file-status widget
author Chris Cannam
date Tue, 23 Nov 2010 11:33:15 +0000
parents
children 622da79c0f4f
comparison
equal deleted inserted replaced
87:a7904378ac6a 88:c5e34ed5b791
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 EasyMercurial
5
6 Based on HgExplorer by Jari Korhonen
7 Copyright (c) 2010 Jari Korhonen
8 Copyright (c) 2010 Chris Cannam
9 Copyright (c) 2010 Queen Mary, University of London
10
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version. See the file
15 COPYING included with this distribution for more information.
16 */
17
18 #include "filestatuswidget.h"
19
20 #include <QLabel>
21 #include <QListWidget>
22 #include <QGridLayout>
23
24 FileStatusWidget::FileStatusWidget(QWidget *parent) :
25 QWidget(parent)
26 {
27 QGridLayout *layout = new QGridLayout;
28 setLayout(layout);
29
30 int row = 0;
31
32 layout->addWidget(new QLabel(tr("Local:")), row, 0);
33 m_localPathLabel = new QLabel;
34 layout->addWidget(m_localPathLabel, row, 1);
35
36 ++row;
37 layout->addWidget(new QLabel(tr("Remote:")), row, 0);
38 m_remoteURLLabel = new QLabel;
39 layout->addWidget(m_remoteURLLabel, row, 1);
40
41 m_modifiedList = new QListWidget;
42 m_addedList = new QListWidget;
43 m_unknownList = new QListWidget;
44 m_removedList = new QListWidget;
45 m_missingList = new QListWidget;
46
47 layout->addWidget(m_modifiedList, ++row, 0, 1, 2);
48 layout->addWidget(m_addedList, ++row, 0, 1, 2);
49 layout->addWidget(m_removedList, ++row, 0, 1, 2);
50 layout->addWidget(m_unknownList, ++row, 0, 1, 2);
51 layout->addWidget(m_missingList, ++row, 0, 1, 2);
52 }
53
54 void
55 FileStatusWidget::setLocalPath(QString p)
56 {
57 m_localPath = p;
58 m_localPathLabel->setText(p);
59 }
60
61 void
62 FileStatusWidget::setRemoteURL(QString r)
63 {
64 m_remoteURL = r;
65 m_remoteURLLabel->setText(r);
66 }
67
68 void
69 FileStatusWidget::setStatParser(StatParser p)
70 {
71 m_statParser = p;
72 updateWidgets();
73 }
74
75 void
76 FileStatusWidget::updateWidgets()
77 {
78 m_modifiedList->clear();
79 m_addedList->clear();
80 m_unknownList->clear();
81 m_removedList->clear();
82 m_missingList->clear();
83
84 m_modifiedList->addItems(m_statParser.modified);
85 m_addedList->addItems(m_statParser.added);
86 m_unknownList->addItems(m_statParser.unknown);
87 m_removedList->addItems(m_statParser.removed);
88 m_missingList->addItems(m_statParser.missing);
89 }
90