1 | #include <qiconview.h>
|
---|
2 | #include <qdragobject.h>
|
---|
3 | #include <qlayout.h>
|
---|
4 | #include <qmultilineedit.h>
|
---|
5 |
|
---|
6 | #include "dnd.h"
|
---|
7 | #include "styledbutton.h"
|
---|
8 | #include "listview.h"
|
---|
9 | #include "iconview.h"
|
---|
10 |
|
---|
11 | DnDDemo::DnDDemo( QWidget* parent, const char* name )
|
---|
12 | : DnDDemoBase( parent, name )
|
---|
13 | {
|
---|
14 | buttonPixmap1->setEditor( StyledButton::PixmapEditor );
|
---|
15 | buttonPixmap2->setEditor( StyledButton::PixmapEditor );
|
---|
16 | buttonPixmap3->setEditor( StyledButton::PixmapEditor );
|
---|
17 | buttonPixmap4->setEditor( StyledButton::PixmapEditor );
|
---|
18 |
|
---|
19 | multiLine1->setTextFormat( RichText );
|
---|
20 | multiLine1->setText( "<p><b>Faust</b> - <i>Goethe</i></p>"
|
---|
21 | "Habe nun, ach! Philosophie,<br>"
|
---|
22 | "Juristerei und Medizin,<br>"
|
---|
23 | "Und leider auch Theologie<br>"
|
---|
24 | "Durchaus studiert, mit heißem Bemühn.<br>"
|
---|
25 | "Da steh ich nun, ich armer Tor!<br>"
|
---|
26 | "Und bin so klug als wie zuvor;<br>"
|
---|
27 | "Heiße Magister, heiße Doktor gar<br>"
|
---|
28 | "Und ziehe schon an die zehen Jahr<br>"
|
---|
29 | "Herauf, herab und quer und krumm<br>"
|
---|
30 | "Meine Schüler an der Nase herum-<br>"
|
---|
31 | "Und sehe, daß wir nichts wissen können!<br>"
|
---|
32 | "Das will mir schier das Herz verbrennen.<br>"
|
---|
33 | "Zwar bin ich gescheiter als all die Laffen,<br>"
|
---|
34 | "Doktoren, Magister, Schreiber und Pfaffen;<br>"
|
---|
35 | "Mich plagen keine Skrupel noch Zweifel,<br>"
|
---|
36 | "Fürchte mich weder vor Hölle noch Teufel-<br>"
|
---|
37 | "Dafür ist mir auch alle Freud entrissen,<br>"
|
---|
38 | "Bilde mir nicht ein, was Rechts zu wissen,<br>"
|
---|
39 | "Bilde mir nicht ein, ich könnte was lehren,<br>"
|
---|
40 | "Die Menschen zu bessern und zu bekehren.<br>"
|
---|
41 | "Auch hab ich weder Gut noch Geld,<br>"
|
---|
42 | "Noch Ehr und Herrlichkeit der Welt;<br>"
|
---|
43 | "Es möchte kein Hund so länger leben!<br>"
|
---|
44 | "Drum hab ich mich der Magie ergeben,<br>"
|
---|
45 | "Ob mir durch Geistes Kraft und Mund<br>"
|
---|
46 | "Nicht manch Geheimnis würde kund;<br>"
|
---|
47 | "Daß ich nicht mehr mit saurem Schweiß<br>"
|
---|
48 | "Zu sagen brauche, was ich nicht weiß;<br>"
|
---|
49 | "Daß ich erkenne, was die Welt<br>"
|
---|
50 | "Im Innersten zusammenhält,<br>"
|
---|
51 | "Schau alle Wirkenskraft und Samen,<br>"
|
---|
52 | "Und tu nicht mehr in Worten kramen. <br>" );
|
---|
53 |
|
---|
54 | multiLine2->setTextFormat( RichText );
|
---|
55 | multiLine2->setText( "<p><b>To Milton</b> - <i>Oscar Wilde</i></p>"
|
---|
56 | "Milton! I think thy spirit hath passed away<br>"
|
---|
57 | "From these white cliffs and high-embattled towers;<br>"
|
---|
58 | "This gorgeous fiery-coloured world of ours<br>"
|
---|
59 | "Seems fallen into ashes dull and grey,<br>"
|
---|
60 | "And the age changed unto a mimic play<br>"
|
---|
61 | "Wherein we waste our else too-crowded hours:<br>"
|
---|
62 | "For all our pomp and pageantry and powers<br>"
|
---|
63 | "We are but fit to delve the common clay,<br>"
|
---|
64 | "Seeing this little isle on which we stand,<br>"
|
---|
65 | "This England, this sea-lion of the sea,<br>"
|
---|
66 | "By ignorant demagogues is held in fee,<br>"
|
---|
67 | "Who love her not: Dear God! is this the land<br>"
|
---|
68 | "Which bare a triple empire in her hand<br>"
|
---|
69 | "When Cromwell spake the word Democracy!<br>" );
|
---|
70 |
|
---|
71 |
|
---|
72 | items.insert( tr("copy"), IconItem( tr("Copy"), "editcopy.png" ) );
|
---|
73 | items.insert( tr("cut"), IconItem( tr("Cut"), "editcut.png" ));
|
---|
74 | items.insert( tr("paste"), IconItem( tr("Paste"), "editpaste.png" ));
|
---|
75 | items.insert( tr("raise"), IconItem( tr("Raise"), "editraise.png" ));
|
---|
76 | items.insert( tr("lower"), IconItem( tr("Lower"), "editlower.png" ));
|
---|
77 | items.insert( tr("new"), IconItem( tr("New"), "filenew.png" ));
|
---|
78 | items.insert( tr("load"), IconItem( tr("Load"), "fileopen.png" ));
|
---|
79 | items.insert( tr("save"), IconItem( tr("Save"), "filesave.png" ));
|
---|
80 | items.insert( tr("undo"), IconItem( tr("Undo"), "undo.png" ));
|
---|
81 | items.insert( tr("redo"), IconItem( tr("Redo"), "redo.png" ));
|
---|
82 | items.insert( tr("delete"), IconItem( tr("Delete"), "editdelete.png" ));
|
---|
83 | items.insert( tr("help"), IconItem( tr("Help"), "help.png" ));
|
---|
84 | items.insert( tr("home"), IconItem( tr("Home"), "home.png" ));
|
---|
85 |
|
---|
86 | listView->addColumn( tr("Actions"), 240 );
|
---|
87 | listView->setColumnWidthMode( 0, QListView::Maximum );
|
---|
88 |
|
---|
89 | QMap<QString,IconItem>::Iterator it;
|
---|
90 | for( it = items.begin(); it != items.end(); ++it ) {
|
---|
91 | IconItem item = it.data();
|
---|
92 |
|
---|
93 | QIconViewItem *iitem = new IconViewItem( iconView, item.name(), *item.pixmap(), it.key() );
|
---|
94 | iitem->setRenameEnabled( TRUE );
|
---|
95 | QListViewItem *litem = new ListViewItem( listView, item.name(), it.key() );
|
---|
96 | litem->setPixmap( 0, *item.pixmap() );
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 | DnDDemo::~DnDDemo()
|
---|
101 | {
|
---|
102 |
|
---|
103 | }
|
---|
104 |
|
---|
105 | IconItem::IconItem( const QString& name, const QString& icon )
|
---|
106 | {
|
---|
107 | _name = name;
|
---|
108 | _pixmap = loadPixmap( icon );
|
---|
109 | }
|
---|
110 |
|
---|
111 | QPixmap IconItem::loadPixmap( const QString& name )
|
---|
112 | {
|
---|
113 | QPixmap pix( "textdrawing/" + name );
|
---|
114 | return pix;
|
---|
115 | }
|
---|
116 |
|
---|
117 | IconItem DnDDemo::findItem( const QString& tag )
|
---|
118 | {
|
---|
119 | return items[ tag ];
|
---|
120 | }
|
---|