QByteArray Plugin::GetCurrentSession () const
	{
		QByteArray result;
		QDataStream str (&result, QIODevice::WriteOnly);
		Q_FOREACH (auto tab, Tabs_)
		{
			ITabWidget *tw = qobject_cast<ITabWidget*> (tab);
			if (!tw)
				continue;

			IInfo *plugin = qobject_cast<IInfo*> (tw->ParentMultiTabs ());
			if (!plugin)
				continue;

			auto rec = qobject_cast<IRecoverableTab*> (tab);
			const auto& data = rec->GetTabRecoverData ();
			if (data.isEmpty ())
				continue;

			QIcon forRecover = QIcon (rec->GetTabRecoverIcon ().pixmap (32, 32));

			str << plugin->GetUniqueID ()
					<< data
					<< rec->GetTabRecoverName ()
					<< forRecover
					<< GetSessionProps (tab);
		}
	void Plugin::handleRemoveTab (QWidget *widget)
	{
		auto tab = qobject_cast<ITabWidget*> (widget);
		if (!tab)
			return;

		auto recTab = qobject_cast<IRecoverableTab*> (widget);
		if (!recTab)
			return;

		const auto& recoverData = recTab->GetTabRecoverData ();
		if (recoverData.isEmpty ())
			return;

		TabUncloseInfo info
		{
			{
				recoverData,
				GetSessionProps (widget)
			},
			qobject_cast<IHaveRecoverableTabs*> (tab->ParentMultiTabs ())
		};

		const auto rootWM = Proxy_->GetRootWindowsManager ();
		const auto winIdx = rootWM->GetWindowForTab (tab);
		const auto tabIdx = rootWM->GetTabWidget (winIdx)->IndexOf (widget);
		info.RecInfo_.DynProperties_.append ({ "TabSessManager/Position", tabIdx });

		const auto pos = std::find_if (UncloseAct2Data_.begin (), UncloseAct2Data_.end (),
				[&info] (const TabUncloseInfo& that) { return that.RecInfo_.Data_ == info.RecInfo_.Data_; });
		if (pos != UncloseAct2Data_.end ())
		{
			auto act = pos.key ();
			UncloseMenu_->removeAction (act);
			UncloseAct2Data_.erase (pos);
			delete act;
		}

		const auto& fm = UncloseMenu_->fontMetrics ();
		const QString& elided = fm.elidedText (recTab->GetTabRecoverName (), Qt::ElideMiddle, 300);
		QAction *action = new QAction (recTab->GetTabRecoverIcon (), elided, this);
		UncloseAct2Data_ [action] = info;

		connect (action,
				SIGNAL (triggered ()),
				this,
				SLOT (handleUnclose ()));

		if (UncloseMenu_->defaultAction ())
			UncloseMenu_->defaultAction ()->setShortcut (QKeySequence ());
		UncloseMenu_->insertAction (UncloseMenu_->actions ().value (0), action);
		UncloseMenu_->setDefaultAction (action);
		action->setShortcut (QString ("Ctrl+Shift+T"));
	}