Tue, 27 Nov 2012 20:05:59 +0100
Started implementing the IRC network edit dialog.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Network/IRC/IrcNetworkEditDialog.py Tue Nov 27 20:05:59 2012 +0100 @@ -0,0 +1,135 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2012 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog for editing IRC network definitions. +""" + +from PyQt4.QtCore import pyqtSlot +from PyQt4.QtGui import QDialog, QDialogButtonBox, QTreeWidgetItem + +from .Ui_IrcNetworkEditDialog import Ui_IrcNetworkEditDialog + +from .IrcNetworkManager import IrcIdentity + +import UI.PixmapCache + + +class IrcNetworkEditDialog(QDialog, Ui_IrcNetworkEditDialog): + """ + Class implementing a dialog for editing IRC network definitions. + """ + def __init__(self, manager, networkName, parent=None): + """ + Constructor + + @param manager reference to the IRC network manager object (IrcNetworkManager) + @param networkName name of the network to work on (string) + @param parent reference to the parent widget (QWidget) + """ + super().__init__(parent) + self.setupUi(self) + + self.__manager = manager + + self.editIdentitiesButton.setIcon(UI.PixmapCache.getIcon("ircConfigure.png")) + self.editServersButton.setIcon(UI.PixmapCache.getIcon("ircConfigure.png")) + self.editChannelButton.setIcon(UI.PixmapCache.getIcon("ircConfigure.png")) + self.addChannelButton.setIcon(UI.PixmapCache.getIcon("plus.png")) + self.deleteChannelButton.setIcon(UI.PixmapCache.getIcon("minus.png")) + + self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) + + self.networkEdit.setText(networkName) + identities = list(sorted(self.__manager.getIdentityNames())) + identities[identities.index(IrcIdentity.DefaultIdentityName)] = \ + IrcIdentity.DefaultIdentityDisplay + self.identityCombo.addItems(identities) + + self.__updateOkButton() + + def __updateOkButton(self): + """ + Private method to update the OK button state. + """ + enable = True + enable &= self.networkEdit.text() != "" + enable &= self.serverCombo.currentText() != "" + + self.__okButton.setEnabled(enable) + + @pyqtSlot(str) + def on_networkEdit_textChanged(self, txt): + """ + Private slot to handle changes of the network name. + + @param txt text entered into the network name edit (string) + """ + self.__updateOkButton() + + @pyqtSlot() + def on_editIdentitiesButton_clicked(self): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError + + @pyqtSlot(str) + def on_serverCombo_activated(self, txt): + """ + Private slot to handle the selection of a server. + + @param txt selected server (string) + """ + self.__updateOkButton() + + @pyqtSlot() + def on_editServersButton_clicked(self): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError + + @pyqtSlot() + def on_addChannelButton_clicked(self): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError + + @pyqtSlot() + def on_editChannelButton_clicked(self): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError + + @pyqtSlot() + def on_deleteChannelButton_clicked(self): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError + + @pyqtSlot(QTreeWidgetItem, int) + def on_channelList_itemActivated(self, item, column): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError + + @pyqtSlot() + def on_channelList_itemSelectionChanged(self): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Network/IRC/IrcNetworkEditDialog.ui Tue Nov 27 20:05:59 2012 +0100 @@ -0,0 +1,224 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>IrcNetworkEditDialog</class> + <widget class="QDialog" name="IrcNetworkEditDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>321</height> + </rect> + </property> + <property name="windowTitle"> + <string>IRC Network</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Network Name:</string> + </property> + </widget> + </item> + <item row="0" column="1" colspan="2"> + <widget class="QLineEdit" name="networkEdit"> + <property name="toolTip"> + <string>Enter the name of the IRC network</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Identity:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="identityCombo"> + <property name="toolTip"> + <string>Select the identity to be used for the IRC network</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QToolButton" name="editIdentitiesButton"> + <property name="toolTip"> + <string>Press to edit the identities</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Server:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="serverCombo"> + <property name="toolTip"> + <string>Select the server to be used for the IRC network</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QToolButton" name="editServersButton"> + <property name="toolTip"> + <string>Press to edit the servers</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Channels:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QTreeWidget" name="channelList"> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <property name="itemsExpandable"> + <bool>false</bool> + </property> + <property name="expandsOnDoubleClick"> + <bool>false</bool> + </property> + <column> + <property name="text"> + <string>Channel</string> + </property> + </column> + <column> + <property name="text"> + <string>Join Automatically</string> + </property> + </column> + </widget> + </item> + <item row="3" column="2"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QToolButton" name="addChannelButton"> + <property name="toolTip"> + <string>Press to add a new channel</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="editChannelButton"> + <property name="toolTip"> + <string>Press to edit the selected channel</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="deleteChannelButton"> + <property name="toolTip"> + <string>Press to delete the selected channel</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>98</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="4" column="0" colspan="3"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>networkEdit</tabstop> + <tabstop>identityCombo</tabstop> + <tabstop>editIdentitiesButton</tabstop> + <tabstop>serverCombo</tabstop> + <tabstop>editServersButton</tabstop> + <tabstop>channelList</tabstop> + <tabstop>addChannelButton</tabstop> + <tabstop>editChannelButton</tabstop> + <tabstop>deleteChannelButton</tabstop> + <tabstop>buttonBox</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>IrcNetworkEditDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>IrcNetworkEditDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- a/Network/IRC/IrcNetworkListDialog.py Tue Nov 27 18:50:02 2012 +0100 +++ b/Network/IRC/IrcNetworkListDialog.py Tue Nov 27 20:05:59 2012 +0100 @@ -15,6 +15,7 @@ from .Ui_IrcNetworkListDialog import Ui_IrcNetworkListDialog from .IrcNetworkManager import IrcIdentity +from .IrcNetworkEditDialog import IrcNetworkEditDialog class IrcNetworkListDialog(QDialog, Ui_IrcNetworkListDialog): @@ -84,7 +85,7 @@ @pyqtSlot() def on_networksList_itemSelectionChanged(self): """ - Slot documentation goes here. + Privat slot to handle changes of the selection of networks. """ self.__checkButtons() @@ -99,10 +100,15 @@ @pyqtSlot() def on_editButton_clicked(self): """ - Slot documentation goes here. + Private slot to edit the selected network. """ - # TODO: not implemented yet - raise NotImplementedError + itm = self.networksList.selectedItems()[0] + if itm: + networkName = itm.text(0) + dlg = IrcNetworkEditDialog(self.__manager, networkName, self) + if dlg.exec_() == QDialog.Accepted: + pass + # TODO: not implemented yet @pyqtSlot() def on_deleteButton_clicked(self):
--- a/eric5.e4p Tue Nov 27 18:50:02 2012 +0100 +++ b/eric5.e4p Tue Nov 27 20:05:59 2012 +0100 @@ -1063,6 +1063,7 @@ <Source>Network/IRC/IrcUtilities.py</Source> <Source>Preferences/ConfigurationPages/IrcPage.py</Source> <Source>Network/IRC/IrcNetworkListDialog.py</Source> + <Source>Network/IRC/IrcNetworkEditDialog.py</Source> </Sources> <Forms> <Form>PyUnit/UnittestDialog.ui</Form> @@ -1372,6 +1373,7 @@ <Form>Network/IRC/IrcNetworkWidget.ui</Form> <Form>Preferences/ConfigurationPages/IrcPage.ui</Form> <Form>Network/IRC/IrcNetworkListDialog.ui</Form> + <Form>Network/IRC/IrcNetworkEditDialog.ui</Form> </Forms> <Translations> <Translation>i18n/eric5_cs.qm</Translation>