from qt import *
class IrcClientChannelListDialog(QDialog):
	def __init__ (self, parent):
		
		QDialog.__init__(self, parent,"")
		
		self.parent = parent

		self.baseGridLayout = QGridLayout(self, 1, 1)

		self.setMinimumSize(400,500)
		self.setBaseSize(250,300)

		self.setCaption("Qt ProgXRC - Channel List")
		self.serverListChannelView = QListView(self)
		self.serverListChannelView.setHScrollBarMode(QScrollView.AlwaysOn)
		self.serverListChannelView.setVScrollBarMode(QScrollView.AlwaysOn)

		self.serverListChannelView.addColumn("Channel name",122)
		self.serverListChannelView.addColumn("Users")
		self.serverListChannelView.addColumn("Topic",250)

		self.serverListChannelView.setAllColumnsShowFocus(1)
		self.baseGridLayout.addWidget(self.serverListChannelView,0,0)
		
		self.connect(self.serverListChannelView, SIGNAL("doubleClicked( QListViewItem * )"), self.join)


	def append(self,chan,nb,topic):
		self.ligneChan = QListViewItem(self.serverListChannelView, chan, nb, self.parent.beautify(topic))
		
	def clear(self):
		self.serverListChannelView.clear()
		
	def join(self,listChan):
		self.parent.con.join([listChan.text(0).latin1()])
		
		