Esempio n. 1
0
void LayerStack::resize(int top, int right, int bottom, int left)
{
	int newtop = -top;
	int newleft = -left;
	int newright = _width + right;
	int newbottom = _height + bottom;
	if(newtop >= newbottom || newleft >= newright) {
		qWarning() << "Invalid resize: borders reversed";
		return;
	}
	_width = newright - newleft;
	_height = newbottom - newtop;

	_xtiles = Tile::roundTiles(_width);
	_ytiles = Tile::roundTiles(_height);
	_cache = QPixmap(_width, _height);
	_dirtytiles = QBitArray(_xtiles*_ytiles, true);

	foreach(Layer *l, _layers)
		l->resize(top, right, bottom, left);

	if(left || top) {
		// Update annotation positions
		QPoint offset(left, top);
		foreach(Annotation *a, _annotations) {
			a->setRect(a->rect().translated(offset));
			emit annotationChanged(a->id());
		}
Esempio n. 2
0
void AnnotationState::addAnnotation(const Annotation &annotation)
{
	// Make sure ID is unique
	if(findById(annotation.id)>=0) {
		qWarning("Cannot add annotation: ID (%d) not unique!", annotation.id);
		return;
	}

	m_annotations.append(annotation);
	emit annotationChanged(annotation);
}
Esempio n. 3
0
void AnnotationState::changeAnnotation(int id, const QString &newtext, const QColor &bgcolor)
{
	int idx = findById(id);
	if(idx<0) {
		qWarning("Cannot change annotation: ID %d not found!", id);
		return;
	}
	m_annotations[idx].text = newtext;
	m_annotations[idx].background = bgcolor;
	emit annotationChanged(m_annotations[idx]);
}
Esempio n. 4
0
void AnnotationState::reshapeAnnotation(int id, const QRect &newrect)
{
	int idx = findById(id);
	if(idx<0) {
		qWarning("Cannot reshape annotation: ID %d not found!", id);
		return;
	}

	m_annotations[idx].rect = newrect;
	emit annotationChanged(m_annotations[idx]);
}
Esempio n. 5
0
DlgEditTokens::DlgEditTokens(CardDatabaseModel *_cardDatabaseModel, QWidget *parent)
    : QDialog(parent), currentCard(0), cardDatabaseModel(_cardDatabaseModel)
{
    nameLabel = new QLabel(tr("&Name:"));
    nameEdit = new QLineEdit;
    nameEdit->setEnabled(false);
    nameLabel->setBuddy(nameEdit);
    
    colorLabel = new QLabel(tr("C&olor:"));
    colorEdit = new QComboBox;
    colorEdit->addItem(tr("white"), "w");
    colorEdit->addItem(tr("blue"), "u");
    colorEdit->addItem(tr("black"), "b");
    colorEdit->addItem(tr("red"), "r");
    colorEdit->addItem(tr("green"), "g");
    colorEdit->addItem(tr("multicolor"), "m");
    colorEdit->addItem(tr("colorless"), QString());
    colorLabel->setBuddy(colorEdit);
    connect(colorEdit, SIGNAL(currentIndexChanged(int)), this, SLOT(colorChanged(int)));
    
    ptLabel = new QLabel(tr("&P/T:"));
    ptEdit = new QLineEdit;
    ptLabel->setBuddy(ptEdit);
    connect(ptEdit, SIGNAL(textChanged(QString)), this, SLOT(ptChanged(QString)));
    
    annotationLabel = new QLabel(tr("&Annotation:"));
    annotationEdit = new QLineEdit;
    annotationLabel->setBuddy(annotationEdit);
    connect(annotationEdit, SIGNAL(textChanged(QString)), this, SLOT(annotationChanged(QString)));
    
    QGridLayout *grid = new QGridLayout;
    grid->addWidget(nameLabel, 0, 0);
    grid->addWidget(nameEdit, 0, 1);
    grid->addWidget(colorLabel, 1, 0);
    grid->addWidget(colorEdit, 1, 1);
    grid->addWidget(ptLabel, 2, 0);
    grid->addWidget(ptEdit, 2, 1);
    grid->addWidget(annotationLabel, 3, 0);
    grid->addWidget(annotationEdit, 3, 1);
    
    QGroupBox *tokenDataGroupBox = new QGroupBox(tr("Token data"));
    tokenDataGroupBox->setLayout(grid);
    
    cardDatabaseDisplayModel = new CardDatabaseDisplayModel(this);
    cardDatabaseDisplayModel->setSourceModel(cardDatabaseModel);
    cardDatabaseDisplayModel->setIsToken(CardDatabaseDisplayModel::ShowTrue);
    
    chooseTokenView = new QTreeView;
    chooseTokenView->setModel(cardDatabaseDisplayModel);
    chooseTokenView->setUniformRowHeights(true);
    chooseTokenView->setRootIsDecorated(false);
    chooseTokenView->setAlternatingRowColors(true);
    chooseTokenView->setSortingEnabled(true);
    chooseTokenView->sortByColumn(0, Qt::AscendingOrder);
    chooseTokenView->resizeColumnToContents(0);
    chooseTokenView->header()->setStretchLastSection(false);
    chooseTokenView->header()->hideSection(1);
    chooseTokenView->header()->hideSection(2);
#if QT_VERSION < 0x050000
    chooseTokenView->header()->setResizeMode(3, QHeaderView::ResizeToContents);
    chooseTokenView->header()->setResizeMode(4, QHeaderView::ResizeToContents);
#else
    chooseTokenView->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
    chooseTokenView->header()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
#endif
    connect(chooseTokenView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(tokenSelectionChanged(QModelIndex, QModelIndex)));
    
    QAction *aAddToken = new QAction(tr("Add token"), this);
    aAddToken->setIcon(QIcon(":/resources/increment.svg"));
    connect(aAddToken, SIGNAL(triggered()), this, SLOT(actAddToken()));
    QAction *aRemoveToken = new QAction(tr("Remove token"), this);
    aRemoveToken->setIcon(QIcon(":/resources/decrement.svg"));
    connect(aRemoveToken, SIGNAL(triggered()), this, SLOT(actRemoveToken()));
    
    QToolBar *databaseToolBar = new QToolBar;
    databaseToolBar->addAction(aAddToken);
    databaseToolBar->addAction(aRemoveToken);
    
    QVBoxLayout *leftVBox = new QVBoxLayout;
    leftVBox->addWidget(chooseTokenView);
    leftVBox->addWidget(databaseToolBar);
    
    QHBoxLayout *hbox = new QHBoxLayout;
    hbox->addLayout(leftVBox);
    hbox->addWidget(tokenDataGroupBox);
    
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(hbox);
    mainLayout->addWidget(buttonBox);

    setLayout(mainLayout);
    setWindowTitle(tr("Edit tokens"));
}