comparison filestatuswidget.cpp @ 100:0dc7305acbc8

* Helpful texts
author Chris Cannam
date Wed, 24 Nov 2010 19:53:36 +0000
parents a5a2d74a83a7
children f9af5e93de0e
comparison
equal deleted inserted replaced
99:a5a2d74a83a7 100:0dc7305acbc8
47 m_remoteURLLabel = new QLabel; 47 m_remoteURLLabel = new QLabel;
48 layout->addWidget(m_remoteURLLabel, row, 1); 48 layout->addWidget(m_remoteURLLabel, row, 1);
49 49
50 layout->setColumnStretch(1, 20); 50 layout->setColumnStretch(1, 20);
51 51
52 layout->addItem(new QSpacerItem(5, 8), ++row, 0); 52 m_simpleLabels[FileStates::Clean] = tr("Unmodified:");
53 53 m_simpleLabels[FileStates::Modified] = tr("Modified:");
54 QMap<FileStates::State, QString> labels; 54 m_simpleLabels[FileStates::Added] = tr("Added:");
55 labels[FileStates::Clean] = tr("Unmodified files:"); 55 m_simpleLabels[FileStates::Removed] = tr("Removed:");
56 labels[FileStates::Modified] = tr("Modified files:"); 56 m_simpleLabels[FileStates::Missing] = tr("Missing:");
57 labels[FileStates::Added] = tr("Added files:"); 57 m_simpleLabels[FileStates::Unknown] = tr("Untracked:");
58 labels[FileStates::Removed] = tr("Removed files:"); 58
59 labels[FileStates::Missing] = tr("Missing files:"); 59 m_descriptions[FileStates::Clean] = tr("You have not changed these files.");
60 labels[FileStates::Unknown] = tr("Untracked files:"); 60 m_descriptions[FileStates::Modified] = tr("You have changed these files since you last committed them.");
61 m_descriptions[FileStates::Added] = tr("These files will be added to version control next time you commit.");
62 m_descriptions[FileStates::Removed] = tr("These files will be removed from version control next time you commit.<br>"
63 "They will not be deleted from the local folder.");
64 m_descriptions[FileStates::Missing] = tr("These files are recorded in the version control but absent from your working folder.<br>"
65 "If you deleted them intentionally, select them here and use <b>Remove</b> to tell the version control system about it.");
66 m_descriptions[FileStates::Unknown] = tr("These files are in your working folder but are not under version control.<br>"
67 "Select a file and use Add to place it under version control or Ignore to remove it from this list.");
68
69 m_highlightExplanation = tr("Files highlighted in red "
70 "have appeared since your most recent commit or update.");
61 71
62 for (int i = int(FileStates::FirstState); 72 for (int i = int(FileStates::FirstState);
63 i <= int(FileStates::LastState); ++i) { 73 i <= int(FileStates::LastState); ++i) {
74
75 layout->addItem(new QSpacerItem(5, 8), ++row, 0);
64 76
65 FileStates::State s = FileStates::State(i); 77 FileStates::State s = FileStates::State(i);
66 78
67 QWidget *box = new QWidget; 79 QWidget *box = new QWidget;
68 QGridLayout *boxlayout = new QGridLayout; 80 QGridLayout *boxlayout = new QGridLayout;
69 boxlayout->setMargin(0); 81 boxlayout->setMargin(0);
70 box->setLayout(boxlayout); 82 box->setLayout(boxlayout);
71 83
72 boxlayout->addWidget(new QLabel(labels[s]), 0, 0); 84 boxlayout->addWidget(new QLabel(labelFor(s)), 0, 0);
73 85
74 QListWidget *w = new QListWidget; 86 QListWidget *w = new QListWidget;
75 m_stateListMap[s] = w; 87 m_stateListMap[s] = w;
76 w->setSelectionMode(QListWidget::ExtendedSelection); 88 w->setSelectionMode(QListWidget::ExtendedSelection);
77 boxlayout->addWidget(w, 1, 0); 89 boxlayout->addWidget(w, 1, 0);
87 } 99 }
88 100
89 FileStatusWidget::~FileStatusWidget() 101 FileStatusWidget::~FileStatusWidget()
90 { 102 {
91 delete m_dateReference; 103 delete m_dateReference;
104 }
105
106 QString FileStatusWidget::labelFor(FileStates::State s, bool addHighlightExplanation)
107 {
108 if (addHighlightExplanation) {
109 return QString("<qt><b>%1</b><br>%2<br>%3</qt>")
110 .arg(m_simpleLabels[s])
111 .arg(m_descriptions[s])
112 .arg(m_highlightExplanation);
113 } else {
114 return QString("<qt><b>%1</b><br>%2</qt>")
115 .arg(m_simpleLabels[s])
116 .arg(m_descriptions[s]);
117 }
92 } 118 }
93 119
94 void FileStatusWidget::itemSelectionChanged() 120 void FileStatusWidget::itemSelectionChanged()
95 { 121 {
96 m_selectedFiles.clear(); 122 m_selectedFiles.clear();
242 // We want to highlight untracked files that have appeared 268 // We want to highlight untracked files that have appeared
243 // since the last interaction with the repo 269 // since the last interaction with the repo
244 QString fn(m_localPath + "/" + file); 270 QString fn(m_localPath + "/" + file);
245 DEBUG << "comparing with " << fn << endl; 271 DEBUG << "comparing with " << fn << endl;
246 QFileInfo fi(fn); 272 QFileInfo fi(fn);
247 if (fi.exists() && fi.lastModified() > lastInteractionTime) { 273 if (fi.exists() && fi.created() > lastInteractionTime) {
248 DEBUG << "file " << fn << " is newer (" << fi.lastModified() 274 DEBUG << "file " << fn << " is newer (" << fi.lastModified()
249 << ") than reference" << endl; 275 << ") than reference" << endl;
250 highlighted = true; 276 highlighted = true;
251 } 277 }
252 } 278 }
269 QListWidgetItem *item = new QListWidgetItem(file); 295 QListWidgetItem *item = new QListWidgetItem(file);
270 w->addItem(item); 296 w->addItem(item);
271 item->setSelected(selectedFiles.contains(file)); 297 item->setSelected(selectedFiles.contains(file));
272 } 298 }
273 299
300 setLabelFor(w, s, !highPriority.empty());
301
274 w->parentWidget()->setVisible(!files.empty()); 302 w->parentWidget()->setVisible(!files.empty());
275 } 303 }
276 } 304 }
277 305
306 void FileStatusWidget::setLabelFor(QWidget *w, FileStates::State s, bool addHighlight)
307 {
308 QString text = labelFor(s, addHighlight);
309 QWidget *p = w->parentWidget();
310 QList<QLabel *> ql = p->findChildren<QLabel *>();
311 if (!ql.empty()) ql[0]->setText(text);
312 }