~ubuntu-branches/ubuntu/maverick/scribus-ng/maverick-backports

« back to all changes in this revision

Viewing changes to scribus/selfield.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oleksandr Moskalenko
  • Date: 2009-02-09 09:25:18 UTC
  • mfrom: (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090209092518-iqsxmh3pjspgrdyd
Tags: 1.3.5.dfsg~svn20090208-2
debian/control: Use "type-handling -n arm,armel,armeb any" to generate the
list of architectures to build on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
for which a new license (GPL+exception) is in place.
6
6
*/
7
7
 
8
 
#include "scfonts.h"
9
8
#include "selfield.h"
10
 
#include "selfield.moc"
11
 
#include <qstringlist.h>
 
9
 
 
10
#include <QPixmap>
 
11
#include <QHBoxLayout>
 
12
#include <QVBoxLayout>
 
13
#include <QSpacerItem>
 
14
#include <QListWidget>
 
15
#include <QListWidgetItem>
 
16
#include <QPushButton>
 
17
#include <QLabel>
12
18
 
13
19
#include "commonstrings.h"
14
 
 
15
 
extern QPixmap loadIcon(QString nam);
16
 
 
17
 
SelectFields::SelectFields( QWidget* parent, QString Felder, QString Own, ScribusDoc *Doc, int Art )
18
 
                : QDialog( parent, "sef", true, 0 )
 
20
#include "scfonts.h"
 
21
#include "util_icon.h"
 
22
 
 
23
SelectFields::SelectFields(QWidget* parent, QString Felder, QString Own, ScribusDoc *Doc, int Art) : QDialog(parent)
19
24
{
20
 
        setCaption( tr( "Select Fields" ) );
21
 
        setIcon(loadIcon("AppIcon.png"));
 
25
        setModal(true);
 
26
        setWindowTitle( tr( "Select Fields" ) );
 
27
        setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));
22
28
        FTyp = Art;
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);
26
38
 
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)
32
44
        {
33
45
                PageItem* item = Doc->Items->at(se);
34
46
                if (Art < 2)
35
47
                {
36
48
                        if ((item->isAnnotation()) && (item->annotation().Type() > 1))
37
 
                                AvailFields->insertItem(item->itemName());
 
49
                                AvailFields->addItem(item->itemName());
38
50
                }
39
51
                else
40
52
                {
41
53
                        if ((item->isAnnotation()) && (item->annotation().Type() == Art) && (item->itemName() != Own))
42
 
                                AvailFields->insertItem(item->itemName());
 
54
                                AvailFields->addItem(item->itemName());
43
55
                }
44
56
        }
45
57
        Layout1->addWidget( AvailFields );
47
59
 
48
60
        if (Art > 1)
49
61
        {
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 ) );
65
81
                QStringList pfol;
66
 
                pfol = pfol.split(",", Felder);
 
82
                pfol = Felder.split(",", QString::SkipEmptyParts);
67
83
                if (pfol.count() > 0)
68
84
                {
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());
71
87
                }
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()));
79
95
        }
80
96
        SelectFieldsLayout->addLayout( Layout5 );
81
97
        S_Fields = "";
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*)));
96
114
}
97
115
 
98
116
void SelectFields::SetRetVal()
101
119
        if (FTyp > 1)
102
120
        {
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();
107
125
        }
108
126
        else
109
 
                S_Fields = AvailFields->currentText();
 
127
                S_Fields = AvailFields->currentItem()->text();
110
128
        accept();
111
129
}
112
130
 
113
131
void SelectFields::RemoveSel()
114
132
{
115
 
        SelFields->removeItem(SelFields->currentItem());
 
133
        QListWidgetItem *it = SelFields->takeItem(SelFields->currentRow());
 
134
        delete it;
116
135
        SelFields->clearSelection();
117
136
        if (SelFields->count() == 0)
118
137
                FromSel->setEnabled(false);
122
141
{
123
142
        if (SelFields->count() != 0)
124
143
        {
125
 
                if (SelFields->findItem(AvailFields->currentText()) == NULL)
126
 
                        SelFields->insertItem(AvailFields->currentText());
 
144
                if (SelFields->findItems(AvailFields->currentItem()->text(), Qt::MatchExactly).count() == 0)
 
145
                        SelFields->addItem(AvailFields->currentItem()->text());
127
146
        }
128
147
        else
129
 
                SelFields->insertItem(AvailFields->currentText());
 
148
                SelFields->addItem(AvailFields->currentItem()->text());
130
149
}
131
150
 
132
 
void SelectFields::SelAField(QListBoxItem *c)
 
151
void SelectFields::SelAField(QListWidgetItem *c)
133
152
{
134
153
        if ((c != NULL) && (FTyp > 1))
135
154
        {
139
158
        }
140
159
}
141
160
 
142
 
void SelectFields::SelEField(QListBoxItem *c)
 
161
void SelectFields::SelEField(QListWidgetItem *c)
143
162
{
144
163
        if (c != NULL)
145
164
        {