chatgui: preserve active channel selection on reload, members sync, profile settings, member list model
This commit is contained in:
1 parent
ce6de7307a
commit
618cfe9bc5
28 files changed
+1895
-91
No files matched your search
@@ -99,6 +99,14 @@ ChannelList::ChannelList(DbManager* db, QWidget *parent)
|
||||
}
|
||||
|
||||
void ChannelList::loadChannels() {
|
||||
QModelIndex curIdx = m_listView->currentIndex();
|
||||
QString selectedCid;
|
||||
int selectedRow = -1;
|
||||
if (curIdx.isValid()) {
|
||||
selectedCid = curIdx.data(ChannelChannelIdRole).toString();
|
||||
selectedRow = curIdx.row();
|
||||
}
|
||||
|
||||
m_model->clear();
|
||||
if (!m_db || !m_db->isOpen()) return;
|
||||
|
||||
@@ -121,8 +129,15 @@ void ChannelList::loadChannels() {
|
||||
ci++;
|
||||
}
|
||||
|
||||
if (m_model->rowCount() > 0)
|
||||
m_listView->setCurrentIndex(m_model->index(0, 0));
|
||||
if (!selectedCid.isEmpty())
|
||||
selectChannel(selectedCid);
|
||||
if (!m_listView->currentIndex().isValid()) {
|
||||
int fallbackRow = (selectedRow >= 0) ? selectedRow : 0;
|
||||
if (fallbackRow >= m_model->rowCount())
|
||||
fallbackRow = m_model->rowCount() - 1;
|
||||
if (fallbackRow >= 0)
|
||||
m_listView->setCurrentIndex(m_model->index(fallbackRow, 0));
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelList::selectChannel(const QString& channelId) {
|
||||
|
||||
Reference in new issue
Block a user