reverted back to original deck editor layout but including filtertree
the original layout is actually more space efficient if using CardFrame instead of CardInfoWidget and reducing the size of the deck editor toolbar. this commit also removes the old search feature by removing the search button and the clear search button. the clear search menu item is left in place, however it now clears the filtertree. finally, the stretch factor for the right frame in the main layout was reduced to zero so that the card database gets priority for extra space. this makes more sense because the deck editor does not actually need very much horizontal space.
This commit is contained in:
parent
16d30fb9e1
commit
c786e180c3
9 changed files with 80 additions and 125 deletions
|
@ -158,10 +158,12 @@ void CardDatabaseDisplayModel::clearSearch()
|
|||
cardText.clear();
|
||||
cardTypes.clear();
|
||||
cardColors.clear();
|
||||
if (filterTree != NULL)
|
||||
filterTree->clear();
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void CardDatabaseDisplayModel::setFilterTree(const FilterTree *filterTree)
|
||||
void CardDatabaseDisplayModel::setFilterTree(FilterTree *filterTree)
|
||||
{
|
||||
if (this->filterTree != NULL)
|
||||
disconnect(this->filterTree, 0, this, 0);
|
||||
|
|
|
@ -38,10 +38,10 @@ private:
|
|||
FilterBool isToken;
|
||||
QString cardNameBeginning, cardName, cardText;
|
||||
QSet<QString> cardNameSet, cardTypes, cardColors;
|
||||
const FilterTree *filterTree;
|
||||
FilterTree *filterTree;
|
||||
public:
|
||||
CardDatabaseDisplayModel(QObject *parent = 0);
|
||||
void setFilterTree(const FilterTree *filterTree);
|
||||
void setFilterTree(FilterTree *filterTree);
|
||||
void setIsToken(FilterBool _isToken) { isToken = _isToken; invalidate(); }
|
||||
void setCardNameBeginning(const QString &_beginning) { cardNameBeginning = _beginning; invalidate(); }
|
||||
void setCardName(const QString &_cardName) { cardName = _cardName; invalidate(); }
|
||||
|
|
|
@ -5,15 +5,12 @@
|
|||
#include "carddatabase.h"
|
||||
#include "main.h"
|
||||
|
||||
CardFrame::CardFrame(const QString &cardName, QWidget *parent, Qt::WindowFlags flags)
|
||||
: QLabel(parent, flags)
|
||||
CardFrame::CardFrame(const QString &cardName, QWidget *parent)
|
||||
: QLabel(parent)
|
||||
, info(0)
|
||||
{
|
||||
this->setAlignment(Qt::AlignCenter);
|
||||
|
||||
setFrameStyle(QFrame::Panel | QFrame::Raised);
|
||||
setFixedWidth(250);
|
||||
|
||||
setMaximumWidth(250);
|
||||
setCard(db->getCard(cardName));
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ private:
|
|||
CardInfo *info;
|
||||
|
||||
public:
|
||||
CardFrame(const QString &cardName = QString(), QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
CardFrame(const QString &cardName = QString(), QWidget *parent = 0);
|
||||
QString getCardName() const;
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -328,3 +328,9 @@ bool FilterTree::acceptsCard(const CardInfo *info) const
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FilterTree::clear()
|
||||
{
|
||||
while(childCount() > 0)
|
||||
deleteAt(0);
|
||||
}
|
||||
|
|
|
@ -27,23 +27,18 @@ public:
|
|||
virtual bool isLeaf() const { return false; }
|
||||
virtual const char *textCStr() const { return text().toStdString().c_str(); }
|
||||
virtual void nodeChanged() const {
|
||||
printf("%s -> ", textCStr());
|
||||
if (parent() != NULL) parent()->nodeChanged();
|
||||
}
|
||||
virtual void preInsertChild(const FilterTreeNode *p, int i) const {
|
||||
//printf("%s -> ", textCStr());
|
||||
if (parent() != NULL) parent()->preInsertChild(p, i);
|
||||
}
|
||||
virtual void postInsertChild(const FilterTreeNode *p, int i) const {
|
||||
//printf("%s -> ", textCStr());
|
||||
if (parent() != NULL) parent()->postInsertChild(p, i);
|
||||
}
|
||||
virtual void preRemoveChild(const FilterTreeNode *p, int i) const {
|
||||
printf("%s -> ", textCStr());
|
||||
if (parent() != NULL) parent()->preRemoveChild(p, i);
|
||||
}
|
||||
virtual void postRemoveChild(const FilterTreeNode *p, int i) const {
|
||||
printf("%s -> ", textCStr());
|
||||
if (parent() != NULL) parent()->postRemoveChild(p, i);
|
||||
}
|
||||
};
|
||||
|
@ -139,6 +134,13 @@ private:
|
|||
CardFilter::Type type);
|
||||
|
||||
bool testAttr(const CardInfo *info, const LogicMap *lm) const;
|
||||
|
||||
void nodeChanged() const { emit changed(); }
|
||||
void preInsertChild(const FilterTreeNode *p, int i) const { emit preInsertRow(p, i); }
|
||||
void postInsertChild(const FilterTreeNode *p, int i) const { emit postInsertRow(p, i); }
|
||||
void preRemoveChild(const FilterTreeNode *p, int i) const { emit preRemoveRow(p, i); }
|
||||
void postRemoveChild(const FilterTreeNode *p, int i) const { emit postRemoveRow(p, i); }
|
||||
|
||||
public:
|
||||
FilterTree();
|
||||
~FilterTree();
|
||||
|
@ -153,13 +155,8 @@ public:
|
|||
QString text() const { return QString("root"); }
|
||||
int index() const { return 0; }
|
||||
|
||||
void nodeChanged() const { printf("root\n"); emit changed(); }
|
||||
void preInsertChild(const FilterTreeNode *p, int i) const { emit preInsertRow(p, i); }
|
||||
void postInsertChild(const FilterTreeNode *p, int i) const { emit postInsertRow(p, i); }
|
||||
void preRemoveChild(const FilterTreeNode *p, int i) const { printf("root\n"); emit preRemoveRow(p, i); }
|
||||
void postRemoveChild(const FilterTreeNode *p, int i) const { printf("root\n"); emit postRemoveRow(p, i); }
|
||||
|
||||
bool acceptsCard(const CardInfo *info) const;
|
||||
void clear();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,7 @@ private:
|
|||
public:
|
||||
FilterTreeModel(QObject *parent = 0);
|
||||
~FilterTreeModel();
|
||||
const FilterTree *filterTree() const { return fTree; }
|
||||
FilterTree *filterTree() const { return fTree; }
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "carddatabase.h"
|
||||
#include "carddatabasemodel.h"
|
||||
#include "decklistmodel.h"
|
||||
#include "dlg_cardsearch.h"
|
||||
#include "cardinfowidget.h"
|
||||
#include "dlg_load_deck_from_clipboard.h"
|
||||
#include "dlg_edit_tokens.h"
|
||||
#include "main.h"
|
||||
|
@ -33,20 +33,9 @@
|
|||
#include "pending_command.h"
|
||||
#include "pb/response.pb.h"
|
||||
#include "pb/command_deck_upload.pb.h"
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QStyle>
|
||||
#include <QMouseEvent>
|
||||
#include <QDesktopWidget>
|
||||
#include "filtertreemodel.h"
|
||||
#include "cardframe.h"
|
||||
#include "filterbuilder.h"
|
||||
//#include "carditem.h"
|
||||
//#include "carddatabase.h"
|
||||
#include "main.h"
|
||||
#include "settingscache.h"
|
||||
#include "filtertreemodel.h"
|
||||
|
||||
void SearchLineEdit::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
|
@ -58,9 +47,6 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event)
|
|||
TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
||||
: Tab(_tabSupervisor, parent), modified(false)
|
||||
{
|
||||
aSearch = new QAction(QString(), this);
|
||||
aSearch->setIcon(QIcon(":/resources/icon_search.svg"));
|
||||
connect(aSearch, SIGNAL(triggered()), this, SLOT(actSearch()));
|
||||
aClearSearch = new QAction(QString(), this);
|
||||
aClearSearch->setIcon(QIcon(":/resources/icon_clearsearch.svg"));
|
||||
connect(aClearSearch, SIGNAL(triggered()), this, SLOT(actClearSearch()));
|
||||
|
@ -70,16 +56,15 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
searchLabel->setBuddy(searchEdit);
|
||||
connect(searchEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &)));
|
||||
connect(searchEdit, SIGNAL(returnPressed()), this, SLOT(actAddCard()));
|
||||
QToolButton *searchButton = new QToolButton;
|
||||
searchButton->setDefaultAction(aSearch);
|
||||
QToolButton *clearSearchButton = new QToolButton;
|
||||
clearSearchButton->setDefaultAction(aClearSearch);
|
||||
|
||||
QToolBar *deckEditToolBar = new QToolBar;
|
||||
deckEditToolBar->setOrientation(Qt::Horizontal);
|
||||
deckEditToolBar->setIconSize(QSize(24, 24));
|
||||
|
||||
QHBoxLayout *searchLayout = new QHBoxLayout;
|
||||
searchLayout->addWidget(deckEditToolBar);
|
||||
searchLayout->addWidget(searchLabel);
|
||||
searchLayout->addWidget(searchEdit);
|
||||
searchLayout->addWidget(searchButton);
|
||||
searchLayout->addWidget(clearSearchButton);
|
||||
|
||||
databaseModel = new CardDatabaseModel(db, this);
|
||||
databaseDisplayModel = new CardDatabaseDisplayModel(this);
|
||||
|
@ -98,16 +83,33 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
connect(databaseView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actAddCard()));
|
||||
searchEdit->setTreeView(databaseView);
|
||||
|
||||
cardInfo = new CardFrame();
|
||||
cardInfo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
QVBoxLayout *leftFrame = new QVBoxLayout;
|
||||
leftFrame->addLayout(searchLayout);
|
||||
leftFrame->addWidget(databaseView);
|
||||
|
||||
QToolBar *verticalToolBar = new QToolBar;
|
||||
verticalToolBar->setOrientation(Qt::Horizontal);
|
||||
verticalToolBar->setIconSize(QSize(24, 24));
|
||||
QHBoxLayout *verticalToolBarLayout = new QHBoxLayout;
|
||||
//verticalToolBarLayout->addStretch();
|
||||
verticalToolBarLayout->addWidget(verticalToolBar);
|
||||
//verticalToolBarLayout->addStretch();
|
||||
cardInfo = new CardFrame();
|
||||
filterModel = new FilterTreeModel();
|
||||
databaseDisplayModel->setFilterTree(filterModel->filterTree());
|
||||
filterView = new QTreeView;
|
||||
filterView->setModel(filterModel);
|
||||
filterView->setMaximumWidth(250);
|
||||
filterView->setUniformRowHeights(true);
|
||||
filterView->setHeaderHidden(true);
|
||||
filterView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(filterModel, SIGNAL(layoutChanged()), filterView, SLOT(expandAll()));
|
||||
connect(filterView, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||
this, SLOT(filterViewCustomContextMenu(const QPoint &)));
|
||||
FilterBuilder *filterBuilder = new FilterBuilder;
|
||||
filterBuilder->setMaximumWidth(250);
|
||||
connect(filterBuilder, SIGNAL(add(const CardFilter *)), filterModel, SLOT(addFilter(const CardFilter *)));
|
||||
|
||||
QVBoxLayout *filter = new QVBoxLayout;
|
||||
filter->addWidget(filterBuilder, 0, Qt::AlignTop);
|
||||
filter->addWidget(filterView, 10);
|
||||
|
||||
QVBoxLayout *middleFrame = new QVBoxLayout;
|
||||
middleFrame->addWidget(cardInfo, 0, Qt::AlignTop);
|
||||
middleFrame->addLayout(filter, 10);
|
||||
|
||||
deckModel = new DeckListModel(this);
|
||||
connect(deckModel, SIGNAL(deckHashChanged()), this, SLOT(updateHash()));
|
||||
|
@ -133,6 +135,9 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
grid->addWidget(nameLabel, 0, 0);
|
||||
grid->addWidget(nameEdit, 0, 1);
|
||||
|
||||
grid->addWidget(commentsLabel, 1, 0);
|
||||
grid->addWidget(commentsEdit, 1, 1);
|
||||
|
||||
grid->addWidget(hashLabel1, 2, 0);
|
||||
grid->addWidget(hashLabel, 2, 1);
|
||||
|
||||
|
@ -153,49 +158,15 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
deckToolbarLayout->addWidget(deckToolBar);
|
||||
deckToolbarLayout->addStretch();
|
||||
|
||||
QVBoxLayout *deckFrame = new QVBoxLayout;
|
||||
deckFrame->addLayout(grid);
|
||||
deckFrame->addWidget(deckView, 10);
|
||||
deckFrame->addLayout(deckToolbarLayout);
|
||||
QVBoxLayout *rightFrame = new QVBoxLayout;
|
||||
rightFrame->addLayout(grid);
|
||||
rightFrame->addWidget(deckView, 10);
|
||||
rightFrame->addLayout(deckToolbarLayout);
|
||||
|
||||
QHBoxLayout *topFrame = new QHBoxLayout;
|
||||
topFrame->addWidget(cardInfo, 10);
|
||||
topFrame->addLayout(deckFrame);
|
||||
|
||||
QVBoxLayout *botFrame = new QVBoxLayout;
|
||||
QGridLayout *searchAndButtons = new QGridLayout;
|
||||
searchAndButtons->addLayout(verticalToolBarLayout, 0, 0);
|
||||
searchAndButtons->addLayout(searchLayout, 0, 1);
|
||||
botFrame->addLayout(searchAndButtons);
|
||||
|
||||
filterModel = new FilterTreeModel();
|
||||
databaseDisplayModel->setFilterTree(filterModel->filterTree());
|
||||
filterView = new QTreeView;
|
||||
filterView->setModel(filterModel);
|
||||
filterView->setMaximumWidth(250);
|
||||
filterView->setUniformRowHeights(true);
|
||||
filterView->setHeaderHidden(true);
|
||||
filterView->setExpandsOnDoubleClick(false);
|
||||
filterView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(filterModel, SIGNAL(layoutChanged()), filterView, SLOT(expandAll()));
|
||||
connect(filterView, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||
this, SLOT(filterViewCustomContextMenu(const QPoint &)));
|
||||
FilterBuilder *filterBuilder = new FilterBuilder;
|
||||
filterBuilder->setMaximumWidth(250);
|
||||
connect(filterBuilder, SIGNAL(add(const CardFilter *)), filterModel, SLOT(addFilter(const CardFilter *)));
|
||||
|
||||
QVBoxLayout *filter = new QVBoxLayout;
|
||||
filter->addWidget(filterBuilder, 0, Qt::AlignTop);
|
||||
filter->addWidget(filterView);
|
||||
|
||||
QHBoxLayout *dbFrame = new QHBoxLayout;
|
||||
dbFrame->addLayout(filter);
|
||||
dbFrame->addWidget(databaseView);
|
||||
botFrame->addLayout(dbFrame);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(topFrame, 10);
|
||||
mainLayout->addLayout(botFrame, 10);
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->addLayout(leftFrame, 10);
|
||||
mainLayout->addLayout(middleFrame);
|
||||
mainLayout->addLayout(rightFrame);
|
||||
setLayout(mainLayout);
|
||||
|
||||
aNewDeck = new QAction(QString(), this);
|
||||
|
@ -249,7 +220,6 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
dbMenu->addAction(aEditSets);
|
||||
dbMenu->addAction(aEditTokens);
|
||||
dbMenu->addSeparator();
|
||||
dbMenu->addAction(aSearch);
|
||||
dbMenu->addAction(aClearSearch);
|
||||
addTabMenu(dbMenu);
|
||||
|
||||
|
@ -269,14 +239,12 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
aDecrement->setIcon(QIcon(":/resources/decrement.svg"));
|
||||
connect(aDecrement, SIGNAL(triggered()), this, SLOT(actDecrement()));
|
||||
|
||||
verticalToolBar->addAction(aAddCard);
|
||||
verticalToolBar->addAction(aAddCardToSideboard);
|
||||
verticalToolBar->addAction(aRemoveCard);
|
||||
verticalToolBar->addAction(aIncrement);
|
||||
verticalToolBar->addAction(aDecrement);
|
||||
verticalToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
|
||||
dlgCardSearch = new DlgCardSearch(this);
|
||||
deckEditToolBar->addAction(aAddCard);
|
||||
deckEditToolBar->addAction(aAddCardToSideboard);
|
||||
deckEditToolBar->addAction(aRemoveCard);
|
||||
deckEditToolBar->addAction(aIncrement);
|
||||
deckEditToolBar->addAction(aDecrement);
|
||||
deckEditToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
|
||||
retranslateUi();
|
||||
|
||||
|
@ -290,7 +258,6 @@ TabDeckEditor::~TabDeckEditor()
|
|||
|
||||
void TabDeckEditor::retranslateUi()
|
||||
{
|
||||
aSearch->setText(tr("&Search..."));
|
||||
aClearSearch->setText(tr("&Clear search"));
|
||||
searchLabel->setText(tr("&Search for:"));
|
||||
|
||||
|
@ -299,11 +266,11 @@ void TabDeckEditor::retranslateUi()
|
|||
hashLabel1->setText(tr("Hash:"));
|
||||
|
||||
aUpdatePrices->setText(tr("&Update prices"));
|
||||
aUpdatePrices->setShortcut(tr("Ctrl+U"));
|
||||
|
||||
aNewDeck->setText(tr("&New deck"));
|
||||
aLoadDeck->setText(tr("&Load deck..."));
|
||||
aSaveDeck->setText(tr("&Save deck"));
|
||||
aUpdatePrices->setShortcut(tr("Ctrl+U"));
|
||||
|
||||
aNewDeck->setText(tr("&New deck"));
|
||||
aLoadDeck->setText(tr("&Load deck..."));
|
||||
aSaveDeck->setText(tr("&Save deck"));
|
||||
aSaveDeckAs->setText(tr("Save deck &as..."));
|
||||
aLoadDeckFromClipboard->setText(tr("Load deck from cl&ipboard..."));
|
||||
aSaveDeckToClipboard->setText(tr("Save deck to clip&board"));
|
||||
|
@ -532,17 +499,6 @@ void TabDeckEditor::actEditTokens()
|
|||
db->saveToFile(settingsCache->getTokenDatabasePath(), true);
|
||||
}
|
||||
|
||||
void TabDeckEditor::actSearch()
|
||||
{
|
||||
if (dlgCardSearch->exec()) {
|
||||
searchEdit->clear();
|
||||
databaseDisplayModel->setCardName(dlgCardSearch->getCardName());
|
||||
databaseDisplayModel->setCardText(dlgCardSearch->getCardText());
|
||||
databaseDisplayModel->setCardTypes(dlgCardSearch->getCardTypes());
|
||||
databaseDisplayModel->setCardColors(dlgCardSearch->getCardColors());
|
||||
}
|
||||
}
|
||||
|
||||
void TabDeckEditor::actClearSearch()
|
||||
{
|
||||
databaseDisplayModel->clearSearch();
|
||||
|
|
|
@ -12,7 +12,6 @@ class QTreeView;
|
|||
class QTableView;
|
||||
class CardFrame;
|
||||
class QTextEdit;
|
||||
class DlgCardSearch;
|
||||
class QLabel;
|
||||
class DeckLoader;
|
||||
class Response;
|
||||
|
@ -50,7 +49,6 @@ private slots:
|
|||
void actEditSets();
|
||||
void actEditTokens();
|
||||
|
||||
void actSearch();
|
||||
void actClearSearch();
|
||||
|
||||
void actAddCard();
|
||||
|
@ -83,13 +81,12 @@ private:
|
|||
QTextEdit *commentsEdit;
|
||||
QLabel *hashLabel1;
|
||||
QLabel *hashLabel;
|
||||
DlgCardSearch *dlgCardSearch;
|
||||
FilterTreeModel *filterModel;
|
||||
QTreeView *filterView;
|
||||
|
||||
QMenu *deckMenu, *dbMenu;
|
||||
QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aAnalyzeDeck, *aClose;
|
||||
QAction *aEditSets, *aEditTokens, *aSearch, *aClearSearch;
|
||||
QAction *aEditSets, *aEditTokens, *aClearSearch;
|
||||
QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement, *aUpdatePrices;
|
||||
|
||||
bool modified;
|
||||
|
|
Loading…
Reference in a new issue