QTfrontend/ui/widget/mapContainer.cpp
changeset 9744 1ee4842a9c86
parent 9739 c2c9dd2544b8
child 9745 258c320256dc
equal deleted inserted replaced
9743:6e505ea936ad 9744:1ee4842a9c86
    55     mapgen(MAPGEN_REGULAR),
    55     mapgen(MAPGEN_REGULAR),
    56     m_previewSize(256, 128)
    56     m_previewSize(256, 128)
    57 {
    57 {
    58     // don't show preview anything until first show event
    58     // don't show preview anything until first show event
    59     m_previewEnabled = false;
    59     m_previewEnabled = false;
       
    60     m_missionsViewSetup = false;
       
    61     m_staticViewSetup = false;
    60 
    62 
    61     hhSmall.load(":/res/hh_small.png");
    63     hhSmall.load(":/res/hh_small.png");
    62     hhLimit = 18;
    64     hhLimit = 18;
    63     templateFilter = 0;
    65     templateFilter = 0;
    64     m_master = true;
    66     m_master = true;
   159     rightLayout->addWidget(lblMapList, 0);
   161     rightLayout->addWidget(lblMapList, 0);
   160 
   162 
   161     /* Static maps list */
   163     /* Static maps list */
   162 
   164 
   163     staticMapList = new QListView;
   165     staticMapList = new QListView;
   164     staticMapList->setModel(m_staticMapModel);
       
   165     rightLayout->addWidget(staticMapList, 1);
   166     rightLayout->addWidget(staticMapList, 1);
   166     staticMapList->setEditTriggers(QAbstractItemView::NoEditTriggers);
       
   167     m_childWidgets << staticMapList;
   167     m_childWidgets << staticMapList;
   168     QItemSelectionModel * staticSelectionModel = staticMapList->selectionModel();
       
   169     connect(staticSelectionModel,
       
   170             SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)),
       
   171             this,
       
   172             SLOT(staticMapChanged(const QModelIndex &, const QModelIndex &)));
       
   173 
   168 
   174     /* Mission maps list */
   169     /* Mission maps list */
   175 
   170 
   176     missionMapList = new QListView;
   171     missionMapList = new QListView(this);
   177     missionMapList->setModel(m_missionMapModel);
       
   178     missionMapList->setEditTriggers(QAbstractItemView::NoEditTriggers);
       
   179     rightLayout->addWidget(missionMapList, 1);
   172     rightLayout->addWidget(missionMapList, 1);
   180     m_childWidgets << missionMapList;
   173     m_childWidgets << missionMapList;
   181     QItemSelectionModel * missionSelectionModel = missionMapList->selectionModel();
       
   182     connect(missionSelectionModel,
       
   183             SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)),
       
   184             this,
       
   185             SLOT(missionMapChanged(const QModelIndex &, const QModelIndex &)));
       
   186 
   174 
   187     /* Map load and edit buttons */
   175     /* Map load and edit buttons */
   188 
   176 
   189     drawnControls->addStretch(1);
   177     drawnControls->addStretch(1);
   190 
   178 
   740             setMapInfo(MapModel::MapInfoDrawn);
   728             setMapInfo(MapModel::MapInfoDrawn);
   741             btnLoadMap->show();
   729             btnLoadMap->show();
   742             btnEditMap->show();
   730             btnEditMap->show();
   743             break;
   731             break;
   744         case MapModel::MissionMap:
   732         case MapModel::MissionMap:
       
   733             setupMissionMapsView();
   745             mapgen = MAPGEN_MAP;
   734             mapgen = MAPGEN_MAP;
   746             missionMapChanged(newMap.isValid() ? newMap : missionMapList->currentIndex());
   735             missionMapChanged(newMap.isValid() ? newMap : missionMapList->currentIndex());
   747             lblMapList->setText(tr("Mission:"));
   736             lblMapList->setText(tr("Mission:"));
   748             lblMapList->show();
   737             lblMapList->show();
   749             missionMapList->show();
   738             missionMapList->show();
   750             lblDesc->setText(m_mapInfo.desc);
   739             lblDesc->setText(m_mapInfo.desc);
   751             lblDesc->show();
   740             lblDesc->show();
   752             emit mapChanged(m_curMap);
   741             emit mapChanged(m_curMap);
   753             break;
   742             break;
   754         case MapModel::StaticMap:
   743         case MapModel::StaticMap:
       
   744             setupStaticMapsView();
   755             mapgen = MAPGEN_MAP;
   745             mapgen = MAPGEN_MAP;
   756             staticMapChanged(newMap.isValid() ? newMap : staticMapList->currentIndex());
   746             staticMapChanged(newMap.isValid() ? newMap : staticMapList->currentIndex());
   757             lblMapList->setText(tr("Map:"));
   747             lblMapList->setText(tr("Map:"));
   758             lblMapList->show();
   748             lblMapList->show();
   759             staticMapList->show();
   749             staticMapList->show();
   949 
   939 
   950     m_theme = name;
   940     m_theme = name;
   951     btnTheme->setIcon(QIcon());
   941     btnTheme->setIcon(QIcon());
   952     btnTheme->setText(tr("Theme: %1").arg(name));
   942     btnTheme->setText(tr("Theme: %1").arg(name));
   953 }
   943 }
       
   944 
       
   945 void HWMapContainer::setupMissionMapsView()
       
   946 {
       
   947     if(m_missionsViewSetup) return;
       
   948     m_missionsViewSetup = true;
       
   949 
       
   950     m_missionMapModel->loadMaps();
       
   951     missionMapList->setModel(m_missionMapModel);
       
   952     missionMapList->setEditTriggers(QAbstractItemView::NoEditTriggers);
       
   953     QItemSelectionModel * missionSelectionModel = missionMapList->selectionModel();
       
   954     connect(missionSelectionModel,
       
   955             SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)),
       
   956             this,
       
   957             SLOT(missionMapChanged(const QModelIndex &, const QModelIndex &)));
       
   958     missionSelectionModel->setCurrentIndex(m_missionMapModel->index(0, 0), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
       
   959 }
       
   960 
       
   961 void HWMapContainer::setupStaticMapsView()
       
   962 {
       
   963     if(m_staticViewSetup) return;
       
   964     m_staticViewSetup = true;
       
   965 
       
   966     m_staticMapModel->loadMaps();
       
   967     staticMapList->setModel(m_staticMapModel);
       
   968     staticMapList->setEditTriggers(QAbstractItemView::NoEditTriggers);
       
   969     QItemSelectionModel * staticSelectionModel = staticMapList->selectionModel();
       
   970     connect(staticSelectionModel,
       
   971             SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)),
       
   972             this,
       
   973             SLOT(staticMapChanged(const QModelIndex &, const QModelIndex &)));
       
   974     staticSelectionModel->setCurrentIndex(m_staticMapModel->index(0, 0), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
       
   975 }