Card* Deck::drawCard() { if( ! m_deck.empty() ) { Card* card = m_deck.takeFirst(); emit deckChanged( m_deck.size() ); return card; } return nullptr; }
CollectionWindow::CollectionWindow(QWidget* parent) : QMainWindow(parent) , ui_() , collectionTableModel_() , itemDelegate_(new CollectionItemDelegate(collectionTableModel_)) , rootFilterNode_() { setWindowFlags(Qt::NoDropShadowWindowHint); ui_.setupUi(this); ui_.collectionTbl_->setItemDelegate(itemDelegate_.data()); ui_.collectionTbl_->setModel(&collectionTableModel_); ui_.collectionTbl_->setSortingEnabled(true); ui_.collectionTbl_->setSelectionBehavior(QAbstractItemView::SelectRows); ui_.collectionTbl_->horizontalHeader()->setSectionsMovable(true); ui_.collectionTbl_->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu); ui_.collectionTbl_->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui_.collectionTbl_->horizontalHeader(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(hideColumnsContextMenuRequested(QPoint))); connect(ui_.collectionTbl_, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(rowContextMenuRequested(QPoint))); connect(ui_.collectionTbl_->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(currentRowChanged(QModelIndex, QModelIndex))); connect(ui_.actionAdvancedFilter, SIGNAL(triggered()), this, SLOT(actionAdvancedFilter())); connect(ui_.actionEnableFilter, SIGNAL(triggered(bool)), this, SLOT(actionEnableFilter(bool))); connect(ui_.actionAddToCollection, SIGNAL(triggered()), this, SLOT(actionAddToCollection())); connect(ui_.actionRemoveFromCollection, SIGNAL(triggered()), this, SLOT(actionRemoveFromCollection())); connect(ui_.actionAddToDeck, SIGNAL(triggered()), this, SLOT(actionAddToDeck())); connect(ui_.actionRemoveFromDeck, SIGNAL(triggered()), this, SLOT(actionRemoveFromDeck())); connect(ui_.actionDownloadCardArt, SIGNAL(triggered()), this, SLOT(actionDownloadCardArt())); connect(ui_.actionFetchOnlineData, SIGNAL(triggered()), this, SLOT(actionFetchOnlineData())); connect(&collectionTableModel_, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex))); connect(&DeckManager::instance(), SIGNAL(deckChanged()), this, SLOT(updateUsedCount())); connect(this, SIGNAL(fontChanged()), ui_.collectionTbl_, SLOT(handleFontChanged())); ui_.statusBar->addPermanentWidget(new QLabel("Search: ")); QLabel* permanentStatusBarLabel = new QLabel(); ui_.statusBar->addPermanentWidget(permanentStatusBarLabel); connect(ui_.collectionTbl_, SIGNAL(searchStringChanged(QString)), permanentStatusBarLabel, SLOT(setText(QString))); }