DLG_EditToolBar
::DLG_EditToolBar(QWidget *parent
){
ui.setupUi(this);
m_activeList = new ListWidget; // subclass QListWidget
m_inactiveList = new ListWidget; // subclass QListWidget
ui.gridLayoutAD->addWidget(m_inactiveList);
ui.gridLayoutAT->addWidget(m_activeList);
this->addAct(m_inactiveList);
connect(ui.pushButton_Ad, SIGNAL(clicked()), this, SLOT(addItem()));
connect(ui.pushButton_Rem, SIGNAL(clicked()), this, SLOT(removeItem()));
connect(ui.pushButton_Up, SIGNAL(clicked()), this, SLOT(upItem()));
connect(ui.pushButton_Down, SIGNAL(clicked()), this, SLOT(downItem()));
connect(ui.pushButton_OK, SIGNAL(clicked()), this, SLOT(ok()));
connect(ui.comboBox_BarraFerramentas, SIGNAL(currentIndexChanged(int)), this, SLOT(changeBF(int)));
}
DLG_EditToolBar::~DLG_EditToolBar()
{
}
void DLG_EditToolBar::changeBF(int t)
{
if (t > 0)
{
listItem_toolp.clear(); // type QList<QListWidgetItem *>
int r = m_activeList->count();
for (int i = 0; i < r; i++)
{
listItem_toolp.append(m_activeList->takeItem(0));
}
m_activeList->clear();
for (int i = 0; i < listItem_toolaux.count(); i++)
{
m_activeList->addItem(listItem_toolaux.at(i));
}
}
else
{
listItem_toolaux.clear(); // type QList<QListWidgetItem *>
int r = m_activeList->count();
for (int i = 0; i < r; i++)
{
listItem_toolaux.append(m_activeList->takeItem(0));
}
m_activeList->clear();
for (int i = 0; i < listItem_toolp.count(); i++)
{
m_activeList->addItem(listItem_toolp.at(i));
}
}
}
{
Item *item;
for (int i = 0; i < Actions::listTrAction()->count(); i++)
{
item = new Item(Actions::listTrAction()->at(i), Actions::listTrAction()->at(i)->id(), p);
}
}
void DLG_EditToolBar::addItem()
{
m_activeList->addItem(m_inactiveList->takeItem(m_inactiveList->currentRow()));
}
void DLG_EditToolBar::ok()
{
{
// here is the problem, it works when using the function AddItem,
// but when it does not drag n drop with the mouse.
qDebug() << static_cast<Item *>(i)->idAct();
//MainWindow::toolbar->addAction(static_cast<Item *>(i)->action());
}
{
//MainWindow::toolbarAux->addAction(static_cast<Item *>(i)->action());
}
this->accept();
}
DLG_EditToolBar::DLG_EditToolBar(QWidget *parent)
:QDialog(parent)
{
ui.setupUi(this);
m_activeList = new ListWidget; // subclass QListWidget
m_inactiveList = new ListWidget; // subclass QListWidget
ui.gridLayoutAD->addWidget(m_inactiveList);
ui.gridLayoutAT->addWidget(m_activeList);
this->addAct(m_inactiveList);
connect(ui.pushButton_Ad, SIGNAL(clicked()), this, SLOT(addItem()));
connect(ui.pushButton_Rem, SIGNAL(clicked()), this, SLOT(removeItem()));
connect(ui.pushButton_Up, SIGNAL(clicked()), this, SLOT(upItem()));
connect(ui.pushButton_Down, SIGNAL(clicked()), this, SLOT(downItem()));
connect(ui.pushButton_OK, SIGNAL(clicked()), this, SLOT(ok()));
connect(ui.comboBox_BarraFerramentas, SIGNAL(currentIndexChanged(int)), this, SLOT(changeBF(int)));
}
DLG_EditToolBar::~DLG_EditToolBar()
{
}
void DLG_EditToolBar::changeBF(int t)
{
if (t > 0)
{
listItem_toolp.clear(); // type QList<QListWidgetItem *>
int r = m_activeList->count();
for (int i = 0; i < r; i++)
{
listItem_toolp.append(m_activeList->takeItem(0));
}
m_activeList->clear();
for (int i = 0; i < listItem_toolaux.count(); i++)
{
m_activeList->addItem(listItem_toolaux.at(i));
}
}
else
{
listItem_toolaux.clear(); // type QList<QListWidgetItem *>
int r = m_activeList->count();
for (int i = 0; i < r; i++)
{
listItem_toolaux.append(m_activeList->takeItem(0));
}
m_activeList->clear();
for (int i = 0; i < listItem_toolp.count(); i++)
{
m_activeList->addItem(listItem_toolp.at(i));
}
}
}
void DLG_EditToolBar::addAct(QListWidget *p)
{
Item *item;
for (int i = 0; i < Actions::listTrAction()->count(); i++)
{
item = new Item(Actions::listTrAction()->at(i), Actions::listTrAction()->at(i)->id(), p);
}
}
void DLG_EditToolBar::addItem()
{
m_activeList->addItem(m_inactiveList->takeItem(m_inactiveList->currentRow()));
}
void DLG_EditToolBar::ok()
{
foreach (QListWidgetItem *i, listItem_toolp)
{
// here is the problem, it works when using the function AddItem,
// but when it does not drag n drop with the mouse.
qDebug() << static_cast<Item *>(i)->idAct();
//MainWindow::toolbar->addAction(static_cast<Item *>(i)->action());
}
foreach (QListWidgetItem *i, listItem_toolaux)
{
//MainWindow::toolbarAux->addAction(static_cast<Item *>(i)->action());
}
this->accept();
}
To copy to clipboard, switch view to plain text mode
Bookmarks