comparison examples/draganddrop/dropsite/dropsitewindow.d @ 323:7a3c43424dca signals

make all examples compile with new signals/slots
author eldar_ins@eldar-laptop
date Mon, 28 Dec 2009 16:28:55 +0500
parents 256ab6cb8e85
children 31520b2c0b3c
comparison
equal deleted inserted replaced
322:7c2cf27391c4 323:7a3c43424dca
65 65
66 abstractLabel.setWordWrap(true); 66 abstractLabel.setWordWrap(true);
67 abstractLabel.adjustSize(); 67 abstractLabel.adjustSize();
68 68
69 dropArea = new DropArea; 69 dropArea = new DropArea;
70 connect!("changed")(dropArea, &updateFormatsTable); 70 connect(dropArea, "changed", this, "updateFormatsTable");
71 71
72 string[] labels; 72 string[] labels;
73 labels ~= tr("Format"); 73 labels ~= tr("Format");
74 labels ~= tr("Content"); 74 labels ~= tr("Content");
75 75
76 formatsTable = new QTableWidget; 76 formatsTable = new QTableWidget;
77 formatsTable.setColumnCount(2); 77 formatsTable.setColumnCount(2);
78 formatsTable.setEditTriggers(QAbstractItemView.NoEditTriggers); 78 formatsTable.setEditTriggers(QAbstractItemView.NoEditTriggers);
79 formatsTable.setHorizontalHeaderLabels(labels); 79 formatsTable.setHorizontalHeaderLabels(labels.toQList());
80 formatsTable.horizontalHeader().setStretchLastSection(true); 80 formatsTable.horizontalHeader().setStretchLastSection(true);
81 81
82 clearButton = new QPushButton(tr("Clear")); 82 clearButton = new QPushButton(tr("Clear"));
83 quitButton = new QPushButton(tr("Quit")); 83 quitButton = new QPushButton(tr("Quit"));
84 84
85 buttonBox = new QDialogButtonBox; 85 buttonBox = new QDialogButtonBox;
86 buttonBox.addButton(clearButton, QDialogButtonBox.ActionRole); 86 buttonBox.addButton(clearButton, QDialogButtonBox.ActionRole);
87 buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole); 87 buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole);
88 88
89 connect!("pressed")(quitButton, &close); 89 connect(quitButton, "pressed", this, "close");
90 connect!("pressed")(clearButton, &dropArea.clearArea); 90 connect(clearButton, "pressed", dropArea, "clearArea");
91 91
92 QVBoxLayout mainLayout = new QVBoxLayout; 92 QVBoxLayout mainLayout = new QVBoxLayout;
93 mainLayout.addWidget(abstractLabel); 93 mainLayout.addWidget(abstractLabel);
94 mainLayout.addWidget(dropArea); 94 mainLayout.addWidget(dropArea);
95 mainLayout.addWidget(formatsTable); 95 mainLayout.addWidget(formatsTable);
98 98
99 setWindowTitle(tr("Drop Site")); 99 setWindowTitle(tr("Drop Site"));
100 setMinimumSize(350, 500); 100 setMinimumSize(350, 500);
101 } 101 }
102 102
103 void updateFormatsTable(QMimeData mimeData) 103 void slot_updateFormatsTable(QMimeData mimeData)
104 { 104 {
105 formatsTable.setRowCount(0); 105 formatsTable.setRowCount(0);
106 if (!mimeData) 106 if (!mimeData)
107 return; 107 return;
108 108
115 if (format == "text/plain") { 115 if (format == "text/plain") {
116 text = strip(mimeData.text()); 116 text = strip(mimeData.text());
117 } else if (format == "text/html") { 117 } else if (format == "text/html") {
118 text = strip(mimeData.html()); 118 text = strip(mimeData.html());
119 } else if (format == "text/uri-list") { 119 } else if (format == "text/uri-list") {
120 QUrl[] urlList = mimeData.urls(); 120 auto urlList = mimeData.urls();
121 for (int i = 0; i < urlList.length && i < 32; ++i) { 121 for (int i = 0; i < urlList.length && i < 32; ++i) {
122 string url = urlList[i].path(); 122 string url = urlList[i].path();
123 text ~= url ~ " "; 123 text ~= url ~ " ";
124 } 124 }
125 } else { 125 } else {
146 QTableWidget formatsTable; 146 QTableWidget formatsTable;
147 147
148 QPushButton clearButton; 148 QPushButton clearButton;
149 QPushButton quitButton; 149 QPushButton quitButton;
150 QDialogButtonBox buttonBox; 150 QDialogButtonBox buttonBox;
151
152 mixin Q_OBJECT;
151 } 153 }