All pastes #776045 Raw Edit

Something

public text v1 · immutable
·published 2007-11-15 20:52 UTC
rendered paste body
Index: tabs/tabbablewidget.cpp
===================================================================
--- tabs/tabbablewidget.cpp	(revision 845)
+++ tabs/tabbablewidget.cpp	(working copy)
@@ -1,141 +1,147 @@
-/*
- * tabbable.cpp
- * Copyright (C) 2007 Kevin Smith
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "tabbablewidget.h"
-#include "tabmanager.h"
-#include "tabdlg.h"
-#include "common.h"
-#include "jidutil.h"
-#include "groupchatdlg.h"
-#include <QTimer>
-
-
-#ifdef Q_WS_WIN
-#include <windows.h>
-#endif
-
-//----------------------------------------------------------------------------
-// TabbableWidget
-//----------------------------------------------------------------------------
-
-TabbableWidget::TabbableWidget(const Jid &jid, PsiAccount *pa, TabManager *tabManager)
-	:AdvancedWidget<QWidget>(0), jid_(jid), pa_(pa), tabManager_(tabManager)
-{
-	hide();
-	QTimer::singleShot(0,this,SLOT(ensureTabbedCorrectly()));
-}
-
-void TabbableWidget::ensureTabbedCorrectly() {
-	if (tabManager_->shouldBeTabbed(this)) {
-		if (!isTabbed()) {
-			tabManager_->getTabs()->addTab(this);
-		}
-	} else {
-		if (isTabbed()) {
-			getManagingTabDlg()->closeTab(this, false);
-		}
-	}
-	show();
-}
-
-void TabbableWidget::bringToFront() 
-{
-	if ( isTabbed() )
-	{
-		getManagingTabDlg()->selectTab(this);
-	}
-	::bringToFront(this);
-}
-
-TabbableWidget::~TabbableWidget()
-{
-	hide();
-}
-
-void TabbableWidget::hideEvent ( QHideEvent * event ) {
-	Q_UNUSED(event);
-	if (!isVisible()) {
-		//you can have a hideEvent and still be visible, check the docs.
-		if (isTabbed()) {
-			getManagingTabDlg()->removeTabWithNoChecks(this);
-		}
-	}
-}
-
-bool TabbableWidget::isTabbed() {
-	return tabManager_->isChatTabbed(this);
-}
-
-TabDlg* TabbableWidget::getManagingTabDlg()
-{
-	return tabManager_->getManagingTabs(this);
-}
-
-/**
- * Runs any gumph necessary before hiding a tab.
- * (checking new messages, setting the autodelete, cancelling composing etc)
- * \return TabbableWidget is ready to be hidden.
- */
-bool TabbableWidget::readyToHide()
-{
-	return true;
-}
-
-Jid TabbableWidget::jid() const
-{
-	return jid_;
-}
-
-const QString& TabbableWidget::getDisplayName()
-{
-	return jid_.user();
-}
-
-void TabbableWidget::activated()
-{
-}
-
-bool TabbableWidget::isActiveTab()
-{
-	if ( isHidden() )
-	{
-		return false;
-	}
-	if (!isTabbed()/* && !getManagingTabDlg()*/)
-	{
-		return isActiveWindow();
-	}
-	return getManagingTabDlg()->isActiveWindow() &&
-	       getManagingTabDlg()->tabOnTop(this);
-}
-
-void TabbableWidget::doFlash(bool on)
-{
-	flashing_ = on;
-	if (!isTabbed()) {
-		AdvancedWidget<QWidget>::doFlash(on);
-	}
-	emit updateFlashState();
-}
-
-bool TabbableWidget::flashing() const
-{
-	return flashing_;
-}
+/*
+ * tabbable.cpp
+ * Copyright (C) 2007 Kevin Smith
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include "tabbablewidget.h"
+#include "tabmanager.h"
+#include "tabdlg.h"
+#include "common.h"
+#include "jidutil.h"
+#include "groupchatdlg.h"
+#include <QTimer>
+
+
+#ifdef Q_WS_WIN
+#include <windows.h>
+#endif
+
+//----------------------------------------------------------------------------
+// TabbableWidget
+//----------------------------------------------------------------------------
+
+TabbableWidget::TabbableWidget(const Jid &jid, PsiAccount *pa, TabManager *tabManager)
+	:AdvancedWidget<QWidget>(0), jid_(jid), pa_(pa), tabManager_(tabManager)
+{
+	hide();
+	QTimer::singleShot(0,this,SLOT(ensureTabbedCorrectly()));
+}
+
+void TabbableWidget::ensureTabbedCorrectly() {
+	if (tabManager_->shouldBeTabbed(this)) {
+		if (!isTabbed()) {
+			tabManager_->getTabs()->addTab(this);
+		}
+	} else {
+		if (isTabbed()) {
+			getManagingTabDlg()->closeTab(this, false);
+		}
+	}
+	show();
+}
+
+void TabbableWidget::bringToFront() 
+{
+	if ( isTabbed() )
+	{
+		getManagingTabDlg()->selectTab(this);
+	}
+	::bringToFront(this);
+}
+
+TabbableWidget::~TabbableWidget()
+{
+	hide();
+}
+
+void TabbableWidget::hideEvent ( QHideEvent * event ) {
+	Q_UNUSED(event);
+	if (!isVisible()) {
+		//you can have a hideEvent and still be visible, check the docs.
+		if (isTabbed()) {
+			getManagingTabDlg()->removeTabWithNoChecks(this);
+		}
+	}
+}
+
+bool TabbableWidget::isTabbed() {
+	return tabManager_->isChatTabbed(this);
+}
+
+TabDlg* TabbableWidget::getManagingTabDlg()
+{
+	return tabManager_->getManagingTabs(this);
+}
+
+/**
+ * Runs any gumph necessary before hiding a tab.
+ * (checking new messages, setting the autodelete, cancelling composing etc)
+ * \return TabbableWidget is ready to be hidden.
+ */
+bool TabbableWidget::readyToHide()
+{
+	return true;
+}
+
+Jid TabbableWidget::jid() const
+{
+	return jid_;
+}
+
+const QString& TabbableWidget::getDisplayName()
+{
+	return jid_.user();
+}
+
+void TabbableWidget::activated()
+{
+}
+
+bool TabbableWidget::isActiveTab()
+{
+	if ( isHidden() )
+	{
+		return false;
+	}
+	if (!isTabbed()/* && !getManagingTabDlg()*/)
+	{
+		return isActiveWindow();
+	}
+	return getManagingTabDlg()->isActiveWindow() &&
+	       getManagingTabDlg()->tabOnTop(this);
+}
+
+void TabbableWidget::doFlash(bool on)
+{
+	flashing_ = on;
+	if (!isTabbed()) {
+		AdvancedWidget<QWidget>::doFlash(on);
+	}
+	emit updateFlashState();
+}
+
+bool TabbableWidget::flashing() const
+{
+	return flashing_;
+}
+
+void TabbableWidget::setWindowTitle(const QString &c)
+{
+	AdvancedWidget<QWidget>::setWindowTitle(c);
+	doFlash(flashing());
+}
Index: tabs/tabbablewidget.h
===================================================================
--- tabs/tabbablewidget.h	(revision 845)
+++ tabs/tabbablewidget.h	(working copy)
@@ -1,85 +1,87 @@
-/*
- * tabbable.h
- * Copyright (C) 2007 Kevin Smith
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#ifndef TABBABLE_H
-#define TABBABLE_H
-
-#include "advwidget.h"
-#include "im.h" // ChatState
-
-namespace XMPP {
-	class Jid;
-	class Message;
-}
-using namespace XMPP;
-
-class PsiAccount;
-class TabManager;
-class TabDlg;
-
-class TabbableWidget : public AdvancedWidget<QWidget>
-{
-	Q_OBJECT
-public:
-	TabbableWidget(const Jid &, PsiAccount *, TabManager *tabManager);
-	~TabbableWidget();
-
-	virtual Jid jid() const; 
-	virtual const QString & getDisplayName();
-
-	virtual bool readyToHide();
-	TabDlg* getManagingTabDlg();
-
-	/**
-	 * Checks if the dialog is in a tabset
-	 */
-	bool isTabbed(); 
-
-	/**
-	 * Returns true if this tab is active in the active window.
-	 */ 
-	bool isActiveTab();
-
-	// reimplemented
-	virtual void doFlash(bool on);
-	bool flashing() const;
-
-signals:
-	void updateFlashState();
-	void eventsRead(const Jid &);
-	void captionChanged(QString);
-	void contactStateChanged(XMPP::ChatState);
-	void unreadEventUpdate(int);
-
-public slots:
-	virtual void activated();
-	void bringToFront();
-protected:
-	virtual void hideEvent(QHideEvent *event);
-protected slots:
-	void ensureTabbedCorrectly();
-private:
-	Jid jid_;
-	PsiAccount *pa_;
-	TabManager *tabManager_;
-	bool flashing_;
-};
-
-#endif
+/*
+ * tabbable.h
+ * Copyright (C) 2007 Kevin Smith
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifndef TABBABLE_H
+#define TABBABLE_H
+
+#include "advwidget.h"
+#include "im.h" // ChatState
+
+namespace XMPP {
+	class Jid;
+	class Message;
+}
+using namespace XMPP;
+
+class PsiAccount;
+class TabManager;
+class TabDlg;
+
+class TabbableWidget : public AdvancedWidget<QWidget>
+{
+	Q_OBJECT
+public:
+	TabbableWidget(const Jid &, PsiAccount *, TabManager *tabManager);
+	~TabbableWidget();
+
+	virtual Jid jid() const; 
+	virtual const QString & getDisplayName();
+
+	virtual bool readyToHide();
+	TabDlg* getManagingTabDlg();
+
+	/**
+	 * Checks if the dialog is in a tabset
+	 */
+	bool isTabbed(); 
+
+	/**
+	 * Returns true if this tab is active in the active window.
+	 */ 
+	bool isActiveTab();
+
+	// reimplemented
+	virtual void doFlash(bool on);
+	bool flashing() const;
+
+	void setWindowTitle( const QString &c );
+
+signals:
+	void updateFlashState();
+	void eventsRead(const Jid &);
+	void captionChanged(QString);
+	void contactStateChanged(XMPP::ChatState);
+	void unreadEventUpdate(int);
+
+public slots:
+	virtual void activated();
+	void bringToFront();
+protected:
+	virtual void hideEvent(QHideEvent *event);
+protected slots:
+	void ensureTabbedCorrectly();
+private:
+	Jid jid_;
+	PsiAccount *pa_;
+	TabManager *tabManager_;
+	bool flashing_;
+};
+
+#endif