Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

latest version in development

git-svn-id: https://mt.music.mcgill.ca/svn/dot/branches/v2_max5/mappers/qtmapper@2676 e7448968-c8ac-449e-ac06-376e812423d6
  • Loading branch information...
commit 2045e472f2dea780ec4f76ba2e562fd4d1120cf2 1 parent 519cb82
rudrarajuv authored
View
34 data/mapperdata.cpp
@@ -45,7 +45,7 @@ void MapperData::addDeviceData( mapper_db_device record ) {
}
void MapperData::addSignalData( mapper_db_signal record ) {
- //this->removeSignalData( record );
+ this->removeSignalData( record );
std::list<mapper_db_device>::iterator it;
Utility::device_search_struct_name = record->device_name;
@@ -66,7 +66,7 @@ void MapperData::addMappingData( mapper_db_mapping record ) {
-void MapperData::updateAllMappings( ) {
+void MapperData::updateAllMappingPairs( ) {
this->mapping_struct_map.clear();
@@ -82,6 +82,10 @@ void MapperData::updateAllMappings( ) {
}
void MapperData::updateMappingPair( mapper_db_mapping record ) {
+ printf( "\nMapperData::updateMappingPair src_name %s, dest_name %s\n",
+ record->src_name,
+ record->dest_name );
+
QString str = record->src_name;
QStringList parsed_str = str.split( "/", QString::SkipEmptyParts );
@@ -187,10 +191,20 @@ void MapperData::removeSignalData( mapper_db_signal record ) {
this->device_struct_list.end(),
Utility::findDbDeviceByName );
+ //std::multimap<mapper_db_device, mapper_db_signal>::iterator multi_it;
+ //multi_it = this->signal_struct_map.find( (*it) );
+
+ std::pair<std::multimap<mapper_db_device, mapper_db_signal>::iterator,
+ std::multimap<mapper_db_device, mapper_db_signal>::iterator> ret;
std::multimap<mapper_db_device, mapper_db_signal>::iterator multi_it;
- multi_it = this->signal_struct_map.find( (*it) );
+ ret = this->signal_struct_map.equal_range( (*it) );
+
+ Utility::signal_search_struct = record;
+ multi_it = std::find_if( ret.first,
+ ret.second,
+ Utility::findDbSignalPair );
- if ( multi_it != this->signal_struct_map.end() ) {
+ if ( multi_it != ret.second ) {
this->signal_struct_map.erase( multi_it );
@@ -199,11 +213,17 @@ void MapperData::removeSignalData( mapper_db_signal record ) {
}
void MapperData::removeMappingData( mapper_db_mapping record ) {
+ printf( "\nMapperData::removeMappingPair src_name %s, dest_name %s\n",
+ record->src_name,
+ record->dest_name );
+
+ printf( "before mapping_struct_list size %d\n", this->mapping_struct_list.size() );
+
std::list<mapper_db_mapping>::iterator dbit;
Utility::mapping_search_struct = record;
- std::remove_if( this->mapping_struct_list.begin(),
- this->mapping_struct_list.end(),
- Utility::findDbMapping );
+ this->mapping_struct_list.remove_if( Utility::findDbMapping );
+
+ printf( "after mapping_struct_list size %d\n", this->mapping_struct_list.size() );
}
View
2  data/mapperdata.h
@@ -33,7 +33,7 @@ class MapperData {
void addDeviceData( mapper_db_device record );
void addMappingData( mapper_db_mapping record );
- void updateAllMappings( );
+ void updateAllMappingPairs( );
void updateMappingPair( mapper_db_mapping record );
void addSignalData( mapper_db_signal record );
View
102 gui/form.cpp
@@ -27,9 +27,9 @@ Form::Form( QWidget *parent ) :
graphics_view->setAlignment( Qt::AlignLeft|Qt::AlignTop );
graphics_view->setSceneRect( -400, -400, 4000, 4000 );
- graphics_view_2->setScene( &mapping_scene );
- graphics_view_2->installEventFilter( this );
- graphics_view_2->setAlignment( Qt::AlignLeft|Qt::AlignTop );
+ mappingGraphicsView->setScene( &mapping_scene );
+ mappingGraphicsView->installEventFilter( this );
+ mappingGraphicsView->setAlignment( Qt::AlignLeft|Qt::AlignTop );
displayed_source_model = new QStandardItemModel( 0, 6 );
source_list->setModel( displayed_source_model );
@@ -419,22 +419,28 @@ void Form::updateIsDeletable( bool checked ) {
if ( !checked ) {
+ this->mappingGraphicsView->setDragMode( QGraphicsView::RubberBandDrag );
+
for ( std::list<Link*>::iterator it =
this->displayed_mapping_list.begin();
it != this->displayed_mapping_list.end();
it++ ) {
+ (*it)->setFlag( QGraphicsItem::ItemIsSelectable, true );
(*it)->is_deletable = false;
}
} else {
+ this->mappingGraphicsView->setDragMode( QGraphicsView::NoDrag );
+
for ( std::list<Link*>::iterator it =
this->displayed_mapping_list.begin();
it != this->displayed_mapping_list.end();
it++ ) {
+ (*it)->setFlag( QGraphicsItem::ItemIsSelectable, false );
(*it)->is_deletable = true;
}
@@ -469,8 +475,6 @@ void Form::update( ) {
this->source_signal_list->resizeColumnToContents( 4 );
this->source_signal_list->resizeColumnToContents( 5 );
- //this->updateMappingView();
-
this->updateIsDeletable( this->deleteButton->isChecked() );
}
@@ -621,7 +625,7 @@ void Form::beginToDrawMapping( const QModelIndex& index ) {
printf("begin destination side is valid!\n");
this->selected_dest_circle =
this->mapping_scene.addEllipse(
- graphics_view_2->width() - dest_signal_rect.height() + 4,
+ mappingGraphicsView->width() - dest_signal_rect.height() + 4,
dest_vertical_offset +
dest_signal_rect.topLeft().y() + 1,
dest_signal_rect.height() - 2,
@@ -741,7 +745,7 @@ void Form::finishDrawingMapping( const QModelIndex& index ) {
printf("finish dest side is valid!\n");
this->selected_dest_circle =
this->mapping_scene.addEllipse(
- graphics_view_2->width() - dest_signal_rect.height() + 4,
+ mappingGraphicsView->width() - dest_signal_rect.height() + 4,
dest_vertical_offset +
dest_signal_rect.topLeft().y() + 1,
dest_signal_rect.height() - 2,
@@ -824,14 +828,14 @@ void Form::updateMappingView( ) {
int source_vertical_offset;
int dest_vertical_offset;
- this->graphics_view_2->
- viewport()->setFixedSize( graphics_view_2->width(),
- graphics_view_2->height() );
- this->graphics_view_2->setSceneRect( 0, 0,
- graphics_view_2->width(),
- graphics_view_2->height() );
+ this->mappingGraphicsView->
+ viewport()->setFixedSize( mappingGraphicsView->width(),
+ mappingGraphicsView->height() );
+ this->mappingGraphicsView->setSceneRect( 0, 0,
+ mappingGraphicsView->width(),
+ mappingGraphicsView->height() );
this->clearMappingView( );
- this->database->updateAllMappings();
+ this->database->updateAllMappingPairs();
const char* source_device_name;
const char* source_signal_name;
@@ -969,12 +973,12 @@ void Form::updateMappingView( ) {
*/
- new_link_pointer = new Link( this->graphics_view_2, &mapping_scene );
+ new_link_pointer = new Link( this->mappingGraphicsView, &mapping_scene );
new_link_pointer->mapping = (*it).second;
new_link_pointer->setLine( 0,
source_vertical_offset +
source_signal_rect.topLeft().y(),
- graphics_view_2->width(),
+ mappingGraphicsView->width(),
dest_vertical_offset +
dest_signal_rect.topLeft().y() );
@@ -1013,17 +1017,21 @@ void Form::modifyMapping( mapper_db_mapping record ) {
printf( "\nForm::modifyMapping( ... )\n\n" );
this->database->modifyMappingData( record );
+ this->updateMappingView();
}
void Form::removeMapping( mapper_db_mapping record ) {
+ printf( "\nForm::removeMapping( ... )\n\n" );
this->database->removeMappingData( record );
+ this->updateMappingView();
}
void Form::addNewMapping( mapper_db_mapping record ) {
printf( "\nForm::addNewMapping( ... )\n" );
this->database->addMappingData( record );
+ this->updateMappingView();
}
@@ -1441,66 +1449,6 @@ void Form::clearLinkParameterDisplay() {
}
-/*
-void Form::addNodeToDestinationView( Node* the_node ) {
-
- QModelIndex dummy_index;
- displayed_dest_model->
- appendRow( the_node->dest_model_list );
- destination_signal_list->
- setFirstColumnSpanned( displayed_dest_model->rowCount()-1,
- dummy_index, true );
- the_node->is_destination = true;
- the_node->is_source = false;
- the_node->update();
-
- //destination_signal_list->expand(
- // destination_model->
- // indexFromItem( the_node->destination_model_list.first() )
- // );
-
- updateMappingView();
-
-}
-void Form::removeNodeFromDestinationView( Node* the_node ) {
-
- int i = displayed_dest_model->
- indexFromItem( the_node->
- dest_model_list.first() ).row();
- displayed_dest_model->takeRow( i );
- the_node->is_destination = false;
- the_node->update();
-
-}
-void Form::addNodeToSourceView( Node* the_node ) {
-
- QModelIndex dummy_index;
- displayed_source_model->
- appendRow( the_node->source_model_list );
- source_signal_list->
- setFirstColumnSpanned( displayed_source_model->rowCount()-1,
- dummy_index, true );
-
- the_node->is_source = true;
- the_node->is_destination = false;
- the_node->update();
-
- updateMappingView();
-
-}
-void Form::removeNodeFromSourceView( Node* the_node ) {
-
- int i = displayed_source_model->
- indexFromItem( the_node->
- source_model_list.first() ).row();
- displayed_source_model->takeRow( i );
- the_node->is_source = false;
- the_node->update();
-
-}
-*/
-
-
void Form::updatePressedLink( Link *reference ) {
@@ -1634,7 +1582,6 @@ bool Form::eventFilter( QObject *obj, QEvent *event ) {
((QResizeEvent*)event)->size().width(),
((QResizeEvent*)event)->size().height() );
*/
- //updateMappingView();
return true;
} else if ( event->type() == QEvent::Show) {
@@ -1674,7 +1621,6 @@ void Form::updateEditSelectionMode( int index ) {
} else if ( index == 1 ) {
printf( "selected edit tab %d\n", index );
- //updateMappingView();
}
View
2  gui/form.ui
@@ -434,7 +434,7 @@
</widget>
</item>
<item>
- <widget class="QGraphicsView" name="graphics_view_2">
+ <widget class="QGraphicsView" name="mappingGraphicsView">
<property name="enabled">
<bool>true</bool>
</property>
View
2  gui/utility.h
@@ -33,7 +33,7 @@ class Utility {
static bool findDbDeviceByName( mapper_db_device i );
static bool findDbSignal( mapper_db_signal i );
- bool findDbSignalPair( std::pair<mapper_db_device, mapper_db_signal> i );
+ static bool findDbSignalPair( std::pair<mapper_db_device, mapper_db_signal> i );
static bool findDbMapping( mapper_db_mapping i );
Please sign in to comment.
Something went wrong with that request. Please try again.