mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-31 17:44:52 +01:00
Probably fixed #39.
This commit is contained in:
parent
b8ef2dcab2
commit
b5b4611ba2
@ -111,18 +111,31 @@ void TabWidget::checkTabBarVisibility() {
|
||||
void TabWidget::tabInserted(int index) {
|
||||
QTabWidget::tabInserted(index);
|
||||
checkTabBarVisibility();
|
||||
|
||||
int count_of_tabs = count();
|
||||
|
||||
if (index < count_of_tabs - 1 && count_of_tabs > 1) {
|
||||
// New tab was inserted and the tab is not the last one.
|
||||
fixContentsAfterMove(index, count_of_tabs - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void TabWidget::tabRemoved(int index) {
|
||||
QTabWidget::tabRemoved(index);
|
||||
checkTabBarVisibility();
|
||||
|
||||
int count_of_tabs = count();
|
||||
|
||||
if (index < count_of_tabs && count_of_tabs > 1) {
|
||||
// Some tab was removed and the tab was not the last one.
|
||||
fixContentsAfterMove(index, count_of_tabs - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void TabWidget::createConnections() {
|
||||
connect(tabBar(), SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
|
||||
connect(tabBar(), SIGNAL(emptySpaceDoubleClicked()), this, SLOT(addEmptyBrowser()));
|
||||
connect(tabBar(), SIGNAL(tabMoved(int,int)), this, SLOT(fixContentsAfterMove(int,int)));
|
||||
connect(tabBar(), SIGNAL(currentChanged(int)), this, SLOT(fixContentAfterIndexChange(int)));
|
||||
}
|
||||
|
||||
void TabWidget::initializeTabs() {
|
||||
@ -324,17 +337,12 @@ void TabWidget::changeTitle(int index, const QString &new_title) {
|
||||
setTabToolTip(index, new_title);
|
||||
}
|
||||
|
||||
void TabWidget::fixContentAfterIndexChange(int from) {
|
||||
fixContentsIndexes(from, count() - 1);
|
||||
}
|
||||
|
||||
void TabWidget::fixContentsAfterMove(int from, int to) {
|
||||
fixContentsIndexes(qMin(from, to), qMax(from, to));
|
||||
}
|
||||
from = qMin(from, to);
|
||||
to = qMax(from, to);
|
||||
|
||||
void TabWidget::fixContentsIndexes(int starting_index, int ending_index) {
|
||||
for ( ; starting_index <= ending_index; starting_index++) {
|
||||
TabContent *content = static_cast<TabContent*>(widget(starting_index));
|
||||
content->setIndex(starting_index);
|
||||
for ( ; from <= to; from++) {
|
||||
TabContent *content = static_cast<TabContent*>(widget(from));
|
||||
content->setIndex(from);
|
||||
}
|
||||
}
|
||||
|
@ -85,12 +85,8 @@ class TabWidget : public QTabWidget {
|
||||
|
||||
public slots:
|
||||
// Fixes tabs indexes.
|
||||
void fixContentAfterIndexChange(int from);
|
||||
void fixContentsAfterMove(int from, int to);
|
||||
|
||||
// Fixes indexes of tab contents.
|
||||
void fixContentsIndexes(int starting_index, int ending_index);
|
||||
|
||||
// Called when number of tab pages changes.
|
||||
void checkTabBarVisibility();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user