void DeckView::sort() { makeSnapshot(); mainDeck->sort(); extraDeck->sort(); sideDeck->sort(); }
void DeckView::loadDeck(QString lines, QString _name, bool local) { if(waiting) { return; } int load = ++timestamp; makeSnapshot(false); mainDeck->clearDeck(); extraDeck->clearDeck(); sideDeck->clearDeck(); deckStatus.name = _name; deckStatus.isLocal = local; deckStatus.modified = !local; waiting = true; setReady(false); auto thread = new ItemThread(load, lines, this); connect(thread, &ItemThread::finishLoad, this, &DeckView::loadFinished); connect(thread, &ItemThread::finished, thread, &ItemThread::deleteLater); connect(this, &DeckView::destroyed, thread, &ItemThread::quit); thread->start(); }
void GUISUMOAbstractView::checkSnapshots() { std::map<SUMOTime, std::string>::iterator snapIt = mySnapshots.find(getCurrentTimeStep()); if (snapIt != mySnapshots.end()) { std::string error = makeSnapshot(snapIt->second); if (error != "") { WRITE_WARNING(error); } } }
DeckView::DeckView(QWidget *parent) : QWidget(parent), timestamp(0), waiting(false), sideHidden(false) { if(config->bg) { setStyleSheet("color: white; font-size: 16px"); } else { setStyleSheet("font-size: 16px"); } toolbar = new QToolBar; toolbar->setStyleSheet("color: black; font-size: 12px"); undoAction = new QAction(toolbar); undoAction->setIcon(QIcon(":/icons/undo.png")); undoAction->setToolTip(config->getStr("action", "undo", "撤销")); toolbar->addAction(undoAction); redoAction = new QAction(toolbar); redoAction->setIcon(QIcon(":/icons/redo.png")); redoAction->setToolTip(config->getStr("action", "redo", "重做")); toolbar->addAction(redoAction); toolbar->addSeparator(); auto newAction = new QAction(toolbar); newAction->setIcon(QIcon(":/icons/new.png")); newAction->setToolTip(config->getStr("action", "new", "新建")); toolbar->addAction(newAction); auto saveAction = new QAction(toolbar); saveAction->setIcon(QIcon(":/icons/save.png")); saveAction->setToolTip(config->getStr("action", "save", "保存")); toolbar->addAction(saveAction); auto saveAsAction = new QAction(toolbar); saveAsAction->setIcon(QIcon(":/icons/saveas.png")); saveAsAction->setToolTip(config->getStr("action", "saveas", "另存为")); toolbar->addAction(saveAsAction); auto printAction = new QAction(toolbar); printAction->setIcon(QIcon(":/icons/print.png")); printAction->setToolTip(config->getStr("action", "print", "截图")); toolbar->addAction(printAction); toolbar->addSeparator(); auto deleteAction = new QAction(toolbar); deleteAction->setIcon(QIcon(":/icons/delete.png")); deleteAction->setToolTip(config->getStr("action", "delete", "删除卡组")); toolbar->addAction(deleteAction); toolbar->addSeparator(); abortAction = new QAction(toolbar); abortAction->setIcon(QIcon(":/icons/abort.png")); abortAction->setToolTip(config->getStr("action", "abort", "中止")); abortAction->setEnabled(false); toolbar->addAction(abortAction); toolbar->addSeparator(); auto hideButton = new QToolButton; hideButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); auto hideAction = new QAction("Side", hideButton); hideAction->setIcon(QIcon(":/icons/side.png")); hideButton->addAction(hideAction); hideButton->setDefaultAction(hideAction); toolbar->addWidget(hideButton); auto spacer = new QWidget; spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); toolbar->addWidget(spacer); toolbar->addSeparator(); auto sortAction = new QAction(toolbar); sortAction->setIcon(QIcon(":/icons/sort.png")); sortAction->setToolTip(config->getStr("action", "sort", "排序")); toolbar->addAction(sortAction); auto shuffleAction = new QAction(toolbar); shuffleAction->setIcon(QIcon(":/icons/shuffle.png")); shuffleAction->setToolTip(config->getStr("action", "shuffle", "打乱")); toolbar->addAction(shuffleAction); auto clearAction = new QAction(toolbar); clearAction->setIcon(QIcon(":/icons/clear.png")); clearAction->setToolTip(config->getStr("action", "clear", "清空")); toolbar->addAction(clearAction); toolbar->addSeparator(); auto homeAction = new QAction(toolbar); homeAction->setIcon(QIcon(":/icons/home.png")); homeAction->setToolTip(config->getStr("action", "home", "主页")); toolbar->addAction(homeAction); auto helpAction = new QAction(toolbar); helpAction->setIcon(QIcon(":/icons/help.png")); helpAction->setToolTip(config->getStr("action", "help", "帮助")); toolbar->addAction(helpAction); mainDeck = new DeckWidget(nullptr, 4, 10); auto notExtraFilter = [](quint32 id) { auto card = cardPool->getCard(id); return card && !card->inExtra(); }; mainDeck->filter = notExtraFilter; auto t1 = new DeckSizeLabel(config->getStr("label", "main", "主卡组")); auto mt = new MainDeckLabel; extraDeck = new DeckWidget(nullptr, 1, 10); auto extraFilter = [](quint32 id) { auto card = cardPool->getCard(id); return card && card->inExtra(); }; extraDeck->filter = extraFilter; sideDeck = new DeckWidget(nullptr, 1, 10); auto t2 = new DeckSizeLabel(config->getStr("label", "extra", "额外卡组")); auto et = new ExtraDeckLabel; st = new DeckSizeLabel(config->getStr("label", "side", "副卡组")); auto extFilter = [this](quint32 id) { int sum = 0; sum += mainDeck->countCard(id); sum += extraDeck->countCard(id); sum += sideDeck->countCard(id); return sum < limitCards->getLimit(id); }; mainDeck->extFilter = extFilter; extraDeck->extFilter = extFilter; sideDeck->extFilter = extFilter; auto snapshotMaker = [this]() { makeSnapshot(); }; mainDeck->makeSnapShot = snapshotMaker; extraDeck->makeSnapShot = snapshotMaker; sideDeck->makeSnapShot = snapshotMaker; connect(mainDeck, &DeckWidget::sizeChanged, t1, &DeckSizeLabel::changeSize); connect(mainDeck, &DeckWidget::deckChanged, mt, &MainDeckLabel::deckChanged); connect(mainDeck, &DeckWidget::currentIdChanged, this, &DeckView::currentIdChanged); connect(extraDeck, &DeckWidget::sizeChanged, t2, &DeckSizeLabel::changeSize); connect(extraDeck, &DeckWidget::deckChanged, et, &ExtraDeckLabel::deckChanged); connect(extraDeck, &DeckWidget::currentIdChanged, this, &DeckView::currentIdChanged); connect(sideDeck, &DeckWidget::sizeChanged, st, &DeckSizeLabel::changeSize); connect(sideDeck, &DeckWidget::currentIdChanged, this, &DeckView::currentIdChanged); connect(sortAction, &QAction::triggered, this, &DeckView::sort); connect(clearAction, &QAction::triggered, this, &DeckView::clearDeck); connect(helpAction, &QAction::triggered, this, &DeckView::help); connect(mainDeck, &DeckWidget::clickId, this, &DeckView::clickId); connect(extraDeck, &DeckWidget::clickId, this, &DeckView::clickId); connect(sideDeck, &DeckWidget::clickId, this, &DeckView::clickId); connect(shuffleAction, &QAction::triggered, mainDeck, &DeckWidget::shuffle); connect(undoAction, &QAction::triggered, this, &DeckView::undo); connect(redoAction, &QAction::triggered, this, &DeckView::redo); connect(saveAction, &QAction::triggered, this, &DeckView::saveSlot); connect(saveAsAction, &QAction::triggered, this, &DeckView::save); connect(newAction, &QAction::triggered, this, &DeckView::newDeck); connect(deleteAction, &QAction::triggered, this, &DeckView::deleteDeck); connect(abortAction, &QAction::triggered, this, &DeckView::abort); connect(homeAction, &QAction::triggered, this, &DeckView::home); connect(printAction, &QAction::triggered, this, &DeckView::print); connect(hideAction, &QAction::triggered, this, &DeckView::hideSide); connect(mainDeck, &DeckWidget::details, this, &DeckView::details); connect(extraDeck, &DeckWidget::details, this, &DeckView::details); connect(sideDeck, &DeckWidget::details, this, &DeckView::details); auto vbox = new QVBoxLayout; auto hbox = new QHBoxLayout; vbox->addWidget(toolbar); hbox->addWidget(t1); hbox->addWidget(mt); vbox->addLayout(hbox); vbox->addWidget(mainDeck, 4); hbox = new QHBoxLayout; hbox->addWidget(t2); hbox->addWidget(et); vbox->addLayout(hbox); vbox->addWidget(extraDeck, 1); vbox->addWidget(st); vbox->addWidget(sideDeck, 1); setLayout(vbox); updateButtons(); }
ProcessList::ProcessList() { makeSnapshot(); }