Mercurial > projects > qtd
comparison examples/draganddrop/dropsite/dropsitewindow.d @ 215:8aaa84d48451
Improve examples.
author | SokoL_SD |
---|---|
date | Tue, 14 Jul 2009 15:25:45 +0000 |
parents | 7ea67ec3cf29 |
children | 256ab6cb8e85 |
comparison
equal
deleted
inserted
replaced
214:11f1760d1700 | 215:8aaa84d48451 |
---|---|
39 ** | 39 ** |
40 ****************************************************************************/ | 40 ****************************************************************************/ |
41 | 41 |
42 module dropsitewindow; | 42 module dropsitewindow; |
43 | 43 |
44 version(Tango) { | 44 import std.string; |
45 import tango.text.Util; | |
46 import tango.text.Ascii; | |
47 import tango.text.convert.Format; | |
48 } else { | |
49 import std.string; | |
50 alias strip trim; | |
51 } | |
52 | 45 |
53 import qt.gui.QWidget; | 46 import qt.gui.QWidget; |
54 import qt.gui.QLabel; | 47 import qt.gui.QLabel; |
55 import qt.gui.QTableWidget; | 48 import qt.gui.QTableWidget; |
56 import qt.gui.QPushButton; | 49 import qt.gui.QPushButton; |
118 formatItem.setFlags(Qt.ItemIsEnabled); | 111 formatItem.setFlags(Qt.ItemIsEnabled); |
119 formatItem.setTextAlignment(Qt.AlignTop | Qt.AlignLeft); | 112 formatItem.setTextAlignment(Qt.AlignTop | Qt.AlignLeft); |
120 | 113 |
121 string text; | 114 string text; |
122 if (format == "text/plain") { | 115 if (format == "text/plain") { |
123 text = trim(mimeData.text()); | 116 text = strip(mimeData.text()); |
124 } else if (format == "text/html") { | 117 } else if (format == "text/html") { |
125 text = trim(mimeData.html()); | 118 text = strip(mimeData.html()); |
126 } else if (format == "text/uri-list") { | 119 } else if (format == "text/uri-list") { |
127 QUrl[] urlList = mimeData.urls(); | 120 QUrl[] urlList = mimeData.urls(); |
128 for (int i = 0; i < urlList.length && i < 32; ++i) { | 121 for (int i = 0; i < urlList.length && i < 32; ++i) { |
129 string url = urlList[i].path(); | 122 string url = urlList[i].path(); |
130 text ~= url ~ " "; | 123 text ~= url ~ " "; |
131 } | 124 } |
132 } else { | 125 } else { |
133 QByteArray data = mimeData.data(format); | 126 QByteArray data = mimeData.data(format); |
134 for (int i = 0; i < data.size() && i < 32; ++i) { | 127 for (int i = 0; i < data.size() && i < 32; ++i) { |
135 version(Tango) | 128 string hex = toupper(std.string.format("%x", data.at(i))); |
136 string hex = toUpper(Format("{0:x}", data.at(i))); | |
137 else | |
138 string hex = toupper(std.string.format("%x", data.at(i))); | |
139 text ~= hex ~ " "; | 129 text ~= hex ~ " "; |
140 } | 130 } |
141 } | 131 } |
142 | 132 |
143 int row = formatsTable.rowCount(); | 133 int row = formatsTable.rowCount(); |