FlowChartSymbolPicker::FlowChartSymbolPicker(
        const QMap<int, QString> &symbolMap, QWidget *parent)
    : QDialog(parent)
{
    id = -1;

    listWidget = new QListWidget(this);
    listWidget->setIconSize(QSize(60, 60));

    QMapIterator<int, QString> i(symbolMap);
    while (i.hasNext())
    {
        i.next();
        QListWidgetItem *item = new QListWidgetItem(i.value(),
                                                    listWidget);
        item->setIcon(iconForSymbol(i.value()));
        item->setData(Qt::UserRole, i.key());
    }

    buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
                                     | QDialogButtonBox::Cancel);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(listWidget);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

    setWindowTitle(tr("Flowchart Symbol Picker"));
}
FlowChartSymbolPicker::FlowChartSymbolPicker(const QMap<int, QString> &symbolMap,QWidget *parent) :
    QDialog(parent)
{
    id=-1;
    listWidget=new QListWidget(this);
    listWidget->setIconSize(QSize(20,20));
    listWidget->setEditTriggers(QAbstractItemView::AnyKeyPressed);
    listWidget->setViewMode(QListView::ListMode);
    QMapIterator<int,QString> i(symbolMap);
    while(i.hasNext())
    {
        i.next();
        QListWidgetItem *item=new QListWidgetItem(i.value(),listWidget);
        item->setIcon(iconForSymbol(i.value()));
        item->setData(Qt::UserRole,i.key());
        item->setText("i.key()+");
        item->setToolTip("sdfsdfsdf");
        qDebug()<<i.key()<<"--"<<i.value();
    }

    buttonBox=new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel,this);
    connect(buttonBox,SIGNAL(accepted()),this,SLOT(message()));
    connect(buttonBox,SIGNAL(rejected()),this,SLOT(reject()));


    QVBoxLayout *layout=new QVBoxLayout(this);
    layout->addWidget(listWidget);
    layout->addWidget(buttonBox);

    setLayout(layout);
    setWindowTitle(tr("Flowchart Symbol Picker"));
}
FlowChartSymbolPicker::FlowChartSymbolPicker(
        const QMap<int, QString> &symbolMap, QWidget *parent)
    : QDialog(parent)
{
    id = -1;

    listWidget = new QListWidget;
    listWidget->setIconSize(QSize(60, 60));

    QMapIterator<int, QString> i(symbolMap);
    while (i.hasNext()) {
        i.next();
        QListWidgetItem *item = new QListWidgetItem(i.value(),
                                                    listWidget);
        item->setIcon(iconForSymbol(i.value()));
        item->setData(Qt::UserRole, i.key());
    }

    okButton = new QPushButton(tr("OK"));
    okButton->setDefault(true);

    cancelButton = new QPushButton(tr("Cancel"));

    connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));

    QHBoxLayout *buttonLayout = new QHBoxLayout;
    buttonLayout->addStretch();
    buttonLayout->addWidget(okButton);
    buttonLayout->addWidget(cancelButton);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(listWidget);
    mainLayout->addLayout(buttonLayout);
    setLayout(mainLayout);

    setWindowTitle(tr("Flowchart Symbol Picker"));
}