CustomTabBehaviors.cpp
Go to the documentation of this file.
1 #include <DatabaseUtils/GUI/CustomTabBehaviors.h>
2 #include <DatabaseUtils/GUI/Changeable.h>
3 
4 namespace dbutils {
5 namespace gui {
6 
7 namespace CustomTabBehaviors
8 {
9 
10 /**
11  * Updates the text colors for the specified tabWidget and tabBar
12  * combination to show whether uncommitted changes have been made
13  * on each tab.
14  *
15  * NOTE that the specified tabBar should be the one
16  * that is associated with the specified tabWidget. They only
17  * need to be passed to this method separately because the method
18  * to fetch the tabBar from a tabWidget is protected, by default.
19  */
20 void updateTabTextColors(QTabWidget* tabWidget, QTabBar* tabBar)
21 {
22  QColor stdColor("black");
23  QColor colorForChanges(184, 0, 0);
24 
25  for (int idx = 0; idx < tabWidget->count(); ++idx) {
26  QWidget* theWidget = tabWidget->widget(idx);
27  Changeable* changeableObject = dynamic_cast<Changeable*>(theWidget);
28  if (changeableObject->hasChanges()) {
29  tabBar->setTabTextColor(idx, colorForChanges);
30  }
31  else {
32  tabBar->setTabTextColor(idx, stdColor);
33  }
34  }
35 }
36 
37 } // end of namespace CustomTabBehaviors
38 
39 } // end of namespace gui
40 } // end of namespace dbutils
void updateTabTextColors(QTabWidget *tabWidget, QTabBar *tabBar)
virtual bool hasChanges() const =0