int cQFilterWindow::GetValueChoiceIndex( const eValue iValue, int iItemIndex ) const
/**********************************************************************/
{
    QListWidget *vList = ( QListWidget*)( mGrid.itemAtPosition( (int)iValue, 1 )->widget() );
    
    return vList->row( vList->selectedItems()[ iItemIndex ] );
}
/**
 * Synchronize parameter b_selected in the values list
 * @param object A WidgetMapper
 **/
void ExtensionDialog::SyncSelection( QObject *object )
{
    assert( object != NULL );
    struct /*extension_widget_t::*/extension_widget_value_t *p_value;			// sunqueen modify

    bool lockedHere = false;
    if( !has_lock )
    {
        vlc_mutex_lock( &p_dialog->lock );
        has_lock = true;
        lockedHere = true;
    }

    WidgetMapper *mapping = static_cast< WidgetMapper* >( object );
    extension_widget_t *p_widget = mapping->getWidget();
    assert( p_widget->type == EXTENSION_WIDGET_DROPDOWN
            || p_widget->type == EXTENSION_WIDGET_LIST );

    if( p_widget->type == EXTENSION_WIDGET_DROPDOWN )
    {
        QComboBox *combo = static_cast< QComboBox* >( p_widget->p_sys_intf );
        for( p_value = p_widget->p_values;
             p_value != NULL;
             p_value = p_value->p_next )
        {
//             if( !qstrcmp( p_value->psz_text, qtu( combo->currentText() ) ) )
            if( combo->itemData( combo->currentIndex(), Qt::UserRole ).toInt()
                == p_value->i_id )
            {
                p_value->b_selected = true;
            }
            else
            {
                p_value->b_selected = false;
            }
        }
        free( p_widget->psz_text );
        p_widget->psz_text = strdup( qtu( combo->currentText() ) );
    }
    else if( p_widget->type == EXTENSION_WIDGET_LIST )
    {
        QListWidget *list = static_cast<QListWidget*>( p_widget->p_sys_intf );
        QList<QListWidgetItem *> selection = list->selectedItems();
        for( p_value = p_widget->p_values;
             p_value != NULL;
             p_value = p_value->p_next )
        {
            bool b_selected = false;
            foreach( const QListWidgetItem *item, selection )
            {
//                 if( !qstrcmp( qtu( item->text() ), p_value->psz_text ) )
                if( item->data( Qt::UserRole ).toInt() == p_value->i_id )
                {
                    b_selected = true;
                    break;
                }
            }
            p_value->b_selected = b_selected;
        }
    }
const QList<QListWidgetItem*> cQFilterWindow::GetValueChoice( const eValue iValue ) const
/**********************************************************************/
{
    QListWidget *vList = ( QListWidget*)( mGrid.itemAtPosition( (int)iValue, 1 )->widget() );

    return vList->selectedItems();
}
Esempio n. 4
0
void
PreferencesDialog::moveSelectedListWidgetItems(QListWidget &from,
                                               QListWidget &to) {
  for (auto const &item : from.selectedItems()) {
    auto actualItem = from.takeItem(from.row(item));
    if (actualItem)
      to.addItem(actualItem);
  }
}
Esempio n. 5
0
void MainWindow::focusAssistant()
{
    QListWidget* widget = qobject_cast<QListWidget*>(m_assistantToolBox->currentWidget());
    if (widget) {
        widget->setFocus();
        if (widget->selectedItems().count() == 0) {
            widget->setCurrentItem(widget->itemAt(0, 0));
        }
    }
}
Esempio n. 6
0
void KActionSelectorPrivate::buttonAddClicked()
{
  // move all selected items from available to selected listbox
  QList<QListWidgetItem *> list = availableListWidget->selectedItems();
  foreach (QListWidgetItem* item, list) {
    availableListWidget->takeItem( availableListWidget->row( item ) );
    selectedListWidget->insertItem( insertionIndex( selectedListWidget, selectedInsertionPolicy ), item );
    selectedListWidget->setCurrentItem( item );
    emit q->added( item );
  }
Esempio n. 7
0
void ManageUserDirectories::moveUp() {
  QListWidget *list = listWidget();
  QList<QListWidgetItem *> selected = list->selectedItems();
  for (int i = 0; i < selected.size(); i++) {
    int index = list->row(selected[i]);
    if (index != 0) {
      QListWidgetItem *move = list->takeItem(index);
      list->insertItem(index - 1, move);
    }
    list->setCurrentItem(selected[i]);
  }
}
Esempio n. 8
0
void MainWindow::on_removeVesselPushButton_clicked()
{
    QListWidget* injectionList = findChild<QListWidget*>("InjectableVesselsListView");
    QListWidget* savesList = findChild<QListWidget*>("vesselsInSaveListView");

    QList<QListWidgetItem*> selected = savesList->selectedItems();

    for(QList<QListWidgetItem*>::Iterator it = selected.begin(); it != selected.end(); it++)
    {
        QListWidgetItem* item = (*it);
        savesList->takeItem(savesList->row(item));
        injectionList->addItem(item);
    }
}
Esempio n. 9
0
void SkillEditFrame::on_removeButton_released()
{
	QListWidget *skillList = this->findChild<QListWidget *>("skillList");
	QList<QListWidgetItem *> items = skillList->selectedItems();
	for (int i=0; i<items.size(); ++i) {
		DataListItem *item = (DataListItem *)items[i];
		if (item == 0)
			return;
		if (item->getStringData().size() == 0)
			return;
		character->removeSkill(item->getStringData().c_str());
		
		delete item;
	}
}
Esempio n. 10
0
void MainWindow::on_deleteButton_clicked()
{
    QListWidget *list = ui->taskList;
    for (QListWidgetItem *item : list->selectedItems())
    {
        bool hasId = false;
        int id = item->data(Qt::UserRole).toInt(&hasId);
        if (hasId)
        {
            deleteTask(id);
        }
        list->takeItem(list->row(item));
        delete item;
    }
}
Esempio n. 11
0
void PredicatXUVParmis::delUv()
{
    QListWidget *candidat = sender()->parent()->findChild<QListWidget*>("candidat");
    if(!candidat)
        UTPROFILER_EXCEPTION("L'editeur de prédicat est corrompu");

    QList<QListWidgetItem*> selection = candidat->selectedItems();

    if(selection.isEmpty())
        return;

    for(auto it = selection.begin() ; it != selection.end() ; it++)
    {
        QListWidgetItem *item = *it;
        qDebug() << item->text();
        candidat->removeItemWidget(item);
        candidats.removeOne(item->text()); //TODO changer le nom de tout ça
    }
}
Esempio n. 12
0
void DrawingView::printPdf()
{
    Gui::FileOptionsDialog dlg(this, 0);
    dlg.setFileMode(QFileDialog::AnyFile);
    dlg.setAcceptMode(QFileDialog::AcceptSave);
    dlg.setWindowTitle(tr("Export PDF"));
    dlg.setFilters(QStringList() << tr("PDF file (*.pdf)"));

    QGridLayout *gridLayout;
    QGridLayout *formLayout;
    QGroupBox *groupBox;
    QListWidget *listWidget;
    QListWidgetItem* item;
    QWidget *form = new QWidget(&dlg);
    form->resize(40, 300);
    formLayout = new QGridLayout(form);
    groupBox = new QGroupBox(form);
    gridLayout = new QGridLayout(groupBox);
    listWidget = new QListWidget(groupBox);
    gridLayout->addWidget(listWidget, 0, 0, 1, 1);
    formLayout->addWidget(groupBox, 0, 0, 1, 1);

    groupBox->setTitle(tr("Page sizes"));
    item = new QListWidgetItem(tr("A0"), listWidget);
    item->setData(Qt::UserRole, QVariant(QPrinter::A0));
    item = new QListWidgetItem(tr("A1"), listWidget);
    item->setData(Qt::UserRole, QVariant(QPrinter::A1));
    item = new QListWidgetItem(tr("A2"), listWidget);
    item->setData(Qt::UserRole, QVariant(QPrinter::A2));
    item = new QListWidgetItem(tr("A3"), listWidget);
    item->setData(Qt::UserRole, QVariant(QPrinter::A3));
    item = new QListWidgetItem(tr("A4"), listWidget);
    item->setData(Qt::UserRole, QVariant(QPrinter::A4));
    item = new QListWidgetItem(tr("A5"), listWidget);
    item->setData(Qt::UserRole, QVariant(QPrinter::A5));
    int index = 4; // by default A4
    for (int i=0; i<listWidget->count(); i++) {
        if (listWidget->item(i)->data(Qt::UserRole).toInt() == m_pageSize) {
            index = i;
            break;
        }
    }
    listWidget->item(index)->setSelected(true);
    dlg.setOptionsWidget(Gui::FileOptionsDialog::ExtensionRight, form, false);

    if (dlg.exec() == QDialog::Accepted) {
        Gui::WaitCursor wc;
        QString filename = dlg.selectedFiles().front();
        QPrinter printer(QPrinter::HighResolution);
        printer.setFullPage(true);
        printer.setOutputFormat(QPrinter::PdfFormat);
        printer.setOutputFileName(filename);
        printer.setOrientation(m_orientation);
        QList<QListWidgetItem*> items = listWidget->selectedItems();
        if (items.size() == 1) {
            int AX = items.front()->data(Qt::UserRole).toInt();
            printer.setPaperSize(QPrinter::PageSize(AX));
        }

        print(&printer);
    }
}
void ConversationData::edit(QWidget *parent) {
    // TODO: modularize!
    QDialog *dialog = new QDialog(parent);
    QVBoxLayout *primaryLayout = new QVBoxLayout();

    QTabWidget *tabs = new QTabWidget();
    primaryLayout->addWidget(tabs);

    QPushButton *closeButton = new QPushButton(QObject::tr("&Close"));
    QObject::connect(closeButton, SIGNAL(clicked(bool)),
        dialog, SLOT(accept()));
    primaryLayout->addWidget(closeButton);

    dialog->setLayout(primaryLayout);

    // Character tab
    QVBoxLayout *namesLayout = new QVBoxLayout();
    QListWidget *namesList = new QListWidget;
    for(auto &name : m_characterNames) {
        namesList->addItem(name);
    }
    namesLayout->addWidget(namesList);

    QPushButton *addName = new QPushButton(QObject::tr("&Add"));
    namesLayout->addWidget(addName);
    QObject::connect(addName, &QPushButton::clicked, 
        [=](){
            bool ok = true;
            QString name = QInputDialog::getText(dialog,
                QObject::tr("New name"),
                QObject::tr("Enter new character name:"), QLineEdit::Normal,
                "", &ok);
            if(ok) namesList->addItem(name);
            else namesList->addItem("????");
        });
    QPushButton *removeName = new QPushButton(QObject::tr("&Delete"));
    QObject::connect(removeName, &QPushButton::clicked, 
        [=](){
            for(auto it : namesList->selectedItems()) {
                delete it;
            }
        });
    namesLayout->addWidget(removeName);

    QWidget *namesWidget = new QWidget();
    namesWidget->setLayout(namesLayout);
    tabs->addTab(namesWidget, QObject::tr("Character names"));

    // Contexts tab
    auto contextsLayout = new QVBoxLayout();
    QMap<int, QStandardItem *> contextMap;
    auto contextsModel = makeContextModel(contextMap, true);
    auto contextsView = new QTreeView();
    contextsView->setHeaderHidden(true);
    contextsView->setModel(contextsModel);
    contextsView->setDragDropMode(QAbstractItemView::InternalMove);
    contextsLayout->addWidget(contextsView);

    auto addContext = new QPushButton(QObject::tr("&Add"));
    QObject::connect(addContext, &QPushButton::clicked, 
        [=](){
            bool ok = true;
            QString name = QInputDialog::getText(dialog,
                QObject::tr("New context name"),
                QObject::tr("Enter new context name:"), QLineEdit::Normal,
                "", &ok);
            if(!ok) name = "????";
            int id = getAvailableID();
            auto con = m_contexts[id] = new ConversationContext(id);
            con->setLabel(name);
            auto item = makeContextItem(con, true);
            contextMap[rootContext()->id()]->appendRow(item);
        });
    contextsLayout->addWidget(addContext);
    auto removeContext = new QPushButton(QObject::tr("&Delete"));
    QObject::connect(removeContext, &QPushButton::clicked, 
        [=](){
            qDebug("Removal NYI");
        });
    contextsLayout->addWidget(removeContext);

    auto contextsWidget = new QWidget();
    contextsWidget->setLayout(contextsLayout);
    tabs->addTab(contextsWidget, QObject::tr("Node contexts"));

    dialog->exec();

    // Character tab
    m_characterNames.clear();
    while(namesList->count() > 0) {
        m_characterNames.push_back(namesList->takeItem(0)->text());
    }

    // Contexts tab
    // XXX: local function replacement
    class ContextsRearranger {
    public:
        static void rearrange(QMap<int, ConversationContext *> &contexts,
            QStandardItem *item) {

            auto thisID = item->data(0x100).toInt();
            auto thisContext = contexts[thisID];
            for(int i = 0; i < item->rowCount(); i ++) {
                auto it = item->child(i);
                auto id = it->data(0x100).toInt();
                contexts[id]->setParent(thisContext);
                contexts[id]->setLabel(it->text());
                rearrange(contexts, item->child(i));
            }
        }
    };

    ContextsRearranger::rearrange(m_contexts, contextMap[rootContext()->id()]);

    // TODO: delete all unparented contexts

    dialog->deleteLater();
}