2
* kover - Kover is an easy to use WYSIWYG CD cover printer with CDDB support.
3
* Copyright (C) 2001, 2008 by Adrian Reber
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
/* This is the dialog for freedb server selection */
24
#include <cddb_fill.h>
27
#include <QVBoxLayout>
29
#include <QPushButton>
33
cddb_fill *bla = new cddb_fill();
34
bla->sites(server_list);
36
QVBoxLayout *top_layout = new QVBoxLayout(this);
38
top_layout->setMargin(7);
39
top_layout->addSpacing(10);
40
QLabel *label = new QLabel (tr("Choose wisely!"), this);
42
top_layout->addWidget(label);
43
top_layout->addSpacing(10);
44
box = new QListWidget(this);
45
list < server * >::iterator item;
49
for (item = server_list.begin(); item != server_list.end(); item++) {
52
if (((*item)->get_proto()).compare("http")) {
53
string = ((*item)->get_site()).c_str();
55
string += ((*item)->get_description()).c_str();
57
QListWidgetItem *newItem = new QListWidgetItem;
58
newItem->setText(string);
59
box->addItem(newItem);
63
connect(box, SIGNAL(itemDoubleClicked(QListWidgetItem *)), SLOT(double_clicked(QListWidgetItem *)));
65
top_layout->addWidget(box);
66
top_layout->addSpacing(20);
68
QBoxLayout *button_layout = new QBoxLayout(QBoxLayout::RightToLeft);
70
top_layout->addLayout(button_layout);
71
QPushButton *ok = new QPushButton(tr("Ok"), this);
75
ok->setMaximumWidth(70);
77
connect(ok, SIGNAL(clicked()), SLOT(accept()));
78
button_layout->addWidget(ok, 0, Qt::AlignRight);
79
button_layout->addSpacing(5);
81
QPushButton *quit = new QPushButton(tr("Quit"), this);
83
connect(quit, SIGNAL(clicked()), SLOT(quit()));
84
quit->setMaximumWidth(70);
85
button_layout->addWidget(quit, 0, Qt::AlignRight);
86
button_layout->addStretch(20);
92
fprintf(stderr, "%s:sd::~sd()\n", PACKAGE);
94
while (server_list.size()) {
95
delete((server_list.back()));
96
server_list.pop_back();
101
* The accept() slot. Setting the return value.
102
* reimplemented from QDialog
107
QDialog::done(box->currentRow());
111
* The done() slot. Setting the return value.
120
* The double_clicked() slot. Setting the return value.
121
* reimplemented from QDialog
124
sd::double_clicked(QListWidgetItem *item)
126
QDialog::done(item->listWidget()->currentRow());
130
* The exec() method. Executing the dialog.
131
* reimplemented from QDialog
132
* @see double_clicked(QListBoxItem *item)
134
* @return an int representation of the selected item
139
if (server_list.size() == 1) {
142
return QDialog::exec();
148
* @param index the int value returned by exec()
150
* @return the string containing the cddb id and category. Can be freed with free(3).
152
string sd::get(int index)
157
list < server * >::iterator item;
159
for (item = server_list.begin(); item != server_list.end(); item++) {
160
if (i++ == index * 2)
161
return (*item)->get_site();