23 #include <QLabel> |
23 #include <QLabel> |
24 #include <QLineEdit> |
24 #include <QLineEdit> |
25 #include <QMessageBox> |
25 #include <QMessageBox> |
26 #include <QHeaderView> |
26 #include <QHeaderView> |
27 #include <QTableView> |
27 #include <QTableView> |
|
28 |
|
29 #include <QSortFilterProxyModel> |
28 |
30 |
29 #include "ammoSchemeModel.h" |
31 #include "ammoSchemeModel.h" |
30 #include "pageroomslist.h" |
32 #include "pageroomslist.h" |
31 #include "hwconsts.h" |
33 #include "hwconsts.h" |
32 #include "chatwidget.h" |
34 #include "chatwidget.h" |
472 chatWidget->setUser(nickname); |
474 chatWidget->setUser(nickname); |
473 } |
475 } |
474 |
476 |
475 void PageRoomsList::setModel(QAbstractTableModel *model) |
477 void PageRoomsList::setModel(QAbstractTableModel *model) |
476 { |
478 { |
477 roomsList->setModel(model); |
479 roomsModel = new QSortFilterProxyModel(this); |
|
480 roomsModel->setSourceModel(model); |
|
481 roomsModel->setDynamicSortFilter(true); |
|
482 roomsModel->setSortCaseSensitivity(Qt::CaseInsensitive); |
|
483 roomsList->setModel(roomsModel); |
478 |
484 |
479 roomsList->hideColumn(0); |
485 roomsList->hideColumn(0); |
480 |
486 |
481 QHeaderView * h = roomsList->horizontalHeader(); |
487 QHeaderView * h = roomsList->horizontalHeader(); |
|
488 |
482 h->setResizeMode(1, QHeaderView::Stretch); |
489 h->setResizeMode(1, QHeaderView::Stretch); |
483 h->resizeSection(2, 16); |
490 h->resizeSection(2, 32); |
484 h->resizeSection(3, 16); |
491 h->resizeSection(3, 32); |
485 h->resizeSection(4, 100); |
492 h->resizeSection(4, 100); |
486 h->resizeSection(5, 100); |
493 h->resizeSection(5, 100); |
487 h->resizeSection(6, 100); |
494 h->resizeSection(6, 100); |
488 h->resizeSection(7, 100); |
495 h->resizeSection(7, 100); |
489 |
496 |
490 } |
497 connect(h, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), |
|
498 this, SLOT(onSortIndicatorChanged(int, Qt::SortOrder))); |
|
499 |
|
500 } |
|
501 |
|
502 void PageRoomsList::onSortIndicatorChanged(int logicalIndex, Qt::SortOrder order) |
|
503 { |
|
504 roomsList->horizontalHeader()->setSortIndicatorShown(true); |
|
505 roomsModel->sort(logicalIndex, order); |
|
506 } |