Mercurial > projects > qtd
comparison examples/draganddrop/dropsite/dropsitewindow.d @ 206:aeeaae4dd540
'Dropsite' fixes for d2.
author | SokoL_SD |
---|---|
date | Tue, 14 Jul 2009 09:13:27 +0000 |
parents | 6aeaf24018d7 |
children | 7ea67ec3cf29 |
comparison
equal
deleted
inserted
replaced
205:3dadfee97421 | 206:aeeaae4dd540 |
---|---|
45 import tango.text.Util; | 45 import tango.text.Util; |
46 import tango.text.Ascii; | 46 import tango.text.Ascii; |
47 import tango.text.convert.Format: format = Format; | 47 import tango.text.convert.Format: format = Format; |
48 } else { | 48 } else { |
49 import std.string; | 49 import std.string; |
50 alias strip trim; | |
50 } | 51 } |
51 | 52 |
52 import qt.gui.QWidget; | 53 import qt.gui.QWidget; |
53 import qt.gui.QLabel; | 54 import qt.gui.QLabel; |
54 import qt.gui.QTableWidget; | 55 import qt.gui.QTableWidget; |
73 abstractLabel.adjustSize(); | 74 abstractLabel.adjustSize(); |
74 | 75 |
75 dropArea = new DropArea; | 76 dropArea = new DropArea; |
76 dropArea.changed.connect(&updateFormatsTable); | 77 dropArea.changed.connect(&updateFormatsTable); |
77 | 78 |
78 char[][] labels; | 79 string[] labels; |
79 labels ~= tr("Format"); | 80 labels ~= tr("Format"); |
80 labels ~= tr("Content"); | 81 labels ~= tr("Content"); |
81 | 82 |
82 formatsTable = new QTableWidget; | 83 formatsTable = new QTableWidget; |
83 formatsTable.setColumnCount(2); | 84 formatsTable.setColumnCount(2); |
110 { | 111 { |
111 formatsTable.setRowCount(0); | 112 formatsTable.setRowCount(0); |
112 if (!mimeData) | 113 if (!mimeData) |
113 return; | 114 return; |
114 | 115 |
115 foreach (char[] format; mimeData.formats()) { | 116 foreach (string format; mimeData.formats()) { |
116 QTableWidgetItem formatItem = new QTableWidgetItem(format); | 117 QTableWidgetItem formatItem = new QTableWidgetItem(format); |
117 formatItem.setFlags(Qt.ItemIsEnabled); | 118 formatItem.setFlags(Qt.ItemIsEnabled); |
118 formatItem.setTextAlignment(Qt.AlignTop | Qt.AlignLeft); | 119 formatItem.setTextAlignment(Qt.AlignTop | Qt.AlignLeft); |
119 | 120 |
120 char[] text; | 121 string text; |
121 if (format == "text/plain") { | 122 if (format == "text/plain") { |
122 text = trim(mimeData.text()); | 123 text = trim(mimeData.text()); |
123 } else if (format == "text/html") { | 124 } else if (format == "text/html") { |
124 text = trim(mimeData.html()); | 125 text = trim(mimeData.html()); |
125 } else if (format == "text/uri-list") { | 126 } else if (format == "text/uri-list") { |
126 QUrl[] urlList = mimeData.urls(); | 127 QUrl[] urlList = mimeData.urls(); |
127 for (int i = 0; i < urlList.length && i < 32; ++i) { | 128 for (int i = 0; i < urlList.length && i < 32; ++i) { |
128 char[] url = urlList[i].path(); | 129 string url = urlList[i].path(); |
129 text ~= url ~ " "; | 130 text ~= url ~ " "; |
130 } | 131 } |
131 } else { | 132 } else { |
132 QByteArray data = mimeData.data(format); | 133 QByteArray data = mimeData.data(format); |
133 for (int i = 0; i < data.size() && i < 32; ++i) { | 134 for (int i = 0; i < data.size() && i < 32; ++i) { |
134 char[] hex = toUpper(Format("{0:x}", data.at(i))); | 135 version(Tango) |
136 string hex = toUupper(Format("{0:x}", data.at(i))); | |
137 else | |
138 string hex = toupper(std.string.format("%x", data.at(i))); | |
135 text ~= hex ~ " "; | 139 text ~= hex ~ " "; |
136 } | 140 } |
137 } | 141 } |
138 | 142 |
139 int row = formatsTable.rowCount(); | 143 int row = formatsTable.rowCount(); |