void Grid::addWidget(const Widget::Ptr& widget, unsigned int row, unsigned int col, const Borders& borders, Alignment alignment) { // If the widget hasn't already been added then add it now if (std::find(getWidgets().begin(), getWidgets().end(), widget) == getWidgets().end()) add(widget); // Create the row if it did not exist yet if (m_gridWidgets.size() < row + 1) { m_gridWidgets.resize(row + 1); m_objBorders.resize(row + 1); m_objAlignment.resize(row + 1); } // Create the column if it did not exist yet if (m_gridWidgets[row].size() < col + 1) { m_gridWidgets[row].resize(col + 1, nullptr); m_objBorders[row].resize(col + 1); m_objAlignment[row].resize(col + 1); } // If this is a new row then reserve some space for it if (m_rowHeight.size() < row + 1) m_rowHeight.resize(row + 1, 0); // If this is the first row to have so many columns then reserve some space for it if (m_columnWidth.size() < col + 1) m_columnWidth.resize(col + 1, 0); // Add the widget to the grid m_gridWidgets[row][col] = widget; m_objBorders[row][col] = borders; m_objAlignment[row][col] = alignment; // Update the widgets updateWidgets(); // Automatically update the widgets when their size changes m_connectedCallbacks[widget] = widget->connect("SizeChanged", &Grid::updateWidgets, this); }
bool ColumnEdit::slotOk() { getWidgets(); if (_curr != _orig) { if (_orig.name.isEmpty()) _edit->insert(_curr); else _edit->update(_orig, _curr); } _orig = _curr; close(); return true; }
void ColumnEdit::slotReset() { getWidgets(); if (_curr != _orig) { QString msg = QString("Column \"%1\" has been changed. Are you\n" "sure you want to reset?").arg(_orig.name); int result = QMessageBox::warning(this, "Warning", msg, QMessageBox::No, QMessageBox::Yes); if (result != QMessageBox::Yes) return; } _curr = _orig; setWidgets(); }
void ColumnEdit::slotNext() { getWidgets(); if (_curr != _orig) { if (_orig.name.isEmpty()) _edit->insert(_curr); else _edit->update(_orig, _curr); } _curr.clear(); _orig.clear(); setWidgets(); _name->setFocus(); }
bool ColumnEdit::checkChanged() { getWidgets(); if (_curr != _orig) { QString message = QString("Column \"%1\" has been changed.\n" "Save changes?").arg(_curr.name); int result = QMessageBox::warning(this, "Warning", message, QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); if (result == QMessageBox::Yes) if (!slotOk()) return false; if (result == QMessageBox::Cancel) return false; } return true; }
bool ModelEdit::slotOk() { getWidgets(); if (_curr != _orig) { ServerConfig config; config.load(); QString dataDir = parseDir(config.dataDir); _curr.save(dataDir + "/models/" + _curr.version + ".xml"); if (_curr.version != _orig.version) QFile::remove(dataDir + "/models/" + _orig.version + ".xml"); // TODO: inform model_main_window of changes } _orig = _curr; close(); return true; }