summaryrefslogtreecommitdiffstats
path: root/pokemodr/PokeModrUI.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-17 23:34:36 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-17 23:34:36 +0000
commit6679f5cffa9d35a23b76605ddfbf3257f882b6ee (patch)
treec8e41854a60b64e8569939bca6b827807175ef9a /pokemodr/PokeModrUI.cpp
parent05980e883719b1c8ebde1bd2fcbf4f8c16df7ad6 (diff)
[FIX] Frac -> Fraction
[FIX] ImageCache and Ini removed [FIX] Fraction/Point widgets moved to pokemodr [FIX] Copy ctors made for pokemod classes [FIX] Ctors in pokemod fixed [FIX] Copyright headers fixed in pokemodr [FIX] PokeModr updated to new API and fixed in some places git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@99 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/PokeModrUI.cpp')
-rw-r--r--pokemodr/PokeModrUI.cpp141
1 files changed, 71 insertions, 70 deletions
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp
index adc1e2b2..134f5d64 100644
--- a/pokemodr/PokeModrUI.cpp
+++ b/pokemodr/PokeModrUI.cpp
@@ -1,25 +1,21 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name: pokegen/PokeModrUI.cpp
-// Purpose: Main window handling
-// Author: Ben Boeckel
-// Modified by: Ben Boeckel
-// Created: Wed Jan 23 10:42:50 2008
-// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions
-// Licence:
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program. If not, see <http://www.gnu.org/licenses/>.
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2008 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+// KDE includes
#include <kaction.h>
#include <kfiledialog.h>
#include <kicon.h>
@@ -32,30 +28,35 @@
#include <ktoolbar.h>
#include <kurl.h>
-#include <QListIterator>
-#include <QMetaObject>
+// Qt includes
#include <QMutableListIterator>
#include <QString>
+// General includes
#include <BugCatcher.h>
#include <Exception.h>
+// Pokemod includes
#include <Pokemod.h>
-#include "PokeModrUI.h"
+// PokeModr includes
#include "PokeModTreeItem.h"
+// Header include
+#include "PokeModrUI.h"
+
+// STL includes
#include <iostream>
-PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent) :
+PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* parent) :
KMainWindow(parent),
- config(cfg),
- recent("&Recent Files...", NULL),
- clipboard(NULL)
+ m_config(config),
+ m_recent("&Recent Files...", NULL),
+ m_clipboard(NULL)
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
- recent.loadEntries(history);
+ m_recent.loadEntries(history);
KMenuBar* menubar = new KMenuBar(this);
KMenu* menuFile = new KMenu("&File", menubar);
menuFile->addAction(KStandardAction::openNew(this, SLOT(on_actionNew_triggered()), menuFile));
@@ -115,10 +116,10 @@ PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent)
toolbar->addSeparator();
toolbar->addAction(KStandardAction::quit(this, SLOT(on_actionQuit_triggered()), toolbar));
addToolBar(toolbar);
- splitter->setSizes(QList<int>() << cfg.readEntry("treeWidth", 100) << cfg.readEntry("panelWidth", 100));
-// if (cfg.readEntry("reloadOnStart", false))
+ splitter->setSizes(QList<int>() << config.readEntry("treeWidth", 100) << config.readEntry("panelWidth", 100));
+// if (config.readEntry("reloadOnStart", false))
// {
-// for (int i = 0; i < cfg.readEntry("openedFiles", 0); ++i)
+// for (int i = 0; i < config.readEntry("openedFiles", 0); ++i)
// openPokeMod(recent.urls().at(i));
// }
setAutoSaveSettings("MainWindow", true);
@@ -133,17 +134,17 @@ PokeModrUI::~PokeModrUI()
void PokeModrUI::rebuildTree()
{
treePokemod->clear();
- for (QMutableListIterator<Pokemod*> i(pokemods); i.hasNext(); )
- new PokeModTreeItem(treePokemod, i.next());
+ foreach (Pokemod* pokemod, m_pokemods)
+ new PokeModTreeItem(treePokemod, pokemod);
}
void PokeModrUI::openPokeMod(const KUrl& path)
{
if (path.isLocalFile())
{
- pokemods.append(new Pokemod(path.path()));
- recent.addUrl(path);
- recent.saveEntries(config);
+// m_pokemods.append(new Pokemod(path.path()));
+ m_recent.addUrl(path);
+ m_recent.saveEntries(m_config);
rebuildTree();
}
}
@@ -151,7 +152,7 @@ void PokeModrUI::openPokeMod(const KUrl& path)
void PokeModrUI::savePokeMod()
{
if (formPanel->widget())
- static_cast<ObjectUI*>(formPanel->widget())->getOriginal()->getPokemod()->save();
+ static_cast<ObjectUI*>(formPanel->widget())->original()->pokemod()->save();
}
void PokeModrUI::closePokeMod()
@@ -159,7 +160,7 @@ void PokeModrUI::closePokeMod()
if (formPanel->widget())
{
ObjectUI* o = static_cast<ObjectUI*>(formPanel->widget());
- const Pokemod* p = o->getOriginal()->getPokemod();
+ const Pokemod* p = o->original()->pokemod();
if (!o->close())
return;
switch (KMessageBox::questionYesNoCancel(this, "You have unsaved changes, would you like to save them?", "Unsaved PokéMod"))
@@ -171,7 +172,7 @@ void PokeModrUI::closePokeMod()
case KMessageBox::Cancel:
return;
}
- for (QMutableListIterator<Pokemod*> i(pokemods); i.hasNext(); i.next())
+ for (QMutableListIterator<Pokemod*> i(m_pokemods); i.hasNext(); i.next())
{
if (i.value() == p)
{
@@ -193,23 +194,23 @@ void PokeModrUI::closeEvent(QCloseEvent* event)
void PokeModrUI::setChangedTitle(const bool c)
{
if (formPanel->widget())
- setWindowTitle(QString::fromUtf8("%1%2 - PokéModr").arg(static_cast<ObjectUI*>(formPanel->widget())->getOriginal()->getPokemod()->getTitle()).arg(c ? "*" : ""));
+ setWindowTitle(QString::fromUtf8("%1%2 - PokéModr").arg(static_cast<ObjectUI*>(formPanel->widget())->original()->pokemod()->title()).arg(c ? "*" : ""));
else
setWindowTitle(QString::fromUtf8("PokéModr"));
}
void PokeModrUI::on_actionNew_triggered()
{
- QString dir = KFileDialog::getExistingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("New PokéMod"));
- if (dir != "")
- openPokeMod(KUrl(dir));
+// QString dir = KFileDialog::existingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("New PokéMod"));
+// if (dir != "")
+// openPokeMod(KUrl(dir));
}
void PokeModrUI::on_actionOpen_triggered()
{
- QString dir = KFileDialog::getExistingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("Open PokéMod"));
- if (dir != "")
- openPokeMod(KUrl(dir));
+// QString dir = KFileDialog::existingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("Open PokéMod"));
+// if (dir != "")
+// openPokeMod(KUrl(dir));
}
void PokeModrUI::on_actionSave_triggered()
@@ -217,27 +218,27 @@ void PokeModrUI::on_actionSave_triggered()
if (!treePokemod->currentItem())
return;
static_cast<PokeModTreeItem*>(treePokemod->currentItem())->save();
- static_cast<Pokemod*>(static_cast<PokeModTreeItem*>(treePokemod->currentItem())->getObject())->getPokemod()->save();
+ static_cast<Pokemod*>(static_cast<PokeModTreeItem*>(treePokemod->currentItem())->object())->pokemod()->save();
}
void PokeModrUI::on_actionSaveAs_triggered()
{
if (!treePokemod->currentItem())
return;
- QString dir = KFileDialog::getExistingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("Open PokéMod"));
- if (dir != "")
- {
- static_cast<PokeModTreeItem*>(treePokemod->currentItem())->save();
- static_cast<PokeModTreeItem*>(treePokemod->currentItem())->getPokemod()->setPath(dir);
- }
+// QString dir = KFileDialog::existingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("Open PokéMod"));
+// if (dir != "")
+// {
+// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->save();
+// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->pokemod()->setPath(dir);
+// }
}
void PokeModrUI::on_actionQuit_triggered()
{
- while (pokemods.size())
+ while (m_pokemods.size())
closePokeMod();
- if (clipboard)
- delete clipboard;
+ if (m_clipboard)
+ delete m_clipboard;
close();
}
@@ -245,25 +246,25 @@ void PokeModrUI::on_actionCut_triggered()
{
if (!treePokemod->currentItem())
return;
- if (clipboard)
- delete clipboard;
- clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->cut();
+ if (m_clipboard)
+ delete m_clipboard;
+ m_clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->cut();
}
void PokeModrUI::on_actionCopy_triggered()
{
if (!treePokemod->currentItem())
return;
- if (clipboard)
- delete clipboard;
- clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->copy();
+ if (m_clipboard)
+ delete m_clipboard;
+ m_clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->copy();
}
void PokeModrUI::on_actionPaste_triggered()
{
- if (!clipboard || !treePokemod->currentItem())
+ if (!m_clipboard || !treePokemod->currentItem())
return;
- static_cast<PokeModTreeItem*>(treePokemod->currentItem())->paste(clipboard);
+ static_cast<PokeModTreeItem*>(treePokemod->currentItem())->paste(m_clipboard);
}
void PokeModrUI::on_actionPreferences_triggered()
@@ -272,8 +273,8 @@ void PokeModrUI::on_actionPreferences_triggered()
void PokeModrUI::on_splitter_splitterMoved()
{
- config.writeEntry("treeWidth", splitter->sizes()[0]);
- config.writeEntry("panelWidth", splitter->sizes()[1]);
+ m_config.writeEntry("treeWidth", splitter->sizes()[0]);
+ m_config.writeEntry("panelWidth", splitter->sizes()[1]);
}
void PokeModrUI::on_treePokemod_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous)
@@ -294,10 +295,10 @@ void PokeModrUI::on_treePokemod_currentItemChanged(QTreeWidgetItem* current, QTr
formPanel->show();
}
-void PokeModrUI::on_treePokemod_customContextMenuRequested(const QPoint& pos)
+void PokeModrUI::on_treePokemod_customContextMenuRequested(const QPoint& position)
{
- if (treePokemod->itemAt(pos))
- static_cast<PokeModTreeItem*>(treePokemod->itemAt(pos))->makeMenu(pos);
+ if (treePokemod->itemAt(position))
+ static_cast<PokeModTreeItem*>(treePokemod->itemAt(position))->makeMenu(position);
else
{
}