void PreviewContentWidget::setPreview(const QPixmap &preview)
    {
        assert(!preview.isNull());

        __TRACE(
            "preview",
            "setting preview\n" <<
            toLogString() << "\n"
            "----------------------------\n"
            "    preview_size=<" << preview.size() << ">"
        );

        if (PreviewGenuineSize_.isEmpty())
        {
            setPreviewGenuineSize(preview.size());
        }

        Preview_ = preview;

        limitPreviewSize();

        invalidateSizes();

        update();
    }
void FixedHeightTreeModelLayout::setRowHeight(const UInt32& rowHeight)
{
    //TODO:Implement
    AbstractTreeModelLayout::setRowHeight(rowHeight);

    invalidateSizes();
}
	void FileSharingWidget::initializeInternal()
	{
        PreviewContentWidget::initializeInternal();

		__TRACE(
            "fs",
            "initializing file sharing widget\n" <<
            FsInfo_->ToLogString()
        );

		setMouseTracking(true);

		setInitialWidgetSizeAndState();

		if (FsInfo_->IsOutgoing())
		{
			const auto &uploadingProcessId = FsInfo_->GetUploadingProcessId();
			if (!uploadingProcessId.isEmpty())
			{
				assert(FsInfo_->IsOutgoing());
				assert(FsInfo_->HasLocalPath());

				resumeUploading();

				return;
			}
		}

		connectMetainfoSignal(true);
		requestMetainfo();

        invalidateSizes();
        update();
	}
	void FileSharingWidget::imageDownloaded(qint64 seq, QString uri, QPixmap preview, QString)
	{
		assert(!uri.isEmpty());

		if (!isCurrentProcessId(seq))
		{
			return;
		}

		const auto isDownloading = isState(State::ImageFile_Downloading);
		if (!isDownloading)
		{
            assert(!"unexpected widget state");
			return;
		}

		assert(!Metainfo_.DownloadUri_.isEmpty());
		assert(uri == Metainfo_.DownloadUri_);

        resetCurrentProcessId();

		if (preview.isNull())
		{
            connectImageDownloadedSignal(false);
			return;
		}

		Preview_.FullImg_ = preview;
		setState(State::ImageFile_Downloaded);
		connectImageDownloadedSignal(false);

        invalidateSizes();
		update();
	}
	void FileSharingWidget::setFileInfo(qint64 seq, QString rawUri, QString miniPreviewUri, QString fullPreviewUri, QString downloadUri, QString filename, qint64 size, bool)
	{
		assert(!rawUri.isEmpty());
		assert(!filename.isEmpty());
		assert(!downloadUri.isEmpty());
		assert(size > 0);

		if (!isCurrentProcessId(seq))
		{
			return;
		}

        const auto isImageFileInitial = isState(State::ImageFile_Initial);
        const auto isPlainFileInitial = isState(State::PlainFile_Initial);

        assert(isImageFileInitial || isPlainFileInitial);

        resetCurrentProcessId();

        const auto isPreviewNotReady = (
            isImageFileInitial &&
            (miniPreviewUri.isEmpty() || fullPreviewUri.isEmpty())
        );
        if (isPreviewNotReady)
        {
            retryRequestLater();
            return;
        }

        connectMetainfoSignal(false);

        RetryCount_ = 0;

		Metainfo_.Filename_ = filename;
		Metainfo_.FileSize_ = size;
		Metainfo_.MiniPreviewUri_ = miniPreviewUri;
		Metainfo_.FullPreviewUri_ = fullPreviewUri;
		Metainfo_.DownloadUri_ = downloadUri;

		if (isImageFileInitial)
		{
			setState(State::ImageFile_MetainfoLoaded);
			requestPreview();
		}
		else
		{
			setState(State::PlainFile_CheckingLocalCopy);
			checkLocalCopyExistence();
		}

        invalidateSizes();
		update();
	}
	void FileSharingWidget::fileDownloaded(qint64 seq, QString rawUri, QString localPath)
	{
		assert(!rawUri.isEmpty());
		assert(QFile::exists(localPath));

		if (!isCurrentProcessId(seq))
		{
			return;
		}

		DownloadedFileLocalPath_ = localPath;

        const auto isPlainFileDownloading = isState(State::PlainFile_Downloading);
		if (isPlainFileDownloading)
		{
			setState(State::PlainFile_Downloaded);
		}

		const auto isImageDownloading = isState(State::ImageFile_Downloading);
		if (isImageDownloading)
		{
            setState(State::ImageFile_Downloaded);
		}

		stopDataTransferAnimation();

        invalidateSizes();
		update();

        if (CopyFile_)
        {
            CopyFile_ = false;
            copyFile();
        }

        if (SaveAs_)
        {
            SaveAs_ = false;
        }
	}
    void PreviewContentWidget::resizeEvent(QResizeEvent *e)
    {
        MessageContentWidget::resizeEvent(e);

        invalidateSizes();
    }