src/main.cpp

changeset 351
9e3c1f838406
parent 350
676d0b43b577
child 352
59a31dd8a33a
equal deleted inserted replaced
350:676d0b43b577 351:9e3c1f838406
213 result = QObject::tr("<unnamed>"); 213 result = QObject::tr("<unnamed>");
214 } 214 }
215 return result; 215 return result;
216 } 216 }
217 217
218 void rebuildRecentFilesMenu(QMenu* menu, const QStringList& strings, QWidget* parent) 218 static void rebuildRecentFilesMenu(QMenu* menu, const QStringList& strings, QWidget* parent)
219 { 219 {
220 menu->clear(); 220 menu->clear();
221 for (const QString& path : strings) { 221 for (const QString& path : strings) {
222 QAction* action = new QAction{path, parent}; 222 QAction* action = new QAction{path, parent};
223 action->setData(path); 223 action->setData(path);
273 struct ToolWidgets 273 struct ToolWidgets
274 { 274 {
275 CircleToolOptionsWidget* circleToolOptions; 275 CircleToolOptionsWidget* circleToolOptions;
276 }; 276 };
277 277
278 void initializeTools(Ui_MainWindow* ui, ToolWidgets* toolWidgets, QWidget* parent) 278 static void initializeTools(Ui_MainWindow* ui, ToolWidgets* toolWidgets, QWidget* parent)
279 { 279 {
280 const struct 280 const struct
281 { 281 {
282 QString name, tooltip; 282 QString name, tooltip;
283 QPixmap icon; 283 QPixmap icon;
320 ui->toolWidgetStack->setCurrentIndex(i); 320 ui->toolWidgetStack->setCurrentIndex(i);
321 }); 321 });
322 } 322 }
323 } 323 }
324 324
325 constexpr bool sortModelIndexesByRow(const QModelIndex& a, const QModelIndex& b)
326 {
327 return a.row() < b.row();
328 }
329
330 std::vector<int> rows(const QModelIndexList& indexList)
331 {
332 std::vector<int> result;
333 result.reserve(unsigned_cast(indexList.size()));
334 for (const QModelIndex& index : indexList)
335 {
336 result.push_back(index.row());
337 }
338 return result;
339 }
340
341 static void about(QWidget* parent) 325 static void about(QWidget* parent)
342 { 326 {
343 QDialog dialog{parent}; 327 QDialog dialog{parent};
344 Ui_About ui; 328 Ui_About ui;
345 ui.setupUi(&dialog); 329 ui.setupUi(&dialog);
445 if (block.isValid()) { 429 if (block.isValid()) {
446 QTextCursor cursor{block}; 430 QTextCursor cursor{block};
447 cursor.select(QTextCursor::LineUnderCursor); 431 cursor.select(QTextCursor::LineUnderCursor);
448 cursor.insertText(modelElementToString(action.newElement)); 432 cursor.insertText(modelElementToString(action.newElement));
449 } 433 }
450 //model->assignAt(action.position, action.newElement); 434 //model->assignAt(action.position, actio邉󠄌n.newElement);
451 }, 435 },
452 }, action); 436 }, action);
453 437
454 }; 438 };
455 const auto openModelForEditing = [&](const ModelId modelId){ 439 const auto openModelForEditing = [&](const ModelId modelId){

mercurial