From 3d5735bcd701a0806b57e202a5ad9497cc136c2f Mon Sep 17 00:00:00 2001 From: Vladimir Date: Sun, 19 Dec 2010 20:27:08 +0500 Subject: [PATCH] Character's list on EditorTabFont connected to FontContainer. --- classes/bitmapcontainer.cpp | 4 ++-- classes/fontcontainer.cpp | 9 ++++++--- controls/editortabfont.cpp | 6 ++++++ controls/editortabfont.h | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/classes/bitmapcontainer.cpp b/classes/bitmapcontainer.cpp index 7bf2263..ae651a2 100644 --- a/classes/bitmapcontainer.cpp +++ b/classes/bitmapcontainer.cpp @@ -9,8 +9,8 @@ BitmapContainer::BitmapContainer(QObject *parent) : QObject(parent) { //this->mImage = NULL; - this->mImage = new QImage(":/images/template"); - this->mImage = new QImage(this->mImage->scaled(20, 10)); + //this->mImage = new QImage(":/images/template"); + this->mImage = new QImage(QImage(":/images/template").scaled(20, 10)); //this->createNew(10, 10); } //----------------------------------------------------------------------------- diff --git a/classes/fontcontainer.cpp b/classes/fontcontainer.cpp index 2d04fcb..cfaddeb 100644 --- a/classes/fontcontainer.cpp +++ b/classes/fontcontainer.cpp @@ -23,9 +23,12 @@ QImage *FontContainer::image(const QString &key) //----------------------------------------------------------------------------- void FontContainer::setImage(const QString &key, QImage *image) { - QImage *imageOld = this->mImageMap.value(key); - this->mImageMap.remove(key); - delete imageOld; + if (this->mImageMap.contains(key)) + { + QImage *imageOld = this->mImageMap.value(key); + this->mImageMap.remove(key); + delete imageOld; + } this->mImageMap.insert(key, image); emit this->imageChanged(key); } diff --git a/controls/editortabfont.cpp b/controls/editortabfont.cpp index 082e859..c599eca 100644 --- a/controls/editortabfont.cpp +++ b/controls/editortabfont.cpp @@ -59,6 +59,11 @@ void EditorTabFont::on_editor_dataChanged() emit this->dataChanged(); } //----------------------------------------------------------------------------- +void EditorTabFont::on_listWidgetCharacters_currentTextChanged(const QString &value) +{ + this->mEditor->selectImage(value); +} +//----------------------------------------------------------------------------- bool EditorTabFont::load(const QString &fileName) { bool result = false; @@ -190,6 +195,7 @@ void EditorTabFont::assignFontCharacters(const QString &chars, for (int i = 0; i < chars.count(); i++) { this->ui->listWidgetCharacters->addItem(QString(chars.at(i))); + this->mContainer->setImage(QString(chars.at(i)), new QImage(":/images/template")); } } //----------------------------------------------------------------------------- diff --git a/controls/editortabfont.h b/controls/editortabfont.h index 040f430..9e8efa5 100644 --- a/controls/editortabfont.h +++ b/controls/editortabfont.h @@ -52,6 +52,7 @@ private: private slots: void on_editor_dataChanged(); + void on_listWidgetCharacters_currentTextChanged(const QString &value); signals: void dataChanged(); };