void check_page(t_block *b) { t_page *page; t_block *first; page = block_parent_page(b); first = page->first; if (first != NULL && first->is_free && first->next == NULL) del_page(page); }
CEvent_editor_dialog::CEvent_editor_dialog(CEvent event, qint32 ticket_id, QList<template_xml_element> *elements, //the templates QHash<quint32, QString> *bool_names_pnt, QHash<quint32, QString> *variable_names_pnt, QHash<quint32, QString> *text_names_pnt, QString projectPath ) { // Event Edit Dialog Constructor //* 1 Storing Overloaded Values //* 1.1 Validating received cacheEvent //* 2 Translating Hash to QStringList //* 3 Creating GUI //* 4 Loading initial Data //* 1 Storing Overloaded Values this->ticket_id = ticket_id; this->elements = elements; // the template elements this->previous_listWidgetIndex = 0; this->project_path = projectPath; //* 2 Translating Hash to QStringList //bools:: 1 :: getting biggest index quint32 bools_max = 0; QHash<quint32, QString>::iterator b_it = bool_names_pnt->begin(); for (1; b_it != bool_names_pnt->end(); ++b_it) { if ( b_it.key() >= bools_max ) bools_max = b_it.key(); // qDebug() << i.key() << ": " << i.value() << endl; } //bools:: 2 :: filling list for ( quint32 j = 0; j <= bools_max; j++ ) this->names_bool.append( bool_names_pnt->value( j ) ); //vars:: 1 :: getting biggest index quint32 vars_max = 0; QHash<quint32, QString>::iterator v_it = variable_names_pnt->begin(); for (1; v_it != variable_names_pnt->end(); ++v_it) if ( v_it.key() >= vars_max ) vars_max = v_it.key(); //vars:: 2 :: filling list for ( quint32 j = 0; j <= vars_max; j++ ) this->names_variable.append( variable_names_pnt->value( j ) ); //texts:: 1 :: getting biggest index quint32 texts_max = 0; QHash<quint32, QString>::iterator t_it = text_names_pnt->begin(); for (1; t_it != text_names_pnt->end(); ++t_it) if ( t_it.key() >= texts_max ) texts_max = t_it.key(); //texts:: 2 :: filling list for ( quint32 j = 0; j <= texts_max; j++ ) this->names_texts.append( text_names_pnt->value( j ) ); //* 3 Creating GUI this->widget_edit = new Cevent_input_mask( &this->names_bool, &this->names_variable, projectPath ); QObject::connect( this->widget_edit->gui_enable_add_condition_btn, SIGNAL(clicked()), this, SLOT(re_minHeight_input_mask()) ); this->widget_templates = new Ctemplatez_page( ); QObject::connect( this->widget_templates->pickbox, SIGNAL(currentIndexChanged(int)), this, SLOT(switch_behaviour(int))); QObject::connect( this->widget_templates, SIGNAL(apply_code()), this, SLOT(confirm_install_template()) ); this->btn_templates_edit = new QPushButton( QIcon( ":/resources/img/event_editor_code_snippets.png" ), tr( "Templates" ), this ); this->btn_templates_edit->setIconSize( QSize( 48,48 ) ); QObject::connect( this->btn_templates_edit, SIGNAL(clicked()), this, SLOT(switch_templates_and_edit()) ); this->area_edit = new QScrollArea(); this->area_edit->setAlignment( Qt::AlignCenter ); this->area_edit->setWidget( this->widget_edit ); this->area_edit->setBackgroundRole( QPalette::Dark ); this->area_edit->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); this->area_template = new QScrollArea(); this->area_template->setAlignment( Qt::AlignCenter ); this->area_template->setWidget( this->widget_templates ); this->area_template->setBackgroundRole( QPalette::Dark ); this->area_template->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); this->stackPit = new QStackedWidget( this ); this->stackPit->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Expanding ); this->stackPit->addWidget( this->area_edit ); this->stackPit->addWidget( this->area_template ); this->pages_label = new QLabel( tr( "Pages" ) ); this->pages_label->setAlignment( Qt::AlignCenter ); this->pages_listWidget = new QListWidget(); this->pages_listWidget->setCurrentRow( 0 ); QObject::connect( this->pages_listWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(switch_page()) ); QString str = QString( "%1" ).arg( event.tileLocation ); this->label_event_info = new QLabel( event.title + "@" + str ); this->label_event_info->setAlignment( Qt::AlignCenter ); this->btn_cancel = new QPushButton( QIcon( ":/resources/img/cancel.png" ), tr( "Cancel" ) ); this->btn_save_exit = new QPushButton( QIcon( ":/resources/img/save.png" ), tr( "Save and exit" ) ); QObject::connect( this->btn_cancel, SIGNAL(clicked()), this, SLOT(close())); QObject::connect( this->btn_save_exit, SIGNAL(clicked()),this, SLOT(exit_saving()) ); this->pages_control_btn = new QToolButton(); this->pages_control_btn->setIcon( QIcon( ":/resources/img/tool.png" ) ); QMenu *m = new QMenu( tr( "Pages control" ) ); m->addAction( QIcon( ":/resources/img/edit-add.png" ), tr( "Add new page" ) ); m->addAction( QIcon( ":/resources/img/edit-copy.png" ), tr( "Copy current page" ) ); m->addAction( QIcon( ":/resources/img/edit-paste.png" ), tr( "Paste previous copied or cut page" ) ); m->addAction( QIcon( ":/resources/img/edit-cut.png" ), tr( "Cut current page (Copy+Delete)" ) ); m->addAction( QIcon( ":/resources/img/edit-delete.png" ), tr( "Delete current page" ) ); m->addSeparator(); m->addAction( QIcon( ":/resources/img/edit-rename.png" ), tr( "Rename Event" ) ); m->addAction( QIcon( ":/resources/img/edit-rename.png" ), tr( "Relocalte Event" ) ); this->pages_control_btn->setMenu( m ); this->pages_control_btn->setPopupMode( QToolButton::InstantPopup ); QObject::connect( m->actions()[0], SIGNAL(triggered()), this, SLOT(add_page()) ); QObject::connect( m->actions()[1], SIGNAL(triggered()), this, SLOT(copy_page()) ); QObject::connect( m->actions()[2], SIGNAL(triggered()), this, SLOT(paste_page()) ); QObject::connect( m->actions()[3], SIGNAL(triggered()), this, SLOT(cut_page()) ); QObject::connect( m->actions()[4], SIGNAL(triggered()), this, SLOT(del_page()) ); //5 is the seperator QObject::connect( m->actions()[6], SIGNAL(triggered()), this, SLOT(rename_event()) ); QObject::connect( m->actions()[7], SIGNAL(triggered()), this, SLOT(relocate_event()) ); //to forbid pasting empty pages at startup m->actions()[3]->setEnabled( false ); QHBoxLayout *h = new QHBoxLayout(); h->addWidget( this->pages_label ); h->addWidget( this->pages_control_btn ); this->vLay = new QVBoxLayout(); this->vLay->addWidget( this->label_event_info ); this->vLay->addLayout( h ); this->vLay->addWidget( this->pages_listWidget ); this->vLay->addWidget( this->btn_templates_edit ); this->lay = new QHBoxLayout(); QWidget *w = new QWidget(); w->setLayout( this->vLay ); w->setMaximumWidth( 150 ); QHBoxLayout *downer_bar = new QHBoxLayout(); downer_bar->addStretch(); downer_bar->addWidget( this->btn_cancel ); downer_bar->addWidget( this->btn_save_exit ); QVBoxLayout *v = new QVBoxLayout(); v->addWidget( this->stackPit ); v->addLayout( downer_bar ); this->lay->addWidget( w ); this->lay->addLayout( v ); this->setLayout( this->lay ); this->setWindowTitle( this->cacheEvent.title ); this->setWindowIcon( QIcon( ":/resources/img/tokens_mini_event.png" ) ); // this->resize( this->area_edit->width() + this->btn_templates_edit->width() + 44 , 400 ); //* 4 Loading initial Data // appending code snippet elements from the pointer this->widget_templates->pickbox->clear(); for ( int i = 0; i < this->elements->count(); i++ ) { // QListWidgetItem *lwi = new QListWidgetItem( // QIcon( this->project_path + "/res/code_snippets/" + this->elements[i].iconSmall ), // this->elements[i].title ); this->widget_templates->pickbox->addItem( QIcon( this->elements->at(i).iconSmall ), this->elements->at(i).title ); } //setting some first values if ( this->elements->count() > 0 ) { this->widget_templates->label_big_symbol->setPixmap( QPixmap( this->elements->at(0).iconBig ) ); this->widget_templates->label_description_text->setText( this->elements->at(0).description ); } //loading original osps if ( this->cacheEvent.pages.count() >= 1 ) this->widget_edit->gui_behavior_cmd_widget->setOSPs( this->cacheEvent.pages[0].original_commandos_string ); else this->add_page(); // to have at least an empty page this->rebuild_listwidget_entries_index(); this->put_original_strings_into_gui(); // the current page is 0 at this time this->resize(840,400); }