| 119 | public: |
| 120 | ~TreeWidget() { fl = true; } |
| 121 | TreeWidget(File* file, bool& fl, QWidget* parent = nullptr) |
| 122 | : QTreeWidget(nullptr) |
| 123 | , fl(fl = false) |
| 124 | { |
| 125 | setAlternatingRowColors(true); |
| 126 | setAnimated(true); |
| 127 | setUniformRowHeights(true); |
| 128 | |
| 129 | setWindowTitle(DxfObj::tr("Section HEADER")); |
| 130 | setColumnCount(2); |
| 131 | auto iPar = file->header().cbegin(); |
| 132 | QList<QTreeWidgetItem*> items; |
| 133 | while (iPar != file->header().cend()) { |
| 134 | items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(iPar->first))); |
| 135 | { |
| 136 | auto iVal = iPar->second.cbegin(); |
| 137 | while (iVal != iPar->second.cend()) { |
| 138 | items.last()->addChild(new QTreeWidgetItem(static_cast<QTreeWidget*>(nullptr), |
| 139 | { QString::number(iVal->first), iVal->second.toString() })); |
| 140 | ++iVal; |
| 141 | } |
| 142 | } |
| 143 | ++iPar; |
| 144 | } |
| 145 | insertTopLevelItems(0, items); |
| 146 | setWindowFlag(Qt::WindowStaysOnTopHint, true); |
| 147 | expandAll(); |
| 148 | setGeometry({ parent->mapToGlobal(QPoint()), parent->size() }); |
| 149 | |
| 150 | { |
| 151 | setIconSize(QSize(24, 24)); |
| 152 | const int w = indentation(); |
| 153 | const int h = rowHeight(model()->index(0, 0, QModelIndex())); |
| 154 | QImage i(w, h, QImage::Format_ARGB32); |
| 155 | QPainter p(&i); |
| 156 | p.setPen(QColor(128, 128, 128)); |
| 157 | // │ |
| 158 | i.fill(Qt::transparent); |
| 159 | p.drawLine(w >> 1, /**/ 0, w >> 1, /**/ h); |
| 160 | i.save("settings/vline.png", "PNG"); |
| 161 | // ├─ |
| 162 | p.drawLine(w >> 1, h >> 1, /**/ w, h >> 1); |
| 163 | i.save("settings/branch-more.png", "PNG"); |
| 164 | // └─ |
| 165 | i.fill(Qt::transparent); |
| 166 | p.drawLine(w >> 1, /**/ 0, w >> 1, h >> 1); |
| 167 | p.drawLine(w >> 1, h >> 1, /**/ w, h >> 1); |
| 168 | i.save("settings/branch-end.png", "PNG"); |
| 169 | QFile file(":/qtreeviewstylesheet/QTreeView.qss"); |
| 170 | file.open(QFile::ReadOnly); |
| 171 | setStyleSheet(file.readAll()); |
| 172 | header()->setMinimumHeight(h); |
| 173 | } |
| 174 | } |
| 175 | // QWidget interface |
| 176 | protected: |
| 177 | void hideEvent(QHideEvent* event) override |