// Действия при нажатии кнопки редактирования записи void RecordTableController::editFieldContext(QModelIndex proxyIndex) { qDebug() << "RecordTableController::editFieldContext()"; QModelIndex sourceIndex=convertProxyIndexToSourceIndex(proxyIndex); int pos=sourceIndex.row(); // Номер строки в базе // Создается окно ввода данных, после выхода из этой функции окно должно удалиться RecordInfoFieldsEditor editRecordWin; // Выясняется ссылка на таблицу конечных данных RecordTableData *table=recordSourceModel->getTableData(); // Поля окна заполняются начальными значениями editRecordWin.setField("name", table->getField("name", pos) ); editRecordWin.setField("author",table->getField("author", pos) ); editRecordWin.setField("url", table->getField("url", pos) ); editRecordWin.setField("tags", table->getField("tags", pos) ); int i=editRecordWin.exec(); if(i==QDialog::Rejected) return; // Была нажата отмена, ничего ненужно делать // Измененные данные записываются editField(pos, editRecordWin.getField("name"), editRecordWin.getField("author"), editRecordWin.getField("url"), editRecordWin.getField("tags")); }
QString NoteBook::createNewNotebook(QString notebookName) { guid = newGUID("notebooks", "guid"); name = notebookName; stack = ""; serviceCreated = QDateTime::currentDateTime(); serviceUpdated = QDateTime::currentDateTime(); editField(T_GUID); editField(T_NAME); editField(T_STACK); editField(T_CREATED); editField(T_UPDATED); toSQL(); return guid; }
void NoteBook::update(NoteBookUpdates updates) { if (guid.isEmpty()) { if (!updates.contains(T_GUID)) return; guid = updates[T_GUID].toString(); editField(T_GUID); } if (updates.contains(T_NAME)) { name = updates[T_NAME].toString(); editField(T_NAME); } if (updates.contains(T_DEFAULT)) { defaultNotebook = updates[T_DEFAULT].toBool(); editField(T_DEFAULT); } if (updates.contains(T_CREATED)) { serviceCreated = updates[T_CREATED].toDateTime(); editField(T_CREATED); } if (updates.contains(T_UPDATED)) { serviceUpdated = updates[T_UPDATED].toDateTime(); editField(T_UPDATED); } if (updates.contains(T_STACK)) { stack = updates[T_STACK].toString(); editField(T_STACK); } toSQL(); }
void MainWindow::drawField() { int width=40, height=40; QImage editField(width,height,QImage::Format_RGB32); for(int i=0;i<width; i++) { for(int j=0;j<height; j++) { editField.setPixel(i,j, qRgb((i+10*iteration)%255, (j+10*iteration)%255, (i*j)%255)); } } mainImage->setPixmap(QPixmap::fromImage(editField)); }
void BTSpellEditor::handleSpecialField(BTDisplay &d, ObjectSerializer &serial, int val) { val -= 100; if ((val == extra.size()) || (extra[val].name == "type")) { BTDisplay::selectItem lookupItem[BT_SPELLTYPES_USED]; int lookupStart(0); int lookupCurrent(0); for (int i = 0; i < BT_SPELLTYPES_USED; ++i) { lookupItem[i].name = spellTypeLookup.getName(spellTypes[i].type); if ((val != extra.size()) && (extra[val].item->type == spellTypes[i].type)) lookupCurrent = i; } d.addSelection(lookupItem, BT_SPELLTYPES_USED, lookupStart, lookupCurrent); if ((27 != d.process()) && ((val == extra.size()) || (lookupCurrent != extra[val].item->type))) { XMLAction *manifestField = serial.find("manifest", NULL); XMLArray *manifestArray = (reinterpret_cast<XMLArray*>(manifestField->object)); XMLVector<BTManifest*> *manifest = dynamic_cast<XMLVector<BTManifest*> *>(manifestArray); if (val == extra.size()) { manifest->push_back((*spellTypes[lookupCurrent].f)(NULL, NULL)); (*manifest)[manifest->size() - 1]->type = spellTypes[lookupCurrent].type; } else { for (int i = 0; i < manifest->size(); ++i) { if (extra[val].item == (*manifest)[i]) { (*manifest)[i] = dynamic_cast<BTManifest*>((*spellTypes[lookupCurrent].f)(NULL, NULL)); (*manifest)[i]->type = spellTypes[lookupCurrent].type; delete extra[val].item; break; } } } } d.clearText(); } else { ObjectSerializer serialSub; extra[val].item->serialize(&serialSub); XMLAction *manifestField = serialSub.find(extra[val].name.c_str(), NULL); editField(d, serialSub, extra[val].item->getEditFieldDescription(extra[val].value), manifestField, extra[val].value, 0); } }
void BTSerializedEditor::edit(BTDisplay &d, ObjectSerializer &serial) { BTDisplayConfig *oldConfig = d.getConfig(); BTDisplayConfig config; XMLSerializer parser; config.serialize(&parser); parser.parse(BTDisplay::applyDisplayDir("data/specialedit.xml").c_str(), true); d.setConfig(&config); int start(0); int current(0); BitField active; std::vector<BTDisplay::selectItem> list(entries); initActive(serial, active); int len = setup(serial, active, list); d.addSelection(list.data(), len, start, current); int key; char extra[2] = {BTKEY_DEL, 0}; while (27 != (key = d.process(extra))) { d.clearText(); XMLAction *curField = NULL; if (list[current].value < entries) curField = serial.find(field[list[current].value], NULL); if (key == BTKEY_DEL) { if (curField) { int where = 0; if (curField->getType() == XMLTYPE_CREATE) { XMLArray *obj = reinterpret_cast<XMLArray*>(curField->object); int where = 0; for (int i = current - 1; (i >= 0) && (list[i].value == list[current].value); --i) { ++where; } if (where < obj->size()) { obj->erase(where); for (int i = current; i < len - 1; ++i) { list[i].name = list[i + 1].name; list[i].value = list[i + 1].value; } --len; } } else if (curField->getType() == XMLTYPE_VECTORSTRING) { std::vector<std::string> *obj = reinterpret_cast<std::vector<std::string>*>(curField->object); int where = 0; for (int i = current - 1; (i >= 0) && (list[i].value == list[current].value); --i) { ++where; } if (where < obj->size()) { obj->erase(obj->begin() + where); for (int i = current; i < len - 1; ++i) { list[i].name = list[i + 1].name; list[i].value = list[i + 1].value; } --len; } } } else { delSpecialField(d, serial, list[current].value); } } else { if (curField) { int where = 0; if (curField->getType() == XMLTYPE_CREATE) { XMLArray *obj = reinterpret_cast<XMLArray*>(curField->object); for (int i = current - 1; (i >= 0) && (list[i].value == list[current].value); --i) { ++where; } if (where >= obj->size()) { obj->push_back((*reinterpret_cast<XMLObject::create>(curField->data))(field[list[current].value], NULL)); list.push_back(BTDisplay::selectItem()); for (int i = list.size() - 1; i > current; --i) { list[i].name = list[i - 1].name; list[i].value = list[i - 1].value; } len++; } } else if (curField->getType() == XMLTYPE_VECTORSTRING) { std::vector<std::string> *obj = reinterpret_cast<std::vector<std::string>*>(curField->object); for (int i = current - 1; (i >= 0) && (list[i].value == list[current].value); --i) { ++where; } if (where >= obj->size()) { obj->push_back(std::string()); list.push_back(BTDisplay::selectItem()); for (int i = list.size() - 1; i > current; --i) { list[i].name = list[i - 1].name; list[i].value = list[i - 1].value; } len++; } } editField(d, serial, description[list[current].value], curField, list[current].value, where); if (curField->getType() == XMLTYPE_OBJECT) { XMLObject *obj = reinterpret_cast<XMLObject*>(curField->object); BTDice *dice = dynamic_cast<BTDice*>(obj); if (dice) list[current].name = std::string(description[list[current].value]) + ": " + dice->createString(); } else if (curField->getType() == XMLTYPE_VECTORSTRING) { std::vector<std::string> *obj = reinterpret_cast<std::vector<std::string>*>(curField->object); list[current].name = std::string(description[list[current].value]) + ": " + (*obj)[where]; } else if (curField->getType() != XMLTYPE_CREATE) { list[current].name = std::string(description[list[current].value]) + ": " + curField->createString(); } else { XMLArray *obj = reinterpret_cast<XMLArray*>(curField->object); list[current].name = std::string(description[list[current].value]) + ": " + obj->get(where)->createString(); } } else { handleSpecialField(d, serial, list[current].value); } } if (updateActive(serial, active, list[current].value)) len = setup(serial, active, list); d.addSelection(list.data(), len, start, current); } complete(serial); d.clearText(); d.setConfig(oldConfig); }
MainForm::MainForm( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { (void)statusBar(); if ( !name ) setName( "MainForm" ); setCentralWidget( new QWidget( this, "qt_central_widget" ) ); MainFormLayout = new QVBoxLayout( centralWidget(), 11, 6, "MainFormLayout"); listView = new QListView( centralWidget(), "listView" ); listView->addColumn( tr( "Type" ) ); listView->addColumn( tr( "Name" ) ); listView->addColumn( tr( "Login" ) ); listView->addColumn( tr( "Password" ) ); listView->addColumn( tr( "Description" ) ); listView->setResizeMode( QListView::AllColumns ); listView->setSorting(-1); MainFormLayout->addWidget( listView ); // actions createProfileAction = new QAction( this, "createProfileAction" ); createProfileAction->setIconSet( QPixmap::fromMimeSource("new.png") ); openProfileAction = new QAction(this, "openProfileAction" ); openProfileAction->setIconSet( QPixmap::fromMimeSource("open.png") ); tb_openProfileAction = new QAction(this, "tb_openProfileAction"); tb_openProfileAction->setIconSet( QPixmap::fromMimeSource("tb_open.png") ); closeProfileAction = new QAction( this, "closeProfileAction" ); closeProfileAction->setIconSet( QPixmap::fromMimeSource("close.png") ); tb_closeProfileAction = new QAction( this, "tb_closeProfileAction" ); tb_closeProfileAction->setIconSet( QPixmap::fromMimeSource("tb_close.png") ); deleteProfileAction = new QAction( this, "deleteProfileAction" ); deleteProfileAction->setIconSet( QPixmap::fromMimeSource("delete_all.png") ); changeProfileAction = new QAction( this, "changeProfileAction" ); fileQuitAction = new QAction( this, "fileQuitAction" ); fileSaveAction = new QAction( this, "fileSaveAction" ); fileSaveAction->setIconSet( QPixmap::fromMimeSource("save.png") ); tb_fileSaveAction = new QAction( this, "tb_fileSaveAction" ); tb_fileSaveAction->setIconSet( QPixmap::fromMimeSource("tb_save.png") ); editUndoAction = new QAction( this, "editUndoAction" ); editUndoAction->setIconSet( QPixmap::fromMimeSource("undo.png") ); tb_editUndoAction = new QAction( this, "editUndoAction" ); tb_editUndoAction->setIconSet( QPixmap::fromMimeSource("tb_undo.png") ); editRedoAction = new QAction( this, "editRedoAction" ); editRedoAction->setIconSet( QPixmap::fromMimeSource("redo.png") ); tb_editRedoAction = new QAction( this, "tb_editRedoAction" ); tb_editRedoAction->setIconSet( QPixmap::fromMimeSource("tb_redo.png") ); editNewField = new QAction( this, "editNewField" ); editNewField->setIconSet( QPixmap::fromMimeSource("new.png") ); editEditField = new QAction( this, "editEditField" ); editEditField->setIconSet( QPixmap::fromMimeSource("edit.png") ); tb_editEditField = new QAction( this, "tb_editEditField" ); tb_editEditField->setIconSet( QPixmap::fromMimeSource("tb_edit.png") ); tb_editNewField = new QAction( this, "tb_editNewField" ); tb_editNewField->setIconSet( QPixmap::fromMimeSource("tb_new.png") ); editDeleteField = new QAction( this, "editDeleteField" ); editDeleteField->setIconSet( QPixmap::fromMimeSource("delete.png") ); tb_editDeleteField = new QAction( this, "tb_editDeleteField" ); tb_editDeleteField->setIconSet( QPixmap::fromMimeSource("tb_delete.png") ); editDeleteAll = new QAction( this, "editDeleteAll" ); editDeleteAll->setIconSet( QPixmap::fromMimeSource("delete_all.png") ); helpAboutAction = new QAction( this, "helpAboutAction" ); // toolbars fileToolbar = new QToolBar( tr("File"), this, DockTop ); tb_openProfileAction->addTo( fileToolbar); tb_fileSaveAction->addTo( fileToolbar); tb_closeProfileAction->addTo( fileToolbar ); editToolbar = new QToolBar( tr("Edit"), this, DockTop ); tb_editUndoAction->addTo( editToolbar ); tb_editRedoAction->addTo( editToolbar ); editToolbar->addSeparator(); tb_editNewField->addTo( editToolbar ); tb_editEditField->addTo( editToolbar ); tb_editDeleteField->addTo( editToolbar ); // menubar MenuBarEditor = new QMenuBar( this, "MenuBarEditor" ); File = new QPopupMenu( this ); createProfileAction->addTo( File ); openProfileAction->addTo( File ); fileSaveAction->addTo( File ); closeProfileAction->addTo( File ); deleteProfileAction->addTo( File ); changeProfileAction->addTo( File ); File->insertSeparator(); fileQuitAction->addTo( File ); MenuBarEditor->insertItem( QString(""), File, 1 ); Edit = new QPopupMenu( this ); editUndoAction->addTo( Edit ); editRedoAction->addTo( Edit ); Edit->insertSeparator(); editNewField->addTo( Edit ); editEditField->addTo( Edit ); editDeleteField->addTo( Edit ); editDeleteAll->addTo(Edit); MenuBarEditor->insertItem( QString(""), Edit, 2 ); Help = new QPopupMenu( this ); helpAboutAction->addTo( Help ); MenuBarEditor->insertItem( QString(""), Help, 3 ); rmbMenu = new QPopupMenu( this ); editUndoAction->addTo( rmbMenu ); editRedoAction->addTo( rmbMenu ); rmbMenu->insertSeparator(); editNewField->addTo( rmbMenu ); editEditField->addTo( rmbMenu ); editDeleteField->addTo( rmbMenu ); languageChange(); resize( QSize(700, 400).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); connect(createProfileAction, SIGNAL( activated() ), this, SLOT( createProfile() ) ); connect(openProfileAction, SIGNAL( activated() ), this, SLOT( openProfile() ) ); connect(tb_openProfileAction, SIGNAL( activated() ), this, SLOT( openProfile() ) ); connect(closeProfileAction, SIGNAL( activated() ), this, SLOT( closeProfile() ) ); connect(tb_closeProfileAction, SIGNAL( activated() ), this, SLOT( closeProfile() ) ); connect(deleteProfileAction, SIGNAL( activated() ), this, SLOT( deleteProfile() ) ); connect(changeProfileAction, SIGNAL( activated() ), this, SLOT( changeProfile() ) ); connect(fileSaveAction, SIGNAL( activated() ), this, SLOT( save() ) ); connect(tb_fileSaveAction, SIGNAL( activated() ), this, SLOT( save() ) ); connect(fileQuitAction, SIGNAL( activated() ), this, SLOT( close() ) ); connect(editUndoAction, SIGNAL( activated() ), this, SLOT( undo() ) ); connect(tb_editUndoAction, SIGNAL( activated() ), this, SLOT( undo() ) ); connect(editRedoAction, SIGNAL( activated() ), this, SLOT( redo() ) ); connect(tb_editRedoAction, SIGNAL( activated() ), this, SLOT( redo() ) ); connect(editNewField, SIGNAL( activated() ), this, SLOT( newField() ) ); connect(tb_editNewField, SIGNAL( activated() ), this, SLOT( newField() ) ); connect(editEditField, SIGNAL(activated() ), this, SLOT( editField() ) ); connect(tb_editEditField, SIGNAL(activated() ), this, SLOT( editField() ) ); connect(editDeleteField, SIGNAL( activated() ), this, SLOT( deleteField() ) ); connect(tb_editDeleteField, SIGNAL( activated() ), this, SLOT( deleteField() ) ); connect(editDeleteAll, SIGNAL( activated() ), this, SLOT( deleteAll() ) ); connect(helpAboutAction, SIGNAL( activated() ), this, SLOT( about() ) ); connect(listView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( edit(QListViewItem *) ) ); connect(listView, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint&, int) ), this, SLOT( slotRMB( QListViewItem*, const QPoint &, int ) ) ); modified = false; Caption(); if(!ifProfileExists()) createProfile(); else setEnabledActions(1); }
fieldWindow::fieldWindow(int deltaFontSize) : _deltaFontSize(deltaFontSize) { FL_NORMAL_SIZE -= deltaFontSize; int width0 = 34 * FL_NORMAL_SIZE + WB; int height0 = 12 * BH + 4 * WB; int width = (CTX::instance()->fieldSize[0] < width0) ? width0 : CTX::instance()->fieldSize[0]; int height = (CTX::instance()->fieldSize[1] < height0) ? height0 : CTX::instance()->fieldSize[1]; win = new paletteWindow (width, height, CTX::instance()->nonModalWindows ? true : false, "Size fields"); win->box(GMSH_WINDOW_BOX); int x = WB, y = WB, w = (int)(1.5 * BB), h = height - 2 * WB - 3 * BH; Fl_Menu_Button *new_btn = new Fl_Menu_Button(x, y, w, BH, "New"); FieldManager &fields = *GModel::current()->getFields(); std::map<std::string, FieldFactory*>::iterator it; for(it = fields.map_type_name.begin(); it != fields.map_type_name.end(); it++) new_btn->add(it->first.c_str()); new_btn->callback(field_new_cb); y += BH; browser = new Fl_Hold_Browser(x, y + WB, w, h - 2 * WB); browser->callback(field_browser_cb); y += h; delete_btn = new Fl_Button(x, y, w, BH, "Delete"); delete_btn->callback(field_delete_cb, this); y += BH; put_on_view_btn = new Fl_Menu_Button(x, y, w, BH, "Visualize"); put_on_view_btn->callback(field_put_on_view_cb, this); x += w + WB; y = WB; w = width - x - WB; h = height - y - WB; empty_message = new Fl_Box(x, y, w, h, "Create a new field\n\n" "- or -\n\nSelect a field in the browser"); empty_message->align(FL_ALIGN_CENTER); editor_group = new Fl_Group(x, y, w, h); title = new Fl_Box(x, y, w, BH, "field_name"); title->labelfont(FL_BOLD); title->labelsize(FL_NORMAL_SIZE + 3); y += BH + WB; h -= BH + WB; Fl_Tabs *tabs = new Fl_Tabs(x, y , w, h); y += BH; h -= BH; x += WB; w -= 2 * WB; Fl_Group *options_tab = new Fl_Group(x, y, w, h, "Options"); options_scroll = new Fl_Scroll(x, y + WB, w, h - BH - 3 * WB); options_scroll->end(); Fl_Button *apply_btn = new Fl_Return_Button (x + w - BB, y + h - BH - WB, BB, BH, "Apply"); apply_btn->callback(field_apply_cb, this); background_btn = new Fl_Round_Button (x, y + h - BH - WB, w - BB - WB, BH, "Set as background field"); background_btn->tooltip("Only a single field can be set as background field.\n" "To combine multiple fields use the Min or Max fields."); options_tab->end(); Fl_Group *help_tab = new Fl_Group(x, y, w, h, "Help"); help_display = new Fl_Help_View(x, y + WB, w, h - 2 * WB); help_display->textfont(FL_HELVETICA); help_display->textsize(FL_NORMAL_SIZE); help_tab->end(); tabs->end(); editor_group->end(); win->resizable(new Fl_Box((int)(1.5 * BB) + 2 * WB, BH + 2 * WB, width - 3 * WB - (int)(1.5 * BB), height - 3 * BH - 5 * WB)); editor_group->resizable(tabs); tabs->resizable(options_tab); options_tab->resizable(new Fl_Box(3 * BB + 4 * WB, BH + 2 * WB, width - 9 * WB - 5 * BB, height - 3 * BH - 5 * WB)); win->size_range(width0, height0); win->position(CTX::instance()->fieldPosition[0], CTX::instance()->fieldPosition[1]); win->end(); FL_NORMAL_SIZE += deltaFontSize; loadFieldViewList(); editField(NULL); }
/* * Constructs a editTableForm as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ editTableForm::editTableForm( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "editTableForm" ); editTableFormLayout = new QGridLayout( this, 1, 1, 11, 6, "editTableFormLayout"); layout50 = new QVBoxLayout( 0, 0, 6, "layout50"); tableLine = new QLineEdit( this, "tableLine" ); tableLine->setFocusPolicy( QLineEdit::NoFocus ); tableLine->setReadOnly( TRUE ); layout50->addWidget( tableLine ); fieldListView = new QListView( this, "fieldListView" ); fieldListView->addColumn( tr( "Field name" ) ); fieldListView->addColumn( tr( "Field type" ) ); fieldListView->setResizePolicy( QScrollView::Manual ); fieldListView->setResizeMode( QListView::AllColumns ); layout50->addWidget( fieldListView ); editTableFormLayout->addLayout( layout50, 0, 0 ); layout42 = new QVBoxLayout( 0, 0, 6, "layout42"); renameTableButton = new QPushButton( this, "renameTableButton" ); layout42->addWidget( renameTableButton ); QSpacerItem* spacer = new QSpacerItem( 20, 23, QSizePolicy::Minimum, QSizePolicy::Expanding ); layout42->addItem( spacer ); renameFieldButton = new QPushButton( this, "renameFieldButton" ); renameFieldButton->setEnabled( FALSE ); layout42->addWidget( renameFieldButton ); removeFieldButton = new QPushButton( this, "removeFieldButton" ); removeFieldButton->setEnabled( FALSE ); layout42->addWidget( removeFieldButton ); addFieldButton = new QPushButton( this, "addFieldButton" ); layout42->addWidget( addFieldButton ); editTableFormLayout->addLayout( layout42, 0, 1 ); layout41 = new QHBoxLayout( 0, 0, 6, "layout41"); QSpacerItem* spacer_2 = new QSpacerItem( 161, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); layout41->addItem( spacer_2 ); closeButton = new QPushButton( this, "closeButton" ); layout41->addWidget( closeButton ); editTableFormLayout->addMultiCellLayout( layout41, 1, 1, 0, 1 ); languageChange(); resize( QSize(428, 266).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); // signals and slots connections connect( closeButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( renameTableButton, SIGNAL( clicked() ), this, SLOT( renameTable() ) ); connect( removeFieldButton, SIGNAL( clicked() ), this, SLOT( removeField() ) ); connect( addFieldButton, SIGNAL( clicked() ), this, SLOT( addField() ) ); connect( renameFieldButton, SIGNAL( clicked() ), this, SLOT( editField() ) ); connect( fieldListView, SIGNAL( selectionChanged() ), this, SLOT( fieldSelectionChanged() ) ); init(); }
void NoteBook::editField(int field) { editField(guid, field); }