コード例 #1
0
KoInlineObject *InsertTextReferenceAction::createInlineObject()
{
    const QList<KoTextLocator*> textLocators = m_manager->textLocators();
    if (textLocators.isEmpty()) {
        KMessageBox::information(m_canvas->canvasWidget(), i18n("Please create an index to reference first."));
        return 0;
    }

    QWidget *widget = new QWidget();
    QVBoxLayout *lay = new QVBoxLayout(widget);
    widget->setLayout(lay);
    lay->setMargin(0);

    QLabel *label = new QLabel(i18n("Select the index you want to reference"), widget);
    lay->addWidget(label);
    QStringList selectionList;
    foreach(KoTextLocator* locator, textLocators)
        selectionList << locator->word() + '(' + QString::number(locator->pageNumber()) + ')';
    QListWidget *list = new QListWidget(widget);
    lay->addWidget(list);
    list->addItems(selectionList);

    KPageDialog dialog(m_canvas->canvasWidget());
    dialog.setCaption(i18n("%1 Options", i18n("Text Reference"))); // reuse the text passed in the constructor
    dialog.addPage(widget, QString());

    KoVariable *variable = 0;
    if (dialog.exec() == KPageDialog::Accepted && list->currentRow() >= 0) {
        KoTextLocator *locator = textLocators[list->currentRow()];
        Q_ASSERT(locator);
        variable = new KoTextReference(locator->id());
    }
    return variable;
}
コード例 #2
0
void AddPluginDialog::filter()
{
    QListWidget* pluginList = ui->pluginList;

    const int curr_item = 0 < pluginList->count() ? pluginList->currentRow() : 0;
    pluginList->clear();

    static QIcon fallIco = XdgIcon::fromTheme("preferences-plugin");

    int pluginCount = mPlugins.length();
    for (int i = 0; i < pluginCount; ++i)
    {
        const LxQt::PluginInfo &plugin = mPlugins.at(i);

        QString s = QString("%1 %2 %3 %4").arg(plugin.name(),
                                               plugin.comment(),
                                               plugin.value("Name").toString(),
                                               plugin.value("Comment").toString());
        if (!s.contains(ui->searchEdit->text(), Qt::CaseInsensitive))
            continue;

        QListWidgetItem* item = new QListWidgetItem(ui->pluginList);
        item->setText(QString("<b>%1</b><br>\n%2\n").arg(plugin.name(), plugin.comment()));
        item->setIcon(plugin.icon(fallIco));
        item->setData(INDEX_ROLE, i);
    }

    if (pluginCount > 0)
        ui->pluginList->setCurrentRow(curr_item < pluginCount ? curr_item : pluginCount - 1);
}
コード例 #3
0
ファイル: mainwindow.cpp プロジェクト: hermixy/QtModbusLcd
void MainWindow::strDelete(unsigned char strNum)
{
    QListWidget* list;
    list = nullptr;
    switch(strNum)
    {
        case 1:list = listOfRows1;break;
        case 2:list = listOfRows2;break;
        case 3:list = listOfRows3;break;
        case 4:list = listOfRows4;break;
    }
    if(list != nullptr)
    {
        int i = list->currentRow();
        if(list->count()>=2)
        {
            if(i!=0) lcd->setLineNumber(strNum-1,i-1);
            else lcd->setLineNumber(strNum-1,i);
            lcd->getData()->deleteLine(strNum-1,i);

            lcd->setPos(0,strNum-1);
            display->update();
            fillLists(lcd->getData());
        }
        else QMessageBox::warning(this,"Недопустимая операция","Невозможно удалить последнюю строку");
    }
}
コード例 #4
0
ファイル: mainwindow.cpp プロジェクト: hermixy/QtModbusLcd
void MainWindow::strPaste(unsigned char strNum)
{
    QListWidget* list;
    list = nullptr;
    if(copyFlag==false)
    {
        QMessageBox::warning(this,"сообщение","Буфер обмена пуст");
        return;
    }
    else
    {
        switch(strNum)
        {
            case 1:list = listOfRows1;break;
            case 2:list = listOfRows2;break;
            case 3:list = listOfRows3;break;
            case 4:list = listOfRows4;break;
        }
        if(list != nullptr)
        {
            int i = list->currentRow();
            lcd->getData()->insertLine(copyLine,strNum-1,i);
            lcd->setLineNumber(strNum-1,i);
            lcd->setPos(0,strNum-1);
            display->update();
            fillLists(lcd->getData());
        }
    }
}
コード例 #5
0
QString Configurator::getActiveSectionItem()
{
  	QListWidget* listWidget = qobject_cast<QListWidget*>( _sections->currentWidget() );
   	if( 0 != listWidget )
   		return listWidget->objectName() +"/"+ listWidget->item( listWidget->currentRow() )->data( Qt::UserRole ).toString();

	return QString();
}
コード例 #6
0
ファイル: lairtool.cpp プロジェクト: Mesagoppinmypants/Tools
void LairTool::removeBuilding() {
    QListWidget* list = getCurrentBuildingList();

    if (list == NULL)
        return;

    int idx = list->currentRow();

    delete list->takeItem(idx);
}
コード例 #7
0
ファイル: itemorderlist.cpp プロジェクト: DINKIN/CopyQ
void ItemOrderList::on_pushButtonDown_clicked()
{
    QListWidget *list = ui->listWidgetItems;
    const int row = list->currentRow();
    if (row < 0 || row == list->count() - 1)
        return;

    list->blockSignals(true);
    list->insertItem(row + 1, list->takeItem(row));
    list->setCurrentRow(row + 1);
    list->blockSignals(false);
}
コード例 #8
0
ファイル: itemorderlist.cpp プロジェクト: amosbird/CopyQ
void ItemOrderList::onPushButtonUpClicked()
{
    QListWidget *list = ui->listWidgetItems;
    const int row = list->currentRow();
    if (row < 1)
        return;

    list->blockSignals(true);
    list->insertItem(row - 1, list->takeItem(row));
    list->setCurrentRow(row - 1);
    list->blockSignals(false);
}
コード例 #9
0
ファイル: mainwindow.cpp プロジェクト: hermixy/QtModbusLcd
void MainWindow::strCopy(unsigned char strNum)
{
    QListWidget* list;
    list = nullptr;
    switch(strNum)
    {
        case 1:list = listOfRows1;break;
        case 2:list = listOfRows2;break;
        case 3:list = listOfRows3;break;
        case 4:list = listOfRows4;break;
    }
    if(list != nullptr)
    {
        int i = list->currentRow();
        copyLine = *(lcd->getData()->getLine(strNum-1,i));
        copyFlag = true;
        statusBar()->showMessage("Строка скопирована в буфер обмена",2000);
    }
}
コード例 #10
0
ファイル: SettingsWidget.cpp プロジェクト: arthurzam/QMPlay2
void SettingsWidget::moveModule()
{
	if (QToolButton *tB = qobject_cast<QToolButton *>(sender()))
	{
		const bool moveDown = tB->arrowType() == Qt::DownArrow;
		const int idx = tB->property("idx").toInt();
		QListWidget *mL = page2ModulesList[idx]->list;
		int row = mL->currentRow();
		if (row > -1)
		{
			QListWidgetItem *item = mL->takeItem(row);
			mL->clearSelection();
			if (moveDown)
				++row;
			else
				--row;
			mL->insertItem(row, item);
			mL->setCurrentItem(item);
		}
	}
}
コード例 #11
0
// **** keyboard selection dialog *********************************************
int KNHelper::selectDialog(QWidget *parent, const QString &caption, const QStringList &options, int initialValue)
{
  KDialog *dlg = new KDialog( parent );
  dlg->setCaption( caption );
  dlg->setButtons( KDialog::Ok|KDialog::Cancel );
  dlg->setDefaultButton( KDialog::Ok );

  QFrame *page = new QFrame( dlg );
  dlg->setMainWidget( page );
  QHBoxLayout *pageL = new QHBoxLayout(page);
  pageL->setSpacing(5);
  pageL->setMargin(8);

  QListWidget *list = new QListWidget( page );
  pageL->addWidget(list);

  QString s;
  for ( QStringList::ConstIterator it = options.begin(); it != options.end(); ++it ) {
    s = (*it);
    // remove accelerators
    s.replace( QRegExp( "&" ), "" ); // krazy:exclude=doublequote_chars
    list->addItem( s );
  }

  list->setCurrentRow( initialValue );
  list->setFocus();
  QObject::connect( list, SIGNAL( itemActivated( QListWidgetItem* ) ), dlg, SLOT( accept() ) );
  restoreWindowSize("selectBox", dlg, QSize(247,174));

  int ret;
  if (dlg->exec())
    ret = list->currentRow();
  else
    ret = -1;

  saveWindowSize("selectBox", dlg->size());
  delete dlg;
  return ret;
}
コード例 #12
0
ファイル: mainwindow.cpp プロジェクト: hermixy/QtModbusLcd
void MainWindow::strAddAfter(unsigned char strNum)
{
    QListWidget* list;
    list = nullptr;
    switch(strNum)
    {
        case 1:list = listOfRows1;break;
        case 2:list = listOfRows2;break;
        case 3:list = listOfRows3;break;
        case 4:list = listOfRows4;break;
    }
    if(list != nullptr)
    {
        int i = list->currentRow();
        LineOfSymbols line;
        lcd->getData()->insertLineWithShift(line,strNum-1,i+1);
        lcd->setLineNumber(strNum-1,i+1);
        lcd->setPos(0,strNum-1);
        display->update();
        fillLists(lcd->getData());
    }
}
コード例 #13
0
void AddPluginDialog::filter()
{
    QListWidget* pluginList = ui->pluginList;

    const int curr_item = 0 < pluginList->count() ? pluginList->currentRow() : 0;
    pluginList->clear();

    static QIcon fallIco = XdgIcon::fromTheme("preferences-plugin");

    int pluginCount = mPlugins.length();
    for (int i = 0; i < pluginCount; ++i)
    {
        const LXQt::PluginInfo &plugin = mPlugins.at(i);

        QString s = QStringLiteral("%1 %2 %3 %4").arg(plugin.name(),
                                               plugin.comment(),
                                               plugin.value("Name").toString(),
                                               plugin.value("Comment").toString());
        if (!s.contains(ui->searchEdit->text(), Qt::CaseInsensitive))
            continue;

        QListWidgetItem* item = new QListWidgetItem(ui->pluginList);
        // disable single-instances plugins already in use
        if (dynamic_cast<LXQtPanelApplication const *>(qApp)->isPluginSingletonAndRunnig(plugin.id()))
        {
            item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
            item->setBackground(palette().brush(QPalette::Disabled, QPalette::Text));
            item->setText(QStringLiteral("<b>%1</b><br>%2<br><small>%3</small>")
                    .arg(plugin.name(), plugin.comment(), tr("(only one instance can run at a time)")));
        } else
            item->setText(QStringLiteral("<b>%1</b><br>%2").arg(plugin.name(), plugin.comment()));
        item->setIcon(plugin.icon(fallIco));
        item->setData(INDEX_ROLE, i);
    }

    if (pluginCount > 0)
        ui->pluginList->setCurrentRow(curr_item < pluginCount ? curr_item : pluginCount - 1);
}
コード例 #14
0
ファイル: mpv_kde4.cpp プロジェクト: rofl0r/mp-5.x
static mpdm_t kde4_drv_form(mpdm_t a, mpdm_t ctxt)
{
    int n;
    mpdm_t widget_list;
    QWidget *qlist[100];
    mpdm_t r;

    KDialog *dialog = new KDialog(window);

    dialog->setModal(true);
    dialog->setButtons(KDialog::Ok | KDialog::Cancel);

    widget_list = mpdm_aget(a, 0);

    KVBox *vb = new KVBox(dialog);
    dialog->setMainWidget(vb);

    for (n = 0; n < mpdm_size(widget_list); n++) {
        mpdm_t w = mpdm_aget(widget_list, n);
        wchar_t *type;
        mpdm_t t;
        KHBox *hb = new KHBox(vb);

        type = mpdm_string(mpdm_hget_s(w, L"type"));

        if ((t = mpdm_hget_s(w, L"label")) != NULL) {
            QLabel *ql = new QLabel(hb);
            ql->setText(str_to_qstring(mpdm_gettext(t)));
        }

        t = mpdm_hget_s(w, L"value");

        if (wcscmp(type, L"text") == 0) {
            mpdm_t h;
            QComboBox *ql = new QComboBox(hb);

            ql->setEditable(true);
            ql->setMinimumContentsLength(30);
            ql->setMaxVisibleItems(8);

            if (t != NULL)
                ql->setEditText(str_to_qstring(t));

            qlist[n] = ql;

            if ((h = mpdm_hget_s(w, L"history")) != NULL) {
                int i;

                /* has history; fill it */
                h = mp_get_history(h);

                for (i = mpdm_size(h) - 1; i >= 0; i--)
                    ql->addItem(str_to_qstring(mpdm_aget(h, i)));
            }
        }
        else
        if (wcscmp(type, L"password") == 0) {
            QLineEdit *ql = new QLineEdit(hb);

            ql->setEchoMode(QLineEdit::Password);

            qlist[n] = ql;
        }
        else
        if (wcscmp(type, L"checkbox") == 0) {
            QCheckBox *qc = new QCheckBox(hb);

            if (mpdm_ival(t))
                qc->setCheckState(Qt::Checked);

            qlist[n] = qc;
        }
        else
        if (wcscmp(type, L"list") == 0) {
            int i;
            QListWidget *ql = new QListWidget(hb);
            ql->setMinimumWidth(480);

            /* use a monospaced font */
            ql->setFont(QFont(QString("Mono")));

            mpdm_t l = mpdm_hget_s(w, L"list");

            for (i = 0; i < mpdm_size(l); i++)
                ql->addItem(str_to_qstring(mpdm_aget(l, i)));

            ql->setCurrentRow(mpdm_ival(t));

            qlist[n] = ql;
        }

        if (n == 0)
            qlist[n]->setFocus(Qt::OtherFocusReason);
    }

    n = dialog->exec();

    if (!n)
        return NULL;

    r = MPDM_A(mpdm_size(widget_list));

    /* fill the return values */
    for (n = 0; n < mpdm_size(widget_list); n++) {
        mpdm_t w = mpdm_aget(widget_list, n);
        mpdm_t v = NULL;
        wchar_t *type;

        type = mpdm_string(mpdm_hget_s(w, L"type"));

        if (wcscmp(type, L"text") == 0) {
            mpdm_t h;
            QComboBox *ql = (QComboBox *) qlist[n];

            v = qstring_to_str(ql->currentText());

            /* if it has history, add to it */
            if ((h = mpdm_hget_s(w, L"history")) != NULL &&
                v != NULL && mpdm_cmp_s(v, L"") != 0) {
                h = mp_get_history(h);

                if (mpdm_cmp(v, mpdm_aget(h, -1)) != 0)
                    mpdm_push(h, v);
            }
        }
        else
        if (wcscmp(type, L"password") == 0) {
            QLineEdit *ql = (QLineEdit *) qlist[n];

            v = qstring_to_str(ql->text());
        }
        else
        if (wcscmp(type, L"checkbox") == 0) {
            QCheckBox *qb = (QCheckBox *) qlist[n];

            v = MPDM_I(qb->checkState() == Qt::Checked);
        }
        else
        if (wcscmp(type, L"list") == 0) {
            QListWidget *ql = (QListWidget *) qlist[n];

            v = MPDM_I(ql->currentRow());
        }

        mpdm_aset(r, v, n);
    }

    return r;
}