2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Divide structs into several data/ modules.

This commit is contained in:
John Preston
2017-09-26 14:49:16 +03:00
parent f2a5862714
commit ffc20e4492
68 changed files with 4985 additions and 4065 deletions

View File

@@ -20,6 +20,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#include "overview/overview_layout.h"
#include "data/data_document.h"
#include "styles/style_overview.h"
#include "styles/style_history.h"
#include "core/file_utilities.h"
@@ -75,6 +76,16 @@ void ItemBase::clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pr
Ui::repaintHistoryItem(_parent);
}
void RadialProgressItem::setDocumentLinks(DocumentData *document) {
ClickHandlerPtr save;
if (document->voice()) {
save.reset(new DocumentOpenClickHandler(document));
} else {
save.reset(new DocumentSaveClickHandler(document));
}
setLinks(MakeShared<DocumentOpenClickHandler>(document), std::move(save), MakeShared<DocumentCancelClickHandler>(document));
}
void RadialProgressItem::clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) {
ItemBase::clickHandlerActiveChanged(action, active);
if (action == _openl || action == _savel || action == _cancell) {
@@ -461,6 +472,21 @@ void Video::invalidateCache() {
_check->invalidateCache();
}
}
float64 Video::dataProgress() const {
return _data->progress();
}
bool Video::dataFinished() const {
return !_data->loading();
}
bool Video::dataLoaded() const {
return _data->loaded();
}
bool Video::iconAnimated() const {
return true;
}
void Video::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, QPoint point) const {
bool loaded = _data->loaded();
@@ -642,6 +668,22 @@ void Voice::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, QPoint p
}
}
float64 Voice::dataProgress() const {
return _data->progress();
}
bool Voice::dataFinished() const {
return !_data->loading();
}
bool Voice::dataLoaded() const {
return _data->loaded();
}
bool Voice::iconAnimated() const {
return true;
}
void Voice::updateName() {
auto version = 0;
if (auto forwarded = _parent->Get<HistoryMessageForwarded>()) {
@@ -937,6 +979,30 @@ void Document::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, QPoin
}
}
float64 Document::dataProgress() const {
return _data->progress();
}
bool Document::dataFinished() const {
return !_data->loading();
}
bool Document::dataLoaded() const {
return _data->loaded();
}
bool Document::iconAnimated() const {
return _data->song() || !_data->loaded() || (_radial && _radial->animating());
}
bool Document::withThumb() const {
return !_data->song()
&& !_data->thumb->isNull()
&& _data->thumb->width()
&& _data->thumb->height()
&& !documentIsExecutableName(_data->name);
}
bool Document::updateStatusText() {
bool showPause = false;
int32 statusSize = 0, realDuration = 0;

View File

@@ -100,15 +100,7 @@ public:
protected:
ClickHandlerPtr _openl, _savel, _cancell;
void setLinks(ClickHandlerPtr &&openl, ClickHandlerPtr &&savel, ClickHandlerPtr &&cancell);
void setDocumentLinks(DocumentData *document) {
ClickHandlerPtr save;
if (document->voice()) {
save.reset(new DocumentOpenClickHandler(document));
} else {
save.reset(new DocumentSaveClickHandler(document));
}
setLinks(MakeShared<DocumentOpenClickHandler>(document), std::move(save), MakeShared<DocumentCancelClickHandler>(document));
}
void setDocumentLinks(DocumentData *document);
void step_radial(TimeMs ms, bool timer);
@@ -219,18 +211,10 @@ public:
void invalidateCache() override;
protected:
float64 dataProgress() const override {
return _data->progress();
}
bool dataFinished() const override {
return !_data->loading();
}
bool dataLoaded() const override {
return _data->loaded();
}
bool iconAnimated() const override {
return true;
}
float64 dataProgress() const override;
bool dataFinished() const override;
bool dataLoaded() const override;
bool iconAnimated() const override;
private:
void ensureCheckboxCreated();
@@ -257,18 +241,10 @@ public:
void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, QPoint point) const override;
protected:
float64 dataProgress() const override {
return _data->progress();
}
bool dataFinished() const override {
return !_data->loading();
}
bool dataLoaded() const override {
return _data->loaded();
}
bool iconAnimated() const override {
return true;
}
float64 dataProgress() const override;
bool dataFinished() const override;
bool dataLoaded() const override;
bool iconAnimated() const override;
private:
DocumentData *_data;
@@ -298,18 +274,10 @@ public:
}
protected:
float64 dataProgress() const override {
return _data->progress();
}
bool dataFinished() const override {
return !_data->loading();
}
bool dataLoaded() const override {
return _data->loaded();
}
bool iconAnimated() const override {
return _data->song() || !_data->loaded() || (_radial && _radial->animating());
}
float64 dataProgress() const override;
bool dataFinished() const override;
bool dataLoaded() const override;
bool iconAnimated() const override;
private:
DocumentData *_data;
@@ -326,9 +294,7 @@ private:
int32 _datew, _extw;
int32 _thumbw, _colorIndex;
bool withThumb() const {
return !_data->song() && !_data->thumb->isNull() && _data->thumb->width() && _data->thumb->height() && !documentIsExecutableName(_data->name);
}
bool withThumb() const;
bool updateStatusText();
};