diff options
Diffstat (limited to 'pokemodr/PokeModrUI.cpp')
| -rw-r--r-- | pokemodr/PokeModrUI.cpp | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp index 6a9ea1b1..80341383 100644 --- a/pokemodr/PokeModrUI.cpp +++ b/pokemodr/PokeModrUI.cpp @@ -46,12 +46,12 @@ PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* parent) : KMainWindow(parent), m_config(config), - m_recent(new KRecentFilesAction("&Recent Files...", this)), - m_clipboard(NULL) + m_recent(new KRecentFilesAction("&Recent Files...", this)) { setupUi(this); QMetaObject::connectSlotsByName(this); m_recent->loadEntries(history); + // TODO: Somehow get KAction/KMenus into the ui files KMenuBar* menubar = new KMenuBar(this); KMenu* menuFile = new KMenu("&File", menubar); menuFile->addAction(KStandardAction::openNew(this, SLOT(newPokemod()), menuFile)); @@ -135,11 +135,7 @@ void PokeModrUI::closeEvent(QCloseEvent* event) void PokeModrUI::setChangedTitle(const bool changed) { - // TODO: set the title -// if (formPanel->widget()) -// setWindowTitle(QString::fromUtf8("%1%2 - PokéModr").arg(static_cast<ObjectUI*>(formPanel->widget())->original()->pokemod()->title()).arg(c ? "*" : "")); -// else -// setWindowTitle(QString::fromUtf8("PokéModr")); + setWindowTitle(QString::fromUtf8("%1%2 - PokéModr").arg(treePokemod->description(treePokemod->currentIndex())).arg(changed ? "*" : "")); } void PokeModrUI::newPokemod() @@ -231,30 +227,17 @@ void PokeModrUI::quit() void PokeModrUI::cutObject() { - // TODO: cut the item -// if (!treePokemod->currentItem()) -// return; -// if (m_clipboard) -// delete m_clipboard; -// m_clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->cut(); + m_clipboard = treePokemod->cut(treePokemod->currentIndex()); } void PokeModrUI::copyObject() { - // TODO: copy the item -// if (!treePokemod->currentItem()) -// return; -// if (m_clipboard) -// delete m_clipboard; -// m_clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->copy(); + m_clipboard = treePokemod->copy(treePokemod->currentIndex()); } void PokeModrUI::pasteObject() { - // TODO: paste the item -// if (!m_clipboard || !treePokemod->currentItem()) -// return; -// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->paste(m_clipboard); + treePokemod->paste(treePokemod->currentIndex(), m_clipboard); } void PokeModrUI::preferences() @@ -270,7 +253,6 @@ void PokeModrUI::on_splitter_splitterMoved() void PokeModrUI::on_treePokemod_clicked(const QModelIndex& index) { - // TODO: update the panel with the new widget needed QWidget* widget = treePokemod->editorWidget(index); if (widget) { @@ -279,6 +261,8 @@ void PokeModrUI::on_treePokemod_clicked(const QModelIndex& index) if (!static_cast<ObjectUI*>(formPanel->widget())->close()) return; } + connect(widget, SIGNAL(changed(bool)), this, SLOT(setChangedTitle(bool))); + setChangedTitle(false); formPanel->setWidget(widget); formPanel->show(); } @@ -286,10 +270,7 @@ void PokeModrUI::on_treePokemod_clicked(const QModelIndex& index) void PokeModrUI::on_treePokemod_customContextMenuRequested(const QPoint& position) { - // TODO: figure out which item was clicked -// if (treePokemod->itemAt(position)) -// static_cast<PokeModTreeItem*>(treePokemod->itemAt(position))->makeMenu(position); -// else -// { -// } + KMenu* menu = treePokemod->contextMenu(treePokemod->indexAt(position)); + if (menu) + menu->popup(mapToGlobal(position)); } |
