Ejemplo n.º 1
0
 def setTimeslice(self, ts):
     if not ts == self.chart.timeslice:
         maxdt = QDateTime()
         maxdt.setTime_t(self.chart.sensorgroup.stop-ts)
         self.StartInput.setMaximumDate(maxdt.date())
         self.chart.setTimeslice(ts)
         self.updateChart()
Ejemplo n.º 2
0
 def __init__(self, date):
     if date:
         d = QDateTime(QDate(0, 0, 0))
         d.setTime_t(int(date))
         EdwCell.__init__(self, d.toString("yyyy-MM-dd hh:mm"))
     else:
         EdwCell.__init__(self, tr("Never"))
Ejemplo n.º 3
0
 def setChartCanvas(self, chart, canvas):
     self.chart = chart
     self.canvas = canvas
     slc = chart.standardSlice
     self.startTime = chart.sensorgroup.stop - slc
     dt = QDateTime()
     dt.setTime_t(self.startTime)
     self.StartInput.setDateTime(dt)
     mindt = QDateTime()
     mindt.setTime_t(chart.sensorgroup.start)
     self.StartInput.setMinimumDate(mindt.date())
     # try to guess unit*factor from slice
     uF = unitFactors[:]
     uF.reverse()
     for f in uF:
         if not slc % f:
             self.LengthUnitInput.setCurrentIndex(unitFactors.index(f))
             self.LengthInput.setValue(slc / f)
             self.setTimeslice(slc)
             break
     else:
         self.LengthInput.setValue(1)
         self.LengthUnitInput.setCurrentIndex(3)
         self.setTimeslice(unitFactors[3])
     self.blockUpdates = False
     self.updateChart()
Ejemplo n.º 4
0
	def __convertXData(self, data):
		loc = QLocale()
		out = []
		for polozka in data:
			time = QDateTime()
			time.setTime_t(polozka)
			out.append(time.toString(loc.dateFormat(QLocale.ShortFormat)))
		return out
Ejemplo n.º 5
0
 def go(self, p, rel=True):
     if rel:
         t = self.StartInput.dateTime().toTime_t()
     else:
         t = 0
     dt = QDateTime()
     dt.setTime_t(t + p)
     self.StartInput.setDateTime(dt)
Ejemplo n.º 6
0
    def filter_score(self, index):
        """
            Returns the number of filters matching the given index.

            :param index:
                The index of the item that will be checked against the filters.
        """
        column = index.column()
        field_name = self.git_model.get_columns()[column]
        filters = self._filters

        if field_name in TIME_FIELDS:
            filters = self._filters
            timestamp, tz = self.git_model.data(index)
            _q_datetime = QDateTime()
            _q_datetime.setTime_t(timestamp)

            item_date = _q_datetime.date()
            item_weekday = item_date.dayOfWeek()
            item_time = _q_datetime.time()

            date_time_filters = ("afterWeekday", "beforeWeekday",
                                 "beforeDate", "afterDate",
                                 "beforeHour", "afterHour")
            has_date_time_filter = False
            for model_filter in filters:
                if model_filter in date_time_filters:
                    has_date_time_filter = True

            if not has_date_time_filter:
                return 0
            else:
                return self.date_match(item_date) + \
                       self.weekday_match(item_weekday) + \
                       self.time_match(item_time)

        elif field_name in ACTOR_FIELDS:
            if "nameEmail" in filters:
                regexp = filters["nameEmail"]
                value = self.git_model.data(index)
                if regexp.isValid() and regexp.indexIn(value) != -1:
                    return 1

        elif field_name in TEXT_FIELDS:
            if "message" in filters:
                regexp = filters["message"]
                commit_message = self.git_model.data(index)
                if regexp.isValid() and regexp.indexIn(commit_message) != -1:
                    return 1

        elif field_name == "hexsha":
            if "localOnly" in filters:
                commits = self.git_model.get_commits()
                commit = commits[index.row()]
                if not self.git_model.is_commit_pushed(commit):
                    return 1

        return 0
Ejemplo n.º 7
0
class DateLabel(QLabel):
    def __init__(self, text, parent, date_format):
        self.date_format = date_format
        self.t = QDateTime()
        super(DateLabel, self).__init__(text=text, parent=parent)

    def setValue(self, unixtimestampe):
        """Set the text with a value from a unix timestamp"""
        self.t.setTime_t(unixtimestampe)
        super(DateLabel, self).setText(self.t.toString(self.date_format))
Ejemplo n.º 8
0
def tickStringsDate(self, values, scale, spacing):
    """Return HH:mm:ss strings from unixtime values"""
    # FIXME Change date format depending of min max value
    # FIXME Make better date locator
    out = []
    for value in values:
        t = QDateTime()
        t.setTime_t(value)
        out.append(t.toString('HH:mm:ss'))
    return out
def convert_timestamp_to_qdatetime(timestamp):
    from PyQt4.QtCore import QDateTime
    from math import modf
    timestamp_frac, timestamp_whole = modf(timestamp)
    # Qt time
    qdatetime = QDateTime()
    qdatetime.setTime_t(int(timestamp_whole))
    qdatetime = qdatetime.addMSecs(int(timestamp_frac*1000))
    #
    return qdatetime
Ejemplo n.º 10
0
def tickStringsDate(self, values, scale, spacing):
    """Return HH:mm:ss strings from unixtime values"""
    # FIXME Change date format depending of min max value
    # FIXME Make better date locator
    out = []
    for value in values:
        t = QDateTime()
        t.setTime_t(value)
        out.append(t.toString('HH:mm:ss'))
    return out
Ejemplo n.º 11
0
def convert_timestamp_to_qdatetime(timestamp):
    from PyQt4.QtCore import QDateTime
    from math import modf
    timestamp_frac, timestamp_whole = modf(timestamp)
    # Qt time
    qdatetime = QDateTime()
    qdatetime.setTime_t(int(timestamp_whole))
    qdatetime = qdatetime.addMSecs(int(timestamp_frac * 1000))
    #
    return qdatetime
Ejemplo n.º 12
0
class DateLabel(QLabel):
    def __init__(self, text, parent, date_format):
        self.date_format = date_format
        self.t = QDateTime()
        super(DateLabel, self).__init__(text=text, parent=parent)

    def setValue(self, unixtimestampe):
        """Set the text with a value from a unix timestamp"""
        self.t.setTime_t(unixtimestampe)
        super(DateLabel, self).setText(self.t.toString(self.date_format))
Ejemplo n.º 13
0
    def __init__(self, client, arg, value, compatibility=None):
        ArgFilterBase.__init__(self, client, arg, value, compatibility=compatibility)
        QDateTimeEdit.__init__(self)

        datevalue = QDateTime()
        try:
            datevalue.setTime_t(int(value))
            self.setDateTime(datevalue)
        except (TypeError, ValueError):
            self.setDateTime(QDateTime.currentDateTime())

        self.setCalendarPopup(True)
Ejemplo n.º 14
0
    def setEditorData(self, editor, index):
        columns = index.model().get_git_model().get_columns()
        field_name = columns[index.column()]

        if field_name in TEXT_FIELDS or field_name in ACTOR_FIELDS:
            text = index.model().data(index, Qt.EditRole).toString()
            editor.setText(text)
        elif field_name in TIME_FIELDS:
            timestamp, tz = index.model().data(index, Qt.EditRole)
            _q_datetime = QDateTime()
            _q_datetime.setTime_t(timestamp)
            editor.setDateTime(_q_datetime)
Ejemplo n.º 15
0
 def toQtCookie(PyCookie):
     qc = QNetworkCookie( PyCookie.name, PyCookie.value )
     qc.setSecure(PyCookie.secure)
     if PyCookie.path_specified:
         qc.setPath(PyCookie.path)
     if PyCookie.domain != "" :
         qc.setDomain(PyCookie.domain)
     if PyCookie.expires != 0:
         t = QDateTime()
         t.setTime_t(PyCookie.expires)
         qc.setExpirationDate(t)
     # not yet handled(maybe less useful):
     #   py cookie.rest / QNetworkCookie.setHttpOnly()
     return qc
Ejemplo n.º 16
0
 def toQtCookie(pyCookie):
     qc = QNetworkCookie(pyCookie.name, pyCookie.value)
     qc.setSecure(pyCookie.secure)
     if pyCookie.path_specified:
         qc.setPath(pyCookie.path)
     if pyCookie.domain != "":
         qc.setDomain(pyCookie.domain)
     if pyCookie.expires != 0:
         t = QDateTime()
         t.setTime_t(pyCookie.expires)
         qc.setExpirationDate(t)
     # not yet handled(maybe less useful):
     #   py cookie.rest / QNetworkCookie.setHttpOnly()
     return qc
Ejemplo n.º 17
0
 def line2qcookie(line):
         domain,initial_dot,path,isSecure,expires,name,value=line.split()
         isSecure=(isSecure=="TRUE")
         dt=QDateTime()
         dt.setTime_t(int(expires))
         expires=dt
         c=QNetworkCookie()
         c.setDomain(domain)
         c.setPath(path)
         c.setSecure(isSecure)
         c.setExpirationDate(expires)
         c.setName(name)
         c.setValue(value)
         return c
Ejemplo n.º 18
0
    def __init__(self, parent, sg):
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self.setWindowTitle(str(QCoreApplication.translate("DataStorageBrowser", "Data export from %s")) % sg.path)
        self.sensorgroup = sg
        self.connect(self, SIGNAL("accepted()"), self.exportData)

        self.connect(self.fileNameButton, SIGNAL("clicked()"), self.changeFileName)
        self.fileName = os.path.join(SimuVis4.Globals.defaultFolder, sg.name + ".csv")
        while os.path.exists(self.fileName):
            self.fileName = self.fileName[:-4] + "_X.csv"
        self.fileNameInput.setText(self.fileName)
        self.fileType = "CSV"

        self.sensorList.setSelectionMode(QAbstractItemView.MultiSelection)
        for i, s in enumerate(sg.keys()):
            self.sensorList.addItem(s)
            self.sensorList.item(i).setSelected(True)
        self.connect(self.sensorList, SIGNAL("itemSelectionChanged()"), self.showInfo)

        self.connect(self.startInput, SIGNAL("dateTimeChanged(QDateTime)"), self.startTimeChanged)
        self.connect(self.stopInput, SIGNAL("dateTimeChanged(QDateTime)"), self.stopTimeChanged)
        self.startTime = sg.start
        self.stopTime = sg.stop
        mindt = QDateTime()
        mindt.setTimeSpec(Qt.UTC)
        mindt.setTime_t(self.startTime)
        maxdt = QDateTime()
        mindt.setTimeSpec(Qt.UTC)
        maxdt.setTime_t(self.stopTime)
        self.startInput.setMinimumDate(mindt.date())
        self.startInput.setMaximumDate(maxdt.date())
        self.stopInput.setMinimumDate(mindt.date())
        self.stopInput.setMaximumDate(maxdt.date())
        self.startInput.setDateTime(mindt)
        self.stopInput.setDateTime(maxdt)
Ejemplo n.º 19
0
 def addRichTypes(self, l):
     """set the list of richtypes"""
     for q in l:
         i = len(self.richTypes)
         self.richTypes.append(q)
         l = QLabel(self)
         self.qlabels.append(l)
         l.setText(q.name)
         l.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
         l.setToolTip(q.descr)
         self.gridLayout.addWidget(l, i, 0, 1, 1)
         cls = q.__class__
         if cls == Text:
             w = QLineEdit(self)
             w.setMinimumSize(300, 30)
             if q.maxLen: w.setMaxLength(q.maxLen)
             w.setText(q.v)
         elif cls == MLText:
             w = QTextEdit(self)
             w.setAcceptRichText(False)
             w.setMinimumSize(300, 60)
             w.setText(q.v)
         elif cls == Choice:
             w = QComboBox(self)
             c = [unicode(x) for x in q.choices]
             c.sort()
             w.addItems(c)
             idx = w.findText(unicode(q.v))
             if idx >= 0:
                 w.setCurrentIndex(idx)
         elif cls == MultiChoice:
             w = QListWidget(self)
             w.setSelectionMode(QAbstractItemView.MultiSelection)
             w.setMinimumSize(100, 60)
             c = [unicode(x) for x in q.choices]
             c.sort()
             v = [unicode(x) for x in q.v]
             for ii, s in enumerate(c):
                 w.addItem(s)
                 if s in v:
                     w.item(ii).setSelected(True)
         elif cls == Bool:
             w = QCheckBox(self)
             if q.v:
                 w.setCheckState(Qt.Checked)
             else:
                 w.setCheckState(Qt.Unchecked)
         elif cls == Integer:
             w = QSpinBox(self)
             if q.min is not None:
                 w.setMinimum(q.min)
             if q.max is not None:
                 w.setMaximum(q.max)
             if q.step is not None:
                 w.setSingleStep(q.step or 0.01)
             if q.unit: w.setSuffix(' '+q.unit)
             w.setValue(q.v)
         elif cls == Float:
             w = QDoubleSpinBox(self)
             if q.min is not None:
                 w.setMinimum(q.min)
             if q.max is not None:
                 w.setMaximum(q.max)
             w.setSingleStep(q.step or 0.01)
             if q.unit: w.setSuffix(' '+q.unit)
             w.setValue(q.v)
         elif cls == DateTime:
             w = QDateTimeEdit(self)
             w.setCalendarPopup(True)
             dt = QDateTime()
             dt.setTime_t(q.v)
             w.setDateTime(dt)
             if q.min is not None:
                 mindt = QDateTime()
                 mindt.setTime_t(q.min)
                 w.setMinimumDate(mindt.date())
             if q.max is not None:
                 maxdt = QDateTime()
                 maxdt.setTime_t(q.max)
                 w.setMaximumDate(maxdt.date())
         l.setBuddy(w)
         w.setToolTip(q.descr)
         w.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
         w.adjustSize()
         self.gridLayout.addWidget(w, i, 1, 1, 1)
         self.qwidgets.append(w)
     self.adjustSize()
Ejemplo n.º 20
0
def qdt(time_t):
    """make QDateTime from time_t"""
    dt = QDateTime()
    dt.setTimeSpec(Qt.UTC)
    dt.setTime_t(time_t)
    return dt #.toLocalTime()