From a11019a6a1d0c121f817562eab836f847a28bd8d Mon Sep 17 00:00:00 2001 From: Stathis Kamperis Date: Mon, 21 Jul 2008 23:18:00 +0300 Subject: [PATCH] Add support for rank list plus minor changes here and there --- qt/leleja/leleja.cpp | 19 +++++++++++++++++-- qt/leleja/leleja.h | 8 ++++++++ qt/leleja/leleja.ui | 8 ++++---- qt/leleja/myreportdialog.cpp | 20 +++++++++++++++++--- qt/leleja/myreportdialog.h | 8 ++++++++ 5 files changed, 54 insertions(+), 9 deletions(-) diff --git a/qt/leleja/leleja.cpp b/qt/leleja/leleja.cpp index be821cd..e222084 100644 --- a/qt/leleja/leleja.cpp +++ b/qt/leleja/leleja.cpp @@ -1,8 +1,12 @@ // akis.vasilias@vasilias-lights.gr #include #include +#include +#include + #include "leleja.h" #include "myreportdialog.h" +#include "myrank.h" Leleja::Leleja(QWidget *parent) : QDialog(parent) @@ -23,6 +27,19 @@ Leleja::Leleja(QWidget *parent) // Connect signals to slots connect(exitButton, SIGNAL(clicked()), this, SLOT(close())); + + // Populate rank list + myRankList << MyRank("Δόκιμος", "./insignia/GR-Army-WOb.gif"); + myRankList << MyRank("Ανθστής", "./insignia/GR-Army-WOa.gif"); + +#ifdef DEBUG + QTextStream qout(stdout); + for (int i = 0; i < myRankList.size(); i++) { + qout << "Rank = " << myRankList.at(i).getRankName() << "\t" + << "Image = " << myRankList.at(i).getImageFileName() << '\n'; + } +#endif + } Leleja::~Leleja() @@ -56,8 +73,6 @@ void Leleja::on_calcButton_clicked() std::cout << "Lelela::daysLeft = " << daysLeft << std::endl; std::cout << "Leleja::daysOff = " << daysOff << std::endl; - - // Validate user input if (dayinDate > QDate::currentDate()) { QMessageBox::warning(this, tr("Leleja reloaded"), diff --git a/qt/leleja/leleja.h b/qt/leleja/leleja.h index 6146857..aad8899 100644 --- a/qt/leleja/leleja.h +++ b/qt/leleja/leleja.h @@ -2,9 +2,14 @@ #define LELEJA_H #include +#include + #include "ui_leleja.h" +#include "myrank.h" #include "myreportdialog.h" +#define DEBUG + class Leleja : public QDialog, public Ui::Leleja { Q_OBJECT @@ -18,6 +23,9 @@ private slots: private: MyReportDialog *myreportdialog; + + // Rank list (it's populated inside the leleja's constructor) + QList myRankList; }; #endif // LELEJA_H diff --git a/qt/leleja/leleja.ui b/qt/leleja/leleja.ui index 2225054..dfe20e7 100644 --- a/qt/leleja/leleja.ui +++ b/qt/leleja/leleja.ui @@ -5,7 +5,7 @@ 0 0 - 355 + 375 119 @@ -17,13 +17,13 @@ - 355 + 375 0 - 355 + 375 200 @@ -35,7 +35,7 @@ 10 10 - 337 + 357 100 diff --git a/qt/leleja/myreportdialog.cpp b/qt/leleja/myreportdialog.cpp index bf00e06..69705bc 100644 --- a/qt/leleja/myreportdialog.cpp +++ b/qt/leleja/myreportdialog.cpp @@ -1,5 +1,6 @@ #include #include "myreportdialog.h" +#include "myrank.h" #include #include @@ -41,7 +42,7 @@ void MyReportDialog::drawMyPie(QPainter *painter) painter->setBrush(QBrush(Qt::red, Qt::SolidPattern)); painter->drawPie(0, 0, this->size().width(), - this->size().height(), + this->size().height() / 2, 0, ((float) m_daysLeft / m_totalDays) * 16 * 360); @@ -49,7 +50,7 @@ void MyReportDialog::drawMyPie(QPainter *painter) painter->setBrush(QBrush(Qt::blue, Qt::SolidPattern)); painter->drawPie(0, 0, this->size().width(), - this->size().height(), + this->size().height() / 2, ((float) m_daysLeft / m_totalDays) * 16 * 360, ((float) m_daysOff / m_totalDays) * 16 * 360); @@ -57,7 +58,7 @@ void MyReportDialog::drawMyPie(QPainter *painter) painter->setBrush(QBrush(Qt::green, Qt::SolidPattern)); painter->drawPie(0, 0, this->size().width(), - this->size().height(), + this->size().height() / 2, ((float) (m_daysLeft + m_daysOff) / m_totalDays) * 16 * 360, ((float) (m_totalDays - m_daysLeft - m_daysOff) / m_totalDays) * 16 * 360); } @@ -86,6 +87,16 @@ void MyReportDialog::drawMyLegend(QPainter *painter) painter->drawText(contentsRect(), Qt::AlignCenter, result); } +void MyReportDialog::drawMyRank(QPainter *painter) +{ + std::cout << "MyReportDialog::drawMyRank()\n"; + + // Draw rank image + // painter->drawImage(QPoint(this->size().width() / 2, + // this->size().height(), + // m_rank.m_image)); +} + void MyReportDialog::drawPixmap(void) { // Create a pixmap @@ -107,6 +118,9 @@ void MyReportDialog::drawPixmap(void) // Draw label drawMyLegend(&painter); + // Draw rank image + drawMyRank(&painter); + // This function won't invoke an immediate repaint, // instead it will schedule a paint event that will be processed, // whenever Qt returns to the main event loop. diff --git a/qt/leleja/myreportdialog.h b/qt/leleja/myreportdialog.h index 628dcbc..099d35b 100644 --- a/qt/leleja/myreportdialog.h +++ b/qt/leleja/myreportdialog.h @@ -4,6 +4,8 @@ #include #include +#include "myrank.h" + class MyReportDialog : public QDialog { Q_OBJECT @@ -26,9 +28,15 @@ protected: private: void drawMyLegend(QPainter *painter); void drawMyPie(QPainter *painter); + void drawMyRank(QPainter *painter); void drawPixmap(void); + // Off screen image representation that can be used as a paint device QPixmap m_pixmap; + + // Holds information regarding the rank (mark, name, etc) + MyRank m_rank; + unsigned int m_daysLeft; unsigned int m_daysOff; unsigned int m_totalDays; -- 2.11.4.GIT