#from sfa.util.rspecHelper import RSpec
from sfa.rspecs.rspec_parser import parse_rspec
from sface.config import config
-from sface.sfirenew import SfiRenewer
+from sface.sfirenew import RenewWindow
from sface.sfiprocess import SfiProcess
from sface.screens.sfascreen import SfaScreen
MEMBERSHIP_STATUS_COLUMN = 2
KIND_COLUMN = 3
+# maximum length of a name to display before clipping
+NAME_MAX_LEN = 48
+
def itemType(index):
if index.parent().parent().isValid():
return "tag"
def __init__(self, parent):
QStyledItemDelegate.__init__(self, parent)
+ def displayText(self, value, locale):
+ data = str(QStyledItemDelegate.displayText(self, value, locale))
+ if (len(data)>NAME_MAX_LEN):
+ data = data[:(NAME_MAX_LEN-3)] + "..."
+ return QString(data)
+
def paint(self, painter, option, index):
model = index.model()
+ data = str(self.displayText(index.data(), QLocale()))
status_index = model.index(index.row(), MEMBERSHIP_STATUS_COLUMN, index.parent())
status_data = status_index.data().toString()
fm = QFontMetrics(option.font)
rect = QRect(option.rect)
- data = index.data().toString()
rect.setHeight(rect.height() - 2)
rect.setWidth(fm.width(QString(data)) + 6)
rect.setX(rect.x() + 5)
def renew(self):
dlg = RenewWindow(parent=self)
- if (dlg.exec_() == QDialog.Accepted):
- self.setStatus("Renewing Slice.")
-
- self.renewProcess = SfiRenewer(config.getSlice(), dlg.get_new_expiration(), self)
- self.connect(self.renewProcess, SIGNAL('finished()'), self.renewFinished)
-
- def renewFinished(self):
- if self.renewProcess.statusMsg:
- self.setStatus("Renew " + self.renewProcess.status + ": " + self.renewProcess.statusMsg)
- else:
- self.setStatus("Renew " + self.renewProcess.status)
- self.disconnect(self.renewProcess, SIGNAL('finished()'), self.renewFinished)
- self.renewProcess = None
+ dlg.exec_()
def refresh(self):
if not config.getSlice():
def nodeSelectionChanged(self, hostname):
self.parent().nodeSelectionChanged(hostname)
-class RenewWindow(QDialog):
- def __init__(self, parent=None):
- super(RenewWindow, self).__init__(parent)
- self.setWindowTitle("Renew Slivers")
-
- self.duration = QComboBox()
-
- self.expirations = []
-
- durations = ( (1, "One Week"), (2, "Two Weeks"), (3, "Three Weeks"), (4, "One Month") )
-
- now = datetime.datetime.utcnow()
- for (weeks, desc) in durations:
- exp = now + datetime.timedelta(days = weeks * 7)
- desc = desc + " " + exp.strftime("%Y-%m-%d %H:%M:%S")
- self.expirations.append(exp)
- self.duration.addItem(desc)
-
- self.duration.setCurrentIndex(0)
-
- buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
- buttonBox.button(QDialogButtonBox.Ok).setDefault(True)
-
- layout = QVBoxLayout()
- layout.addWidget(self.duration)
- layout.addWidget(buttonBox)
- self.setLayout(layout)
-
- self.connect(buttonBox, SIGNAL("accepted()"), self, SLOT("accept()"))
- self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()"))
-
- def accept(self):
- QDialog.accept(self)
-
- def get_new_expiration(self):
- index = self.duration.currentIndex()
- return self.expirations[index]
-
class MainScreen(SfaScreen):
def __init__(self, parent):
SfaScreen.__init__(self, parent)