QTfrontend/ui/page/pageroomslist.cpp
changeset 13201 25502e6b3e08
parent 13198 ceae8e01af98
child 13325 4a713e29a4da
equal deleted inserted replaced
13200:a0ce9573bfe8 13201:25502e6b3e08
   588 
   588 
   589     h->setSortIndicatorShown(true);
   589     h->setSortIndicatorShown(true);
   590     h->setSortIndicator(RoomsListModel::StateColumn, Qt::AscendingOrder);
   590     h->setSortIndicator(RoomsListModel::StateColumn, Qt::AscendingOrder);
   591     h->setSectionResizeMode(RoomsListModel::NameColumn, QHeaderView::Stretch);
   591     h->setSectionResizeMode(RoomsListModel::NameColumn, QHeaderView::Stretch);
   592 
   592 
   593     if (!restoreHeaderState())
   593 	h->resizeSection(RoomsListModel::PlayerCountColumn, 32);
   594     {
   594 	h->resizeSection(RoomsListModel::TeamCountColumn, 32);
   595         h->resizeSection(RoomsListModel::PlayerCountColumn, 32);
   595 	h->resizeSection(RoomsListModel::OwnerColumn, 100);
   596         h->resizeSection(RoomsListModel::TeamCountColumn, 32);
   596 	h->resizeSection(RoomsListModel::MapColumn, 100);
   597         h->resizeSection(RoomsListModel::OwnerColumn, 100);
   597 	h->resizeSection(RoomsListModel::SchemeColumn, 100);
   598         h->resizeSection(RoomsListModel::MapColumn, 100);
   598 	h->resizeSection(RoomsListModel::WeaponsColumn, 100);
   599         h->resizeSection(RoomsListModel::SchemeColumn, 100);
       
   600         h->resizeSection(RoomsListModel::WeaponsColumn, 100);
       
   601     }
       
   602 
   599 
   603     // hide column used for filtering
   600     // hide column used for filtering
   604     roomsList->hideColumn(RoomsListModel::StateColumn);
   601     roomsList->hideColumn(RoomsListModel::StateColumn);
   605 
       
   606     // save header state on change
       
   607     connect(roomsList->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
       
   608             this, SLOT(saveHeaderState()));
       
   609     connect(roomsList->horizontalHeader(), SIGNAL(sectionResized(int, int, int)),
       
   610             this, SLOT(saveHeaderState()));
       
   611 
   602 
   612     roomsList->repaint();
   603     roomsList->repaint();
   613 }
   604 }
   614 
   605 
   615 
   606 
   669 
   660 
   670 void PageRoomsList::setSettings(QSettings *settings)
   661 void PageRoomsList::setSettings(QSettings *settings)
   671 {
   662 {
   672     m_gameSettings = settings;
   663     m_gameSettings = settings;
   673 }
   664 }
   674 
       
   675 bool PageRoomsList::restoreHeaderState()
       
   676 {
       
   677     if (m_gameSettings->contains("frontend/roomslist_splitter"))
       
   678     {
       
   679         m_splitter->restoreState(QByteArray::fromBase64(
       
   680             (m_gameSettings->value("frontend/roomslist_splitter").toByteArray())));
       
   681     }
       
   682 
       
   683     if (m_gameSettings->contains("frontend/roomslist_header"))
       
   684     {
       
   685         return roomsList->horizontalHeader()->restoreState(QByteArray::fromBase64(
       
   686             (m_gameSettings->value("frontend/roomslist_header").toByteArray())));
       
   687     } else return false;
       
   688 }
       
   689 
       
   690 void PageRoomsList::saveHeaderState()
       
   691 {
       
   692     m_gameSettings->setValue("frontend/roomslist_header",
       
   693         QString(roomsList->horizontalHeader()->saveState().toBase64()));
       
   694 
       
   695     m_gameSettings->setValue("frontend/roomslist_splitter",
       
   696         QString(m_splitter->saveState().toBase64()));
       
   697 }