QWidget *SpreadSheetDelegate::createEditor(QWidget *parent,
                                          const QStyleOptionViewItem &,
                                          const QModelIndex &index) const
{
    if (index.column() == 1) {
        QDateTimeEdit *editor = new QDateTimeEdit(parent);
        editor->setDisplayFormat("dd/M/yyyy");
        editor->setCalendarPopup(true);
        return editor;
    }

    QLineEdit *editor = new QLineEdit(parent);

    // create a completer with the strings in the column as model
    QStringList allStrings;
    for (int i = 1; i<index.model()->rowCount(); i++) {
        QString strItem(index.model()->data(index.sibling(i, index.column()),
            Qt::EditRole).toString());

        if (!allStrings.contains(strItem))
            allStrings.append(strItem);
    }

    QCompleter *autoComplete = new QCompleter(allStrings);
    editor->setCompleter(autoComplete);
    connect(editor, &QLineEdit::editingFinished, this, &SpreadSheetDelegate::commitAndCloseEditor);
    return editor;
}
コード例 #2
0
QWidget *DateTimeCalendarDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex &/* index */) const
{
    QDateTimeEdit *editor = new QDateTimeEdit(parent);
    editor->setCalendarPopup( true );
    editor->installEventFilter(const_cast<DateTimeCalendarDelegate*>(this));
    return editor;
}
コード例 #3
0
QWidget * ExtArgTimestamp::createEditor(QWidget * parent)
{
    QDateTimeEdit * tsBox;
    QString text = defaultValue();

    if ( _argument->pref_valptr && *_argument->pref_valptr)
    {
        QString storeValue(*_argument->pref_valptr);

        if ( storeValue.length() > 0 && storeValue.compare(text) != 0 )
            text = storeValue.trimmed();
    }

    ts = QDateTime::fromTime_t(text.toInt());
    tsBox = new QDateTimeEdit(ts, parent);
    tsBox->setDisplayFormat(QLocale::system().dateTimeFormat());
    tsBox->setCalendarPopup(true);

    if ( _argument->tooltip != NULL )
        tsBox->setToolTip(QString().fromUtf8(_argument->tooltip));

    connect(tsBox, SIGNAL(dateTimeChanged(QDateTime)), SLOT(onDateTimeChanged(QDateTime)));

    return tsBox;
}
コード例 #4
0
ファイル: sakhits.cpp プロジェクト: zanettea/SAK
QWidget *MyDateItemDelegate::createEditor(QWidget *parent,
                                          const QStyleOptionViewItem &/* option */,
                                          const QModelIndex & index ) const
{
    QDateTimeEdit *editor = new QDateTimeEdit(parent);
    editor->setCalendarPopup(true);
    editor->setDisplayFormat(DATETIMEFORMAT);
    editor->setDateTime(QDateTime::fromString(index.data().toString(), DATETIMEFORMAT));
    return editor;
}
コード例 #5
0
ファイル: logbooktreewidget.cpp プロジェクト: hanzz/hamlog
		QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
			if (index.column() == 2) {
				QDateTimeEdit *editor = new QDateTimeEdit(parent);
				editor->setCalendarPopup(true);
				editor->setDisplayFormat("yyyy-MM-dd hh:mm");
				return editor;
			}
			else {
				return QItemDelegate::createEditor(parent, option, index);
			}
		}
コード例 #6
0
ファイル: WeeklyTopBias.cpp プロジェクト: ErrAza/amarok
QWidget*
Dynamic::WeeklyTopBias::widget( QWidget* parent )
{
    QWidget *widget = new QWidget( parent );
    QVBoxLayout *layout = new QVBoxLayout( widget );

    QLabel *label = new QLabel( i18nc( "in WeeklyTopBias. Label for the date widget", "from:" ) );
    QDateTimeEdit *fromEdit = new QDateTimeEdit( QDate::currentDate().addDays( -7 ) );
    fromEdit->setMinimumDate( QDateTime::fromTime_t( 1111320001 ).date() ); // That's the first week in last fm
    fromEdit->setMaximumDate( QDate::currentDate() );
    fromEdit->setCalendarPopup( true );
    if( m_range.from.isValid() )
        fromEdit->setDateTime( m_range.from );

    connect( fromEdit, SIGNAL( dateTimeChanged( const QDateTime& ) ),
             this, SLOT( fromDateChanged( const QDateTime& ) ) );
    label->setBuddy( fromEdit );
    layout->addWidget( label );
    layout->addWidget( fromEdit );

    label = new QLabel( i18nc( "in WeeklyTopBias. Label for the date widget", "to:" ) );
    QDateTimeEdit *toEdit = new QDateTimeEdit( QDate::currentDate().addDays( -7 ) );
    toEdit->setMinimumDate( QDateTime::fromTime_t( 1111320001 ).date() ); // That's the first week in last fm
    toEdit->setMaximumDate( QDate::currentDate() );
    toEdit->setCalendarPopup( true );
    if( m_range.to.isValid() )
        toEdit->setDateTime( m_range.to );

    connect( toEdit, SIGNAL( dateTimeChanged( const QDateTime& ) ),
             this, SLOT( toDateChanged( const QDateTime& ) ) );
    label->setBuddy( toEdit );
    layout->addWidget( label );
    layout->addWidget( toEdit );

    return widget;
}
コード例 #7
0
ファイル: mainwindow.cpp プロジェクト: Anne081031/ParkCode
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{


    QString strNumber = "k";
    int nNumber = strNumber.toInt( );
    strNumber = "";
    nNumber = strNumber.toInt( );
    QString strDateTime = "2011-01-06 01:02:03";
    QString strFormat = "yyyy-M-d H:m:s";
    QDateTime dt = QDateTime::fromString( strDateTime, strFormat );
    strDateTime = "";
    strDateTime = dt.toString( "yyyy-MM-dd HH:mm:ss" );
    ui->setupUi(this);
    //QPalette pal;
    //QPixmap map( "D:/WinParkUI/debug/Image/NewIcon/CommonBG-normal.jpg");
    //QBrush br( map );
    //pal.setBrush( backgroundRole( ), br );
    //setPalette( pal );
    //setAutoFillBackground( true );

    //mysql.DbConnect( "192.168.1.51", "test", "test", "parkadmin", 3306 );

    //QSplitter *splitter = new QSplitter(this);
    //splitter->setGeometry( this->geometry( ) );
    //splitter->addWidget( ui->pushButton );
    //splitter->addWidget( ui->tableWidget );
    //splitter->addWidget( ui->pushButton_3 );

    QWidgetAction* act = new QWidgetAction( ui->menuTest );
    QComboBox* cbx = new QComboBox( ui->menuTest );
    QStringList lst;
    lst << "1" << "2" << "3";
    cbx->addItems( lst );
    act->setDefaultWidget( cbx );
    //ui->toolBar->addAction( act );

    act->setText( "Hello" );
    ui->menuTest->addAction( act );

    act = new QWidgetAction( ui->menuTest );
    QDateTimeEdit* edit = new QDateTimeEdit( ui->menuTest );
    edit->setCalendarPopup( true );
    act->setDefaultWidget( edit );
    ui->menuTest->addAction( act );
}
コード例 #8
0
void ContactDialog::addAnniversary(const DateItem &ann)
{
    anniversaryDetails.push_back(ann);
    // Value
    QDateTimeEdit* dte = new QDateTimeEdit(this);
    dte->setObjectName(QString("dteAnn%1Date").arg(anniversaryCount+1));
    dte->setDateTime(ann.value);
    DateDetailsDialog::setDateFormat(dte, ann.hasTime);
    dte->setCalendarPopup(true);
    layAnniversaries->addWidget(dte, anniversaryCount, 0);
    // Details button
    QPushButton* btnDet = new QPushButton(this);
    btnDet->setObjectName(QString("btnAnn%1Details").arg(anniversaryCount+1));
    btnDet->setText(ui->btnBDayDetails->text());
    connect(btnDet, SIGNAL(clicked()), this, SLOT(slotAnnDetails()));
    layAnniversaries->addWidget(btnDet, anniversaryCount, 1);
    // Delete button
    QToolButton* btnD = addDelButton(anniversaryCount, "Ann", SLOT(slotDelAnniversary()));
    layAnniversaries->addWidget(btnD, anniversaryCount, 2);
    anniversaryCount++;
}
コード例 #9
0
void CDlgBulkRegister::AddDateTimeItem( int nRow, int nCol, const QDateTime& dtDeafult, QTableWidget* pTable )
{
    QDateTimeEdit* pDateTime = new QDateTimeEdit( dtDeafult );
    pDateTime->setCalendarPopup( true );
    pTable->setCellWidget( nRow, nCol, pDateTime );
}
コード例 #10
0
QWidget *QFRDRTableDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const {
    QVariant dat=index.data(Qt::DisplayRole);
    QString expression=index.data(QFRDRTable::TableExpressionRole).toString();
    if (expression.isEmpty()) {
        if (dat.type()==QVariant::Invalid) {
            dat=index.data(Qt::EditRole);
        }
         if ( dat.type() == QVariant::DateTime || dat.type() == QVariant::Time || dat.type() == QVariant::Date ) {
             QDateTimeEdit *editor = new QDateTimeEdit(parent);
             //editor->setDisplayFormat("dd/M/yyyy");
             editor->setCalendarPopup(true);
             return editor;
         }
         if ( !index.isValid() || dat.type() == QVariant::Double ) {
             QFDoubleEdit* editor=new QFDoubleEdit(parent);
             editor->setCheckBounds(false, false);
             editor->setShowUpDown(false);
             return editor;
         }
         if ( dat.type() == QVariant::Int || dat.type() == QVariant::LongLong ) {
             QSpinBox* editor=new QSpinBox(parent);
             editor->setRange(INT_MIN, INT_MAX);
             editor->setButtonSymbols(QAbstractSpinBox::NoButtons);
             return editor;
         }
         if ( dat.type() == QVariant::UInt || dat.type() == QVariant::ULongLong ) {
             QSpinBox* editor=new QSpinBox(parent);
             editor->setRange(0, UINT_MAX);
             editor->setButtonSymbols(QAbstractSpinBox::NoButtons);
             return editor;
         }
         if ( dat.type() == QVariant::Bool) {
             QCheckBox* editor=new QCheckBox(parent);
             return editor;
         }

         QLineEdit *editor = new QLineEdit(parent);

         // create a completer with the strings in the column as model
         QStringList allStrings;
         for (int i = 1; i<index.model()->rowCount(); i++) {
             QString strItem(index.model()->data(index.sibling(i, index.column()),
                 Qt::EditRole).toString());

             if (!allStrings.contains(strItem))
                 allStrings.append(strItem);
         }

         QCompleter *autoComplete = new QCompleter(allStrings);
         editor->setCompleter(autoComplete);
         connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
         return editor;
    } else {
        QWidget* widExpression=new QWidget(parent);
        widExpression->setFocusPolicy(Qt::StrongFocus);
        widExpression->setAutoFillBackground(true);
        QHBoxLayout* layout=new QHBoxLayout();
        layout->setContentsMargins(0,0,0,0);
        layout->setSpacing(1);
        widExpression->setLayout(layout);
        QLabel* label=new QLabel(widExpression);
        layout->addWidget(label, 1);
        label->setTextFormat(Qt::RichText);
        label->setText(tr("<b><font color=\"blue\">&Sigma;:</font> %1</b><i>&nbsp;&nbsp;= %2</i>").arg(expression).arg(dat.toString()));
        label->setAutoFillBackground(true);
        QFont f=label->font();
        f.setPointSizeF(f.pointSizeF()*0.9);
        label->setFont(f);
        QAction* actEdtExp;        
        QToolButton* btnEdtExp=createButtonAndAction(actEdtExp, QIcon(":/table/formula.png"), tr("edit expression ..."), widExpression);
        actEdtExp->setParent(widExpression);
        connect(actEdtExp, SIGNAL(triggered()), this, SLOT(doEditExpression()));
        layout->addWidget(btnEdtExp);
        QAction* actClearExp;
        QToolButton* btnClearExp=createButtonAndAction(actClearExp, QIcon(":/table/formulaclear.png"), tr("clear expression ..."), widExpression);
        actClearExp->setParent(widExpression);
        connect(actClearExp, SIGNAL(triggered()), this, SLOT(doClearExpression()));
        layout->addWidget(btnClearExp);
        widExpression->setFocus();
        return widExpression;
    }
}