Crossfire Server, Trunk
FacesetsPanel.cpp
Go to the documentation of this file.
1 #include <QtWidgets>
2 
3 #include "FacesetsPanel.h"
4 
5 #include "assets.h"
6 #include "AssetsManager.h"
7 #include "LicenseManager.h"
8 #include "FacesetsWrapper.h"
9 
10 FacesetsPanel::FacesetsPanel(QWidget* parent, LicenseManager *licenseManager) : AssetWrapperPanel(parent), myLicenseManager(licenseManager) {
11  addLabel(tr("Prefix:"), "prefix");
12  addLabel(tr("Full name:"), "fullname");
13  addLabel(tr("Fallback:"), "fallback");
14  addLabel(tr("Size:"), "size");
15  addLabel(tr("Extension:"), "extension");
16  addWidget(tr("Defined faces:"), myImages = new QLabel(this), true, nullptr, nullptr);
17  addWidget(tr("License information:"), myLicenses = new QLabel(this), true, nullptr, nullptr);
19 }
20 
23  auto fs = dynamic_cast<FacesetsWrapper *>(asset)->wrappedItem();
24 
25  size_t count = 0, total = getManager()->faces()->count(), licenses = 0;
26 
27  getManager()->faces()->each([&] (const Face * face) {
28  if (face->number < fs->allocated && fs->faces[face->number].datalen > 0) {
29  count++;
30  if (myLicenseManager->getForFace(face->name).count(fs->prefix) > 0) {
31  licenses++;
32  }
33  }
34  });
35 
36  uint8_t percent = count * 100 / total;
37  if (percent == 100 && count < total)
38  percent = 99;
39 
40  myImages->setText(QString("%1 out of %2 (%3%)").arg(count).arg(total).arg(percent));
41 
42  percent = licenses * 100 / count;
43  if (percent == 100 && licenses < count)
44  percent = 99;
45  myLicenses->setText(QString("%1 faces have license information out of %2 (%3%)").arg(licenses).arg(count).arg(percent));
46 }
AssetsCollection::count
size_t count() const
Definition: AssetsCollection.h:57
AssetWrapperPanel
Definition: AssetWrapperPanel.h:16
Face
Definition: face.h:14
FacesetsPanel.h
AssetsManager.h
FacesetsPanel::myLicenses
QLabel * myLicenses
Definition: FacesetsPanel.h:18
FacesetsPanel::FacesetsPanel
FacesetsPanel(QWidget *parent, LicenseManager *licenseManager)
Definition: FacesetsPanel.cpp:10
mail_login.total
total
Definition: mail_login.py:30
AssetWrapperPanel::setItem
virtual void setItem(AssetWrapper *item) override
Definition: AssetWrapperPanel.cpp:13
getManager
AssetsManager * getManager()
Definition: assets.cpp:333
LicenseManager.h
Face::number
uint16_t number
Definition: face.h:15
AssetWrapper
Definition: AssetWrapper.h:11
AssetWrapperPanel::addBottomFiller
void addBottomFiller()
Definition: AssetWrapperPanel.cpp:106
AssetsManager::faces
Faces * faces()
Definition: AssetsManager.h:39
FacesetsWrapper.h
disinfect.count
int count
Definition: disinfect.py:7
AssetWrapperPanel::addLabel
QLabel * addLabel(const QString &label, const char *property)
Definition: AssetWrapperPanel.cpp:35
AssetsCollection::each
void each(std::function< void(T *)> op)
Definition: AssetsCollection.h:135
LicenseManager
Definition: LicenseManager.h:25
AssetWrapperPanel::addWidget
T * addWidget(const QString &label, T *widget, bool sideBySide, const char *property, const char *widgetProperty)
Definition: AssetWrapperPanel.h:44
assets.h
FacesetsPanel::setItem
virtual void setItem(AssetWrapper *asset) override
Definition: FacesetsPanel.cpp:21
FacesetsWrapper
Definition: FacesetsWrapper.h:16
FacesetsPanel::myImages
QLabel * myImages
Definition: FacesetsPanel.h:17