From atlantik-devel Tue Jan 21 02:36:44 2003 From: kde () office ! kde ! org Date: Tue, 21 Jan 2003 02:36:44 +0000 To: atlantik-devel Subject: [atlantik-cvs] CVS: kdegames/atlantik/libatlantikui board.cpp,1.96.6.2,1.96.6.3 board.h,1.59,1.59.6. X-MARC-Message: https://marc.info/?l=atlantik-devel&m=104311670420450 Update of /home/kde/kdegames/atlantik/libatlantikui In directory office:/tmp/cvs-serv22220/libatlantikui Modified Files: Tag: KDE_3_1_BRANCH board.cpp board.h estatedetails.cpp estatedetails.h Log Message: backport display, fix 52208 Index: board.cpp =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantikui/board.cpp,v retrieving revision 1.96.6.2 retrieving revision 1.96.6.3 diff -u -d -r1.96.6.2 -r1.96.6.3 --- board.cpp 20 Jan 2003 22:28:07 -0000 1.96.6.2 +++ board.cpp 21 Jan 2003 02:36:42 -0000 1.96.6.3 @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -95,8 +96,7 @@ return m_estateViews; } - -EstateView *AtlantikBoard::getEstateView(Estate *estate) +EstateView *AtlantikBoard::findEstateView(Estate *estate) { EstateView *estateView; for (QPtrListIterator i(m_estateViews); *i; ++i) @@ -196,7 +196,7 @@ QTimer::singleShot(100, this, SLOT(slotResizeAftermath())); } -void AtlantikBoard::playerChanged() +void AtlantikBoard::playerChanged(Player *player) { kdDebug() << "Board::playerChanged()" << endl; // TODO: implement decent AtlantikBoard::playerChanged to update tokens @@ -366,10 +366,8 @@ m_displayQueue.prepend(new QWidget(this)); break; case 1: - if (m_displayQueue.getFirst() == m_lastServerDisplay) - m_lastServerDisplay = 0; - m_displayQueue.removeFirst(); - m_displayQueue.prepend(new QWidget(this)); + if (EstateDetails *display = dynamic_cast(m_lastServerDisplay)) + display->setEstate(0); break; default: if (m_displayQueue.getFirst() == m_lastServerDisplay) @@ -380,79 +378,47 @@ updateCenter(); } -void AtlantikBoard::displayText(QString caption, QString body) -{ - BoardDisplay *bDisplay = new BoardDisplay(caption, body, this); - m_lastServerDisplay = bDisplay; - - if (m_displayQueue.getFirst() != m_lastServerDisplay) - m_displayQueue.removeFirst(); - - m_displayQueue.prepend(bDisplay); - updateCenter(); - - connect(bDisplay, SIGNAL(buttonCommand(QString)), this, SIGNAL(buttonCommand(QString))); - connect(bDisplay, SIGNAL(buttonClose()), this, SLOT(displayDefault())); -} - void AtlantikBoard::displayButton(QString command, QString caption, bool enabled) { - if (BoardDisplay *display = dynamic_cast(m_lastServerDisplay)) - display->addButton(command, caption, enabled); - else if (EstateDetails *display = dynamic_cast(m_lastServerDisplay)) + if (EstateDetails *display = dynamic_cast(m_lastServerDisplay)) display->addButton(command, caption, enabled); } void AtlantikBoard::addCloseButton() { - BoardDisplay *bDisplay = 0; EstateDetails *eDetails = 0; - if ((bDisplay = dynamic_cast(m_lastServerDisplay)) && bDisplay != m_displayQueue.getLast()) - bDisplay->addCloseButton(); - else if ((eDetails = dynamic_cast(m_lastServerDisplay)) && eDetails != m_displayQueue.getLast()) + if ((eDetails = dynamic_cast(m_lastServerDisplay)) && eDetails != m_displayQueue.getLast()) eDetails->addCloseButton(); } -void AtlantikBoard::insertEstateDetails(Estate *estate) +void AtlantikBoard::insertDetails(QString text, bool clearText, bool clearButtons, Estate *estate) { - if (!estate) - return; - EstateDetails *eDetails = 0; - // This might just be a update - if ((eDetails = dynamic_cast(m_lastServerDisplay)) && eDetails->estate() == estate) + if ((eDetails = dynamic_cast(m_lastServerDisplay))) { - eDetails->newUpdate(); + if (clearText) + eDetails->setText(text); + else + eDetails->appendText(text); + + if (clearButtons) + eDetails->clearButtons(); + + eDetails->setEstate(estate); return; } if (m_displayQueue.getFirst() != m_lastServerDisplay) m_displayQueue.removeFirst(); - else - { - if (BoardDisplay *display = dynamic_cast(m_lastServerDisplay)) - display->addCloseButton(); - else if (EstateDetails *display = dynamic_cast(m_lastServerDisplay)) - display->addCloseButton(); - } - eDetails = new EstateDetails(estate, this); + eDetails = new EstateDetails(estate, text, this); m_lastServerDisplay = eDetails; connect(eDetails, SIGNAL(buttonCommand(QString)), this, SIGNAL(buttonCommand(QString))); connect(eDetails, SIGNAL(buttonClose()), this, SLOT(displayDefault())); - // Don't overwrite possible chance cards or previous estates - int uid = 0; - if (BoardDisplay *display = dynamic_cast(m_displayQueue.getFirst())) - uid = 1; - else if (EstateDetails *display = dynamic_cast(m_displayQueue.getFirst())) - uid = 1; - - m_displayQueue.insert(uid, eDetails); - - if (uid == 0) - updateCenter(); + m_displayQueue.insert(0, eDetails); + updateCenter(); } void AtlantikBoard::prependEstateDetails(Estate *estate) @@ -460,7 +426,7 @@ if (!estate) return; - EstateDetails *eDetails = new EstateDetails(estate, this); + EstateDetails *eDetails = new EstateDetails(estate, QString::null, this); eDetails->addCloseButton(); if (m_displayQueue.getFirst() != m_lastServerDisplay) Index: board.h =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantikui/board.h,v retrieving revision 1.59 retrieving revision 1.59.6.1 diff -u -d -r1.59 -r1.59.6.1 --- board.h 25 Jul 2002 14:38:36 -0000 1.59 +++ board.h 21 Jan 2003 02:36:42 -0000 1.59.6.1 @@ -46,6 +46,7 @@ void addToken(Player *player, EstateView *location = 0); void indicateUnownedChanged(); QPtrList estateViews(); + EstateView *findEstateView(Estate *estate); QWidget *centerWidget(); public slots: @@ -53,12 +54,11 @@ void slotResizeAftermath(); private slots: - void playerChanged(); + void playerChanged(Player *player); void displayDefault(); - void displayText(QString caption, QString body); void displayButton(QString command, QString caption, bool enabled); void prependEstateDetails(Estate *); - void insertEstateDetails(Estate *); + void insertDetails(QString text, bool clearText, bool clearButtons, Estate *estate = 0); void addCloseButton(); signals: @@ -69,7 +69,6 @@ void resizeEvent(QResizeEvent *); private: - EstateView *getEstateView(Estate *estate); void moveToken(Token *, int destination); void updateCenter(); Index: estatedetails.cpp =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantikui/estatedetails.cpp,v retrieving revision 1.12.4.1 retrieving revision 1.12.4.2 diff -u -d -r1.12.4.1 -r1.12.4.2 --- estatedetails.cpp 27 Dec 2002 01:37:20 -0000 1.12.4.1 +++ estatedetails.cpp 21 Jan 2003 02:36:42 -0000 1.12.4.2 @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include #include @@ -33,34 +35,45 @@ #include "estatedetails.h" #include "estatedetails.moc" -EstateDetails::EstateDetails(Estate *estate, QWidget *parent, const char *name) : QWidget(parent, name) +EstateDetails::EstateDetails(Estate *estate, QString text, QWidget *parent, const char *name) : QWidget(parent, name) { - m_estate = estate; - setPaletteBackgroundColor(m_estate->bgColor()); - m_pixmap = 0; + m_quartzBlocks = 0; b_recreate = true; + m_recreateQuartz = true; + + m_estate = 0; - m_quartzBlocks = 0; m_closeButton = 0; m_buttons.setAutoDelete(true); - m_recreateQuartz = true; m_mainLayout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint()); Q_CHECK_PTR(m_mainLayout); - m_mainLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding)); + m_mainLayout->addItem(new QSpacerItem(KDialog::spacingHint(), KDialog::spacingHint()+50, QSizePolicy::Fixed, QSizePolicy::Minimum)); + + m_infoListView = new KListView(this, "infoListView"); + m_infoListView->addColumn(m_estate ? m_estate->name() : QString::null); + m_infoListView->setSorting(-1); + m_mainLayout->addWidget(m_infoListView); + + if (!text.isEmpty()) + appendText(text); m_buttonBox = new QHBoxLayout(this, 0, KDialog::spacingHint()); m_mainLayout->addItem(m_buttonBox); m_buttonBox->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); + + setEstate(estate); + setPaletteBackgroundColor(m_estate ? m_estate->bgColor() : Qt::white); } EstateDetails::~EstateDetails() { delete m_pixmap; delete m_quartzBlocks; + delete m_infoListView; } void EstateDetails::paintEvent(QPaintEvent *) @@ -103,7 +116,7 @@ painter.setPen(Qt::black); - painter.setBrush(m_estate->bgColor()); + painter.setBrush(m_estate ? m_estate->bgColor() : Qt::white); painter.drawRect(rect()); /* @@ -112,96 +125,77 @@ painter.drawPixmap( (width() - icon->width())/2, (height() - icon->height())/2, *icon); */ - int titleHeight = 50; - QColor titleColor = (m_estate->color().isValid() ? m_estate->color() : m_estate->bgColor().light(80)); - - KPixmap* quartzBuffer = new KPixmap; - quartzBuffer->resize(25, (height()/4)-2); - - QPainter quartzPainter; - quartzPainter.begin(quartzBuffer, this); + if (m_estate) + { + int titleHeight = 50; + QColor titleColor = (m_estate->color().isValid() ? m_estate->color() : m_estate->bgColor().light(80)); - painter.setBrush(titleColor); - painter.drawRect(0, 0, width(), titleHeight); + KPixmap* quartzBuffer = new KPixmap; + quartzBuffer->resize(25, (height()/4)-2); - if (m_quartzBlocks) - { - quartzPainter.drawPixmap(0, 0, *m_quartzBlocks); - painter.drawPixmap(1, 1, *quartzBuffer); - } + QPainter quartzPainter; + quartzPainter.begin(quartzBuffer, this); - if (m_estate->houses() > 0) - { - int titleWidth = width()/2; + painter.setBrush(titleColor); + painter.drawRect(0, 0, width(), titleHeight); - if (m_estate->houses() == 5) - { - // Hotel - painter.setBrush(redHotel); - painter.drawRect(2, 2, titleWidth-4, titleHeight-4); - } - else + if (m_quartzBlocks) { - // Houses - painter.setBrush(greenHouse); - int h = titleHeight-4, w = titleWidth-4; - for ( unsigned int i=0 ; i < m_estate->houses() ; i++ ) - painter.drawRect(2+(i*(w+2)), 2, w, h); + quartzPainter.drawPixmap(0, 0, *m_quartzBlocks); + painter.drawPixmap(1, 1, *quartzBuffer); } - } - quartzPainter.end(); - delete quartzBuffer; - - // TODO: steal blur code from kicker/taskbar/taskcontainer.cpp + if (m_estate->houses() > 0) + { + int titleWidth = width() / 5; - // Estate name - painter.setPen(Qt::white); - int fontSize = KGlobalSettings::generalFont().pointSize(); - if (fontSize == -1) - fontSize = KGlobalSettings::generalFont().pixelSize(); + if (m_estate->houses() == 5) + { + // Hotel + painter.setBrush(redHotel); + painter.drawRect(2, 2, titleWidth-4, titleHeight-4); + } + else + { + // Houses + painter.setBrush(greenHouse); + int h = titleHeight-4, w = titleWidth-4; + for ( unsigned int i=0 ; i < m_estate->houses() ; i++ ) + painter.drawRect(2+(i*(w+2)), 2, w, h); + } + } - painter.setFont(QFont(KGlobalSettings::generalFont().family(), fontSize * 2, QFont::Bold)); - painter.drawText(KDialog::marginHint(), KDialog::marginHint(), width()-KDialog::marginHint(), titleHeight, Qt::AlignJustify, m_estate->name()); + quartzPainter.end(); + delete quartzBuffer; - painter.setPen(Qt::black); + // TODO: steal blur code from kicker/taskbar/taskcontainer.cpp - int xText = 0; - // Estate group - if (m_estate->estateGroup()) - { - xText = titleHeight - fontSize - KDialog::marginHint(); - painter.setFont(QFont(KGlobalSettings::generalFont().family(), fontSize, QFont::Bold)); - painter.drawText(5, xText, width()-10, titleHeight, Qt::AlignRight, m_estate->estateGroup()->name().upper()); - } + // Estate name + painter.setPen(Qt::white); + int fontSize = KGlobalSettings::generalFont().pointSize(); + if (fontSize == -1) + fontSize = KGlobalSettings::generalFont().pixelSize(); - xText = titleHeight + fontSize + 5; - painter.setFont(QFont(KGlobalSettings::generalFont().family(), fontSize, QFont::Normal)); + painter.setFont(QFont(KGlobalSettings::generalFont().family(), fontSize * 2, QFont::Bold)); + painter.drawText(KDialog::marginHint(), KDialog::marginHint(), width()-KDialog::marginHint(), titleHeight, Qt::AlignJustify, m_estate->name()); - // Price - if (m_estate->price()) - { - painter.drawText(5, xText, i18n("Price: %1").arg(m_estate->price())); - xText += (fontSize + 5); - } + painter.setPen(Qt::black); - // Owner, houses, isMortgaged - if (m_estate->canBeOwned()) - { - painter.drawText(5, xText, i18n("Owner: %1").arg(m_estate->owner() ? m_estate->owner()->name() : i18n("unowned"))); - xText += (fontSize + 5); + int xText = 0; - if (m_estate->isOwned()) + // Estate group + if (m_estate->estateGroup()) { - painter.drawText(5, xText, i18n("Houses: %1").arg(m_estate->houses())); - xText += (fontSize + 5); - - painter.drawText(5, xText, i18n("Mortgaged: %1").arg(m_estate->isMortgaged() ? i18n("Yes") : i18n("No"))); - xText += (fontSize + 5); + xText = titleHeight - fontSize - KDialog::marginHint(); + painter.setFont(QFont(KGlobalSettings::generalFont().family(), fontSize, QFont::Bold)); + painter.drawText(5, xText, width()-10, titleHeight, Qt::AlignRight, m_estate->estateGroup()->name().upper()); } - } + xText = titleHeight + fontSize + 5; + painter.setFont(QFont(KGlobalSettings::generalFont().family(), fontSize, QFont::Normal)); + } b_recreate = false; + } bitBlt(this, 0, 0, m_pixmap); } @@ -234,7 +228,64 @@ connect(m_closeButton, SIGNAL(pressed()), this, SIGNAL(buttonClose())); } -void EstateDetails::newUpdate() +void EstateDetails::setEstate(Estate *estate) +{ + if (m_estate != estate) + { + m_estate = estate; + + QString columnText = m_estate ? m_estate->name() : QString::null; + m_infoListView->setColumnText(0, columnText); + + // Price + if (m_estate) + { + QListViewItem *infoText = 0; + + if (m_estate->price()) + { + infoText = new QListViewItem(m_infoListView, m_infoListView->lastItem(), i18n("Price: %1").arg(m_estate->price())); + infoText->setPixmap(0, QPixmap(SmallIcon("info"))); + } + + // Owner, houses, isMortgaged + if (m_estate && m_estate->canBeOwned()) + { + infoText = new QListViewItem(m_infoListView, m_infoListView->lastItem(), i18n("Owner: %1").arg(m_estate->owner() ? m_estate->owner()->name() : i18n("unowned"))); + infoText->setPixmap(0, QPixmap(SmallIcon("info"))); + + if (m_estate->isOwned()) + { + infoText = new QListViewItem(m_infoListView, m_infoListView->lastItem(), i18n("Houses: %1").arg(m_estate->houses())); + infoText->setPixmap(0, QPixmap(SmallIcon("info"))); + + infoText = new QListViewItem(m_infoListView, m_infoListView->lastItem(), i18n("Mortgaged: %1").arg(m_estate->isMortgaged() ? i18n("Yes") : i18n("No"))); + infoText->setPixmap(0, QPixmap(SmallIcon("info"))); + } + } + } + + b_recreate = true; + update(); + } +} + +void EstateDetails::setText(QString text) +{ + m_infoListView->clear(); + appendText(text); +} + +void EstateDetails::appendText(QString text) +{ + QListViewItem *infoText = new QListViewItem(m_infoListView, m_infoListView->lastItem(), text); + if (text.contains("rolls")) + infoText->setPixmap(0, QPixmap(SmallIcon("roll"))); + else + infoText->setPixmap(0, QPixmap(SmallIcon("atlantik"))); +} + +void EstateDetails::clearButtons() { if (m_closeButton) { @@ -245,10 +296,6 @@ // Delete buttons m_buttons.clear(); m_buttonCommandMap.clear(); - - // Redraw details - b_recreate = true; - update(); } void EstateDetails::buttonPressed() Index: estatedetails.h =================================================================== RCS file: /home/kde/kdegames/atlantik/libatlantikui/estatedetails.h,v retrieving revision 1.7.4.1 retrieving revision 1.7.4.2 diff -u -d -r1.7.4.1 -r1.7.4.2 --- estatedetails.h 27 Dec 2002 01:37:20 -0000 1.7.4.1 +++ estatedetails.h 21 Jan 2003 02:36:42 -0000 1.7.4.2 @@ -20,10 +20,12 @@ #include class QPixmap; +class QString; class QHBoxLayout; class QVBoxLayout; class QVGroupBox; +class KListView; class KPixmap; class KPushButton; @@ -35,13 +37,16 @@ Q_OBJECT public: - EstateDetails(Estate *estate, QWidget *parent, const char *name = 0); + EstateDetails(Estate *estate, QString text, QWidget *parent, const char *name = 0); ~EstateDetails(); Estate *estate() { return m_estate; } void addButton(const QString command, const QString caption, bool enabled); void addCloseButton(); - void newUpdate(); + void setEstate(Estate *estate); + void setText(QString text); + void appendText(QString text); + void clearButtons(); protected: void paintEvent(QPaintEvent *); @@ -58,6 +63,7 @@ Estate *m_estate; QPixmap *m_pixmap; KPixmap *m_quartzBlocks; + KListView *m_infoListView; KPushButton *m_closeButton; bool b_recreate, m_recreateQuartz; QVBoxLayout *m_mainLayout; _______________________________________________ atlantik-cvs mailing list atlantik-cvs@mail.kde.org http://mail.kde.org/mailman/listinfo/atlantik-cvs