diff options
-rw-r--r-- | qt-ui/divelistview.cpp | 4 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 19 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 5 | ||||
-rw-r--r-- | qt-ui/mainwindow.ui | 4 | ||||
-rw-r--r-- | qt-ui/undobuffer.cpp | 78 | ||||
-rw-r--r-- | qt-ui/undobuffer.h | 39 | ||||
-rw-r--r-- | subsurface.pro | 6 |
7 files changed, 3 insertions, 152 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 6d8642272..b866a1aa1 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -14,7 +14,6 @@ #include <QKeyEvent> #include <QFileDialog> #include "qthelper.h" -#include "undobuffer.h" // # Date Rtg Dpth Dur Tmp Wght Suit Cyl Gas SAC OTU CNS Loc static int defaultWidth[] = { 70, 140, 90, 50, 50, 50, 50, 70, 50, 50, 70, 50, 50, 500}; @@ -735,9 +734,6 @@ void DiveListView::deleteDive() for_each_dive (i, d) { if (!d->selected) continue; - struct dive* undo_entry = alloc_dive(); - copy_dive(get_dive(i), undo_entry); - MainWindow::instance()->undoBuffer->recordbefore("Delete Dive", undo_entry); delete_single_dive(i); i--; // so the next dive isn't skipped... it's now #i lastDiveNr = i; diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 163ff7d61..9908e2402 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -36,7 +36,6 @@ #include "usermanual.h" #endif #include <QNetworkProxy> -#include "undobuffer.h" MainWindow *MainWindow::m_Instance = NULL; @@ -108,7 +107,6 @@ MainWindow::MainWindow() : QMainWindow(), connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled())); connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); - connect(ui.menu_Edit, SIGNAL(aboutToShow()), this, SLOT(checkForUndoAndRedo())); #ifdef NO_PRINTING ui.printPlan->hide(); ui.menuFile->removeAction(ui.actionPrint); @@ -182,7 +180,6 @@ MainWindow::MainWindow() : QMainWindow(), toolBar->setContentsMargins(zeroMargins); updateManager = new UpdateManager(this); - undoBuffer = new UndoBuffer(this); } MainWindow::~MainWindow() @@ -1502,22 +1499,6 @@ void MainWindow::on_actionFilterTags_triggered() ui.multiFilter->setVisible(true); } -void MainWindow::on_action_Undo_triggered() -{ - undoBuffer->undo(); -} - -void MainWindow::on_action_Redo_triggered() -{ - undoBuffer->redo(); -} - -void MainWindow::checkForUndoAndRedo() -{ - ui.action_Undo->setEnabled(undoBuffer->canUndo()); - ui.action_Redo->setEnabled(undoBuffer->canRedo()); -} - void MainWindow::registerApplicationState(const QByteArray& state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight) { applicationState[state] = WidgetForQuadrant(topLeft, topRight, bottomLeft, bottomRight); diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 716968bbd..5ee085c29 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -34,7 +34,6 @@ class DivePlannerWidget; class ProfileWidget2; class PlannerDetails; class PlannerSettingsWidget; -class UndoBuffer; enum MainWindowTitleFormat { MWTF_DEFAULT, @@ -89,7 +88,6 @@ public: void printPlan(); void checkSurvey(QSettings *s); void setApplicationState(const QByteArray& state); - UndoBuffer *undoBuffer; private slots: /* file menu action */ @@ -159,9 +157,6 @@ slots: void on_paste_triggered(); void on_actionFilterTags_triggered(); void on_actionConfigure_Dive_Computer_triggered(); - void on_action_Undo_triggered(); - void on_action_Redo_triggered(); - void checkForUndoAndRedo(); protected: void closeEvent(QCloseEvent *); diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index ced02c964..b6cd4a358 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -50,7 +50,7 @@ <x>0</x> <y>0</y> <width>861</width> - <height>32</height> + <height>25</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -130,8 +130,6 @@ <property name="title"> <string>&Edit</string> </property> - <addaction name="action_Undo"/> - <addaction name="action_Redo"/> </widget> <addaction name="menuFile"/> <addaction name="menu_Edit"/> diff --git a/qt-ui/undobuffer.cpp b/qt-ui/undobuffer.cpp deleted file mode 100644 index 4ee0cf608..000000000 --- a/qt-ui/undobuffer.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "undobuffer.h" -#include "mainwindow.h" - -UndoBuffer::UndoBuffer(QObject *parent) : QObject(parent) -{ - curIdx = 0; -} - -UndoBuffer::~UndoBuffer() -{ - -} - -bool UndoBuffer::canUndo() -{ - return curIdx > 0; -} - -bool UndoBuffer::canRedo() -{ - return curIdx < list.count(); -} - -void UndoBuffer::redo() -{ - current()->redo(); - curIdx++; - if (curIdx > list.count()) - curIdx = list.count() - 1; -} - -void UndoBuffer::undo() -{ - current()->undo(); - curIdx = list.indexOf(current()); -} - -void UndoBuffer::recordbefore(QString commandName, dive *affectedDive) -{ - UndoCommand *cmd = new UndoCommand(commandName, affectedDive); - //If we are within the list, clear the extra UndoCommands. - if (list.count() > 0) { - if (curIdx + 1 < list.count()) { - for (int i = curIdx + 1; i < list.count(); i++) { - list.removeAt(i); - } - } - } - list.append(cmd); - curIdx = list.count(); -} - -void UndoBuffer::recordAfter(dive *affectedDive) -{ - list.at(curIdx - 1)->setStateAfter(affectedDive); -} - - - -UndoCommand::UndoCommand(QString commandName, dive *affectedDive) -{ - name = commandName; - stateBefore = affectedDive; -} - -void UndoCommand::undo() -{ - if (name == "Delete Dive") { - record_dive(stateBefore); - MainWindow::instance()->recreateDiveList(); - } -} - -void UndoCommand::redo() -{ - //To be implemented -} - diff --git a/qt-ui/undobuffer.h b/qt-ui/undobuffer.h deleted file mode 100644 index 9fac14710..000000000 --- a/qt-ui/undobuffer.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef UNDOBUFFER_H -#define UNDOBUFFER_H - -#include <QObject> -#include "dive.h" - -class UndoCommand { -private: - dive* stateBefore; - dive* stateAfter; - QString name; - -public: - explicit UndoCommand(QString commandName, dive* affectedDive); - void setStateAfter(dive* affectedDive) { stateAfter = affectedDive; } - void undo(); - void redo(); -}; - -class UndoBuffer : public QObject -{ - Q_OBJECT -public: - explicit UndoBuffer(QObject *parent = 0); - ~UndoBuffer(); - bool canUndo(); - bool canRedo(); - UndoCommand *current() const { return list.at(curIdx - 1); } -private: - QList<UndoCommand*> list; - int curIdx; -public slots: - void redo(); - void undo(); - void recordbefore(QString commandName, dive *affectedDive); - void recordAfter(dive *affectedDive); -}; - -#endif // UNDOBUFFER_H diff --git a/subsurface.pro b/subsurface.pro index e59b32378..5fb6ab5d2 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -104,8 +104,7 @@ HEADERS = \ qt-ui/statistics/statisticsbar.h \ qt-ui/statistics/yearstatistics.h \ qt-ui/diveshareexportdialog.h \ - qt-ui/filtermodels.h \ - qt-ui/undobuffer.h + qt-ui/filtermodels.h android: HEADERS -= \ qt-ui/usermanual.h \ @@ -199,8 +198,7 @@ SOURCES = \ qt-ui/statistics/statisticsbar.cpp \ qt-ui/statistics/monthstatistics.cpp \ qt-ui/diveshareexportdialog.cpp \ - qt-ui/filtermodels.cpp \ - qt-ui/undobuffer.cpp + qt-ui/filtermodels.cpp android: SOURCES += android.cpp else: win32: SOURCES += windows.c |