/*************************************************************************** * Copyright 2007 Robert Gruber * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "editorsview.h" #include #include #include #include #include #include "cvsplugin.h" #include "cvsjob.h" #include "cvsproxy.h" EditorsView::EditorsView(CvsJob* job, QWidget *parent) : QWidget(parent), Ui::EditorsViewBase() { Ui::EditorsViewBase::setupUi(this); if (job) { connect(job, SIGNAL(result(KJob*)), this, SLOT(slotJobFinished(KJob*))); } } EditorsView::~EditorsView() { } void EditorsView::slotJobFinished(KJob* job) { if ( job->error() ) { textbrowser->append( i18n("Listing editors failed") ); return; } CvsJob * cvsjob = dynamic_cast(job); if (!cvsjob) { return; } QMultiMap lockedFiles; parseOutput(cvsjob->output(), lockedFiles); if (lockedFiles.size() == 0) { textbrowser->append(i18n("No files from your query are marked as being edited.")); } else { QString html; foreach (const QString &key, lockedFiles.uniqueKeys()) { html += "

"+key+"


"; foreach(const CvsLocker &item, lockedFiles.values( key )) { html += ""+i18n("User")+": "+item.user+"
"; html += ""+i18n("Date")+": "+item.date+"
"; html += ""+i18n("Machine")+": "+item.machine+"
"; html += ""+i18n("Repository")+": "+item.localrepo+"
"; html += "
"; } html += "
"; } textbrowser->setHtml( html ); } } void EditorsView::parseOutput(const QString& jobOutput, QMultiMap& editorsInfo) { // the first line contains the filename and than the locker information static QRegExp re("([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+" "([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+(.*)"); // if there are more than one locker of a single file, the second line for a file // only contains the locker information (no filename) static QRegExp subre("\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+" "([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+(.*)"); QString lastfilename; QStringList lines = jobOutput.split('\n'); for (int i=0; i