First changes with feedback from #kopete
From 030d1a97bf70ebaff9c76c4c1962b1d35e41da61 Mon Sep 17 00:00:00 2001
From: Duncan Mac-Vicar P <[EMAIL PROTECTED]>
Date: Tue, 13 Nov 2007 19:03:27 +0100
Subject: [PATCH] Various suggestions from #kopete
 - use contactAt in data()
 - tabs, guards, etc

---
 kopete/kopete/chatwindow/chatmemberslistview.h   |    4 +-
 kopete/kopete/chatwindow/kopetechatwindow.cpp    |    9 ++--
 kopete/kopete/chatwindow/kopetechatwindow.h      |    2 +-
 kopete/kopete/chatwindow/kopetechatwindow.rc     |    2 +-
 kopete/libkopete/chatsessionmemberslistmodel.cpp |   63 ++++++++++------------
 kopete/libkopete/chatsessionmemberslistmodel.h   |   11 +++-
 6 files changed, 44 insertions(+), 47 deletions(-)

diff --git a/kopete/kopete/chatwindow/chatmemberslistview.h b/kopete/kopete/chatwindow/chatmemberslistview.h
index 54ae029..7f017d2 100644
--- a/kopete/kopete/chatwindow/chatmemberslistview.h
+++ b/kopete/kopete/chatwindow/chatmemberslistview.h
@@ -15,8 +15,8 @@
     *************************************************************************
 */
 
-#ifndef CHATMEMBERSLISTWIDGET_H
-#define CHATMEMBERSLISTWIDGET_H
+#ifndef CHATMEMBERSLISTVIEW_H
+#define CHATMEMBERSLISTVIEW_H
 
 #include <QListView>
 
diff --git a/kopete/kopete/chatwindow/kopetechatwindow.cpp b/kopete/kopete/chatwindow/kopetechatwindow.cpp
index f97c87d..c857dd3 100644
--- a/kopete/kopete/chatwindow/kopetechatwindow.cpp
+++ b/kopete/kopete/chatwindow/kopetechatwindow.cpp
@@ -451,10 +451,9 @@ void KopeteChatWindow::initActions(void)
         coll->addAction( "options_membersright", membersRight );
 	connect( membersRight, SIGNAL(toggled(bool)), this, SLOT(slotViewMembersRight()) );
 
-	toggleMembers = new KToggleAction( i18n( "Show" ), coll );
-        coll->addAction( "options_togglemembers", toggleMembers );
-	toggleMembers->setCheckedState( KGuiItem( i18n("Hide") ) );
-	connect( toggleMembers, SIGNAL(toggled(bool)), this, SLOT(slotToggleViewMembers()) );
+	toggleMembers = m_participantsWidget->toggleViewAction();
+	toggleMembers->setText(i18n( "Participants" ));
+	coll->addAction( "options_togglemembers", toggleMembers );
 
 	toggleAutoSpellCheck = new KToggleAction( i18n( "Automatic Spell Checking" ), coll );
         coll->addAction( "enable_auto_spell_check", toggleAutoSpellCheck );
@@ -462,7 +461,7 @@ void KopeteChatWindow::initActions(void)
 	connect( toggleAutoSpellCheck, SIGNAL(triggered(bool)), this, SLOT(toggleAutoSpellChecking()) );
 
 	QAction *toggleParticipantsAction = m_participantsWidget->toggleViewAction( );
-	toggleParticipantsAction->setText( i18n( "Show Participants" ) );
+	toggleParticipantsAction->setText( i18n( "Participants" ) );
 	coll->addAction ( "show_participants_widget", toggleParticipantsAction );
 
 	actionSmileyMenu = new KopeteEmoticonAction( coll );
diff --git a/kopete/kopete/chatwindow/kopetechatwindow.h b/kopete/kopete/chatwindow/kopetechatwindow.h
index 3aed8d6..dadfe64 100644
--- a/kopete/kopete/chatwindow/kopetechatwindow.h
+++ b/kopete/kopete/chatwindow/kopetechatwindow.h
@@ -164,7 +164,7 @@ private:
 
 	KToggleAction* membersLeft;
 	KToggleAction* membersRight;
-	KToggleAction* toggleMembers;
+	QAction* toggleMembers;
 	KToggleAction* toggleAutoSpellCheck;
 
 	KopeteEmoticonAction *actionSmileyMenu;
diff --git a/kopete/kopete/chatwindow/kopetechatwindow.rc b/kopete/kopete/chatwindow/kopetechatwindow.rc
index 459b776..12d1ca9 100644
--- a/kopete/kopete/chatwindow/kopetechatwindow.rc
+++ b/kopete/kopete/chatwindow/kopetechatwindow.rc
@@ -1,5 +1,5 @@
 <!DOCTYPE kpartgui>
-<kpartgui version="33" name="kopetechatwindow">
+<kpartgui version="34" name="kopetechatwindow">
 	<MenuBar>
 		<Menu noMerge="1" name="file">
 			<text>&amp;Chat</text>
diff --git a/kopete/libkopete/chatsessionmemberslistmodel.cpp b/kopete/libkopete/chatsessionmemberslistmodel.cpp
index 23ac5c8..c81446a 100644
--- a/kopete/libkopete/chatsessionmemberslistmodel.cpp
+++ b/kopete/libkopete/chatsessionmemberslistmodel.cpp
@@ -45,7 +45,7 @@ void ChatSessionMembersListModel::setChatSession(ChatSession *session)
 	reset();
 }
 
-Kopete::Contact * ChatSessionMembersListModel::contactAt( const QModelIndex &index )
+Kopete::Contact * ChatSessionMembersListModel::contactAt( const QModelIndex &index ) const
 {
 	if ( m_session )
 	{
@@ -66,6 +66,7 @@ Kopete::Contact * ChatSessionMembersListModel::contactAt( const QModelIndex &ind
 
 int ChatSessionMembersListModel::rowCount(const QModelIndex &parent) const
 {
+	Q_UNUSED(parent)
 	if ( m_session )
 		return m_session->members().count() + 1;
 	
@@ -74,41 +75,28 @@ int ChatSessionMembersListModel::rowCount(const QModelIndex &parent) const
 
 QVariant ChatSessionMembersListModel::data(const QModelIndex &index, int role) const
 {
-	if ( m_session )
+	Contact *c = contactAt(index);
+	if (!c)
+		return QVariant();
+
+	if (role == Qt::DisplayRole)
 	{
-		if (!index.isValid())
-			return QVariant();
-	
-		if (index.row() >= m_session->members().size() + 1)
-			return QVariant();
-	
-		const Contact *c;
-		if ( index.row() == 0 )
-			c = m_session->myself();
-		else
-			c = m_session->members().at(index.row() - 1);
-
-		if (role == Qt::DisplayRole)
-		{
-			QString nick = c->property(Kopete::Global::Properties::self()->nickName().key()).value().toString();
-			if ( nick.isEmpty() )
-				nick = c->contactId();
-			
-			return nick;
-		}
-		else if (role == Qt::DecorationRole)
-		{
-			return c->onlineStatus().iconFor(c);
-		}
-		else if (role == Qt::ToolTipRole)
-		{
-			return c->toolTip();
-		}
-		else
-			return QVariant();
+		QString nick = c->property(Kopete::Global::Properties::self()->nickName().key()).value().toString();
+		if ( nick.isEmpty() )
+			nick = c->contactId();
+		
+		return nick;
 	}
-
-	return QVariant();
+	else if (role == Qt::DecorationRole)
+	{
+		return c->onlineStatus().iconFor(c);
+	}
+	else if (role == Qt::ToolTipRole)
+	{
+		return c->toolTip();
+	}
+	else
+		return QVariant();
 }
 
 QVariant ChatSessionMembersListModel::headerData(int section, Qt::Orientation orientation, int role) const
@@ -124,6 +112,7 @@ QVariant ChatSessionMembersListModel::headerData(int section, Qt::Orientation or
 
 void ChatSessionMembersListModel::slotContactAdded( const Kopete::Contact *contact )
 {
+	Q_UNUSED(contact)
 	// NOTE in the future the adding of a contact
   // could be done just for the contact
 	reset();
@@ -131,6 +120,7 @@ void ChatSessionMembersListModel::slotContactAdded( const Kopete::Contact *conta
 
 void ChatSessionMembersListModel::slotContactRemoved( const Kopete::Contact *contact )
 {
+	Q_UNUSED(contact)
 	// NOTE in the future the removal of a contact
   // could be done just for the contact
 	reset();
@@ -138,6 +128,8 @@ void ChatSessionMembersListModel::slotContactRemoved( const Kopete::Contact *con
 
 void ChatSessionMembersListModel::slotContactStatusChanged( Kopete::Contact *contact, const Kopete::OnlineStatus &status )
 {
+	Q_UNUSED(contact)
+	Q_UNUSED(status)
 	// NOTE in the future the change of a contact
   // could be done just for the contact
 	reset();
@@ -148,4 +140,5 @@ void ChatSessionMembersListModel::slotSessionChanged()
 	reset();
 }
 
-}
\ No newline at end of file
+}
+
diff --git a/kopete/libkopete/chatsessionmemberslistmodel.h b/kopete/libkopete/chatsessionmemberslistmodel.h
index c47e124..de227b4 100644
--- a/kopete/libkopete/chatsessionmemberslistmodel.h
+++ b/kopete/libkopete/chatsessionmemberslistmodel.h
@@ -15,6 +15,9 @@
     *************************************************************************
 */
 
+#ifndef Kopete_ChatSessionMembersListModel_H
+#define Kopete_ChatSessionMembersListModel_H
+
 #include <QAbstractListModel>
 
 #include "kopetechatsession.h"
@@ -37,7 +40,7 @@ public:
 	QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
 	Kopete::ChatSession *session() { return m_session; }
 
-	Kopete::Contact *contactAt( const QModelIndex &index );
+	Kopete::Contact *contactAt( const QModelIndex &index ) const;
 public slots:
 	/**
 	 * Called when the ChatSession change for this list (eg. when the tab in the KopeteChatWindow is changing)
@@ -67,8 +70,8 @@ private slots:
 	void slotContactStatusChanged( Kopete::Contact *contact, const Kopete::OnlineStatus &status );
 
 	/**
-   * Called when something in the session changed that requires a full
-   * model reset
+	 * Called when something in the session changed that requires a full
+	 * model reset
 	 */
 	void slotSessionChanged();
 
@@ -79,3 +82,5 @@ private:
 
 }
 
+#endif
+
-- 
1.5.3.2

_______________________________________________
kopete-devel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kopete-devel

Reply via email to