5
5
for which a new license (GPL+exception) is in place.
9
8
#include "selfield.h"
10
#include "selfield.moc"
11
#include <qstringlist.h>
11
#include <QHBoxLayout>
12
#include <QVBoxLayout>
13
#include <QSpacerItem>
14
#include <QListWidget>
15
#include <QListWidgetItem>
16
#include <QPushButton>
13
19
#include "commonstrings.h"
15
extern QPixmap loadIcon(QString nam);
17
SelectFields::SelectFields( QWidget* parent, QString Felder, QString Own, ScribusDoc *Doc, int Art )
18
: QDialog( parent, "sef", true, 0 )
21
#include "util_icon.h"
23
SelectFields::SelectFields(QWidget* parent, QString Felder, QString Own, ScribusDoc *Doc, int Art) : QDialog(parent)
20
setCaption( tr( "Select Fields" ) );
21
setIcon(loadIcon("AppIcon.png"));
26
setWindowTitle( tr( "Select Fields" ) );
27
setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));
23
SelectFieldsLayout = new QVBoxLayout( this, 11, 6, "SelectFieldsLayout");
24
Layout5 = new QHBoxLayout( 0, 0, 6, "Layout5");
25
Layout1 = new QVBoxLayout( 0, 0, 6, "Layout1");
29
SelectFieldsLayout = new QVBoxLayout( this );
30
SelectFieldsLayout->setMargin(10);
31
SelectFieldsLayout->setSpacing(5);
32
Layout5 = new QHBoxLayout;
33
Layout5->setMargin(0);
34
Layout5->setSpacing(5);
35
Layout1 = new QVBoxLayout;
36
Layout1->setMargin(0);
37
Layout1->setSpacing(5);
27
Text1 = new QLabel( tr( "Available Fields" ), this, "Text1" );
39
Text1 = new QLabel( tr( "Available Fields" ), this );
28
40
Layout1->addWidget( Text1 );
29
AvailFields = new QListBox( this, "AvailFields" );
41
AvailFields = new QListWidget( this );
30
42
AvailFields->setMinimumSize( QSize( 130, 180 ) );
31
for (uint se = 0; se < Doc->Items->count(); ++se)
43
for (int se = 0; se < Doc->Items->count(); ++se)
33
45
PageItem* item = Doc->Items->at(se);
36
48
if ((item->isAnnotation()) && (item->annotation().Type() > 1))
37
AvailFields->insertItem(item->itemName());
49
AvailFields->addItem(item->itemName());
41
53
if ((item->isAnnotation()) && (item->annotation().Type() == Art) && (item->itemName() != Own))
42
AvailFields->insertItem(item->itemName());
54
AvailFields->addItem(item->itemName());
45
57
Layout1->addWidget( AvailFields );
50
Layout2 = new QVBoxLayout( 0, 0, 6, "Layout2");
62
Layout2 = new QVBoxLayout;
63
Layout2->setMargin(0);
64
Layout2->setSpacing(5);
51
65
QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
52
66
Layout2->addItem( spacer );
53
ToSel = new QPushButton( tr( "&>>" ), this, "ToSel" );
67
ToSel = new QPushButton( tr( "&>>" ), this );
54
68
Layout2->addWidget( ToSel );
55
FromSel = new QPushButton( tr( "&<<" ), this, "FromSel" );
69
FromSel = new QPushButton( tr( "&<<" ), this );
56
70
Layout2->addWidget( FromSel );
57
71
QSpacerItem* spacer_2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
58
72
Layout2->addItem( spacer_2 );
59
73
Layout5->addLayout( Layout2 );
60
Layout3 = new QVBoxLayout( 0, 0, 6, "Layout3");
61
Text2 = new QLabel( tr( "Selected Fields" ), this, "Text2" );
74
Layout3 = new QVBoxLayout;
75
Layout3->setMargin(0);
76
Layout3->setSpacing(5);
77
Text2 = new QLabel( tr( "Selected Fields" ), this );
62
78
Layout3->addWidget( Text2 );
63
SelFields = new QListBox( this, "SelFields" );
79
SelFields = new QListWidget( this );
64
80
SelFields->setMinimumSize( QSize( 130, 180 ) );
66
pfol = pfol.split(",", Felder);
82
pfol = Felder.split(",", QString::SkipEmptyParts);
67
83
if (pfol.count() > 0)
69
for (uint cfx = 0; cfx < pfol.count(); ++cfx)
70
SelFields->insertItem(pfol[cfx].stripWhiteSpace());
85
for (int cfx = 0; cfx < pfol.count(); ++cfx)
86
SelFields->addItem(pfol[cfx].simplified());
72
88
FromSel->setEnabled(false);
73
89
ToSel->setEnabled(false);
74
90
Layout3->addWidget( SelFields );
75
91
Layout5->addLayout( Layout3 );
76
connect(SelFields, SIGNAL(clicked(QListBoxItem*)), this, SLOT(SelEField(QListBoxItem*)));
92
connect(SelFields, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SelEField(QListWidgetItem*)));
77
93
connect(ToSel, SIGNAL(clicked()), this, SLOT(PutToSel()));
78
94
connect(FromSel, SIGNAL(clicked()), this, SLOT(RemoveSel()));
80
96
SelectFieldsLayout->addLayout( Layout5 );
82
Layout4 = new QHBoxLayout( 0, 0, 6, "Layout4");
98
Layout4 = new QHBoxLayout;
99
Layout4->setMargin(0);
100
Layout4->setSpacing(5);
83
101
QSpacerItem* spacer_3 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
84
102
Layout4->addItem( spacer_3 );
85
OK = new QPushButton( CommonStrings::tr_OK, this, "OK" );
103
OK = new QPushButton( CommonStrings::tr_OK, this );
86
104
OK->setDefault( true );
87
105
Layout4->addWidget( OK );
88
Cancel = new QPushButton( CommonStrings::tr_Cancel, this, "Cancel" );
106
Cancel = new QPushButton( CommonStrings::tr_Cancel, this );
89
107
Layout4->addWidget( Cancel );
90
108
QSpacerItem* spacer_4 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
91
109
Layout4->addItem( spacer_4 );
92
110
SelectFieldsLayout->addLayout( Layout4 );
93
111
connect(OK, SIGNAL(clicked()), this, SLOT(SetRetVal()));
94
112
connect(Cancel, SIGNAL(clicked()), this, SLOT(reject()));
95
connect(AvailFields, SIGNAL(clicked(QListBoxItem*)), this, SLOT(SelAField(QListBoxItem*)));
113
connect(AvailFields, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SelAField(QListWidgetItem*)));
98
116
void SelectFields::SetRetVal()
103
121
if (SelFields->count() > 0)
104
S_Fields = SelFields->text(0);
105
for (uint r = 1; r < SelFields->count(); ++r)
106
S_Fields += ", "+SelFields->text(r);
122
S_Fields = SelFields->item(0)->text();
123
for (int r = 1; r < SelFields->count(); ++r)
124
S_Fields += ", "+SelFields->item(r)->text();
109
S_Fields = AvailFields->currentText();
127
S_Fields = AvailFields->currentItem()->text();
113
131
void SelectFields::RemoveSel()
115
SelFields->removeItem(SelFields->currentItem());
133
QListWidgetItem *it = SelFields->takeItem(SelFields->currentRow());
116
135
SelFields->clearSelection();
117
136
if (SelFields->count() == 0)
118
137
FromSel->setEnabled(false);