fields = ()
view_list_fields = ()
view_display_fields = ()
- view_display_fields_hidden = ()
+ view_display_fields_hidden = 'ID', 'Connection ID'
+ is_bound_to_connection = True
def __init__(self, model=None, view_list=None, view_display=None, parent=None, views=None):
super(BaseController, self).__init__(parent=parent)
# Create model header from fields list.
for i, field in enumerate(self.fields):
self.model.setHeaderData(
- i, QtCore.Qt.Horizontal, QtCore.QVariant(field))
+ i, QtCore.Qt.Horizontal,
+ QtCore.QVariant(QtGui.QApplication.translate(
+ "MainWindow", field, None,
+ QtGui.QApplication.UnicodeUTF8)))
# Fetch model data.
self.model.select()
self.view_list.resizeColumnsToContents()
self.view_list.resizeRowsToContents()
self.view_list.horizontalHeader().setStretchLastSection(True)
+
+ # Select first row.
self.view_list.selectRow(0)
# Are we given an existing view display?
# If view_display_fields is not send, display all fields except
# the first one that is usually the ID.
- display_fields = self.getDisplayFields()
+ display_fields = [
+ field for field in self.fields if not field in
+ self.view_display_fields_hidden]
+
for i, field in enumerate(self.fields):
if field in display_fields:
field_widget = self.getFieldWidget(field)
QtCore.QObject.connect(
sender, QtCore.SIGNAL(signal), receiver, QtCore.SLOT(slot))
-
- def getDisplayFields(self):
- """
- Return the list of fields to display.
-
- If it's not set explicitly, use all defined fields except the first
- which usually is the primary key.
- """
- # Do we have the fields to display explicitly set?
- if self.view_display_fields:
- fields = self.view_display_fields
- else:
- # Do we have hidden fields set?
- if self.view_display_fields_hidden:
- hidden = self.view_display_fields_hidden
- # If not, hide the first one.
- else:
- hidden = self.fields[0]
-
- # Filter away all hidden fields.
- fields = [field for field in self.fields if not field in hidden]
-
- return fields
-
def getFieldWidget(self, field):
"""
Return widget for given field name.
# Clear all displayed fields.
for field in self.getDisplayFields():
- self.getFieldWidget(field).clear()
+ if hasattr(field, 'clear'):
+ self.getFieldWidget(field).clear()
def save(self):
"""
# on its own.
self.view_display.submit()
self.getFieldWidget('Add').setEnabled(True)
-
+
+ def update(self):
+ pass
class ConnectionController(BaseController):
Connections controller.
"""
fields = (
- 'ID', 'Name', 'Local IP Address', 'Local Port',
- 'Freeswitch IP Address', 'Freeswitch Port')
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Name'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Local IP Address'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Local Port'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Freeswitch IP Address'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Freeswitch Port'))
view_list_fields = 'Name', 'Freeswitch IP Address', 'Freeswitch Port'
def clone(self):
This creates a new connection with bound data copied from another one.
"""
+
class SipProfileController(BaseController):
"""
SIP Profile controller.
"""
fields = (
- 'ID', 'Connection ID', 'Name', 'External RTP IP', 'External SIP IP',
- 'RTP IP', 'SIP IP', 'SIP Port', 'Accept Blind Registration',
- 'Authenticate Calls', 'Is Active')
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Connection ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Name'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'External RTP IP'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'External SIP IP'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'RTP IP'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'SIP IP'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'SIP Port'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Accept Blind Registration'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Authenticate Calls'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Is Active'))
view_list_fields = 'Name', 'SIP IP', 'SIP Port'
- view_display_fields_hidden = 'ID', 'Connection ID'
-
+
class DomainController(BaseController):
"""
Domain controller.
"""
- fields = 'ID', 'SIP Profile ID', 'Host Name', 'Is Active'
+ fields = (
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Connection ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'SIP Profile ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Host Name'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Is Active'))
view_list_fields = 'SIP Profile ID', 'Host Name', 'Is Active'
Gateway controller.
"""
fields = (
- 'ID', 'SIP Profile ID', 'Name', 'Username', 'Password', 'Realm',
- 'From Domain', 'Expire In Seconds', 'Retry In Seconds',
- 'Caller ID In From Field', 'Is Active')
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Connection ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'SIP Profile ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Name'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Username'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Password'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Realm'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'From Domain'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Expire In Seconds'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Retry In Seconds'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Caller ID In From Field'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Is Active'))
view_list_fields = 'SIP Profile ID', 'Name'
"""
Endpoint controller.
"""
- fields = 'ID', 'User ID', 'Password', 'Domain ID', 'Is Active'
-
+ fields = (
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Connection ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'User ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Password'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Domain ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Is Active'))
+ view_list_fields = 'User ID', 'Password', 'Domain ID'
+
class ExtensionController(BaseController):
"""
Extension controller.
"""
fields = (
- 'ID', 'Destination Match', 'XML Dialplan', 'Domain ID', 'Endpoint ID',
- 'Authenticate Calls', 'Is Active')
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Connection ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Destination Match'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'XML Dialplan'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Domain ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Endpoint ID'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Authenticate Calls'),
+ QtCore.QT_TRANSLATE_NOOP('MainWindow', 'Is Active'))
view_list_fields = 'Destination Match', 'Domain ID', 'Endpoint ID'
;
CREATE TABLE "ipypbxweb_domain" (
"id" integer NOT NULL PRIMARY KEY,
+ "connection_id" integer NOT NULL REFERENCES "ipypbxweb_connection" ("id"),
"sip_profile_id" integer NOT NULL REFERENCES "ipypbxweb_sipprofile" ("id"),
"host_name" varchar(100) NOT NULL,
"is_active" bool NOT NULL
;
CREATE TABLE "ipypbxweb_gateway" (
"id" integer NOT NULL PRIMARY KEY,
+ "connection_id" integer NOT NULL REFERENCES "ipypbxweb_connection" ("id"),
"sip_profile_id" integer NOT NULL REFERENCES "ipypbxweb_sipprofile" ("id"),
"name" varchar(100) NOT NULL,
"username" varchar(100) NOT NULL,
;
CREATE TABLE "ipypbxweb_endpoint" (
"id" integer NOT NULL PRIMARY KEY,
+ "connection_id" integer NOT NULL REFERENCES "ipypbxweb_connection" ("id"),
"user_id" varchar(100) NOT NULL,
"password" varchar(100) NOT NULL,
"domain_id" integer NOT NULL REFERENCES "ipypbxweb_domain" ("id"),
;
CREATE TABLE "ipypbxweb_extension" (
"id" integer NOT NULL PRIMARY KEY,
+ "connection_id" integer NOT NULL REFERENCES "ipypbxweb_connection" ("id"),
"destination_match" varchar(100) NOT NULL,
"xml_dialplan" text NOT NULL,
"domain_id" integer NOT NULL REFERENCES "ipypbxweb_domain" ("id"),
)
;
CREATE INDEX "ipypbxweb_sipprofile_connection_id" ON "ipypbxweb_sipprofile" ("connection_id");
+CREATE INDEX "ipypbxweb_domain_connection_id" ON "ipypbxweb_domain" ("connection_id");
CREATE INDEX "ipypbxweb_domain_sip_profile_id" ON "ipypbxweb_domain" ("sip_profile_id");
+CREATE INDEX "ipypbxweb_gateway_connection_id" ON "ipypbxweb_gateway" ("connection_id");
CREATE INDEX "ipypbxweb_gateway_sip_profile_id" ON "ipypbxweb_gateway" ("sip_profile_id");
+CREATE INDEX "ipypbxweb_endpoint_connection_id" ON "ipypbxweb_endpoint" ("connection_id");
CREATE INDEX "ipypbxweb_endpoint_domain_id" ON "ipypbxweb_endpoint" ("domain_id");
+CREATE INDEX "ipypbxweb_extension_connection_id" ON "ipypbxweb_extension" ("connection_id");
CREATE INDEX "ipypbxweb_extension_domain_id" ON "ipypbxweb_extension" ("domain_id");
CREATE INDEX "ipypbxweb_extension_endpoint_id" ON "ipypbxweb_extension" ("endpoint_id");
\ No newline at end of file