# HG changeset patch # User Chris Cannam # Date 1290628416 0 # Node ID 0dc7305acbc8fa23523b52b5af8574de5cec57e4 # Parent a5a2d74a83a75ddbb5790d76239e43961ab83d5c * Helpful texts diff -r a5a2d74a83a7 -r 0dc7305acbc8 filestatuswidget.cpp --- a/filestatuswidget.cpp Wed Nov 24 17:29:31 2010 +0000 +++ b/filestatuswidget.cpp Wed Nov 24 19:53:36 2010 +0000 @@ -49,19 +49,31 @@ layout->setColumnStretch(1, 20); - layout->addItem(new QSpacerItem(5, 8), ++row, 0); + m_simpleLabels[FileStates::Clean] = tr("Unmodified:"); + m_simpleLabels[FileStates::Modified] = tr("Modified:"); + m_simpleLabels[FileStates::Added] = tr("Added:"); + m_simpleLabels[FileStates::Removed] = tr("Removed:"); + m_simpleLabels[FileStates::Missing] = tr("Missing:"); + m_simpleLabels[FileStates::Unknown] = tr("Untracked:"); - QMap labels; - labels[FileStates::Clean] = tr("Unmodified files:"); - labels[FileStates::Modified] = tr("Modified files:"); - labels[FileStates::Added] = tr("Added files:"); - labels[FileStates::Removed] = tr("Removed files:"); - labels[FileStates::Missing] = tr("Missing files:"); - labels[FileStates::Unknown] = tr("Untracked files:"); + m_descriptions[FileStates::Clean] = tr("You have not changed these files."); + m_descriptions[FileStates::Modified] = tr("You have changed these files since you last committed them."); + m_descriptions[FileStates::Added] = tr("These files will be added to version control next time you commit."); + m_descriptions[FileStates::Removed] = tr("These files will be removed from version control next time you commit.
" + "They will not be deleted from the local folder."); + m_descriptions[FileStates::Missing] = tr("These files are recorded in the version control but absent from your working folder.
" + "If you deleted them intentionally, select them here and use Remove to tell the version control system about it."); + m_descriptions[FileStates::Unknown] = tr("These files are in your working folder but are not under version control.
" + "Select a file and use Add to place it under version control or Ignore to remove it from this list."); + + m_highlightExplanation = tr("Files highlighted in red " + "have appeared since your most recent commit or update."); for (int i = int(FileStates::FirstState); i <= int(FileStates::LastState); ++i) { + layout->addItem(new QSpacerItem(5, 8), ++row, 0); + FileStates::State s = FileStates::State(i); QWidget *box = new QWidget; @@ -69,7 +81,7 @@ boxlayout->setMargin(0); box->setLayout(boxlayout); - boxlayout->addWidget(new QLabel(labels[s]), 0, 0); + boxlayout->addWidget(new QLabel(labelFor(s)), 0, 0); QListWidget *w = new QListWidget; m_stateListMap[s] = w; @@ -91,6 +103,20 @@ delete m_dateReference; } +QString FileStatusWidget::labelFor(FileStates::State s, bool addHighlightExplanation) +{ + if (addHighlightExplanation) { + return QString("%1
%2
%3
") + .arg(m_simpleLabels[s]) + .arg(m_descriptions[s]) + .arg(m_highlightExplanation); + } else { + return QString("%1
%2
") + .arg(m_simpleLabels[s]) + .arg(m_descriptions[s]); + } +} + void FileStatusWidget::itemSelectionChanged() { m_selectedFiles.clear(); @@ -244,7 +270,7 @@ QString fn(m_localPath + "/" + file); DEBUG << "comparing with " << fn << endl; QFileInfo fi(fn); - if (fi.exists() && fi.lastModified() > lastInteractionTime) { + if (fi.exists() && fi.created() > lastInteractionTime) { DEBUG << "file " << fn << " is newer (" << fi.lastModified() << ") than reference" << endl; highlighted = true; @@ -271,7 +297,16 @@ item->setSelected(selectedFiles.contains(file)); } + setLabelFor(w, s, !highPriority.empty()); + w->parentWidget()->setVisible(!files.empty()); } } +void FileStatusWidget::setLabelFor(QWidget *w, FileStates::State s, bool addHighlight) +{ + QString text = labelFor(s, addHighlight); + QWidget *p = w->parentWidget(); + QList ql = p->findChildren(); + if (!ql.empty()) ql[0]->setText(text); +} diff -r a5a2d74a83a7 -r 0dc7305acbc8 filestatuswidget.h --- a/filestatuswidget.h Wed Nov 24 17:29:31 2010 +0000 +++ b/filestatuswidget.h Wed Nov 24 19:53:36 2010 +0000 @@ -68,12 +68,17 @@ QLabel *m_remoteURLLabel; FileStates m_fileStates; + QMap m_simpleLabels; + QMap m_descriptions; QMap m_stateListMap; + QString m_highlightExplanation; QFileInfo *m_dateReference; QStringList m_selectedFiles; void updateWidgets(); + QString labelFor(FileStates::State, bool addHighlightExplanation = false); + void setLabelFor(QWidget *w, FileStates::State, bool addHighlightExplanation); }; #endif