예제 #1
0
파일: DialDialog.cpp 프로젝트: KDE/kfritz
DialDialog::DialDialog(QWidget *parent, std::string number)
:KDialog(parent) {
	setButtons(Ok | Cancel);
	setButtonText(Ok, i18n("Dial"));
	connect(this, SIGNAL(okClicked()), this, SLOT(dialNumber()));
	resize(300,100);
	setCaption(i18n("Dial number"));
	QWidget *widget = new QWidget();
	ui = new Ui::DialDialog();
	ui->setupUi(widget);
	setMainWidget(widget);
	ui->numberLine->setText(number.c_str());
	QRegExp rx("[0-9\\*#]+");
	QRegExpValidator *validator = new QRegExpValidator(rx, this);
	ui->numberLine->setValidator(validator);
	ui->numberLine->setFocus();

	// populate msn combo box
	std::vector<std::string> names = fritz::gConfig->getSipNames();
	std::vector<std::string> msns = fritz::gConfig->getSipMsns();
	ui->msnComboBox->addItem(i18n("Default"), "");
	QString line("*111# - ");
	line.append(i18n("Conventional telephone network"));
	ui->msnComboBox->addItem(line, "*111#");
	for (size_t i=0; i<names.size(); i++) {
		std::stringstream prefix;
		prefix << "*12" << (i+1) << "#";
		std::stringstream line;
		line << prefix.str() << " - " << names[i] << " (" << msns[i] << ")";
		ui->msnComboBox->addItem(line.str().c_str(), prefix.str().c_str());
	}
}
예제 #2
0
void ExtendedTableWidget::contextMenuEvent(QContextMenuEvent * event)
{
    QTableWidgetItem *item = itemAt(event->pos());
    QAction *action;
    if (item) {
        event->accept();
        QMenu contextMenu( this );
        if (m_editable) {
            action = contextMenu.addAction(tr("&Remove"), this, SLOT(remove()));
            action->setProperty("row", row(item));
        }
        if (PhoneNumber::phone_re().exactMatch(item->text())) {
            action = contextMenu.addAction(tr("&Dial"), this, SLOT(dialNumber()));
            action->setProperty("number", item->text());
        } else if(item->text().contains("@")) {
            action = contextMenu.addAction(tr("Send an E-mail"),
                                           this, SLOT(sendMail()) );
            action->setProperty("email", item->text());
        }
        if(!contextMenu.isEmpty()) {
            contextMenu.exec(event->globalPos());
        }
    } else {
        event->ignore();
    }
}
예제 #3
0
/*! \brief display the context Menu
 */
void ExtendedTableWidget::contextMenuEvent(QContextMenuEvent * event)
{
    qDebug() << Q_FUNC_INFO << event;
    qDebug() << "   " << event->pos();
    QTableWidgetItem *item = itemAt(event->pos());
    QAction *action;
    if (item) {
        event->accept();
        QMenu contextMenu( this );
        if (m_editable) {
            action = contextMenu.addAction(tr("&Remove"), this, SLOT(remove()));
            action->setProperty("row", row(item));
        }
        if (m_re_number.exactMatch(item->text())) {
            action = contextMenu.addAction(tr("&Dial"), this, SLOT(dialNumber()));
            action->setProperty("number", item->text());

            QMenu *transferMenu = new QMenu(tr("Direct &Transfer"), &contextMenu);
            QMenu *indirectTransferMenu = new QMenu(tr("&Indirect Transfer"), &contextMenu);
            UserInfo *ui = b_engine->getXivoClientUser();
            if (ui) {
                foreach (const QString phone, ui->phonelist()) {
                    const PhoneInfo * pi = ui->getPhoneInfo( phone );
                    if (pi) {
                        QMapIterator<QString, QVariant> it( pi->comms() );
                        while(it.hasNext()) {
                            it.next();
                            QMap<QString, QVariant> call = it.value().toMap();
                            // Add the transfer entry with the callerid name and num
                            QString text;
                            if (call.contains("calleridname")) {
                                text.append( call["calleridname"].toString() );
                                text.append(" : ");
                            }
                            text.append(call["calleridnum"].toString() );

                            action = transferMenu->addAction(text, this, SLOT(dtransfer()));
                            action->setProperty("chan", call["peerchannel"]);
                            action->setProperty("number", item->text());

                            action = indirectTransferMenu->addAction(text, this, SLOT(itransfer()));
                            action->setProperty("chan", call["thischannel"]);
                            action->setProperty("number", item->text());
                        }
                    }
                }
            }
            if (!transferMenu->isEmpty()) {
                contextMenu.addMenu(transferMenu);
            }
            if (!indirectTransferMenu->isEmpty()) {
                contextMenu.addMenu(indirectTransferMenu);
            }
        } else if(item->text().contains("@")) { // this is an email address