FileDigger::FileDigger(MergedRepository *pRepository, QWidget *pParent) : KMainWindow(pParent) { setWindowIcon(KIcon(QLatin1String("chronometer"))); KToolBar *lAppToolBar = toolBar(); lAppToolBar->addAction(KStandardAction::quit(this, SLOT(close()), this)); QSplitter *lSplitter = new QSplitter(); mMergedVfsModel = new MergedVfsModel(pRepository, this); mMergedVfsView = new QTreeView(); mMergedVfsView->setHeaderHidden(true); mMergedVfsView->setSelectionMode(QAbstractItemView::SingleSelection); mMergedVfsView->setModel(mMergedVfsModel); lSplitter->addWidget(mMergedVfsView); connect(mMergedVfsView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateVersionModel(QModelIndex,QModelIndex))); mVersionView = new QListView(); mVersionView->setSelectionMode(QAbstractItemView::SingleSelection); mVersionModel = new VersionListModel(this); mVersionView->setModel(mVersionModel); VersionListDelegate *lVersionDelegate = new VersionListDelegate(mVersionView,this); mVersionView->setItemDelegate(lVersionDelegate); lSplitter->addWidget(mVersionView); connect(lVersionDelegate, SIGNAL(openRequested(QModelIndex)), SLOT(open(QModelIndex))); connect(lVersionDelegate, SIGNAL(restoreRequested(QModelIndex)), SLOT(restore(QModelIndex))); mMergedVfsView->setFocus(); //expand all levels from the top until the node has more than one child QModelIndex lIndex; forever { mMergedVfsView->expand(lIndex); if(mMergedVfsModel->rowCount(lIndex) == 1) { lIndex = mMergedVfsModel->index(0, 0, lIndex); } else { break; } } mMergedVfsView->selectionModel()->setCurrentIndex(lIndex.child(0,0), QItemSelectionModel::Select); setCentralWidget(lSplitter); }
EditorMainWindow::EditorMainWindow(QWidget *parent) : QMainWindow(parent) { camera_ = 0; ui.setupUi(this); QApplication::connect(ui.action_Open, SIGNAL(triggered()), this, SLOT(openRequested())); QApplication::connect(ui.action_Save, SIGNAL(triggered()), this, SLOT(saveRequested())); QApplication::connect(ui.actionDerive_map, SIGNAL(triggered()), this, SLOT(deriveMap())); QApplication::connect(ui.action_Quit, SIGNAL(triggered()), QApplication::instance(), SLOT(quit())); QApplication::connect(ui.actionZoom_In, SIGNAL(triggered()), this, SLOT(zoominRequested())); QApplication::connect(ui.actionZoom_Out, SIGNAL(triggered()), this, SLOT(zoomoutRequested())); QApplication::connect(ui.horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(horzScroll(int))); QApplication::connect(ui.verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vertScroll(int))); QApplication::connect(ui.actionRotate_Left, SIGNAL(triggered()), this, SLOT(rotateLeft())); QApplication::connect(ui.actionRotate_Right, SIGNAL(triggered()), this, SLOT(rotateRight())); QApplication::connect(ui.actionTilt_Up, SIGNAL(triggered()), this, SLOT(tiltUp())); QApplication::connect(ui.actionTilt_Down, SIGNAL(triggered()), this, SLOT(tiltDown())); QApplication::connect(ui.actionUndo, SIGNAL(triggered()), this, SLOT(undo())); QApplication::connect(ui.actionRedo, SIGNAL(triggered()), this, SLOT(redo())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S),this), SIGNAL(activated()), this, SLOT(saveRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_O),this), SIGNAL(activated()), this, SLOT(openRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Z),this), SIGNAL(activated()), this, SLOT(zoominRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_X),this), SIGNAL(activated()), this, SLOT(zoomoutRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left),this), SIGNAL(activated()), this, SLOT(rotateLeft())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right),this), SIGNAL(activated()), this, SLOT(rotateRight())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up),this), SIGNAL(activated()), this, SLOT(tiltUp())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down),this), SIGNAL(activated()), this, SLOT(tiltDown())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Left),this), SIGNAL(activated()), this, SLOT(panLeft())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Right),this), SIGNAL(activated()), this, SLOT(panRight())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Up),this), SIGNAL(activated()), this, SLOT(panUp())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Down),this), SIGNAL(activated()), this, SLOT(panDown())); ui.action_Save->setEnabled(false); ui.editorGLWidget->setEnabled(false); QToolButton* party_button = new QToolButton(); party_button->setText("Parties"); party_button->setCheckable(true); party_button->setChecked(false); handlers_.push_back(new TerrainHandler(*this, "party", false, tool_buttons_.size())); QApplication::connect(party_button, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_P),this), SIGNAL(activated()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(party_button); tool_buttons_.push_back(party_button); QToolButton* height_button = new QToolButton(); height_button->setText("Height"); height_button->setCheckable(true); height_button->setChecked(true); handlers_.push_back(new TerrainHandler(*this, "", false, tool_buttons_.size())); QApplication::connect(height_button, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_H),this), SIGNAL(activated()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(height_button); tool_buttons_.push_back(height_button); QToolButton* picker_button = new QToolButton(); picker_button->setText("Picker"); picker_button->setCheckable(true); handlers_.push_back(new TerrainHandler(*this, "", true, tool_buttons_.size())); QApplication::connect(picker_button, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(picker_button); tool_buttons_.push_back(picker_button); std::vector<std::string> terrain_ids; hex::base_terrain::get_terrain_ids(terrain_ids); for(int n = 0; n != terrain_ids.size(); ++n) { QToolButton* b = new QToolButton(); b->setText(hex::base_terrain::get(terrain_ids[n])->name().c_str()); b->setCheckable(true); handlers_.push_back(new TerrainHandler(*this, terrain_ids[n], false, tool_buttons_.size())); QApplication::connect(b, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(b); tool_buttons_.push_back(b); } terrain_ids.clear(); hex::terrain_feature::get_feature_ids(terrain_ids); for(int n = 0; n != terrain_ids.size(); ++n) { QToolButton* b = new QToolButton(); b->setText(hex::terrain_feature::get(terrain_ids[n])->name().c_str()); b->setCheckable(true); handlers_.push_back(new TerrainHandler(*this, terrain_ids[n], true, tool_buttons_.size())); QApplication::connect(b, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(b); tool_buttons_.push_back(b); } }