void HgMergeDialog::updateInitialDialog() { HgWrapper *hgWrapper = HgWrapper::instance(); // update label - current branch QString line("<b>parents:</b> "); line += hgWrapper->getParentsOfHead(); m_currentChangeset->setText(line); // update heads list QProcess process; process.setWorkingDirectory(hgWrapper->getBaseDir()); QStringList args; args << QLatin1String("heads"); args << QLatin1String("--template"); args << QLatin1String("{rev}\n{node|short}\n{branch}\n" "{author}\n{desc|firstline}\n"); process.start(QLatin1String("hg"), args); m_commitInfoWidget->clear(); const int FINAL = 5; char buffer[FINAL][1024]; int count = 0; while (process.waitForReadyRead()) { while (process.readLine(buffer[count], sizeof(buffer[count])) > 0) { if (count == FINAL - 1) { QString rev = QTextCodec::codecForLocale()->toUnicode(buffer[0]).trimmed(); QString changeset = QTextCodec::codecForLocale()->toUnicode(buffer[1]).trimmed(); QString branch = QTextCodec::codecForLocale()->toUnicode(buffer[2]).trimmed(); QString author = QTextCodec::codecForLocale()->toUnicode(buffer[3]).trimmed(); QString log = QTextCodec::codecForLocale()->toUnicode(buffer[4]).trimmed(); QListWidgetItem *item = new QListWidgetItem; item->setData(Qt::DisplayRole, changeset); item->setData(Qt::UserRole + 1, rev); item->setData(Qt::UserRole + 2, branch); item->setData(Qt::UserRole + 3, author); item->setData(Qt::UserRole + 4, log); m_commitInfoWidget->addItem(item); } count = (count + 1)%FINAL; } } }
void HgStatusList::reloadStatusTable() { m_statusTable->clearContents(); m_statusTable->resizeRowsToContents(); m_statusTable->resizeColumnsToContents(); m_statusTable->horizontalHeader()->setStretchLastSection(true); HgWrapper *hgWrapper = HgWrapper::instance(); QHash<QString, KVersionControlPlugin2::ItemVersion> hgVsState; hgWrapper->getItemVersions(hgVsState); QMutableHashIterator<QString, KVersionControlPlugin2::ItemVersion> it(hgVsState); int rowCount = 0; while (it.hasNext()) { it.next(); KVersionControlPlugin2::ItemVersion currentStatus = it.value(); // Get path relative to root directory of repository // FIXME: preferred method, but not working :| bad hack below // QString currentFile // = KUrl::relativeUrl(hgWrapper->getBaseDir(), it.key()); QString currentFile = it.key().mid(hgWrapper->getBaseDir().length()+1); QString currentStatusString; //one character status indicator // Temporarily ignoring // TODO: Ask to add file if this is checked by user if (currentStatus == KVersionControlPlugin2::UnversionedVersion || currentStatus == KVersionControlPlugin2::IgnoredVersion) { continue; } QTableWidgetItem *check = new QTableWidgetItem; QTableWidgetItem *status = new QTableWidgetItem; QTableWidgetItem *fileName = new QTableWidgetItem; switch (currentStatus) { case KVersionControlPlugin2::AddedVersion: status->setForeground(Qt::darkCyan); fileName->setForeground(Qt::darkCyan); check->setCheckState(Qt::Checked); currentStatusString = QLatin1String("A"); break; case KVersionControlPlugin2::LocallyModifiedVersion: status->setForeground(Qt::blue); fileName->setForeground(Qt::blue); check->setCheckState(Qt::Checked); currentStatusString = QLatin1String("M"); break; case KVersionControlPlugin2::RemovedVersion: status->setForeground(Qt::red); fileName->setForeground(Qt::red); check->setCheckState(Qt::Checked); currentStatusString = QLatin1String("R"); break; case KVersionControlPlugin2::UnversionedVersion: status->setForeground(Qt::darkMagenta); fileName->setForeground(Qt::darkMagenta); currentStatusString = QLatin1String("?"); break; case KVersionControlPlugin2::IgnoredVersion: status->setForeground(Qt::black); fileName->setForeground(Qt::black); currentStatusString = QLatin1String("I"); break; case KVersionControlPlugin2::MissingVersion: status->setForeground(Qt::black); fileName->setForeground(Qt::black); currentStatusString = QLatin1String("!"); break; default: break; } status->setText(QString(currentStatusString)); fileName->setText(currentFile); m_statusTable->insertRow(rowCount); check->setCheckState(Qt::Checked); //Change. except untracked, ignored m_statusTable->setItem(rowCount, 0, check); m_statusTable->setItem(rowCount, 1, status); m_statusTable->setItem(rowCount, 2, fileName); ++rowCount; } }