Mercurial > hg > easyhg
changeset 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 | b43355c2473a |
files | filestatuswidget.cpp hgexpwidget.cpp |
diffstat | 2 files changed, 56 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/filestatuswidget.cpp Tue Nov 23 11:33:15 2010 +0000 +++ b/filestatuswidget.cpp Tue Nov 23 14:49:13 2010 +0000 @@ -31,6 +31,9 @@ layout->addWidget(new QLabel(tr("Local:")), row, 0); m_localPathLabel = new QLabel; + QFont f(m_localPathLabel->font()); + f.setBold(true); + m_localPathLabel->setFont(f); layout->addWidget(m_localPathLabel, row, 1); ++row; @@ -38,17 +41,39 @@ m_remoteURLLabel = new QLabel; layout->addWidget(m_remoteURLLabel, row, 1); - m_modifiedList = new QListWidget; - m_addedList = new QListWidget; - m_unknownList = new QListWidget; - m_removedList = new QListWidget; - m_missingList = new QListWidget; + layout->setColumnStretch(1, 20); - layout->addWidget(m_modifiedList, ++row, 0, 1, 2); - layout->addWidget(m_addedList, ++row, 0, 1, 2); - layout->addWidget(m_removedList, ++row, 0, 1, 2); - layout->addWidget(m_unknownList, ++row, 0, 1, 2); - layout->addWidget(m_missingList, ++row, 0, 1, 2); + QStringList labels; + labels << tr("Modified files:") + << tr("Added files:") + << tr("Removed files:") + << tr("New untracked files:") + << tr("Missing files:"); + + QList<QListWidget **> lists; + lists << &m_modifiedList + << &m_addedList + << &m_removedList + << &m_unknownList + << &m_missingList; + + for (int i = 0; i < labels.size(); ++i) { + + QWidget *box = new QWidget; + QGridLayout *boxlayout = new QGridLayout; + box->setLayout(boxlayout); + + boxlayout->addWidget(new QLabel(labels[i]), 0, 0); + + *lists[i] = new QListWidget; + (*lists[i])->setSelectionMode(QListWidget::ExtendedSelection); + boxlayout->addWidget(*lists[i], 1, 0); + + layout->addWidget(box, ++row, 0, 1, 2); + box->hide(); + } + + layout->setRowStretch(++row, 20); } void @@ -75,16 +100,18 @@ void FileStatusWidget::updateWidgets() { - m_modifiedList->clear(); - m_addedList->clear(); - m_unknownList->clear(); - m_removedList->clear(); - m_missingList->clear(); + StatParser &sp = m_statParser; + QMap<QStringList *, QListWidget *> listmap; + listmap[&sp.modified] = m_modifiedList; + listmap[&sp.added] = m_addedList; + listmap[&sp.removed] = m_removedList; + listmap[&sp.missing] = m_missingList; + listmap[&sp.unknown] = m_unknownList; - m_modifiedList->addItems(m_statParser.modified); - m_addedList->addItems(m_statParser.added); - m_unknownList->addItems(m_statParser.unknown); - m_removedList->addItems(m_statParser.removed); - m_missingList->addItems(m_statParser.missing); + foreach (QStringList *sl, listmap.keys()) { + listmap[sl]->clear(); + listmap[sl]->addItems(*sl); + listmap[sl]->parentWidget()->setVisible(!sl->empty()); + } }
--- a/hgexpwidget.cpp Tue Nov 23 11:33:15 2010 +0000 +++ b/hgexpwidget.cpp Tue Nov 23 14:49:13 2010 +0000 @@ -107,11 +107,13 @@ mainLayout -> addWidget(grpRemoteRepo, 1); mainLayout -> addWidget(grpLocalRepo, 8); mainLayout -> addWidget(grpWorkFolder, 12); - addTab(workPageWidget, tr("My work")); +//!!! addTab(workPageWidget, tr("My work")); // New work page fileStatusWidget = new FileStatusWidget; - addTab(fileStatusWidget, tr("My work (new)")); + fileStatusWidget->setLocalPath(workFolderPath); + fileStatusWidget->setRemoteURL(remoteRepo); + addTab(fileStatusWidget, tr("My work")); // History graph page historyGraphPageWidget = new QWidget; @@ -238,6 +240,8 @@ { statParser = StatParser(fileList); + fileStatusWidget->setStatParser(statParser); + workFolderFileList-> clear(); workFolderFileList -> addItems(fileList.split("\n")); } @@ -407,6 +411,9 @@ grpRemoteRepo -> setTitle(tr(REMOTE_REPO_STR) + remoteRepoPath); grpLocalRepo -> setTitle(tr(LOCAL_REPO_STR) + workFolderPath + getHgDirName()); grpWorkFolder -> setTitle(tr(WORKFOLDER_STR) + workFolderPath); + + fileStatusWidget->setLocalPath(workFolderPath); + fileStatusWidget->setRemoteURL(remoteRepoPath); } #define MERC_SHA1_MARKER_LEN 12