2 * Qt OBS - A Qt based OBS client
4 * Copyright (C) 2010 Novell Inc, Klaas Freitag <freitag@suse.de>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) version 3.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Written by Klaas Freitag <freitag@suse.de>
26 #include <QTreeWidgetItem>
28 #include "projectresulttreewidget.h"
29 #include "obsbuildresults.h"
31 ProjectResultTreeWidget::ProjectResultTreeWidget( QWidget *parent )
32 : QTreeWidget( parent )
37 void ProjectResultTreeWidget::showStatus( OBSProjectBuildResults results )
40 headers << tr("Package") << results.repositories();
41 qDebug() << "XXXXXXXXX " << headers << " - " << headers.count();
42 setColumnCount( headers.count() );
44 setHeaderLabels( headers );
46 QMap<QString, QTreeWidgetItem*> packLineMap;
47 QListIterator<OBSProjectBuildResult> i( results );
48 while( i.hasNext() ) {
49 OBSProjectBuildResult res = i.next();
51 QListIterator<OBSPackageBuildResult> pi( res.packageResults() );
52 qDebug() << "---> " << res.project() << " - " << res.repository() << " - " << res.architecture() << endl;
54 QString repo = res.repository();
55 QString arch = res.architecture();
57 while( pi.hasNext()) {
58 OBSPackageBuildResult pRes = pi.next();
59 qDebug() << " Package:> " << pRes.name();
60 QString package = pRes.name();
61 QString state = pRes.state();
62 QTreeWidgetItem *displayItem = 0;
64 if( packLineMap.contains( package ) ) {
65 displayItem = packLineMap.value( package );
67 // the package is new and a display item needs to be created
68 displayItem = new QTreeWidgetItem( this );
69 packLineMap.insert( package, displayItem );
70 displayItem->setText( 0, package );
74 int pos = headers.indexOf( repo );
75 displayState( displayItem, pos, arch, state );
82 void ProjectResultTreeWidget::displayState( QTreeWidgetItem *item, int col, const QString& arch, const QString& state )
84 QString currContent = item->text( col );
86 QString newArchDisplay = arch;
88 QString newInfo = QString (" %1 %2(%3)").arg(currContent).arg(arch).arg(state);
90 item->setText( col, newInfo );