示例#1
0
GameList::GameList(QWidget* parent) : QStackedWidget(parent)
{
  m_model = new GameListModel(this);
  m_table_proxy = new QSortFilterProxyModel(this);
  m_table_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
  m_table_proxy->setSortRole(Qt::InitialSortOrderRole);
  m_table_proxy->setSourceModel(m_model);
  m_list_proxy = new ListProxyModel(this);
  m_list_proxy->setSourceModel(m_model);

  MakeTableView();
  MakeListView();
  MakeEmptyView();

  connect(m_table, &QTableView::doubleClicked, this, &GameList::GameSelected);
  connect(m_list, &QListView::doubleClicked, this, &GameList::GameSelected);
  connect(&Settings::Instance(), &Settings::PathAdded, m_model, &GameListModel::DirectoryAdded);
  connect(&Settings::Instance(), &Settings::PathRemoved, m_model, &GameListModel::DirectoryRemoved);
  connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
  connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);

  addWidget(m_table);
  addWidget(m_list);
  addWidget(m_empty);
  m_prefer_table = Settings::Instance().GetPreferredView();
  ConsiderViewChange();
}
示例#2
0
GameList::GameList(QWidget* parent): QStackedWidget(parent)
{
	m_model = new GameListModel(this);
	m_table_proxy = new TableProxyModel(this);
	m_table_proxy->setSourceModel(m_model);
	m_list_proxy = new ListProxyModel(this);
	m_list_proxy->setSourceModel(m_model);

	MakeTableView();
	MakeListView();
	MakeEmptyView();

	connect(m_table, &QTableView::doubleClicked, this, &GameList::GameSelected);
	connect(m_list, &QListView::doubleClicked, this, &GameList::GameSelected);
	connect(this, &GameList::DirectoryAdded, m_model, &GameListModel::DirectoryAdded);
	connect(this, &GameList::DirectoryRemoved, m_model, &GameListModel::DirectoryRemoved);
	connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
	connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);

	addWidget(m_table);
	addWidget(m_list);
	addWidget(m_empty);
	m_prefer_table = Settings().GetPreferredView();
	ConsiderViewChange();
}
示例#3
0
GameList::GameList(QWidget* parent) : QStackedWidget(parent)
{
  m_model = Settings::Instance().GetGameListModel();
  m_list_proxy = new ListProxyModel(this);
  m_list_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
  m_list_proxy->setSortRole(Qt::InitialSortOrderRole);
  m_list_proxy->setSourceModel(m_model);
  m_grid_proxy = new GridProxyModel(this);
  m_grid_proxy->setSourceModel(m_model);

  MakeListView();
  MakeGridView();
  MakeEmptyView();

  if (Settings::GetQSettings().contains(QStringLiteral("gridview/scale")))
    m_model->SetScale(Settings::GetQSettings().value(QStringLiteral("gridview/scale")).toFloat());

  connect(m_list, &QTableView::doubleClicked, this, &GameList::GameSelected);
  connect(m_grid, &QListView::doubleClicked, this, &GameList::GameSelected);
  connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
  connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);

  addWidget(m_list);
  addWidget(m_grid);
  addWidget(m_empty);
  m_prefer_list = Settings::Instance().GetPreferredView();
  ConsiderViewChange();

  auto* zoom_in = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus), this);
  auto* zoom_out = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus), this);

  connect(zoom_in, &QShortcut::activated, this, &GameList::ZoomIn);
  connect(zoom_out, &QShortcut::activated, this, &GameList::ZoomOut);

  connect(&Settings::Instance(), &Settings::MetadataRefreshCompleted, this,
          [this] { m_grid_proxy->invalidate(); });
}