CollectionEditor::CollectionEditor(QWidget* parent, Collection* fc) : QDialog(parent) { Q_ASSERT(fc != NULL); m_original = fc; setupUi(this); m_add->setIcon(QIcon(":/edit_add.png")); m_remove->setIcon(QIcon(":/edit_remove.png")); connect(m_nameEdit, SIGNAL(textEdited(const QString&)), this, SLOT(slotNameEdited(const QString&))); connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd())); connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove())); m_fc = new Collection(this); m_fc->copyFrom(fc); Q_ASSERT(m_fc != NULL); m_nameEdit->setText(m_fc->name()); slotNameEdited(m_fc->name()); updateFunctionList(); }
void FunctionListArea::generalSetting() { QWidget *widget = new QWidget(); QHBoxLayout *layout = new QHBoxLayout(); QLabel *label = new QLabel(tr("函数列表:"), this); widget->setLayout(layout); layout->addWidget(label); layout->addWidget(functionListBox, 1); setTitleBarWidget(widget); setWidget(new QWidget()); setFixedHeight(24); layout->setContentsMargins(5, 4, 5, 0); connect(functionListBox, SIGNAL(activated(int)), this, SLOT(cursorMove(int)) ); connect(functionListBox, SIGNAL(updateFunctionList()), this, SLOT(createFunctionList()) ); QFont afont(font()); afont.setPointSize(10); setFont(afont); setWindowTitle(tr("")); setAllowedAreas(Qt::TopDockWidgetArea); setFeatures(QDockWidget::DockWidgetClosable); //QDockWidget::DockWidgetVerticalTitleBar); QMainWindow *main = qobject_cast<QMainWindow *>(parent()); main->addDockWidget(Qt::TopDockWidgetArea, this); hide();//默认关闭 }
void FunctionCollectionEditor::init() { QString dir; _app->settings()->get(KEY_SYSTEM_DIR, dir); dir += QString("/") + PIXMAPPATH; m_addFunction->setPixmap(QPixmap(dir + "/add.xpm")); m_removeFunction->setPixmap(QPixmap(dir + "/remove.xpm")); m_nameEdit->setText(m_fc->name()); updateFunctionList(); }
void CollectionEditor::slotAdd() { FunctionSelection fs(this, m_doc); fs.setDisabledFunctions(QList <quint32>() << m_fc->id()); if (fs.exec() == QDialog::Accepted) { QListIterator <quint32> it(fs.selection()); while (it.hasNext() == true) m_fc->addFunction(it.next()); updateFunctionList(); } }
void CollectionEditor::slotAdd() { FunctionSelection sel(this, true, m_original->id()); if (sel.exec() == QDialog::Accepted) { t_function_id fid; QListIterator <t_function_id> it(sel.selection()); while (it.hasNext() == true) { fid = it.next(); m_fc->addFunction(fid); } updateFunctionList(); } }
void CollectionEditor::slotAdd() { FunctionSelection sel(this, true, m_original->id(), Function::Undefined, false); if (sel.exec() == QDialog::Accepted) { t_function_id fid; QListIterator <t_function_id> it(sel.selection); while (it.hasNext() == true) { fid = it.next(); if (isAlreadyMember(fid) == false) m_fc->addItem(fid); } updateFunctionList(); } }
void FunctionCollectionEditor::slotAddFunctionClicked() { FunctionTree* ft = new FunctionTree(this); assert(ft); ft->setInactiveID(m_original->id()); if (ft->exec() == QDialog::Accepted && ft->functionID() != KNoID) { if (isAlreadyMember(ft->functionID())) { QString msg("The selected function is already in collection."); QMessageBox::warning(this, KApplicationNameShort, msg); } else { m_fc->addItem(ft->functionID()); updateFunctionList(); } } delete ft; }
CollectionEditor::CollectionEditor(QWidget* parent, Collection* fc, Doc* doc) : QWidget(parent) , m_doc(doc) , m_fc(fc) { Q_ASSERT(doc != NULL); Q_ASSERT(fc != NULL); setupUi(this); connect(m_nameEdit, SIGNAL(textEdited(const QString&)), this, SLOT(slotNameEdited(const QString&))); connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd())); connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove())); m_nameEdit->setText(m_fc->name()); m_nameEdit->setSelection(0, m_nameEdit->text().length()); updateFunctionList(); // Set focus to the editor m_nameEdit->setFocus(); }
void FunctionCollectionEditor::show() { updateFunctionList(); QDialog::show(); }