QWidget *KisInputModeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
{
    KComboBox *combo = new KComboBox(parent);
    QStringList sorted = d->action->shortcutIndexes().keys();
    qSort(sorted);
    combo->addItems(sorted);
    return combo;
}
Exemplo n.º 2
0
/**
 * Add a new Row
 */
RowWidgetController* ClassifierListTab::addRow(bool ignoreModified)
{
    m_centralTableTW->setRowCount(m_centralTableTW->rowCount()+1);
    QString typeName;
    QString newItemType;
    RowWidgetController* aRow = new RowWidgetController(m_itemType, m_pClassifier, ignoreModified);
    switch (m_itemType) {
    case ot_Attribute: {
        QTableWidgetItem* nameWidget = new QTableWidgetItem("");
        nameWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,0,nameWidget);
        aRow->setName(nameWidget);
        //connect(nameWidget,SIGNAL(destroyed(QObject*)),aRow,SLOT(destroyTableItem(QObject*)));
        RowWidgetController::linker[nameWidget] = aRow;
        
        TypeCombo* typeCbb = new TypeCombo(this);
        m_centralTableTW->setCellWidget(m_rowCount,1,typeCbb);
        aRow->setType(typeCbb);
        
        QTableWidgetItem* inititalWidget = new QTableWidgetItem("");
        inititalWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,2,inititalWidget);
        aRow->setInitial(inititalWidget);
        //connect(inititalWidget,SIGNAL(destroyed(QObject*)),aRow,SLOT(destroyTableItem(QObject*)));
        RowWidgetController::linker[inititalWidget] = aRow;
        
        KComboBox* visibilityCbb = new KComboBox(this);
        QStringList availableVisibilities;
        availableVisibilities << "Public" << "Private" << "Protected" << "Implementation";
        visibilityCbb->addItems(availableVisibilities);
        m_centralTableTW->setCellWidget(m_rowCount,3,visibilityCbb);
        aRow->setVisibility(visibilityCbb);
        
        QTableWidgetItem* stereotypeWidget = new QTableWidgetItem("");
        stereotypeWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,4,stereotypeWidget);
        aRow->setStereotype(stereotypeWidget);
        //connect(stereotypeWidget,SIGNAL(destroyed(QObject*)),aRow,SLOT(destroyTableItem(QObject*)));
        RowWidgetController::linker[stereotypeWidget] = aRow;
        
        QCheckBox* staticCb = new QCheckBox(this);
        m_centralTableTW->setCellWidget(m_rowCount,5,staticCb);
        aRow->setStaticV(staticCb);
        
        PopupButton* docPb = new PopupButton(this);
        docPb->setText("Doc");
        m_centralTableTW->setCellWidget(m_rowCount,6,docPb);
        aRow->setDocumentation(docPb);
        
      }
      break;
    case ot_Operation: {
        typeName = i18n("Operations");
        QTableWidgetItem* nameWidget = new QTableWidgetItem("");
        nameWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,0,nameWidget);
        aRow->setName(nameWidget);
        //connect(nameWidget,SIGNAL(destroyed(QObject*)),aRow,SLOT(destroyTableItem(QObject*)));
        RowWidgetController::linker[nameWidget] = aRow;
        
        ParamWidget* paramWdg = new ParamWidget(this);
        m_centralTableTW->setCellWidget(m_rowCount,1,paramWdg);
        aRow->setParameters(paramWdg);
        
        TypeCombo* typeCbb = new TypeCombo(this);
        typeCbb->setEditable(true);
        m_centralTableTW->setCellWidget(m_rowCount,2,typeCbb);
        aRow->setType(typeCbb);
        
        KComboBox* visibilityCbb = new KComboBox(this);
        QStringList availableVisibilities;
        availableVisibilities << "Public" << "Private" << "Protected" << "Implementation"; //TODO anything better?
        visibilityCbb->addItems(availableVisibilities);
        m_centralTableTW->setCellWidget(m_rowCount,3,visibilityCbb);
        aRow->setVisibility(visibilityCbb);
        
        QTableWidgetItem* stereotypeWidget = new QTableWidgetItem("");
        stereotypeWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,4,stereotypeWidget);
        aRow->setStereotype(stereotypeWidget);
        //connect(stereotypeWidget,SIGNAL(destroyed(QObject*)),aRow,SLOT(destroyTableItem(QObject*)));
        RowWidgetController::linker[stereotypeWidget] = aRow;
        
        QCheckBox* staticCb = new QCheckBox(this);
        m_centralTableTW->setCellWidget(m_rowCount,5,staticCb);
        aRow->setStaticV(staticCb);
        
        QCheckBox* abstractCb = new QCheckBox(this);
        m_centralTableTW->setCellWidget(m_rowCount,6,abstractCb);
        aRow->setAbstract(abstractCb);
        
        QCheckBox* constCb = new QCheckBox(this);
        m_centralTableTW->setCellWidget(m_rowCount,7,constCb);
        aRow->setConstV(constCb);
        
        PopupButton* docPb = new PopupButton(this);
        docPb->setText("Doc");
        m_centralTableTW->setCellWidget(m_rowCount,8,docPb);
        aRow->setDocumentation(docPb);
        
        PopupButton* sourcePb = new PopupButton(this);
        sourcePb->setText("Source");
        m_centralTableTW->setCellWidget(m_rowCount,9,sourcePb);
        aRow->setSource(sourcePb);
        
      }
      break;
    case ot_Template: {
        typeName = i18n("Templates");
        QTableWidgetItem* nameWidget = new QTableWidgetItem("");
        nameWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,0,nameWidget);
        aRow->setName(nameWidget);
        //connect(nameWidget,SIGNAL(destroyed(QObject*)),aRow,SLOT(destroyTableItem(QObject*)));
        RowWidgetController::linker[nameWidget] = aRow;
        
        TypeCombo* typeCbb = new TypeCombo(this);
        typeCbb->setEditable(true);
        m_centralTableTW->setCellWidget(m_rowCount,1,typeCbb);
        aRow->setType(typeCbb);
        
        QTableWidgetItem* stereotypeWidget = new QTableWidgetItem("");
        stereotypeWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,2,stereotypeWidget);
        aRow->setStereotype(stereotypeWidget);
        //connect(stereotypeWidget,SIGNAL(destroyed(QObject*)),aRow,SLOT(destroyTableItem(QObject*)));
        RowWidgetController::linker[stereotypeWidget] = aRow;
        
      }
      break;
    case ot_EnumLiteral: {
        typeName = i18n("Enum Literals");
        QTableWidgetItem* nameWidget = new QTableWidgetItem("");
        nameWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,0,nameWidget);
        aRow->setName(nameWidget);
        RowWidgetController::linker[nameWidget] = aRow;
        
        QTableWidgetItem* valWidget = new QTableWidgetItem("");
        valWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,1,valWidget);
        aRow->setDefaultValue(valWidget);
        //connect(valWidget,SIGNAL(destroyed(QObject*)),aRow,SLOT(destroyTableItem(QObject*)));
        RowWidgetController::linker[valWidget] = aRow;
        
      }
      break;
    case ot_EntityAttribute: {
        typeName = i18n("Entity Attributes");
        newItemType = i18n("N&ew Entity Attribute...");
        
        QTableWidgetItem* nameWidget = new QTableWidgetItem("");
        nameWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,0,nameWidget);
        aRow->setName(nameWidget);
        RowWidgetController::linker[nameWidget] = aRow;
        
        TypeCombo* typeCbb = new TypeCombo(this);
        m_centralTableTW->setCellWidget(m_rowCount,1,typeCbb);
        aRow->setType(typeCbb);
        
        QTableWidgetItem* valWidget = new QTableWidgetItem("");
        valWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,2,valWidget);
        aRow->setDefaultValue(valWidget);
        RowWidgetController::linker[nameWidget] = aRow;
        
        QTableWidgetItem* stereotypeWidget = new QTableWidgetItem("");
        stereotypeWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,3,stereotypeWidget);
        aRow->setStereotype(stereotypeWidget);
        RowWidgetController::linker[nameWidget] = aRow;
        
        QTableWidgetItem* lengthWidget = new QTableWidgetItem("");
        lengthWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        m_centralTableTW->setItem(m_rowCount,4,lengthWidget);
        aRow->setLength(lengthWidget);
        RowWidgetController::linker[nameWidget] = aRow;
        
        KComboBox* attributesCbb = new KComboBox(this);
        //QStringList availableVisibilities;
        //availableVisibilities << "Public" << "Private" << "Protected" << "Implementation";
        //attributesCbb->addItems(availableVisibilities);
        m_centralTableTW->setCellWidget(m_rowCount,5,attributesCbb);
        aRow->setAttributes(attributesCbb);
        
        QCheckBox* autoI = new QCheckBox(this);
        m_centralTableTW->setCellWidget(m_rowCount,6,autoI);
        aRow->setAutoIncrement(autoI);
        
        QCheckBox* allowNull = new QCheckBox(this);
        m_centralTableTW->setCellWidget(m_rowCount,7,allowNull);
        aRow->setAllowNull(allowNull);
        
        QCheckBox* indexed = new QCheckBox(this);
        m_centralTableTW->setCellWidget(m_rowCount,8,indexed);
        aRow->setIndexed(indexed);
        
        PopupButton* docPb = new PopupButton(this);
        docPb->setText("Doc");
        m_centralTableTW->setCellWidget(m_rowCount,9,docPb);
        aRow->setDocumentation(docPb);
      }
      break;
    case ot_EntityConstraint:
        typeName = i18n( "Constraints" );
        newItemType = i18n( "N&ew Constraint..." );
        delete aRow;
        aRow=0;
        break;
    default:
        uWarning() << "unknown listItem type in ClassifierListTab";
        delete aRow;
        aRow=0;
        break;
    }
    m_rowCount++;
    
    if (aRow) {
      aRow->connectSlots();
      rowList << aRow;
    }
    
    return aRow;
}
Exemplo n.º 3
0
/**
 *  Fills the list box with the objects associations.
 */
void AssocTab::fillListBox()
{
    m_List.clear();
    m_pAssocTW->clear();
    setupCols();
    m_pAssocTW->setRowCount(0);
    m_pView->getWidgetAssocs(m_pObject, m_List);
    int i = 0;
    foreach( AssociationWidget* assocwidget, m_List ) {
        if( assocwidget->associationType() != Uml::at_Anchor) {
            m_pAssocTW->setRowCount(m_pAssocTW->rowCount()+1);
            
            QTableWidgetItem* nameWidget = new QTableWidgetItem("");
            nameWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
            nameWidget->setText(assocwidget->getName());
            m_pAssocTW->setItem(m_pAssocTW->rowCount()-1,0,nameWidget);
          
            /*QTableWidgetItem* newItem = new QTableWidgetItem(assocwidget->toString());
            m_pAssocTW->setItem(m_pAssocTW->rowCount()-1,1,newItem);*/
            KComboBox *typeCB = new KComboBox(this);
            m_pAssocTW->setCellWidget(m_pAssocTW->rowCount()-1,3,typeCB);
            
            Uml::Association_Type currentType =  assocwidget->associationType();
            
            int found=-1;
            QStringList assocTypeStrings;
            QList<Uml::Association_Type> assocType;
            // dynamically load all allowed associations
            for ( int i = Uml::at_Generalization; i<= Uml::at_Relationship ;  ++i ) {
                // we don't need to check for current type
                if (  ( Uml::Association_Type )i == currentType )
                    continue;

                if ( AssocRules::allowAssociation( ( Uml::Association_Type )i, assocwidget->getWidget( Uml::A ),
                                                  assocwidget->getWidget( Uml::B ))
                    ) {
                    assocType << (Uml::Association_Type)i;
                    assocTypeStrings << UMLAssociation::toString((Uml::Association_Type)i);
                    if ((Uml::Association_Type)i == currentType) 
                      found=true;
                }
            }

  
            if (found == -1) {
                assocType.insert(0, currentType);
                assocTypeStrings.insert(0,UMLAssociation::toString(currentType));
            }
            else {
              typeCB->setCurrentIndex(found);
            }
            typeCB->addItems(assocTypeStrings);
            
            QTableWidgetItem* newItem2 = new QTableWidgetItem(assocwidget->getWidget(Uml::A)->name());
            m_pAssocTW->setItem(m_pAssocTW->rowCount()-1,1,newItem2);
            
            QTableWidgetItem* newItem3 = new QTableWidgetItem(assocwidget->getWidget(Uml::B)->name());
            m_pAssocTW->setItem(m_pAssocTW->rowCount()-1,2,newItem3);
            
            QPushButton* morePb = new QPushButton(this);
            morePb->setText("Doc");
            m_pAssocTW->setCellWidget(m_pAssocTW->rowCount()-1,4,morePb);
            
            QPushButton* docPb = new QPushButton(this);
            docPb->setText("Doc");
            m_pAssocTW->setCellWidget(m_pAssocTW->rowCount()-1,5,docPb);
            
            i++;
        }
    }
}
Exemplo n.º 4
0
/*
	InputDialog
*/
InputDialog::InputDialog(const QString &caption, uint options, const QStringList& history, const QString& hint, const QString& alter, KileInfo *ki, QWidget *parent, const char *name)
	: KDialog (parent), m_ki(ki)
{
	setModal(true);
	setButtons(Ok | Cancel);
	setDefaultButton(Ok);
	showButtonSeparator(true);
	setObjectName(name);

	QString newcaption = caption;
	setCaption(newcaption.remove('&'));

	m_labelprefix = ( newcaption == "chapter" ) ? "chap:" : "sec:";

	m_usedSelection = false;

	QWidget *page = new QWidget(this);
	setMainWidget(page);
	QGridLayout *gbox = new QGridLayout(page);

	QLabel *lb = new QLabel(hint, page);
	gbox->addWidget(lb, 0, 0, 1, 3);

	m_tag.clear();
	QWidget *focus;
	if((options & KileAction::KeepHistory) || (options & KileAction::FromLabelList) || (options & KileAction::FromBibItemList)) {
		KComboBox *input = new KComboBox(true, page);
		input->setObjectName("input_dialog_input");
		input->setCompletionMode(KGlobalSettings::CompletionAuto);
		input->setMinimumWidth(300);
		focus = input;

		connect(input, SIGNAL(textChanged(const QString&)), this, SLOT(setTag(const QString&)));
		connect(this,  SIGNAL(setInput(const QString&)), input, SLOT(setEditText(const QString&)));
		if(options & KileAction::ShowBrowseButton) {
			gbox->addWidget(input, 1, 0);
		}
		else {
			gbox->addWidget(input, 1, 0, 1, 3);
		}

		QStringList list;

		if(options & KileAction::FromLabelList) {
			list = ki->allLabels();
			if(list.size() > 0) {
				input->addItems(list);
				m_tag = list.first();
			}
		}
		else if(options & KileAction::FromBibItemList) {
			list = ki->allBibItems();
			if(list.size() > 0) {
				input->addItems(list);
				m_tag = list.first();
			}
		}
		else {
			if(history.size() > 0){
				input->addItems(history);
				m_tag = history.first();
			}
		}
	}