aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Haumann <dhaumann@kde.org>2014-01-24 13:50:01 (GMT)
committerDominik Haumann <dhaumann@kde.org>2014-01-24 13:50:01 (GMT)
commit93ad7b68a1d86b469963eadd897c999155a92c90 (patch)
treed4f7a2280cdf963f82ad723cf41d2b3675804b19
parent8a1f8af8656d866528a3364fcaa6a05ae344cf25 (diff)
remove button id from buttons
-rw-r--r--kate/src/katetabbar.cpp38
-rw-r--r--kate/src/katetabbar.h18
-rw-r--r--kate/src/katetabbutton.cpp14
-rw-r--r--kate/src/katetabbutton.h13
4 files changed, 28 insertions, 55 deletions
diff --git a/kate/src/katetabbar.cpp b/kate/src/katetabbar.cpp
index c3fd76b..f8b2694 100644
--- a/kate/src/katetabbar.cpp
+++ b/kate/src/katetabbar.cpp
@@ -167,7 +167,7 @@ int KateTabBar::insertTab(int position, const QString & text)
position = m_tabButtons.size();
}
- KateTabButton *tabButton = new KateTabButton(text, m_nextID, this);
+ KateTabButton *tabButton = new KateTabButton(text, this);
if (m_highlightedTabs.contains(text)) {
tabButton->setHighlightColor(QColor(m_highlightedTabs[text]));
}
@@ -195,11 +195,7 @@ int KateTabBar::insertTab(int position, const QString & text)
*/
int KateTabBar::currentTab() const
{
- if (m_activeButton != 0L) {
- return m_activeButton->buttonID();
- }
-
- return -1;
+ return m_IDToTabButton.key(m_activeButton, -1);
}
/**
@@ -425,7 +421,9 @@ void KateTabBar::tabButtonActivated(KateTabButton *tabButton)
m_activeButton = tabButton;
m_activeButton->setActivated(true);
- emit currentChanged(tabButton->buttonID());
+ const int id = m_IDToTabButton.key(m_activeButton, -1);
+ Q_ASSERT(id >= 0);
+ emit currentChanged(id);
}
/**
@@ -450,7 +448,9 @@ void KateTabBar::tabButtonHighlightChanged(KateTabButton *tabButton)
*/
void KateTabBar::tabButtonCloseRequest(KateTabButton *tabButton)
{
- emit tabCloseRequested(tabButton->buttonID());
+ const int id = m_IDToTabButton.key(tabButton, -1);
+ Q_ASSERT(id >= 0);
+ emit closeTabRequested(id);
}
/**
@@ -460,16 +460,9 @@ void KateTabBar::tabButtonCloseRequest(KateTabButton *tabButton)
*/
void KateTabBar::tabButtonCloseOtherRequest(KateTabButton *tabButton)
{
- QList <int> tabToCloseID;
- for (int i = 0; i < m_tabButtons.size(); ++i) {
- if ((m_tabButtons.at(i))->buttonID() != tabButton->buttonID()) {
- tabToCloseID << (m_tabButtons.at(i))->buttonID();
- }
- }
-
- for (int i = 0; i < tabToCloseID.size(); i++) {
- emit tabCloseRequested(tabToCloseID.at(i));
- }
+ const int id = m_IDToTabButton.key(tabButton, -1);
+ Q_ASSERT(id >= 0);
+ emit closeOtherTabsRequested(id);
}
/**
@@ -479,14 +472,7 @@ void KateTabBar::tabButtonCloseOtherRequest(KateTabButton *tabButton)
*/
void KateTabBar::tabButtonCloseAllRequest()
{
- QList <int> tabToCloseID;
- for (int i = 0; i < m_tabButtons.size(); ++i) {
- tabToCloseID << (m_tabButtons.at(i))->buttonID();
- }
-
- for (int i = 0; i < tabToCloseID.size(); i++) {
- emit tabCloseRequested(tabToCloseID.at(i));
- }
+ emit closeAllTabsRequested();
}
/**
diff --git a/kate/src/katetabbar.h b/kate/src/katetabbar.h
index 2f6b67a..da08f71 100644
--- a/kate/src/katetabbar.h
+++ b/kate/src/katetabbar.h
@@ -95,12 +95,23 @@ Q_SIGNALS:
/**
* This signal is emitted whenever the current activated tab changes.
*/
- void currentChanged(int index);
+ void currentChanged(int id);
/**
- * This signal is emitted whenever a tab should be closed.
+ * This signal is emitted whenever tab @p id should be closed.
*/
- void tabCloseRequested(int index);
+ void closeTabRequested(int id);
+
+ /**
+ * This signal is emitted whenever all tabs except tab @p id
+ * should be closed.
+ */
+ void closeOtherTabsRequested(int id);
+
+ /**
+ * This signal is emitted whenever all tabs should be closed.
+ */
+ void closeAllTabsRequested();
/**
* This signal is emitted whenever a highlight mark changes.
@@ -133,7 +144,6 @@ protected:
virtual void resizeEvent(QResizeEvent *event);
protected:
- void updateFixedHeight();
void updateButtonPositions();
private:
diff --git a/kate/src/katetabbutton.cpp b/kate/src/katetabbutton.cpp
index efabb19..50c947e 100644
--- a/kate/src/katetabbutton.cpp
+++ b/kate/src/katetabbutton.cpp
@@ -35,8 +35,7 @@ QColor KateTabButton::s_predefinedColors[] = { Qt::red, Qt::yellow, Qt::green, Q
const int KateTabButton::s_colorCount = 6;
int KateTabButton::s_currentColor = 0;
-KateTabButton::KateTabButton(const QString &caption,
- int button_id, QWidget *parent)
+KateTabButton::KateTabButton(const QString &caption, QWidget *parent)
: QPushButton(parent)
{
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
@@ -45,7 +44,6 @@ KateTabButton::KateTabButton(const QString &caption,
setMinimumWidth(1);
setFlat(true);
- m_buttonId = button_id;
m_modified = false;
setIcon(QIcon());
@@ -194,16 +192,6 @@ void KateTabButton::mousePressEvent(QMouseEvent *ev)
}
}
-void KateTabButton::setButtonID(int button_id)
-{
- m_buttonId = button_id;
-}
-
-int KateTabButton::buttonID() const
-{
- return m_buttonId;
-}
-
void KateTabButton::setHighlightColor(const QColor &color)
{
if (color.isValid()) {
diff --git a/kate/src/katetabbutton.h b/kate/src/katetabbutton.h
index 1cd307f..ba27f77 100644
--- a/kate/src/katetabbutton.h
+++ b/kate/src/katetabbutton.h
@@ -41,7 +41,7 @@ public:
/**
* Constructs a new tab bar button with \a caption and \a parent.
*/
- KateTabButton(const QString &caption, int button_id, QWidget *parent = 0);
+ KateTabButton(const QString &caption, QWidget *parent = 0);
virtual ~KateTabButton();
@@ -59,16 +59,6 @@ public:
bool isActivated() const;
/**
- * Set a unique button id number.
- */
- void setButtonID(int button_id);
-
- /**
- * Get the unique id number.
- */
- int buttonID() const;
-
- /**
* Set the highlighted state. If @p color.isValid() is \e false the
* button is not highlighted. This does \e not emit the signal
* @p highlightChanged().
@@ -129,7 +119,6 @@ protected:
virtual void mousePressEvent(QMouseEvent *ev);
private:
- int m_buttonId;
bool m_modified;
QColor m_highlightColor;