Mercurial > hg > easyhg
comparison filestatuswidget.cpp @ 89:622da79c0f4f
* A bit more work on new Work (file status) widget
author | Chris Cannam |
---|---|
date | Tue, 23 Nov 2010 14:49:13 +0000 |
parents | c5e34ed5b791 |
children | 06f4fffd5287 |
comparison
equal
deleted
inserted
replaced
88:c5e34ed5b791 | 89:622da79c0f4f |
---|---|
29 | 29 |
30 int row = 0; | 30 int row = 0; |
31 | 31 |
32 layout->addWidget(new QLabel(tr("Local:")), row, 0); | 32 layout->addWidget(new QLabel(tr("Local:")), row, 0); |
33 m_localPathLabel = new QLabel; | 33 m_localPathLabel = new QLabel; |
34 QFont f(m_localPathLabel->font()); | |
35 f.setBold(true); | |
36 m_localPathLabel->setFont(f); | |
34 layout->addWidget(m_localPathLabel, row, 1); | 37 layout->addWidget(m_localPathLabel, row, 1); |
35 | 38 |
36 ++row; | 39 ++row; |
37 layout->addWidget(new QLabel(tr("Remote:")), row, 0); | 40 layout->addWidget(new QLabel(tr("Remote:")), row, 0); |
38 m_remoteURLLabel = new QLabel; | 41 m_remoteURLLabel = new QLabel; |
39 layout->addWidget(m_remoteURLLabel, row, 1); | 42 layout->addWidget(m_remoteURLLabel, row, 1); |
40 | 43 |
41 m_modifiedList = new QListWidget; | 44 layout->setColumnStretch(1, 20); |
42 m_addedList = new QListWidget; | |
43 m_unknownList = new QListWidget; | |
44 m_removedList = new QListWidget; | |
45 m_missingList = new QListWidget; | |
46 | 45 |
47 layout->addWidget(m_modifiedList, ++row, 0, 1, 2); | 46 QStringList labels; |
48 layout->addWidget(m_addedList, ++row, 0, 1, 2); | 47 labels << tr("Modified files:") |
49 layout->addWidget(m_removedList, ++row, 0, 1, 2); | 48 << tr("Added files:") |
50 layout->addWidget(m_unknownList, ++row, 0, 1, 2); | 49 << tr("Removed files:") |
51 layout->addWidget(m_missingList, ++row, 0, 1, 2); | 50 << tr("New untracked files:") |
51 << tr("Missing files:"); | |
52 | |
53 QList<QListWidget **> lists; | |
54 lists << &m_modifiedList | |
55 << &m_addedList | |
56 << &m_removedList | |
57 << &m_unknownList | |
58 << &m_missingList; | |
59 | |
60 for (int i = 0; i < labels.size(); ++i) { | |
61 | |
62 QWidget *box = new QWidget; | |
63 QGridLayout *boxlayout = new QGridLayout; | |
64 box->setLayout(boxlayout); | |
65 | |
66 boxlayout->addWidget(new QLabel(labels[i]), 0, 0); | |
67 | |
68 *lists[i] = new QListWidget; | |
69 (*lists[i])->setSelectionMode(QListWidget::ExtendedSelection); | |
70 boxlayout->addWidget(*lists[i], 1, 0); | |
71 | |
72 layout->addWidget(box, ++row, 0, 1, 2); | |
73 box->hide(); | |
74 } | |
75 | |
76 layout->setRowStretch(++row, 20); | |
52 } | 77 } |
53 | 78 |
54 void | 79 void |
55 FileStatusWidget::setLocalPath(QString p) | 80 FileStatusWidget::setLocalPath(QString p) |
56 { | 81 { |
73 } | 98 } |
74 | 99 |
75 void | 100 void |
76 FileStatusWidget::updateWidgets() | 101 FileStatusWidget::updateWidgets() |
77 { | 102 { |
78 m_modifiedList->clear(); | 103 StatParser &sp = m_statParser; |
79 m_addedList->clear(); | 104 QMap<QStringList *, QListWidget *> listmap; |
80 m_unknownList->clear(); | 105 listmap[&sp.modified] = m_modifiedList; |
81 m_removedList->clear(); | 106 listmap[&sp.added] = m_addedList; |
82 m_missingList->clear(); | 107 listmap[&sp.removed] = m_removedList; |
108 listmap[&sp.missing] = m_missingList; | |
109 listmap[&sp.unknown] = m_unknownList; | |
83 | 110 |
84 m_modifiedList->addItems(m_statParser.modified); | 111 foreach (QStringList *sl, listmap.keys()) { |
85 m_addedList->addItems(m_statParser.added); | 112 listmap[sl]->clear(); |
86 m_unknownList->addItems(m_statParser.unknown); | 113 listmap[sl]->addItems(*sl); |
87 m_removedList->addItems(m_statParser.removed); | 114 listmap[sl]->parentWidget()->setVisible(!sl->empty()); |
88 m_missingList->addItems(m_statParser.missing); | 115 } |
89 } | 116 } |
90 | 117 |