Chris@88: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@88: Chris@88: /* Chris@88: EasyMercurial Chris@88: Chris@88: Based on HgExplorer by Jari Korhonen Chris@88: Copyright (c) 2010 Jari Korhonen Chris@560: Copyright (c) 2012 Chris Cannam Chris@560: Copyright (c) 2012 Queen Mary, University of London Chris@88: Chris@88: This program is free software; you can redistribute it and/or Chris@88: modify it under the terms of the GNU General Public License as Chris@88: published by the Free Software Foundation; either version 2 of the Chris@88: License, or (at your option) any later version. See the file Chris@88: COPYING included with this distribution for more information. Chris@88: */ Chris@88: Chris@88: #include "filestatuswidget.h" Chris@115: #include "debug.h" Chris@115: #include "multichoicedialog.h" Chris@558: #include "findwidget.h" Chris@88: Chris@88: #include Chris@88: #include Chris@88: #include Chris@93: #include Chris@93: #include Chris@93: #include Chris@115: #include Chris@186: #include Chris@186: #include Chris@186: #include Chris@199: #include Chris@230: #include Chris@323: #include Chris@88: Chris@88: FileStatusWidget::FileStatusWidget(QWidget *parent) : Chris@93: QWidget(parent), Chris@93: m_dateReference(0) Chris@88: { Chris@88: QGridLayout *layout = new QGridLayout; Chris@215: layout->setMargin(10); Chris@88: setLayout(layout); Chris@88: Chris@88: int row = 0; Chris@211: Chris@230: m_noModificationsLabel = new QLabel; Chris@230: setNoModificationsLabelText(); Chris@297: layout->addWidget(m_noModificationsLabel, row, 0); Chris@202: m_noModificationsLabel->hide(); Chris@106: Chris@100: m_simpleLabels[FileStates::Clean] = tr("Unmodified:"); Chris@100: m_simpleLabels[FileStates::Modified] = tr("Modified:"); Chris@100: m_simpleLabels[FileStates::Added] = tr("Added:"); Chris@100: m_simpleLabels[FileStates::Removed] = tr("Removed:"); Chris@100: m_simpleLabels[FileStates::Missing] = tr("Missing:"); Chris@163: m_simpleLabels[FileStates::InConflict] = tr("In Conflict:"); Chris@100: m_simpleLabels[FileStates::Unknown] = tr("Untracked:"); Chris@199: m_simpleLabels[FileStates::Ignored] = tr("Ignored:"); Chris@99: Chris@326: m_actionLabels[FileStates::Annotate] = tr("Show annotated version"); Chris@326: m_actionLabels[FileStates::Diff] = tr("Diff to parent"); Chris@325: m_actionLabels[FileStates::Commit] = tr("Commit..."); Chris@328: m_actionLabels[FileStates::Revert] = tr("Revert to last committed state"); Chris@361: m_actionLabels[FileStates::Rename] = tr("Rename..."); Chris@361: m_actionLabels[FileStates::Copy] = tr("Copy..."); Chris@326: m_actionLabels[FileStates::Add] = tr("Add to version control"); Chris@326: m_actionLabels[FileStates::Remove] = tr("Remove from version control"); Chris@326: m_actionLabels[FileStates::RedoMerge] = tr("Redo merge"); Chris@328: m_actionLabels[FileStates::MarkResolved] = tr("Mark conflict as resolved"); Chris@413: m_actionLabels[FileStates::Ignore] = tr("Ignore..."); Chris@421: // Unignore is too difficult in fact, so we just offer to edit the hgignore Chris@421: m_actionLabels[FileStates::UnIgnore] = tr("Edit .hgignore File"); Chris@325: Chris@100: m_descriptions[FileStates::Clean] = tr("You have not changed these files."); Chris@100: m_descriptions[FileStates::Modified] = tr("You have changed these files since you last committed them."); Chris@225: m_descriptions[FileStates::Added] = tr("These files will be added to version control next time you commit them."); Chris@225: m_descriptions[FileStates::Removed] = tr("These files will be removed from version control next time you commit them.
" Chris@100: "They will not be deleted from the local folder."); Chris@109: m_descriptions[FileStates::Missing] = tr("These files are recorded in the version control, but absent from your working folder.
" Chris@153: "If you intended to delete them, select them and use Remove to tell the version control system about it.
" Chris@153: "If you deleted them by accident, select them and use Revert to restore their previous contents."); Chris@482: m_descriptions[FileStates::InConflict] = tr("These files are unresolved following an incomplete merge.
Use Merge to try to resolve the merge again."); Chris@100: m_descriptions[FileStates::Unknown] = tr("These files are in your working folder but are not under version control.
" Chris@186: // "Select a file and use Add to place it under version control or Ignore to remove it from this list."); Chris@186: "Select a file and use Add to place it under version control."); Chris@199: m_descriptions[FileStates::Ignored] = tr("These files have names that match entries in the working folder's .hgignore file,
" Chris@199: "and so will be ignored by the version control system."); Chris@100: Chris@118: m_highlightExplanation = tr("Files highlighted in red " Chris@100: "have appeared since your most recent commit or update."); Chris@89: Chris@230: m_boxesParent = new QWidget(this); Chris@297: layout->addWidget(m_boxesParent, ++row, 0); Chris@230: Chris@230: QGridLayout *boxesLayout = new QGridLayout; Chris@230: boxesLayout->setMargin(0); Chris@230: m_boxesParent->setLayout(boxesLayout); Chris@230: int boxRow = 0; Chris@230: Chris@94: for (int i = int(FileStates::FirstState); Chris@163: i <= int(FileStates::LastState); ++i) { Chris@89: Chris@94: FileStates::State s = FileStates::State(i); Chris@89: Chris@230: QWidget *box = new QWidget(m_boxesParent); Chris@89: QGridLayout *boxlayout = new QGridLayout; Chris@99: boxlayout->setMargin(0); Chris@89: box->setLayout(boxlayout); Chris@89: Chris@211: boxlayout->addItem(new QSpacerItem(3, 3), 0, 0); Chris@101: Chris@230: QLabel *label = new QLabel(labelFor(s)); Chris@230: label->setWordWrap(true); Chris@230: boxlayout->addWidget(label, 1, 0); Chris@89: Chris@94: QListWidget *w = new QListWidget; Chris@94: m_stateListMap[s] = w; Chris@94: w->setSelectionMode(QListWidget::ExtendedSelection); Chris@101: boxlayout->addWidget(w, 2, 0); Chris@89: Chris@95: connect(w, SIGNAL(itemSelectionChanged()), Chris@95: this, SLOT(itemSelectionChanged())); Chris@331: connect(w, SIGNAL(itemDoubleClicked(QListWidgetItem *)), Chris@331: this, SLOT(itemDoubleClicked(QListWidgetItem *))); Chris@95: Chris@325: FileStates::Activities activities = m_fileStates.activitiesSupportedBy(s); Chris@325: int prevGroup = -1; Chris@325: foreach (FileStates::Activity a, activities) { Chris@325: int group = FileStates::activityGroup(a); Chris@325: if (group != prevGroup && prevGroup != -1) { Chris@325: QAction *sep = new QAction("", w); Chris@325: sep->setSeparator(true); Chris@325: w->insertAction(0, sep); Chris@325: } Chris@325: prevGroup = group; Chris@325: QAction *act = new QAction(m_actionLabels[a], w); Chris@326: act->setProperty("state", s); Chris@326: act->setProperty("activity", a); Chris@326: connect(act, SIGNAL(triggered()), this, SLOT(menuActionActivated())); Chris@325: w->insertAction(0, act); Chris@325: } Chris@323: w->setContextMenuPolicy(Qt::ActionsContextMenu); Chris@323: Chris@211: boxlayout->addItem(new QSpacerItem(2, 2), 3, 0); Chris@211: Chris@230: boxesLayout->addWidget(box, ++boxRow, 0); Chris@230: m_boxes.push_back(box); Chris@89: box->hide(); Chris@89: } Chris@89: Chris@230: m_gridlyLayout = false; Chris@230: Chris@89: layout->setRowStretch(++row, 20); Chris@186: Chris@211: layout->addItem(new QSpacerItem(8, 8), ++row, 0); Chris@199: Chris@558: QWidget *opts = new QWidget; Chris@558: QGridLayout *optLayout = new QGridLayout(opts); Chris@558: optLayout->setMargin(0); Chris@558: layout->addWidget(opts, ++row, 0); Chris@558: Chris@558: m_findWidget = new FindWidget(this); Chris@558: optLayout->addWidget(m_findWidget, 0, 0, Qt::AlignLeft); Chris@558: connect(m_findWidget, SIGNAL(findTextChanged(QString)), Chris@558: this, SLOT(setSearchText(QString))); Chris@558: Chris@558: m_showAllFiles = new QCheckBox(tr("Show all file states"), this); Chris@340: m_showAllFiles->setEnabled(false); Chris@558: optLayout->addWidget(m_showAllFiles, 0, 1, Qt::AlignRight); Chris@484: Chris@484: QSettings settings; Chris@484: m_showAllFiles->setChecked(settings.value("showall", false).toBool()); Chris@484: Chris@199: connect(m_showAllFiles, SIGNAL(toggled(bool)), Chris@484: this, SIGNAL(showAllChanged())); Chris@88: } Chris@88: Chris@93: FileStatusWidget::~FileStatusWidget() Chris@93: { Chris@484: QSettings settings; Chris@484: settings.setValue("showall", m_showAllFiles->isChecked()); Chris@484: Chris@93: delete m_dateReference; Chris@93: } Chris@93: Chris@484: bool FileStatusWidget::shouldShowAll() const Chris@484: { Chris@484: return m_showAllFiles->isChecked(); Chris@484: } Chris@484: Chris@542: bool FileStatusWidget::shouldShow(FileStates::State s) const Chris@542: { Chris@542: if (shouldShowAll()) return true; Chris@542: else return (s != FileStates::Clean && Chris@542: s != FileStates::Ignored); Chris@542: } Chris@542: Chris@100: QString FileStatusWidget::labelFor(FileStates::State s, bool addHighlightExplanation) Chris@100: { Chris@230: QSettings settings; Chris@230: settings.beginGroup("Presentation"); Chris@230: if (settings.value("showhelpfultext", true).toBool()) { Chris@230: if (addHighlightExplanation) { Chris@230: return QString("%1
%2
%3
") Chris@230: .arg(m_simpleLabels[s]) Chris@230: .arg(m_descriptions[s]) Chris@230: .arg(m_highlightExplanation); Chris@230: } else { Chris@230: return QString("%1
%2
") Chris@230: .arg(m_simpleLabels[s]) Chris@230: .arg(m_descriptions[s]); Chris@230: } Chris@230: } Chris@542: return QString("%1") Chris@542: .arg(m_simpleLabels[s]); Chris@230: } Chris@230: Chris@230: void FileStatusWidget::setNoModificationsLabelText() Chris@230: { Chris@230: QSettings settings; Chris@230: settings.beginGroup("Presentation"); Chris@558: Chris@558: if (m_searchText != "") { Chris@558: if (!m_showAllFiles->isChecked()) { Chris@558: m_noModificationsLabel->setText Chris@558: (tr("Nothing found
None of the modified files have matching filenames.
Select Show all file states to find matches among unmodified and untracked files as well.
")); Chris@558: } else { Chris@558: m_noModificationsLabel->setText Chris@558: (tr("Nothing found
No files have matching filenames.
")); Chris@558: } Chris@558: } else if (settings.value("showhelpfultext", true).toBool()) { Chris@230: m_noModificationsLabel->setText Chris@230: (tr("This area will list files in your working folder that you have changed.

At the moment you have no uncommitted changes.

To see changes previously made to the repository,
switch to the History tab.

%1
") Chris@230: #if defined Q_OS_MAC Chris@230: .arg(tr("To open the working folder in Finder,
click on the “Local” folder path shown above.")) Chris@230: #elif defined Q_OS_WIN32 Chris@230: .arg(tr("To open the working folder in Windows Explorer,
click on the “Local” folder path shown above.")) Chris@230: #else Chris@230: .arg(tr("To open the working folder in your system file manager,
click the “Local” folder path shown above.")) Chris@230: #endif Chris@230: ); Chris@230: } else { Chris@230: m_noModificationsLabel->setText Chris@230: (tr("You have no uncommitted changes.")); Chris@100: } Chris@100: } Chris@100: Chris@319: Chris@326: void FileStatusWidget::menuActionActivated() Chris@326: { Chris@326: QAction *act = qobject_cast(sender()); Chris@326: if (!act) return; Chris@326: Chris@326: FileStates::State state = (FileStates::State) Chris@326: act->property("state").toUInt(); Chris@326: FileStates::Activity activity = (FileStates::Activity) Chris@326: act->property("activity").toUInt(); Chris@319: Chris@326: DEBUG << "menuActionActivated: state = " << state << ", activity = " Chris@326: << activity << endl; Chris@319: Chris@326: if (!FileStates::supportsActivity(state, activity)) { Chris@326: std::cerr << "WARNING: FileStatusWidget::menuActionActivated: " Chris@326: << "Action state " << state << " does not support activity " Chris@326: << activity << std::endl; Chris@326: return; Chris@326: } Chris@326: Chris@326: QStringList files = getSelectedFilesInState(state); Chris@326: Chris@326: switch (activity) { Chris@326: case FileStates::Annotate: emit annotateFiles(files); break; Chris@326: case FileStates::Diff: emit diffFiles(files); break; Chris@326: case FileStates::Commit: emit commitFiles(files); break; Chris@326: case FileStates::Revert: emit revertFiles(files); break; Chris@361: case FileStates::Rename: emit renameFiles(files); break; Chris@361: case FileStates::Copy: emit copyFiles(files); break; Chris@326: case FileStates::Add: emit addFiles(files); break; Chris@326: case FileStates::Remove: emit removeFiles(files); break; Chris@326: case FileStates::RedoMerge: emit redoFileMerges(files); break; Chris@326: case FileStates::MarkResolved: emit markFilesResolved(files); break; Chris@326: case FileStates::Ignore: emit ignoreFiles(files); break; Chris@326: case FileStates::UnIgnore: emit unIgnoreFiles(files); break; Chris@326: } Chris@326: } Chris@319: Chris@331: void FileStatusWidget::itemDoubleClicked(QListWidgetItem *item) Chris@331: { Chris@331: QStringList files; Chris@350: QString file = item->text(); Chris@350: files << file; Chris@350: Chris@350: switch (m_fileStates.stateOf(file)) { Chris@350: Chris@350: case FileStates::Modified: Chris@350: case FileStates::InConflict: Chris@350: emit diffFiles(files); Chris@350: break; Chris@350: Chris@350: case FileStates::Clean: Chris@350: case FileStates::Missing: Chris@350: emit annotateFiles(files); Chris@350: break; Chris@373: Chris@373: default: Chris@373: break; Chris@350: } Chris@331: } Chris@319: Chris@95: void FileStatusWidget::itemSelectionChanged() Chris@95: { Chris@135: DEBUG << "FileStatusWidget::itemSelectionChanged" << endl; Chris@135: Chris@135: QListWidget *list = qobject_cast(sender()); Chris@135: Chris@135: if (list) { Chris@135: foreach (QListWidget *w, m_stateListMap) { Chris@135: if (w != list) { Chris@135: w->blockSignals(true); Chris@135: w->clearSelection(); Chris@135: w->blockSignals(false); Chris@135: } Chris@135: } Chris@135: } Chris@135: Chris@95: m_selectedFiles.clear(); Chris@95: Chris@95: foreach (QListWidget *w, m_stateListMap) { Chris@95: QList sel = w->selectedItems(); Chris@95: foreach (QListWidgetItem *i, sel) { Chris@95: m_selectedFiles.push_back(i->text()); Chris@95: DEBUG << "file " << i->text() << " is selected" << endl; Chris@95: } Chris@95: } Chris@95: Chris@95: emit selectionChanged(); Chris@95: } Chris@95: Chris@94: void FileStatusWidget::clearSelections() Chris@94: { Chris@95: m_selectedFiles.clear(); Chris@94: foreach (QListWidget *w, m_stateListMap) { Chris@94: w->clearSelection(); Chris@94: } Chris@94: } Chris@94: Chris@95: bool FileStatusWidget::haveChangesToCommit() const Chris@95: { Chris@326: return !getAllCommittableFiles().empty(); Chris@95: } Chris@95: Chris@95: bool FileStatusWidget::haveSelection() const Chris@95: { Chris@95: return !m_selectedFiles.empty(); Chris@95: } Chris@95: Chris@326: QStringList FileStatusWidget::getSelectedFilesInState(FileStates::State s) const Chris@95: { Chris@95: QStringList files; Chris@95: foreach (QString f, m_selectedFiles) { Chris@326: if (m_fileStates.stateOf(f) == s) files.push_back(f); Chris@95: } Chris@95: return files; Chris@326: } Chris@326: Chris@326: QStringList FileStatusWidget::getSelectedFilesSupportingActivity(FileStates::Activity a) const Chris@326: { Chris@326: QStringList files; Chris@326: foreach (QString f, m_selectedFiles) { Chris@326: if (m_fileStates.supportsActivity(f, a)) files.push_back(f); Chris@326: } Chris@326: return files; Chris@326: } Chris@95: Chris@103: QStringList FileStatusWidget::getAllCommittableFiles() const Chris@103: { Chris@326: return m_fileStates.filesSupportingActivity(FileStates::Commit); Chris@109: } Chris@109: Chris@109: QStringList FileStatusWidget::getAllRevertableFiles() const Chris@109: { Chris@326: return m_fileStates.filesSupportingActivity(FileStates::Revert); Chris@163: } Chris@163: Chris@163: QStringList FileStatusWidget::getAllUnresolvedFiles() const Chris@163: { Chris@326: return m_fileStates.filesInState(FileStates::InConflict); Chris@109: } Chris@109: Chris@95: QStringList FileStatusWidget::getSelectedAddableFiles() const Chris@95: { Chris@326: return getSelectedFilesSupportingActivity(FileStates::Add); Chris@103: } Chris@103: Chris@95: QStringList FileStatusWidget::getSelectedRemovableFiles() const Chris@95: { Chris@326: return getSelectedFilesSupportingActivity(FileStates::Remove); Chris@103: } Chris@103: Chris@283: QString Chris@283: FileStatusWidget::localPath() const Chris@283: { Chris@287: return m_localPath; Chris@283: } Chris@283: Chris@88: void Chris@88: FileStatusWidget::setLocalPath(QString p) Chris@88: { Chris@287: m_localPath = p; Chris@93: delete m_dateReference; Chris@93: m_dateReference = new QFileInfo(p + "/.hg/dirstate"); Chris@93: if (!m_dateReference->exists() || Chris@93: !m_dateReference->isFile() || Chris@93: !m_dateReference->isReadable()) { Chris@93: DEBUG << "FileStatusWidget::setLocalPath: date reference file " Chris@93: << m_dateReference->absoluteFilePath() Chris@93: << " does not exist, is not a file, or cannot be read" Chris@93: << endl; Chris@93: delete m_dateReference; Chris@93: m_dateReference = 0; Chris@340: m_showAllFiles->setEnabled(false); Chris@340: } else { Chris@340: m_showAllFiles->setEnabled(true); Chris@93: } Chris@283: } Chris@283: Chris@88: void Chris@92: FileStatusWidget::setFileStates(FileStates p) Chris@88: { Chris@92: m_fileStates = p; Chris@88: updateWidgets(); Chris@88: } Chris@88: Chris@88: void Chris@555: FileStatusWidget::setSearchText(QString text) Chris@555: { Chris@555: if (m_searchText == text) return; Chris@555: m_searchText = text; Chris@555: updateWidgets(); Chris@555: } Chris@555: Chris@555: void Chris@88: FileStatusWidget::updateWidgets() Chris@88: { Chris@95: QDateTime lastInteractionTime; Chris@95: if (m_dateReference) { Chris@95: lastInteractionTime = m_dateReference->lastModified(); Chris@95: DEBUG << "reference time: " << lastInteractionTime << endl; Chris@95: } Chris@95: Chris@95: QSet selectedFiles; Chris@95: foreach (QString f, m_selectedFiles) selectedFiles.insert(f); Chris@95: Chris@230: int visibleCount = 0; Chris@555: bool finding = (m_searchText != ""); Chris@115: Chris@94: foreach (FileStates::State s, m_stateListMap.keys()) { Chris@95: Chris@94: QListWidget *w = m_stateListMap[s]; Chris@94: w->clear(); Chris@542: Chris@542: if (!shouldShow(s)) { Chris@542: w->parentWidget()->hide(); Chris@542: continue; Chris@542: } Chris@542: Chris@324: QStringList files = m_fileStates.filesInState(s); Chris@557: bool foundSomething = false; Chris@93: Chris@95: QStringList highPriority, lowPriority; Chris@95: Chris@95: foreach (QString file, files) { Chris@95: Chris@555: if (finding) { Chris@555: if (file.contains(m_searchText, Qt::CaseInsensitive)) { Chris@555: highPriority.push_back(file); Chris@557: foundSomething = true; Chris@555: } Chris@555: continue; Chris@557: } else { Chris@557: foundSomething = true; Chris@555: } Chris@555: Chris@95: bool highlighted = false; Chris@95: Chris@95: if (s == FileStates::Unknown) { Chris@95: // We want to highlight untracked files that have appeared Chris@95: // since the last interaction with the repo Chris@287: QString fn(m_localPath + "/" + file); Chris@95: DEBUG << "comparing with " << fn << endl; Chris@95: QFileInfo fi(fn); Chris@100: if (fi.exists() && fi.created() > lastInteractionTime) { Chris@95: DEBUG << "file " << fn << " is newer (" << fi.lastModified() Chris@95: << ") than reference" << endl; Chris@95: highlighted = true; Chris@95: } Chris@95: } Chris@95: Chris@95: if (highlighted) { Chris@95: highPriority.push_back(file); Chris@95: } else { Chris@95: lowPriority.push_back(file); Chris@93: } Chris@93: } Chris@95: Chris@95: foreach (QString file, highPriority) { Chris@95: QListWidgetItem *item = new QListWidgetItem(file); Chris@95: w->addItem(item); Chris@555: if (finding) { Chris@555: item->setForeground(QColor("#008400")); Chris@555: } else { Chris@555: item->setForeground(QColor("#d40000")); Chris@555: } Chris@95: item->setSelected(selectedFiles.contains(file)); Chris@95: } Chris@95: Chris@95: foreach (QString file, lowPriority) { Chris@95: QListWidgetItem *item = new QListWidgetItem(file); Chris@95: w->addItem(item); Chris@95: item->setSelected(selectedFiles.contains(file)); Chris@95: } Chris@95: Chris@100: setLabelFor(w, s, !highPriority.empty()); Chris@100: Chris@557: if (!foundSomething) { Chris@115: w->parentWidget()->hide(); Chris@115: } else { Chris@115: w->parentWidget()->show(); Chris@230: ++visibleCount; Chris@115: } Chris@93: } Chris@115: Chris@230: m_noModificationsLabel->setVisible(visibleCount == 0); Chris@230: Chris@230: if (visibleCount > 3) { Chris@230: layoutBoxesGridly(visibleCount); Chris@230: } else { Chris@230: layoutBoxesLinearly(); Chris@230: } Chris@115: Chris@230: setNoModificationsLabelText(); Chris@230: } Chris@230: Chris@230: void FileStatusWidget::layoutBoxesGridly(int visibleCount) Chris@230: { Chris@230: if (m_gridlyLayout && m_lastGridlyCount == visibleCount) return; Chris@230: Chris@230: delete m_boxesParent->layout(); Chris@230: Chris@230: QGridLayout *layout = new QGridLayout; Chris@230: layout->setMargin(0); Chris@230: m_boxesParent->setLayout(layout); Chris@230: Chris@230: int row = 0; Chris@230: int col = 0; Chris@230: Chris@230: DEBUG << "FileStatusWidget::layoutBoxesGridly: visibleCount = " Chris@230: << visibleCount << endl; Chris@230: Chris@230: for (int i = 0; i < m_boxes.size(); ++i) { Chris@230: Chris@230: if (!m_boxes[i]->isVisible()) continue; Chris@230: Chris@230: if (col == 0 && row >= (visibleCount+1)/2) { Chris@230: layout->addItem(new QSpacerItem(10, 5), 0, 1); Chris@230: col = 2; Chris@230: row = 0; Chris@230: } Chris@230: Chris@230: layout->addWidget(m_boxes[i], row, col); Chris@230: Chris@230: ++row; Chris@230: } Chris@230: Chris@230: m_gridlyLayout = true; Chris@230: m_lastGridlyCount = visibleCount; Chris@230: } Chris@230: Chris@230: void FileStatusWidget::layoutBoxesLinearly() Chris@230: { Chris@230: if (!m_gridlyLayout) return; Chris@230: Chris@230: delete m_boxesParent->layout(); Chris@230: Chris@230: QGridLayout *layout = new QGridLayout; Chris@230: layout->setMargin(0); Chris@230: m_boxesParent->setLayout(layout); Chris@230: Chris@230: for (int i = 0; i < m_boxes.size(); ++i) { Chris@230: layout->addWidget(m_boxes[i], i, 0); Chris@230: } Chris@230: Chris@230: m_gridlyLayout = false; Chris@88: } Chris@88: Chris@100: void FileStatusWidget::setLabelFor(QWidget *w, FileStates::State s, bool addHighlight) Chris@100: { Chris@100: QString text = labelFor(s, addHighlight); Chris@100: QWidget *p = w->parentWidget(); Chris@100: QList ql = p->findChildren(); Chris@100: if (!ql.empty()) ql[0]->setText(text); Chris@100: } Chris@115: