# HG changeset patch # User Teemu Piippo # Date 1433696106 -10800 # Node ID 0b3a5bc4e8a8ab088c25693d3ffb49158c1725cc # Parent a5b53cc104362a72fc8200e40b9b1802ac8006f7 VersionGuiEntry is now a proper class. Release versions are now bolded in the version table. diff -r a5b53cc10436 -r 0b3a5bc4e8a8 CMakeLists.txt --- a/CMakeLists.txt Sun Jun 07 19:15:12 2015 +0300 +++ b/CMakeLists.txt Sun Jun 07 19:55:06 2015 +0300 @@ -27,6 +27,7 @@ config/configwindow.cpp config/addversionprompt.cpp config/main.cpp + config/versionguientry.cpp ) set (ZCINEMA_HEADERS @@ -36,6 +37,7 @@ commonlib/version.h config/addversionprompt.h config/configwindow.h + config/versionguientry.h launcher/demo.h launcher/prompts.h ) diff -r a5b53cc10436 -r 0b3a5bc4e8a8 config/addversionprompt.cpp --- a/config/addversionprompt.cpp Sun Jun 07 19:15:12 2015 +0300 +++ b/config/addversionprompt.cpp Sun Jun 07 19:55:06 2015 +0300 @@ -20,6 +20,7 @@ #include #include "addversionprompt.h" #include "configwindow.h" +#include "versionguientry.h" #include "ui_addversion.h" // @@ -36,9 +37,9 @@ connect (ui.buttonBox, SIGNAL (rejected()), this, SLOT (reject())); connect (ui.findExeButton, SIGNAL (clicked()), this, SLOT (findExePath())); - ui.nameField->setText (entry->name); - ui.exePathField->setText (entry->pathItem->text()); - ui.releaseCheckbox->setChecked (entry->isRelease); + ui.nameField->setText (entry->name()); + ui.exePathField->setText (entry->pathItem()->text()); + ui.releaseCheckbox->setChecked (entry->isRelease()); } // @@ -47,10 +48,9 @@ void AddVersionPrompt::acceptPressed() { - m_entry->name = ui.nameField->text(); - m_entry->isRelease = ui.releaseCheckbox->isChecked(); - m_entry->labelItem->setText (m_entry->name); - m_entry->pathItem->setText (ui.exePathField->text()); + m_entry->setName (ui.nameField->text()); + m_entry->setRelease (ui.releaseCheckbox->isChecked()); + m_entry->pathItem()->setText (ui.exePathField->text()); accept(); } diff -r a5b53cc10436 -r 0b3a5bc4e8a8 config/addversionprompt.h --- a/config/addversionprompt.h Sun Jun 07 19:15:12 2015 +0300 +++ b/config/addversionprompt.h Sun Jun 07 19:55:06 2015 +0300 @@ -27,9 +27,9 @@ Q_OBJECT public: - AddVersionPrompt (struct VersionGuiEntry* entry, QWidget* parent = NULL, Qt::WindowFlags f = 0); + AddVersionPrompt (class VersionGuiEntry* entry, QWidget* parent = NULL, Qt::WindowFlags f = 0); virtual ~AddVersionPrompt(); - VersionGuiEntry* getVersionInfo(); + class VersionGuiEntry* getVersionInfo(); private slots: void acceptPressed(); @@ -37,5 +37,5 @@ private: class Ui_AddVersion& ui; - struct VersionGuiEntry* m_entry; + class VersionGuiEntry* m_entry; }; \ No newline at end of file diff -r a5b53cc10436 -r 0b3a5bc4e8a8 config/configwindow.cpp --- a/config/configwindow.cpp Sun Jun 07 19:15:12 2015 +0300 +++ b/config/configwindow.cpp Sun Jun 07 19:55:06 2015 +0300 @@ -18,10 +18,12 @@ #include #include +#include #include #include #include "addversionprompt.h" #include "configwindow.h" +#include "versionguientry.h" #include "ui_configbox.h" // @@ -35,6 +37,16 @@ } // +// ----------------------------------------------------------------------------- +// + +void VersionGuiEntry::setName (const QString& a) +{ + m_name = a; + m_label->setText (a); +} + +// // ------------------------------------------------------------------------------------------------- // @@ -91,20 +103,17 @@ VersionGuiEntry* ConfigWindow::addVersion (const ZandronumVersion& version) { - QTableWidgetItem* labelItem = new QTableWidgetItem (version.name); + QLabel* label = new QLabel (version.name); + QTableWidgetItem* pathItem = new QTableWidgetItem (version.binaryPath); int rownum = ui.exePaths->rowCount(); ui.exePaths->setSortingEnabled (false); ui.exePaths->insertRow (rownum); - ui.exePaths->setItem (rownum, LabelColumn, labelItem); + ui.exePaths->setCellWidget (rownum, LabelColumn, label); ui.exePaths->setItem (rownum, PathColumn, pathItem); ui.exePaths->setSortingEnabled (true); - VersionGuiEntry* entry = new VersionGuiEntry; - entry->isRelease = version.isRelease; - entry->name = version.name; - entry->labelItem = labelItem; - entry->pathItem = pathItem; + VersionGuiEntry* entry = new VersionGuiEntry (version.name, version.isRelease, label, pathItem); m_versionEntries.append (entry); m_versionEntryMap[pathItem] = entry; return entry; @@ -125,8 +134,8 @@ } } - m_versionEntryMap.remove (entry->pathItem); - ui.exePaths->removeRow (entry->pathItem->row()); + m_versionEntryMap.remove (entry->pathItem()); + ui.exePaths->removeRow (entry->pathItem()->row()); delete entry; } @@ -190,7 +199,7 @@ ZandronumVersion VersionGuiEntry::toNonGuiVersion() const { - return ZandronumVersion (name, isRelease, pathItem->text()); + return ZandronumVersion (m_name, m_isRelease, m_pathItem->text()); } // diff -r a5b53cc10436 -r 0b3a5bc4e8a8 config/configwindow.h --- a/config/configwindow.h Sun Jun 07 19:15:12 2015 +0300 +++ b/config/configwindow.h Sun Jun 07 19:55:06 2015 +0300 @@ -23,22 +23,6 @@ // // ------------------------------------------------------------------------------------------------- // -// A ZandronumVersion represented in the config window. -// - -struct VersionGuiEntry -{ - class QTableWidgetItem* labelItem; - class QTableWidgetItem* pathItem; - QString name; - bool isRelease; - - ZandronumVersion toNonGuiVersion() const; -}; - -// -// ------------------------------------------------------------------------------------------------- -// class ConfigWindow : public QDialog { @@ -51,7 +35,7 @@ PathColumn, }; - typedef QMap VersionEntryMap; + typedef QMap VersionEntryMap; ConfigWindow (QWidget* parent = NULL, Qt::WindowFlags f = 0); virtual ~ConfigWindow(); diff -r a5b53cc10436 -r 0b3a5bc4e8a8 config/versionguientry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/versionguientry.cpp Sun Jun 07 19:55:06 2015 +0300 @@ -0,0 +1,72 @@ +#include +#include +#include "versionguientry.h" + +// +// ----------------------------------------------------------------------------- +// + +VersionGuiEntry::VersionGuiEntry (const QString& name, bool isRelease, + QLabel* label, QTableWidgetItem* pathItem) + : m_name (name), + m_isRelease (isRelease), + m_label (label), + m_pathItem (pathItem) +{ + updateStyleSheet(); +} + +// +// ----------------------------------------------------------------------------- +// + +void VersionGuiEntry::setRelease (bool a) +{ + m_isRelease = a; + updateStyleSheet(); +} + +// +// ----------------------------------------------------------------------------- +// + +void VersionGuiEntry::updateStyleSheet() +{ + m_label->setStyleSheet (m_isRelease ? "font-weight: bold" : ""); +} + +// +// ----------------------------------------------------------------------------- +// + +class QLabel* VersionGuiEntry::label() +{ + return m_label; +} + +// +// ----------------------------------------------------------------------------- +// + +class QTableWidgetItem* VersionGuiEntry::pathItem() +{ + return m_pathItem; +} + +// +// ----------------------------------------------------------------------------- +// + +const QString& VersionGuiEntry::name() +{ + return m_name; +} + +// +// ----------------------------------------------------------------------------- +// + +bool VersionGuiEntry::isRelease() +{ + return m_isRelease; +} \ No newline at end of file diff -r a5b53cc10436 -r 0b3a5bc4e8a8 config/versionguientry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/versionguientry.h Sun Jun 07 19:55:06 2015 +0300 @@ -0,0 +1,33 @@ +#pragma once + +class QString; +class QLabel; +class QTableWidgetItem; +struct ZandronumVersion; + +// +// ------------------------------------------------------------------------------------------------- +// +// A ZandronumVersion represented in the config window. +// + +class VersionGuiEntry +{ +public: + VersionGuiEntry (const QString& name, bool isRelease, + QLabel* label, QTableWidgetItem* pathItem); + ZandronumVersion toNonGuiVersion() const; + QLabel* label(); + QTableWidgetItem* pathItem(); + const QString& name(); + void updateStyleSheet(); + bool isRelease(); + void setRelease (bool a); + void setName (const QString& a); + +private: + QLabel* m_label; + QTableWidgetItem* m_pathItem; + QString m_name; + bool m_isRelease; +}; \ No newline at end of file