Пример #1
0
suic::Size TabControl::MeasureOverride(const suic::Size& size)
{
    suic::Size availableSize;

    if (ReadFlag(CoreFlags::IsMeasureDirty))
    {
        _headerHeight = 0;

        int iItems = GetItems()->GetCount();

        for (int i = 0; i < iItems; ++i)
        {
            TabItemPtr tabItem(GetItems()->GetItem(i));

            tabItem->Measure(size);

            if (tabItem->GetDesiredSize().cy > _headerHeight)
            {
                _headerHeight = tabItem->GetDesiredSize().cy;
            }
        }

        TabItemPtr focusTab(_focusItem);

        if (focusTab && focusTab->GetTabContent())
        {
            focusTab->GetTabContent()->Measure(size);
        }

        WriteFlag(CoreFlags::IsMeasureDirty, false);
    }

    return size;
}
Пример #2
0
void StartupDialog::setSession(int index)
{
	m_windowsModel->clear();

	const SessionInformation session(SessionsManager::getSession(m_ui->sessionComboBox->itemData(index).toString()));
	QFont font(m_ui->windowsTreeView->font());
	font.setBold(true);

	for (int i = 0; i < session.windows.count(); ++i)
	{
		QStandardItem *windowItem(new QStandardItem(tr("Window %1").arg(i + 1)));
		windowItem->setData(session.windows.at(i).geometry, Qt::UserRole);

		for (int j = 0; j < session.windows.at(i).windows.count(); ++j)
		{
			QStandardItem *tabItem(new QStandardItem(session.windows.at(i).windows.at(j).getTitle()));
			tabItem->setFlags(windowItem->flags() | Qt::ItemIsUserCheckable);
			tabItem->setData(Qt::Checked, Qt::CheckStateRole);

			if (j == session.windows.at(i).index)
			{
				tabItem->setData(font, Qt::FontRole);
			}

			windowItem->appendRow(tabItem);
		}

		if (session.windows.count() > 1)
		{
			windowItem->setFlags(windowItem->flags() | Qt::ItemIsUserCheckable);
			windowItem->setData(Qt::Checked, Qt::CheckStateRole);
		}

		m_windowsModel->invisibleRootItem()->appendRow(windowItem);
	}

	m_ui->windowsTreeView->expandAll();
}
Пример #3
0
SessionInformation StartupDialog::getSession() const
{
	SessionInformation session;

	if (m_ui->continueSessionButton->isChecked())
	{
		QList<SessionMainWindow> windows;

		session = SessionsManager::getSession(m_ui->sessionComboBox->currentData().toString());

		for (int i = 0; i < m_windowsModel->rowCount(); ++i)
		{
			QStandardItem *windowItem(m_windowsModel->item(i, 0));

			if (!windowItem || (windowItem->flags().testFlag(Qt::ItemIsUserCheckable) && windowItem->data(Qt::CheckStateRole).toInt() == Qt::Unchecked))
			{
				continue;
			}

			const int index(session.windows.value(i, SessionMainWindow()).index - 1);
			SessionMainWindow window;
			window.index = (index + 1);
			window.geometry = windowItem->data(Qt::UserRole).toByteArray();

			for (int j = 0; j < windowItem->rowCount(); ++j)
			{
				QStandardItem *tabItem(windowItem->child(j, 0));

				if (tabItem && tabItem->data(Qt::CheckStateRole).toInt() == Qt::Checked)
				{
					window.windows.append(session.windows.value(i, SessionMainWindow()).windows.value(j, SessionWindow()));
				}
				else
				{
					if (j == index)
					{
						window.index = 1;
					}
					else if (j > 0 && j < index)
					{
						--window.index;
					}
				}
			}

			windows.append(window);
		}

		session.windows = windows;
	}
	else
	{
		WindowHistoryEntry entry;

		if (m_ui->homePageButton->isChecked())
		{
			entry.url = SettingsManager::getValue(QLatin1String("Browser/HomePage")).toString();
		}
		else if (m_ui->startPageRadioButton->isChecked())
		{
			entry.url = QLatin1String("about:start");
		}
		else
		{
			entry.url = QLatin1String("about:blank");
		}

		SessionWindow tab;
		tab.history.append(entry);
		tab.historyIndex = 0;

		SessionMainWindow window;
		window.windows.append(tab);

		session.path = QLatin1String("default");
		session.title = tr("Default");
		session.windows.append(window);
		session.index = 0;
	}

	return session;
}