Remove unused code

This commit is contained in:
crackedmind 2018-10-29 12:44:02 +03:00 committed by leha-bot
parent 21ea23741d
commit 284df273cb
1 changed files with 0 additions and 90 deletions

View File

@ -61,7 +61,6 @@
#include "styles/style_chat_helpers.h"
#include "styles/style_dialogs.h"
#include "styles/style_history.h"
#include "styles/style_profile.h"
#include "styles/style_window.h"
#include "ui/effects/ripple_animation.h"
#include "ui/special_buttons.h"
@ -76,95 +75,6 @@
#include "window/top_bar_widget.h"
#include "window/window_controller.h"
#include <QWindow>
// Smart pointer for QObject*, has move semantics, destroys object if it doesn't have a parent.
template <typename Object> class test_ptr {
public:
test_ptr(std::nullptr_t) {}
// No default constructor, but constructors with at least
// one argument are simply make functions.
template <typename Parent, typename... Args>
explicit test_ptr(Parent &&parent, Args &&... args)
: _object(new Object(std::forward<Parent>(parent), std::forward<Args>(args)...)) {}
test_ptr(const test_ptr &other) = delete;
test_ptr &operator=(const test_ptr &other) = delete;
test_ptr(test_ptr &&other)
: _object(base::take(other._object)) {}
test_ptr &operator=(test_ptr &&other) {
auto temp = std::move(other);
destroy();
std::swap(_object, temp._object);
return *this;
}
template <typename OtherObject, typename = std::enable_if_t<std::is_base_of<Object, OtherObject>::value>>
test_ptr(test_ptr<OtherObject> &&other)
: _object(base::take(other._object)) {}
template <typename OtherObject, typename = std::enable_if_t<std::is_base_of<Object, OtherObject>::value>>
test_ptr &operator=(test_ptr<OtherObject> &&other) {
_object = base::take(other._object);
return *this;
}
test_ptr &operator=(std::nullptr_t) {
_object = nullptr;
return *this;
}
// So we can pass this pointer to methods like connect().
Object *data() const {
return static_cast<Object *>(_object);
}
operator Object *() const {
return data();
}
explicit operator bool() const {
return _object != nullptr;
}
Object *operator->() const {
return data();
}
Object &operator*() const {
return *data();
}
// Use that instead "= new Object(parent, ...)"
template <typename Parent, typename... Args> void create(Parent &&parent, Args &&... args) {
destroy();
_object = new Object(std::forward<Parent>(parent), std::forward<Args>(args)...);
}
void destroy() {
delete base::take(_object);
}
void destroyDelayed() {
if (_object) {
if (auto widget = base::up_cast<QWidget *>(data())) {
widget->hide();
}
base::take(_object)->deleteLater();
}
}
~test_ptr() {
if (auto pointer = _object) {
if (!pointer->parent()) {
destroy();
}
}
}
private:
template <typename OtherObject> friend class test_ptr;
QPointer<QObject> _object;
};
class TestClass;
test_ptr<TestClass> tmp = {nullptr};
namespace {