Subversion Repositories tpanel

Rev

Rev 212 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 212 Rev 213
Line 72... Line 72...
72
    {
72
    {
73
        mLayout = new QHBoxLayout(this);
73
        mLayout = new QHBoxLayout(this);
74
        mLayout->setContentsMargins(0, 0, 0, 0);
74
        mLayout->setContentsMargins(0, 0, 0, 0);
75
 
75
 
76
        if (mMultiline)
76
        if (mMultiline)
-
 
77
        {
77
            mTextArea = new QTextEdit;
78
            mTextArea = new QTextEdit;
-
 
79
        }
78
        else
80
        else
-
 
81
        {
79
            mEdit = new QLineEdit;
82
            mEdit = new QLineEdit;
-
 
83
        }
80
 
84
 
81
        QPalette pal;
85
        QPalette pal;
82
 
86
 
83
        pal.setColor(QPalette::Window, QColorConstants::Transparent);
87
        pal.setColor(QPalette::Window, QColorConstants::Transparent);
-
 
88
        pal.setColor(QPalette::WindowText, QColorConstants::Black);
84
 
89
 
85
        if (!mText.empty())
90
        if (!mText.empty())
86
        {
91
        {
87
            if (mMultiline)
92
            if (mMultiline)
88
                mTextArea->setText(mText.c_str());
93
                mTextArea->setText(mText.c_str());
Line 90... Line 95...
90
                mEdit->setText(mText.c_str());
95
                mEdit->setText(mText.c_str());
91
        }
96
        }
92
 
97
 
93
        if (mMultiline)
98
        if (mMultiline)
94
        {
99
        {
95
            mTextArea->setAutoFillBackground(true);
-
 
96
            mTextArea->setPalette(pal);
100
            QWidget::setPalette(pal);
97
 
101
 
98
            QWidget::connect(mTextArea, &QTextEdit::textChanged, this, &TQEditLine::onTextAreaChanged);
102
            QWidget::connect(mTextArea, &QTextEdit::textChanged, this, &TQEditLine::onTextAreaChanged);
99
            mLayout->addWidget(mTextArea);
103
            mLayout->addWidget(mTextArea);
100
        }
104
        }
101
        else
105
        else
102
        {
106
        {
103
            mEdit->setAutoFillBackground(true);
-
 
104
            mEdit->setPalette(pal);
107
            QWidget::setPalette(pal);
105
 
108
 
106
            QWidget::connect(mEdit, &QLineEdit::textChanged, this, &TQEditLine::onTextChanged);
109
            QWidget::connect(mEdit, &QLineEdit::textChanged, this, &TQEditLine::onTextChanged);
107
            mLayout->addWidget(mEdit);
110
            mLayout->addWidget(mEdit);
108
        }
111
        }
109
 
112
 
Line 281... Line 284...
281
        mEdit->clear();
284
        mEdit->clear();
282
 
285
 
283
    mText.clear();
286
    mText.clear();
284
}
287
}
285
 
288
 
-
 
289
void TQEditLine::setInputMask(const std::string& mask)
-
 
290
{
-
 
291
    DECL_TRACER("TQEditLine::setInputMask(const std::string& mask)");
-
 
292
 
-
 
293
    if (!mMultiline && mEdit)
-
 
294
        mEdit->setInputMask(mask.c_str());
-
 
295
}
-
 
296
 
-
 
297
void TQEditLine::setNumericInput()
-
 
298
{
-
 
299
    DECL_TRACER("TQEditLine::setNumericInput()");
-
 
300
 
-
 
301
    if (!mMultiline && mEdit)
-
 
302
        mEdit->setInputMethodHints(mEdit->inputMethodHints() | Qt::ImhDigitsOnly);
-
 
303
}
-
 
304
 
-
 
305
#ifndef __ANDROID__
-
 
306
void TQEditLine::setClearButtonEnabled(bool state)
-
 
307
{
-
 
308
    DECL_TRACER("TQEditLine::setClearButtonEnabled(bool state)");
-
 
309
 
-
 
310
    if (!mMultiline && mEdit)
-
 
311
        mEdit->setClearButtonEnabled(state);
-
 
312
}
-
 
313
 
-
 
314
void TQEditLine::setCursor(const QCursor& qc)
-
 
315
{
-
 
316
    DECL_TRACER("TQEditLine::setCursor(const QCursor& qc)");
-
 
317
 
-
 
318
    if (mMultiline && mTextArea)
-
 
319
        mTextArea->setCursor(qc);
-
 
320
    else if (!mMultiline && mEdit)
-
 
321
        mEdit->setCursor(qc);
-
 
322
}
-
 
323
#endif
-
 
324
 
286
/*
325
/*
287
 * Here the signal and callback functions follow.
326
 * Here the signal and callback functions follow.
288
 */
327
 */
289
 
328
 
290
bool TQEditLine::event(QEvent* event)
329
bool TQEditLine::event(QEvent* event)
Line 298... Line 337...
298
            if (mMultiline && mTextArea)
337
            if (mMultiline && mTextArea)
299
                mText = mTextArea->toPlainText().toStdString();
338
                mText = mTextArea->toPlainText().toStdString();
300
            else if (!mMultiline && mEdit)
339
            else if (!mMultiline && mEdit)
301
                mText = mEdit->text().toStdString();
340
                mText = mEdit->text().toStdString();
302
            else
341
            else
-
 
342
            {
-
 
343
                if (mMultiline && mTextArea)
-
 
344
                    mTextArea->repaint(mTextArea->visibleRegion());
-
 
345
                else if (!mMultiline && mEdit)
-
 
346
                    mEdit->repaint(visibleRegion());
-
 
347
 
303
                return true;
348
                return true;
-
 
349
            }
304
 
350
 
305
            if (mChanged && gPageManager)
351
            if (mChanged && gPageManager)
306
                gPageManager->inputButtonFinished(mHandle, mText);
352
                gPageManager->inputButtonFinished(mHandle, mText);
307
 
353
 
-
 
354
            if (mMultiline && mTextArea)
-
 
355
                mTextArea->repaint(mTextArea->visibleRegion());
-
 
356
            else if (!mMultiline && mEdit)
-
 
357
                mEdit->repaint(visibleRegion());
-
 
358
 
308
            return true;
359
            return true;
309
        }
360
        }
310
    }
361
    }
311
    else if (event->type() == QEvent::Close ||
362
    else if (event->type() == QEvent::Close ||
312
             event->type() == QEvent::Leave ||
363
             event->type() == QEvent::Leave ||
Line 332... Line 383...
332
{
383
{
333
    DECL_TRACER("TQEditLine::onTextChanged(const QString &text)");
384
    DECL_TRACER("TQEditLine::onTextChanged(const QString &text)");
334
 
385
 
335
    mText = text.toStdString();
386
    mText = text.toStdString();
336
    mChanged = true;
387
    mChanged = true;
-
 
388
 
337
}
389
}
338
 
390
 
339
void TQEditLine::onTextAreaChanged()
391
void TQEditLine::onTextAreaChanged()
340
{
392
{
341
    DECL_TRACER("TQEditLine::onTextAreaChanged()");
393
    DECL_TRACER("TQEditLine::onTextAreaChanged()");