MCPcopy Create free account
hub / github.com/bupticybee/TexasSolver / resizeEvent

Method resizeEvent

htmltableview.cpp:106–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void HtmlTableView::resizeEvent(QResizeEvent* ev){
107 if(model() != NULL){
108 int num_columns = this->model()->columnCount(QModelIndex());
109 int num_rows = this->model()->rowCount(QModelIndex());
110 if (num_columns > 0) {
111 int width = ev->size().width();
112 int used_width = 0;
113 // Set our widths to be a percentage of the available width
114 for (int i = 0; i < num_columns - 1; i++) {
115 //int column_width = width / num_columns;
116 int column_width = (int)((float)width * (i + 1) / num_columns) - (int)((float)width * (i) / num_columns);
117 this->setColumnWidth(i, column_width);
118 used_width += column_width;
119 }
120
121 // Set our last column to the remaining width
122 this->setColumnWidth(num_columns - 1, width - used_width);
123 }
124 if (num_columns > 0) {
125 int height = ev->size().height();
126 int used_height = 0;
127 for (int i = 0; i < num_columns - 1; i++) {
128 //int column_height = height / num_rows;
129 int column_height = (int)((float)height * (i + 1) / num_rows) - (int)((float)height * (i) / num_rows);
130 this->setRowHeight(i, column_height);
131 used_height += column_height;
132 }
133 this->setRowHeight(num_columns - 1, height - used_height);
134 }
135 }
136 QTableView::resizeEvent(ev);
137}

Callers 1

triger_resizeMethod · 0.95

Calls 3

sizeMethod · 0.80
columnCountMethod · 0.45
rowCountMethod · 0.45

Tested by

no test coverage detected