2 * This file is part of the sigrok project.
4 * Copyright (C) 2011 Uwe Hermann <uwe@hermann-uwe.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) any later version.
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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <sigrokdecode.h>
27 #include "decodersform.h"
28 #include "ui_decodersform.h"
30 DecodersForm::DecodersForm(QWidget *parent) :
32 ui(new Ui::DecodersForm)
36 struct srd_decoder *dec;
37 QWidget *pages[MAX_NUM_DECODERS];
43 for (ll = srd_decoder_list(), i = 0; ll; ll = ll->next, ++i) {
44 dec = (struct srd_decoder *)ll->data;
46 /* Add the decoder to the list. */
47 new QListWidgetItem(QString(dec->name), ui->listWidget);
49 /* Add a page for the decoder details. */
50 pages[i] = new QWidget;
52 /* Add some decoder data to that page. */
53 QVBoxLayout *l = new QVBoxLayout;
54 l->addWidget(new QLabel("ID: " + QString(dec->id)));
55 l->addWidget(new QLabel("Name: " + QString(dec->name)));
56 l->addWidget(new QLabel("Long name: " + QString(dec->longname)));
57 l->addWidget(new QLabel("Description: " + QString(dec->desc)));
58 l->addWidget(new QLabel("License: " + QString(dec->license)));
59 s = new QString("Annotations:\n");
60 for (ll2 = dec->annotations; ll2; ll2 = ll2->next) {
61 ann = (char **)ll2->data;
62 s->append(QString(" - %1: %2\n").arg(ann[0]).arg(ann[1]));
64 l->addWidget(new QLabel(*s));
65 s = new QString("Protocol documentation:\n");
66 if (doc = srd_decoder_doc_get(dec)) {
67 s->append(QString("%1\n")
68 .arg(doc[0] == '\n' ? doc + 1 : doc));
71 l->addWidget(new QLabel(*s));
75 pages[i]->setLayout(l);
77 /* Add the decoder's page to the stackedWidget. */
78 ui->stackedWidget->addWidget(pages[i]);
82 DecodersForm::~DecodersForm()
87 void DecodersForm::changeEvent(QEvent *e)
89 QDialog::changeEvent(e);
91 case QEvent::LanguageChange:
92 ui->retranslateUi(this);
99 void DecodersForm::on_closeButton_clicked()
104 void DecodersForm::on_listWidget_currentItemChanged(QListWidgetItem *current,
105 QListWidgetItem *previous)
110 ui->stackedWidget->setCurrentIndex(ui->listWidget->row(current));