Changeset View
Changeset View
Standalone View
Standalone View
core/document.cpp
Context not available. | |||||
3967 | d->m_undoStack->push( uc ); | 3967 | d->m_undoStack->push( uc ); | ||
---|---|---|---|---|---|
3968 | } | 3968 | } | ||
3969 | 3969 | | |||
3970 | void Document::resetFormWidgets() | ||||
3971 | { | ||||
3972 | QVector <QUndoCommand *> widgetsCommands; | ||||
3973 | | ||||
3974 | for( uint pageIdx = 0; pageIdx < pages(); pageIdx++ ) | ||||
3975 | { | ||||
3976 | const Page *currentPage = page( pageIdx ); | ||||
3977 | QLinkedList <FormField *> pageFields = currentPage->formFields(); | ||||
3978 | | ||||
3979 | QList <FormFieldButton *> m_checkBoxForms, m_radioButtonForms; | ||||
3980 | QList <bool> newCheckButtonStates, newRadioButtonStates; | ||||
3981 | | ||||
3982 | QLinkedList <FormField *>::const_iterator ffIt = pageFields.constBegin(), ffEnd = pageFields.constEnd(); | ||||
3983 | QUndoCommand *command; | ||||
3984 | | ||||
3985 | for ( ; ffIt != ffEnd; ++ffIt ) | ||||
3986 | { | ||||
3987 | FormField * ff = *ffIt; | ||||
3988 | ff->type(); | ||||
3989 | | ||||
3990 | switch ( ff->type() ) | ||||
3991 | { | ||||
3992 | case FormField::FormButton: | ||||
3993 | { | ||||
3994 | FormFieldButton * ffb = static_cast< FormFieldButton * >( ff ); | ||||
3995 | switch ( ffb->buttonType() ) | ||||
3996 | { | ||||
3997 | case FormFieldButton::Push: | ||||
3998 | break; | ||||
3999 | case FormFieldButton::CheckBox: // checkbox | ||||
4000 | m_checkBoxForms.append(ffb); | ||||
4001 | newCheckButtonStates.append( false ); | ||||
4002 | break; | ||||
4003 | case FormFieldButton::Radio: // radio button | ||||
4004 | m_radioButtonForms.append(ffb); | ||||
4005 | newRadioButtonStates.append( false ); | ||||
4006 | break; | ||||
4007 | default: ; | ||||
4008 | } | ||||
4009 | break; | ||||
4010 | } | ||||
4011 | case FormField::FormText: // Single Line, multiline, fileEdit | ||||
4012 | { | ||||
4013 | FormFieldText * fft = static_cast< FormFieldText * >( ff ); | ||||
4014 | //resetFormFieldText( i, document, fft ); | ||||
4015 | int prevCursorPos = fft->text().size(); | ||||
4016 | command = new EditFormTextCommand( this->d, fft, pageIdx, QStringLiteral(""), 0, fft->text(), prevCursorPos, prevCursorPos ); | ||||
4017 | widgetsCommands.push_back( command ); | ||||
4018 | break; | ||||
4019 | } | ||||
4020 | case FormField::FormChoice: | ||||
4021 | { | ||||
4022 | FormFieldChoice * ffc = static_cast< FormFieldChoice * >( ff ); | ||||
4023 | switch ( ffc->choiceType() ) | ||||
4024 | { | ||||
4025 | case FormFieldChoice::ListBox: | ||||
4026 | { //resetListEdit(i, document, ffc); | ||||
4027 | const QList< int > prevChoices = ffc->currentChoices(); | ||||
4028 | command = new EditFormListCommand( this->d, ffc, pageIdx, QList<int>(), prevChoices ); | ||||
4029 | widgetsCommands.push_back( command ); | ||||
4030 | break; | ||||
4031 | } | ||||
4032 | case FormFieldChoice::ComboBox: | ||||
4033 | { //resetComboForms(i, document, ffc); | ||||
4034 | QString prevText; | ||||
4035 | if ( ffc->currentChoices().isEmpty() ) | ||||
4036 | { | ||||
4037 | prevText = ffc->editChoice(); | ||||
4038 | } | ||||
4039 | else | ||||
4040 | { | ||||
4041 | prevText = ffc->choices()[ffc->currentChoices().constFirst()]; | ||||
4042 | } | ||||
4043 | | ||||
4044 | command = new EditFormComboCommand( this->d, ffc, pageIdx, QStringLiteral(""), 0, prevText, 0, 0 ); | ||||
4045 | widgetsCommands.push_back( command ); | ||||
4046 | break; | ||||
4047 | } | ||||
4048 | } | ||||
4049 | break; | ||||
4050 | } | ||||
4051 | default: ; | ||||
4052 | } | ||||
4053 | | ||||
4054 | if(m_checkBoxForms.size()) | ||||
4055 | { | ||||
4056 | //resetCheckBoxForms( i, document, m_checkBoxForms, newCheckButtonStates); | ||||
4057 | command = new EditFormButtonsCommand( this->d, pageIdx, m_checkBoxForms, newCheckButtonStates ); | ||||
4058 | widgetsCommands.push_back( command ); | ||||
4059 | } | ||||
4060 | if(m_radioButtonForms.size()) | ||||
4061 | { | ||||
4062 | newRadioButtonStates[0] = true; | ||||
4063 | //resetRadioButtonForms( i, document, m_radioButtonForms, newRadioButtonStates); | ||||
4064 | command = new EditFormButtonsCommand( this->d, pageIdx, m_radioButtonForms, newRadioButtonStates ); | ||||
4065 | widgetsCommands.push_back( command ); | ||||
4066 | } | ||||
4067 | } | ||||
4068 | } | ||||
4069 | | ||||
4070 | QUndoCommand *uc = new EditWidgetsCommand( widgetsCommands ); | ||||
4071 | d->m_undoStack->push( uc ); | ||||
4072 | } | ||||
4073 | | ||||
3970 | void Document::reloadDocument() const | 4074 | void Document::reloadDocument() const | ||
3971 | { | 4075 | { | ||
3972 | const int numOfPages = pages(); | 4076 | const int numOfPages = pages(); | ||
Context not available. |