Beispiel #1
0
void ContentUI::setPanelDisplayingPath(const QString &name, EPath path, EPanels panel)
{
    QLabel* label = getPanelLabel(panel);
    QString pathDividerSign(QDir::toNativeSeparators("/"));
    int labelTextlength = label->text().length();
    int discStrLength = getDiscLength(panel);

    switch(path)
    {
    case EForward:
    {
        QString divider((labelTextlength == discStrLength) ? "" : pathDividerSign);
        label->setText(label->text() += (divider + name));
    }
        break;
    case EBackward:
    {
        int pos = label->text().lastIndexOf(pathDividerSign);
        int removeCount = labelTextlength - (pos + 1) + 1;

        if(pos == (discStrLength - 1)) ++pos;

        label->setText(label->text().remove(pos,  removeCount));
    }
        break;
    }
}
Beispiel #2
0
void Search::slotButtonViewClicked()
{
    QLabel title;
    QLabel year;
    QLabel director;
    QLabel genre;
    QLabel time;
    QLabel link;
    QLabel description;

    QString film = model->index(view->currentIndex().row(), 0).data().toString();

    QSqlQuery query("SELECT * "
                    "FROM films "
                    "WHERE title = '" + film + "'");
    while(query.next())
    {
        title.setText(query.value(0).toString());
        year.setText(query.value(1).toString());
        director.setText(query.value(2).toString());
        genre.setText(query.value(3).toString());
        time.setText(query.value(4).toString());
        description.setText(query.value(5).toString());
        link.setText(query.value(6).toString());
    }

    QPixmap map(link.text());

    info->setWindowTitle(tr("Информация о фильме"));
    info->setText(tr("Название: ") + title.text() + tr("\n\nГод: ") + year.text() + tr("\n\nРежиссер: ") + director.text() + tr("\n\nЖанр: ") + genre.text() + tr("\n\nОписание: ") + description.text());
    info->setIconPixmap(map);
    info->exec();
}
void
ItemSelectorWidget::onDeletePressed()
{
    if ( m_items.count() > 0 )
    {
        QLabel* lastLabel = m_items.takeLast();
        int cursorPos = lastLabel->text().length();
        ui.searchBox->setText( lastLabel->text() + ui.searchBox->text() );
        ui.searchBox->setCursorPosition( cursorPos );
        onItemDeleted( lastLabel );
    }
}
void ListWidget::dealPressList()
{
    QLabel *label = (QLabel *)this->sender();

    if(NULL == label)
        return;

    if (0 != label->text().size())
    {
        emit this->channelNumSignal(QString(label->text().at(0)).toInt());
        this->hide();
    }
}
Beispiel #5
0
		bool eventFilter(QObject *obj, QEvent *event) {
			if ( event->type() == QEvent::Paint ) {
				QLabel *l = static_cast<QLabel*>(obj);
				QPainter painter(l);

				int sep = 20;//l->height()*40/100;
				QLinearGradient grad(0,0,0,sep);
				grad.setColorAt(0,midBg);
				grad.setColorAt(0.25,midLightBg);
				grad.setColorAt(1,midLightBg);
				painter.fillRect(0,0,l->width(),sep,grad);

				grad = QLinearGradient(0,sep,0,40);//l->height());
				grad.setColorAt(0,midLightBg);
				grad.setColorAt(0.25,midBg);
				grad.setColorAt(1,midBg);
				painter.fillRect(0,sep,l->width(),l->height()-sep,grad);

				painter.setPen(borderBg);
				painter.drawLine(0,0,l->width(),0);
				/*
				painter.setPen(Qt::black);
				painter.drawLine(0,0,0,l->height());
				painter.drawLine(0,0,l->width(),0);
				*/

				if ( !l->text().isEmpty() ) {
					grad = QLinearGradient(0,0,l->width(),0);
					grad.setColorAt(0, QColor(255,255,255,0));
					grad.setColorAt(0.25, QColor(255,255,255,128));
					grad.setColorAt(0.5, QColor(255,255,255,192));
					grad.setColorAt(0.75, QColor(255,255,255,128));
					grad.setColorAt(1, QColor(255,255,255,0));
					painter.fillRect(0,l->height()-1,l->width(),1,grad);
				}

				const QPixmap *pm = l->pixmap();
				if ( pm != NULL ) {
					int xofs = (l->width() - pm->width()) / 2;
					int yofs = (l->height() - pm->height()) / 2;
					painter.drawPixmap(xofs,yofs, *pm);
				}

				painter.setPen(Qt::white);
				painter.drawText(l->rect().adjusted(20,0,0,0), Qt::AlignLeft | Qt::AlignVCenter, l->text());

				return true;
			}

			return QObject::eventFilter(obj, event);
		}
Beispiel #6
0
void Progression::addCopy(QString src, QString){
	QLabel * label = new QLabel(src, this);
	label->setObjectName(src);
	label->setMaximumSize(780, 30);
	label->setGeometry(label->x(), label->y(), 780, label->height());
	QProgressBar * prog = new QProgressBar(this);
	prog->setObjectName(src);
	prog->setMaximum(QFile(src).size());
	vbl->addWidget(label);
	vbl->addWidget(prog);
	ProgressBars[label->text()] = prog;
	qDebug() << label->text();
	this->adjustSize();
}
void FormGame::updateTankDeaths(ITank *killer)
{
    ITank* tank = (ITank*)sender();
    int index = _tanks.indexOf(tank);

    if(index > -1)
    {
        int index_of_player = _match_players.value(index);
        QLabel* label = findChild<QLabel*>(QString("_l_deaths_%1").arg(index_of_player));
        label->setText(QString::number(label->text().toInt() + 1));
    }

    int killer_index = _tanks.indexOf(killer);

    if(killer_index > -1)
    {
        int index_of_player = _match_players.value(killer_index);
        QLabel* label = findChild<QLabel*>(QString("_l_kills_%1").arg(index_of_player));
        label->setText(QString::number(label->text().toInt() + 1));
    }
    if(tank == _tank)
    {
        updateTankView();
    }

    PlayerData pd1 = _players_data.at(_tanks.indexOf(killer));
    PlayerData pd2 = _players_data.at(_tanks.indexOf(tank));

    if(killer->isEnemy() != tank->isEnemy())
    {
        KillsDeaths kills = _results.value(pd1).value(pd2);
        kills._kills += 1;
        QMap<PlayerData , KillsDeaths> kills_value;
        kills_value.insert(pd2, kills);
        _results.insert(pd1, kills_value);

        KillsDeaths deaths = _results.value(pd2).value(pd1);
        deaths._deaths += 1;
        QMap<PlayerData , KillsDeaths> deaths_value;
        deaths_value.insert(pd1, deaths);
        _results.insert(pd2, deaths_value);
    }

    QString pd1_team = pd1._team == 1?"g":"r";
    QString pd2_team = pd2._team == 1?"g":"r";
    QString log("<span class='%1'>%2</span><span> ha aniquilado a </span><span class='%3'>%4</span>");
    addLog(_text_style_template.arg(log.arg(pd1_team).arg(pd1._nick).arg(pd2_team).arg(pd2._nick)));
}
Beispiel #8
0
// Handling of the HTML accesskey attribute.
bool KKbdAccessExtensions::handleAccessKey( const QKeyEvent* ev )
{
// Qt interprets the keyevent also with the modifiers, and ev->text() matches that,
// but this code must act as if the modifiers weren't pressed
    if (!d->accessKeyLabels) return false;
    QChar c;
    if( ev->key() >= Key_A && ev->key() <= Key_Z )
        c = 'A' + ev->key() - Key_A;
    else if( ev->key() >= Key_0 && ev->key() <= Key_9 )
        c = '0' + ev->key() - Key_0;
    else {
        // TODO fake XKeyEvent and XLookupString ?
        // This below seems to work e.g. for eacute though.
        if( ev->text().length() == 1 )
            c = ev->text()[ 0 ];
    }
    if( c.isNull())
        return false;

    QLabel* lab = d->accessKeyLabels->first();
    while (lab) {
        if (lab->text() == c) {
            lab->buddy()->setFocus();
            delete d->accessKeyLabels;
            d->accessKeyLabels = 0;
            return true;
        }
        lab = d->accessKeyLabels->next();
    }
    return false;
}
Beispiel #9
0
void QVListLayout::applyQListToLayout(const QStringList &list)
{
  bool toggle = true;
  
  QLabel *bLabel;  
  QFont labelFont;
  labelFont.setBold(true);
  
  foreach(const QString &item, list) 
  {
    if(!item.isEmpty())
    {     
      bLabel = new QLabel(item);
      bLabel->setWordWrap(true);
      if(bLabel->text() != QLatin1String("--"))
      { 
	if(toggle) 
	{ 
	  toggle = false;
	  bLabel->setFont(labelFont);
	} else {
	  bLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
	  bLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
	  bLabel->setAlignment(Qt::AlignTop);
	  toggle = true;
	}
	
      } else {
	bLabel->setText(QLatin1String(""));
      }
      addWidget(bLabel);
    }
  }  
}
Beispiel #10
0
void DragDropArea::mousePressEvent(QMouseEvent *event)
{
    QLabel *child = static_cast<QLabel*>(childAt(event->pos()));
    if (!child)
        return;

    // Only drag children with dynamic property: "drag"
    if (!child->property("drag").toBool())
        return;

    QPoint hotSpot = event->pos() - child->pos();

    QMimeData *mimeData = new QMimeData;
    mimeData->setText(child->text());
    mimeData->setData("application/x-hotspot",
                      QByteArray::number(hotSpot.x())
                      + " " + QByteArray::number(hotSpot.y()));

    QPixmap pixmap(child->size());
    child->render(&pixmap);

    QDrag *drag = new QDrag(this);
    drag->setMimeData(mimeData);
    drag->setPixmap(pixmap);
    drag->setHotSpot(hotSpot);
    drag->exec();
}
Beispiel #11
0
int egx_label_get_text_(egx_wnd_t hwnd, char *text, int length)
{
	QLabel *label = (QLabel*)(hwnd);
	QString qText = label->text();
	strncpy(text,qText.toLocal8Bit().data(),length - 1);
	return 0;
}
Beispiel #12
0
void ChangeLabelAction::perform( GuiElement *e )
{
    kDebug() ;
    editor()->beginEdit();

    QString newLabel;
    bool ok;

    QString currentLabel;
    QLabel *labelWidget = dynamic_cast<QLabel *>( e->labelWidget() );
    if( labelWidget )
        currentLabel = labelWidget->text();

    newLabel = KInputDialog::getText( i18n("Enter the new label"), i18n("Label for %1:", e->ref().toString()),
                                      currentLabel, &ok );

    if( ok ) {
        kDebug() <<"New Label:" << newLabel;
        Hint h;
        h.setRef( e->id() );
        h.setValue( Hint::Label, newLabel );
        emit hintGenerated( h );
    }

    editor()->finishEdit();
}
	void ItemHandlerTreeView::Handle (const QDomElement& item, QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());

		QTreeView *tree = new QTreeView (XSD_);
		tree->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);

		QString prop = item.attribute ("property");
		tree->setObjectName (prop);

		tree->setHeaderHidden (item.attribute ("hideHeader") == "true");

		Factory_->RegisterDatasourceSetter (prop,
				[this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog*)
					{ SetDataSource (str, m); });
		Propname2TreeView_ [prop] = tree;

		QLabel *label = new QLabel (XSD_->GetLabel (item));
		label->setWordWrap (false);

		tree->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
		tree->setProperty ("SearchTerms", label->text ());

		int row = lay->rowCount ();
		lay->addWidget (label, row, 0, Qt::AlignLeft);
		lay->addWidget (tree, row + 1, 0, 1, -1);
	}
Beispiel #14
0
	void ItemHandlerPath::Handle (const QDomElement& item,
			QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());
		QLabel *label = new QLabel (XSD_->GetLabel (item));
		label->setWordWrap (false);

		FilePicker::Type type = FilePicker::Type::ExistingDirectory;
		if (item.attribute ("pickerType") == "openFileName")
			type = FilePicker::Type::OpenFileName;
		else if (item.attribute ("pickerType") == "saveFileName")
			type = FilePicker::Type::SaveFileName;

		FilePicker *picker = new FilePicker (type, XSD_);
		const QVariant& value = XSD_->GetValue (item);
		picker->SetText (value.toString ());
		picker->setObjectName (item.attribute ("property"));
		if (item.attribute ("onCancel") == "clear")
			picker->SetClearOnCancel (true);
		if (item.hasAttribute ("filter"))
			picker->SetFilter (item.attribute ("filter"));

		connect (picker,
				SIGNAL (textChanged (const QString&)),
				this,
				SLOT (updatePreferences ()));

		picker->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
		picker->setProperty ("SearchTerms", label->text ());

		int row = lay->rowCount ();
		lay->addWidget (label, row, 0);
		lay->addWidget (picker, row, 1);
	}
Beispiel #15
0
    virtual dyn_t getGuiValue(void){

      QAbstractButton *button = dynamic_cast<QAbstractButton*>(_widget);
      if (button!=NULL)
        return DYN_create_bool(button->isChecked());

      QAbstractSlider *slider = dynamic_cast<QAbstractSlider*>(_widget);
      if (slider!=NULL)
        return DYN_create_int(slider->value());

      QLabel *label = dynamic_cast<QLabel*>(_widget);
      if (label!=NULL)
        return DYN_create_string(label->text());

      QLineEdit *line_edit = dynamic_cast<QLineEdit*>(_widget);
      if (line_edit!=NULL)
        return DYN_create_string(line_edit->text());

      QTextEdit *text_edit = dynamic_cast<QTextEdit*>(_widget);
      if (text_edit!=NULL)
        return DYN_create_string(text_edit->toPlainText());

      QSpinBox *spinbox = dynamic_cast<QSpinBox*>(_widget);
      if (spinbox!=NULL)
        return DYN_create_int(spinbox->value());

      QDoubleSpinBox *doublespinbox = dynamic_cast<QDoubleSpinBox*>(_widget);
      if (doublespinbox!=NULL)
        return DYN_create_float(doublespinbox->value());
      
                  
      handleError("Gui #%d does not have a getValue method", _gui_num);
      return DYN_create_bool(false);
    }
	void ItemHandlerLineEdit::Handle (const QDomElement& item,
			QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());
		QLabel *label = new QLabel (XSD_->GetLabel (item));
		label->setWordWrap (false);

		const QVariant& value = XSD_->GetValue (item);

		QLineEdit *edit = new QLineEdit (value.toString ());
		XSD_->SetTooltip (edit, item);
		edit->setObjectName (item.attribute ("property"));
		edit->setMinimumWidth (QApplication::fontMetrics ()
				.width ("thisismaybeadefaultsetting"));
		if (item.hasAttribute ("password"))
			edit->setEchoMode (QLineEdit::Password);
		if (item.hasAttribute ("inputMask"))
			edit->setInputMask (item.attribute ("inputMask"));
		connect (edit,
				SIGNAL (textChanged (const QString&)),
				this,
				SLOT (updatePreferences ()));

		edit->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
		edit->setProperty ("SearchTerms", label->text ());

		int row = lay->rowCount ();
		lay->addWidget (label, row, 0, Qt::AlignRight);
		lay->addWidget (edit, row, 1);
	}
Beispiel #17
0
  const char *getCharProperty(GWEN_DIALOG_PROPERTY prop,
                              int index,
                              const char *defaultValue) {
    QLabel *qw;
    QString str;

    qw=(QLabel*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
    assert(qw);

    switch(prop) {
    case GWEN_DialogProperty_Title:
      str=qw->text();
      if (str.isEmpty())
        return defaultValue;
      else {
        GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8());
        return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE);
      }
      break;

    default:
      break;
    }

    DBG_WARN(GWEN_LOGDOMAIN,
             "Function is not appropriate for this type of widget (%s)",
             GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
    return defaultValue;
  };
    virtual void stateChange (bool on) {
	if (firstChild()) {
	    if (!selecting) {
		progressDisplay->setText (QString ("%1electing %2...").arg (on? "S" : "Des").arg (_text));
		counter = depth = 0;
		selecting = true;
		if (doneSetup) *doneSetup = false;
	    }

	    for (QListViewItem *lvi = firstChild(); lvi; lvi = lvi->nextSibling()) {
		XMCheckListItem *cli;
		if ((cli = dynamic_cast <XMCheckListItem *> (lvi)) != 0) {
		    if (!(++counter % 10000)) {
			progressDisplay->setText (progressDisplay->text() + ".");
		    }
		    if (!(counter % 1000)) {	
			kapp->processEvents();
		    }
		    depth++;
		    cli->setOn (on);
		    depth--;
		}
	    }

	    if (depth == 0) {
		selecting = false;
		progressDisplay->setText ("Please select files and directories to be restored.");
		if (doneSetup) *doneSetup = true;
	    }
	}
    }
	void ItemHandlerSpinboxRange::Handle (const QDomElement& item,
			QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());
		QLabel *label = new QLabel (XSD_->GetLabel (item));
		label->setWordWrap (false);

		RangeWidget *widget = new RangeWidget ();
		XSD_->SetTooltip (widget, item);
		widget->setObjectName (item.attribute ("property"));
		widget->SetMinimum (item.attribute ("minimum").toInt ());
		widget->SetMaximum (item.attribute ("maximum").toInt ());

		const QVariant& value = XSD_->GetValue (item);

		widget->SetRange (value);
		connect (widget,
				SIGNAL (changed ()),
				this,
				SLOT (updatePreferences ()));

		widget->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
		widget->setProperty ("SearchTerms", label->text ());

		int row = lay->rowCount ();
		lay->addWidget (label, row, 0, Qt::AlignRight);
		lay->addWidget (widget, row, 1);
	}
//select an assignment by doubleclicking
void StudentWindow::on_tableWidget_cellDoubleClicked(int row)
{
	ui->opslaanButton->setDisabled(false);
	ui->submitButton->setDisabled(false);
	QLabel *opdracht = (QLabel*) ui->tableWidget->cellWidget(row, 0);
	if(opdracht != NULL) {
		opdrachtNaam = opdracht->text();
		message = "SELECT `instructions`, `video`, `sets` FROM `assignment_status` AS a, `assignments` AS b WHERE b.`naam` = '" + opdrachtNaam + "' AND a.`assID` = b.`assID`";
		qDebug(message.toStdString().c_str());
		query = sqlplayer->select(message);
		query.first();
        ui->opdrachtText->setText(query.value(0).toString());
		ui->youtubeView->load(QUrl(query.value(1).toString()));
		ui->categoryTextEdit->setText(query.value(2).toString());

        message = "SELECT a.`solution` FROM `assignment_status` AS a, `assignments` AS b WHERE b.`naam` = '" + opdrachtNaam + "' AND a.`accID` = " + QString::number(ingelogde)+ " AND a.`assID` = b.`assID`";
        query = sqlplayer->select(message);
        query.first();
        ui->opdrachtCode->setText(query.value(0).toString());
	} else {
		ui->opdrachtText->setText("");
		ui->youtubeView->setUrl(QString::fromStdString(""));
		ui->opdrachtCode->setText("");
	}
}
Beispiel #21
0
void MonitorFixture::slotValueStyleChanged(Monitor::ValueStyle style)
{
    m_valueStyle = style;

    QListIterator <QLabel*> it(m_valueLabels);
    while (it.hasNext() == true)
    {
        QLabel* label;
        QString str;
        int value;

        label = it.next();
        Q_ASSERT(label != NULL);

        value = label->text().toInt();

        if (style == Monitor::DMXValues)
        {
            value = int(ceil(SCALE(qreal(value),
                                   qreal(0), qreal(100),
                                   qreal(0), qreal(UCHAR_MAX))));
        }
        else
        {
            value = int(ceil(SCALE(qreal(value),
                                   qreal(0), qreal(UCHAR_MAX),
                                   qreal(0), qreal(100))));
        }

        label->setText(str.sprintf("%.3d", value));
    }
}
Beispiel #22
0
QLabel* LayoutManager::copyLabel(QObject *obj) {
    QLabel *oldLabel = qobject_cast<QLabel*>(obj);
    QLabel *newLabel = new QLabel();

    newLabel->setText(oldLabel->text());
    return newLabel;
}
Beispiel #23
0
bool ElideFadeDrawer::eventFilter(QObject *obj, QEvent *event) {
	if ( event->type() == QEvent::Paint ) {
		QLabel *q = static_cast<QLabel*>(obj);
		QPainter painter(q);
		QFontMetrics fm(q->font());
		QRect rect = q->contentsRect();
		int flags = q->alignment() | Qt::TextSingleLine;

		if ( fm.width(q->text()) > rect.width() ) {
			//QPixmap pixmap(rect.size());//, QImage::Format_ARGB32);
			QImage pixmap(rect.size(), QImage::Format_ARGB32);
			pixmap.fill(Qt::transparent);

			QPainter p(&pixmap);
			p.setPen(painter.pen());
			p.setFont(painter.font());

			/*
			QLinearGradient gradient(rect.topLeft(), rect.topRight());
			QColor from = q->palette().color(QPalette::WindowText);
			QColor to = from;
			to.setAlpha(0);
			gradient.setColorAt(0.8, from);
			gradient.setColorAt(1.0, to);
			p.setPen(QPen(gradient, 0));
			*/
			p.drawText(pixmap.rect(), flags, q->text());

			QLinearGradient alphaGradient(rect.topLeft(), rect.topRight());
			alphaGradient.setColorAt(0.8, QColor(0,0,0,255));
			alphaGradient.setColorAt(1.0, QColor(0,0,0,0));
			p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
			p.fillRect(pixmap.rect(), alphaGradient);

			painter.drawImage(rect.topLeft(), pixmap);
		}
		else {
			painter.setPen(q->palette().color(QPalette::WindowText));
			painter.drawText(rect, flags, q->text());
		}
		
		return true;
	}

	// standard event processing
	return QObject::eventFilter(obj, event);
}
int GTUtilsOptionPanelMsa::getHeight(HI::GUITestOpStatus &os){
    QLabel* alignmentHeightLabel = qobject_cast<QLabel*>(GTWidget::findWidget(os, "alignmentHeight"));
    GT_CHECK_RESULT(alignmentHeightLabel != NULL, "alignmentHeightLabel not found", -1);
    bool ok;
    int result = alignmentHeightLabel->text().toInt(&ok);
    GT_CHECK_RESULT(ok == true, "label text is not int", -1);
    return result;
}
void BlackListBalooEmailCompletionWidgetTest::shouldHaveDefaultValue()
{
    KPIM::BlackListBalooEmailCompletionWidget widget;
    widget.show();
    QTest::qWaitForWindowExposed(&widget);
    QLabel *searchLabel = widget.findChild<QLabel *>(QStringLiteral("search_label"));
    QVERIFY(searchLabel);

    KLineEdit *searchLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
    QVERIFY(searchLineEdit);
    QVERIFY(searchLineEdit->isClearButtonShown());
    QVERIFY(searchLineEdit->trapReturnKey());
    QVERIFY(searchLineEdit->text().isEmpty());

    QPushButton *seachButton = widget.findChild<QPushButton *>(QStringLiteral("search_button"));
    QVERIFY(seachButton);
    QVERIFY(!seachButton->isEnabled());

    QLabel *moreResult = widget.findChild<QLabel *>(QStringLiteral("moreresultlabel"));
    QVERIFY(moreResult);
    QVERIFY(!moreResult->isVisible());

    QLabel *mNumberOfEmailsFound = widget.findChild<QLabel *>(QStringLiteral("numberofemailsfound"));
    QVERIFY(mNumberOfEmailsFound);
    QVERIFY(mNumberOfEmailsFound->text().isEmpty());

    QPushButton *showAllBlackListedEmails = widget.findChild<QPushButton *>(QStringLiteral("show_blacklisted_email_button"));
    QVERIFY(showAllBlackListedEmails);

    KPIM::BlackListBalooEmailList *emailList = widget.findChild<KPIM::BlackListBalooEmailList *>(QStringLiteral("email_list"));
    QVERIFY(emailList);

    QPushButton *selectButton = widget.findChild<QPushButton *>(QStringLiteral("select_email"));
    QVERIFY(selectButton);
    QVERIFY(!selectButton->isEnabled());
    QPushButton *unselectButton = widget.findChild<QPushButton *>(QStringLiteral("unselect_email"));
    QVERIFY(unselectButton);
    QVERIFY(!unselectButton->isEnabled());

    QLabel *excludeDomainLabel = widget.findChild<QLabel *>(QStringLiteral("domain_label"));
    QVERIFY(excludeDomainLabel);

    KLineEdit *excludeDomainLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("domain_lineedit"));
    QVERIFY(excludeDomainLineEdit);
    QVERIFY(excludeDomainLineEdit->trapReturnKey());
    QVERIFY(excludeDomainLineEdit->text().isEmpty());
    QVERIFY(excludeDomainLineEdit->isClearButtonShown());
    QVERIFY(!excludeDomainLineEdit->placeholderText().isEmpty());

    KListWidgetSearchLine *searchInResult = widget.findChild<KListWidgetSearchLine *>(QStringLiteral("searchinresultlineedit"));
    QVERIFY(searchInResult);
    QVERIFY(!searchInResult->placeholderText().isEmpty());
    QVERIFY(searchInResult->text().isEmpty());
    QVERIFY(searchInResult->isClearButtonEnabled());

    KPIM::BlackListBalooEmailWarning *blackListWarning = widget.findChild<KPIM::BlackListBalooEmailWarning *>(QStringLiteral("backlistwarning"));
    QVERIFY(blackListWarning);
}
void NotificationDialog::getDataFromDatabase(){
    ui->tableWidget->setRowCount(0);
    bool disconnect = false;
    bool connected = true;
    if(!db.isOpen()){
        disconnect = true;
        connected = parent->connectToDatabase(&db, false, this);
    }
    if(connected){
        for(int i = 0; i < parent->cNotifications.size(); i++){
            QLabel * item = new QLabel;
            QStringList columnNames = parent->getColumnsNames("Customers");
            QVector<QStringList> retrievedData = parent->executeSelectCommand("Customers", columnNames, "ID=" + QString::number(parent->cNotifications[i].customer));
            if(!retrievedData.isEmpty()){
                if(!retrievedData[0].isEmpty()){
                    item->setText(retrievedData[columnNames.indexOf("Surname")][0] + " " + retrievedData[columnNames.indexOf("Name")][0] + " " + retrievedData[columnNames.indexOf("Patronomic")][0] + "\nТелефонный номер: (" + retrievedData[columnNames.indexOf("PhoneCode")][0] + ")" + retrievedData[columnNames.indexOf("PhoneNumber")][0] + "\nПО: " + parent->cNotifications[i].soft + "\nДата истечения лицензии: " + parent->cNotifications[i].date);
                    QFontMetrics fontMetrics = item->fontMetrics();
                    QSize textSize = fontMetrics.size(0, item->text());
                    int textWidth = textSize.width() + 30;
                    int textHeight = textSize.height() + 20;
                    item->setMinimumSize(textWidth, textHeight);
                    item->resize(textWidth, textHeight);
                    ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
                    ui->tableWidget->setCellWidget(ui->tableWidget->rowCount() - 1, 0, item);
                    ui->tableWidget->setRowHeight(ui->tableWidget->rowCount() - 1, textHeight);
                }
            }
        }
        for(int i = 0; i < parent->lNotifications.size(); i++){
            QLabel * item = new QLabel;
            item->setText("ПО: " + parent->lNotifications[i].soft + "\nОсталось лицензий: " + QString::number(parent->lNotifications[i].count));
            QFontMetrics fontMetrics = item->fontMetrics();
            QSize textSize = fontMetrics.size(0, item->text());
            int textWidth = textSize.width() + 30;
            int textHeight = textSize.height() + 20;
            item->setMinimumSize(textWidth, textHeight);
            item->resize(textWidth, textHeight);
            ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
            ui->tableWidget->setCellWidget(ui->tableWidget->rowCount() - 1, 0, item);
            ui->tableWidget->setRowHeight(ui->tableWidget->rowCount() - 1, textHeight);
        }
    }
    if(disconnect)
        parent->disconnectFromDatabase(&db);
}
Beispiel #27
0
		bool eventFilter(QObject *obj, QEvent *event) {
			if ( event->type() == QEvent::Paint ) {
				QLabel *l = static_cast<QLabel*>(obj);
				QPainter painter(l);

				painter.fillRect(l->rect(), midBg);

				/*
				painter.setPen(Qt::black);
				painter.drawLine(0,0,0,l->height());
				painter.drawLine(0,l->height()-1,l->width(),l->height()-1);
				*/
				painter.setPen(normalText);

				int tw = l->fontMetrics().width(l->text());
				QRect tr = l->rect().adjusted(20,0,-20,0);

				if ( tw > tr.width() ) {
					QPixmap pixmap(tr.size());
					pixmap.fill(Qt::transparent);

					QPainter p(&pixmap);
					p.setPen(painter.pen());
					p.setFont(painter.font());

					p.drawText(pixmap.rect(), l->alignment() | Qt::TextSingleLine, l->text());

					QLinearGradient alphaGradient(QPoint(0,0), QPoint(tr.width(),0));
					alphaGradient.setColorAt(0.8, QColor(0,0,0,255));
					alphaGradient.setColorAt(1.0, QColor(0,0,0,0));
					p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
					p.fillRect(pixmap.rect(), alphaGradient);

					painter.drawPixmap(tr.topLeft(), pixmap);
				}
				else
					painter.drawText(tr, Qt::AlignLeft | Qt::AlignVCenter,
					                 l->text());

				return true;
			}

			return QObject::eventFilter(obj, event);
		}
Beispiel #28
0
//al seleccionar un modulo, se crean las etiquetas y los campos editables de los parametros de dicho modulo.
void ParameterDialog::updateField(QString module){
    ui->label->setText("Parameters of "+module+":");
    int index = ui->currentList->currentRow();
    clearLists();
    if(index < 0 )
        return;
    std::deque<parameter> parametros;
    parametros = getParameters(index);
    int j=0;
    //Se revisa la lista de parametros del module seleccionado.
    for(int i = 0; i < parametros.size(); i++){
        //por cada parametro se crea una etiqueta y su campo editor de dato dependiendo de la tipo del parametro.
        QLabel *labelTemp = new QLabel(ui->scrollAreaWidgetContents);
        parameter &p = parametros[i];
        labelTemp->setText(p.name);
        if( p.type == "int"){
            QSpinBox *lineEditTemp = new QSpinBox(ui->scrollAreaWidgetContents);
            lineEditTemp->setMaximum((va->moduleSequence[index]->listParameters[i].value.toInt())+1000);
            lineEditTemp->setValue(va->moduleSequence[index]->listParameters[i].value.toInt());
            lineEditTemp->setObjectName(va->moduleSequence[index]->listParameters[i].name);
            lineEditTemp->show();
            lineEditTemp->setGeometry(QRect(160,30+j,113,20));
            valueSB.push_back(lineEditTemp);
        }
        else if( p.type == "QString"){
            QLineEdit *lineEditTemp = new QLineEdit(ui->scrollAreaWidgetContents);
            lineEditTemp->setText(p.value);
            lineEditTemp->setObjectName(p.name);
            lineEditTemp->show();
            lineEditTemp->setGeometry(QRect(160,30+j,113,20));
            valueL.push_back(lineEditTemp);
        }
        else if( p.type == "double"){
            QDoubleSpinBox * lineEditTemp = new QDoubleSpinBox(ui->scrollAreaWidgetContents);
            lineEditTemp->setMaximum(p.value.toInt()+1000);
            lineEditTemp->setValue(p.value.toDouble());
            lineEditTemp->setObjectName(p.name);
            lineEditTemp->show();
            lineEditTemp->setGeometry(QRect(160,30+j,113,20));
            valueDSB.push_back(lineEditTemp);
        }
        else {
            QLineEdit *lineEditTemp = new QLineEdit(ui->scrollAreaWidgetContents);
            lineEditTemp->setText(p.value);
            lineEditTemp->setObjectName(p.name);
            lineEditTemp->show();
            lineEditTemp->setGeometry(QRect(160,30+j,113,20));
            valueL.push_back(lineEditTemp);
        }
        labelTemp->show();
        labelTemp->setGeometry(QRect(10,30+j,(labelTemp->text().size())*7,13));
        nameParam.push_back(labelTemp);
        j+=30;
    }
    ui->scrollAreaWidgetContents->setGeometry(ui->scrollAreaWidgetContents->x(), ui->scrollAreaWidgetContents->y(), ui->scrollAreaWidgetContents->width(), j+40);
}
Beispiel #29
0
void GroupChatForm::onUserListChanged()
{
    nusersLabel->setText(tr("%1 users in chat").arg(group->getPeersCount()));

    QLayoutItem *child;
    while ((child = namesListLayout->takeAt(0)))
    {
        child->widget()->hide();
        delete child->widget();
        delete child;
    }
    peerLabels.clear();

    // the list needs peers in peernumber order, nameLayout needs alphabetical
    QMap<QString, QLabel*> orderizer;

    // first traverse in peer number order, storing the QLabels as necessary
    QStringList names = group->getPeerList();
    unsigned nNames = names.size();
    for (unsigned i=0; i<nNames; ++i)
    {
        peerLabels.append(new QLabel(names[i]));
        peerLabels[i]->setTextFormat(Qt::PlainText);
        orderizer[names[i]] = peerLabels[i];
        if (group->isSelfPeerNumber(i))
            peerLabels[i]->setStyleSheet("QLabel {color : green;}");
    }
    // now alphabetize and add to layout
    names.sort(Qt::CaseInsensitive);
    for (unsigned i=0; i<nNames; ++i)
    {
        QLabel* label = orderizer[names[i]];
        if (i != nNames - 1)
            label->setText(label->text() + ", ");

        namesListLayout->addWidget(label);
    }

    // Enable or disable call button
    if (group->getPeersCount() != 1)
    {
        callButton->setEnabled(true);
        callButton->setObjectName("green");
        callButton->style()->polish(callButton);
        callButton->setToolTip(tr("Start audio call"));
    }
    else
    {
        callButton->setEnabled(false);
        callButton->setObjectName("grey");
        callButton->style()->polish(callButton);
        callButton->setToolTip("");
    }
}
Beispiel #30
0
void ErrorListWidget::copyCurrentItem()
{
	QListWidgetItem *item = currentItem();
	QLabel *label = item ? dynamic_cast<QLabel *>(itemWidget(item)) : nullptr;
	if (label) {
		// Extracting a plain text
		QTextDocument document;
		document.setHtml(label->text());
		QApplication::clipboard()->setText(document.toPlainText());
	}
}