Cut and Paste

.. so far
This commit is contained in:
Mark Liversedge
2016-01-03 21:17:06 +00:00
parent 440238eab3
commit c447245d71
6 changed files with 89 additions and 1 deletions

View File

@@ -1407,3 +1407,21 @@ WorkoutWidget::undo()
// update
update();
}
void
WorkoutWidget::cut()
{
qDebug()<<"cut";
}
void
WorkoutWidget::copy()
{
qDebug()<<"copy";
}
void
WorkoutWidget::paste()
{
qDebug()<<"paste";
}

View File

@@ -170,6 +170,11 @@ class WorkoutWidget : public QWidget
void redo();
void undo();
// working with the clipboard
void cut();
void copy();
void paste();
protected:
WWPoint *dragging;

View File

@@ -294,6 +294,19 @@ WWBlockCursor::paint(QPainter *painter)
}
}
void
WWBlockSelection::paint(QPainter *painter)
{
qDebug()<<"select cursor paint";
}
// locate me on the parent widget in paint coordinates
QRectF
WWBlockSelection::bounding()
{
return QRectF();
}
//W'bal curve paint
void
WWWBLine::paint(QPainter *painter)

View File

@@ -38,6 +38,7 @@
#define GCWW_WBLINE 5
#define GCWW_RECT 6 // selection rectangle
#define GCWW_BCURSOR 7 // interval "block" cursor
#define GCWW_BRECT 8 // block selection
//
// ITEMS
@@ -162,6 +163,24 @@ class WWBlockCursor : public WorkoutWidgetItem {
private:
};
class WWBlockSelection : public WorkoutWidgetItem {
public:
WWBlockSelection(WorkoutWidget *w) : WorkoutWidgetItem(w) { w->addItem(this); }
// Reimplement in children
int type() { return GCWW_BRECT; }
void paint(QPainter *painter);
// locate me on the parent widget in paint coordinates
QRectF bounding();
private:
Context *context;
};
// draws the W'bal curve
class WWWBLine : public WorkoutWidgetItem {

View File

@@ -46,6 +46,9 @@ WorkoutWindow::WorkoutWindow(Context *context) :
// block cursos
bcursor = new WWBlockCursor(workout);
// block selection
brect = new WWBlockSelection(workout);
// paint the W'bal curve
wbline = new WWWBLine(workout, context);
@@ -94,6 +97,29 @@ WorkoutWindow::WorkoutWindow(Context *context) :
connect(selectAct, SIGNAL(triggered()), this, SLOT(selectMode()));
toolbar->addAction(selectAct);
selectAct->setEnabled(true);
drawAct->setEnabled(false);
toolbar->addSeparator();
QIcon cutIcon(":images/toolbar/cut.png");
cutAct = new QAction(cutIcon, tr("Cut"), this);
cutAct->setEnabled(true);
toolbar->addAction(cutAct);
connect(cutAct, SIGNAL(triggered()), workout, SLOT(cut()));
QIcon copyIcon(":images/toolbar/copy.png");
copyAct = new QAction(copyIcon, tr("Copy"), this);
copyAct->setEnabled(true);
toolbar->addAction(copyAct);
connect(copyAct, SIGNAL(triggered()), workout, SLOT(copy()));
QIcon pasteIcon(":images/toolbar/paste.png");
pasteAct = new QAction(pasteIcon, tr("Paste"), this);
pasteAct->setEnabled(false);
toolbar->addAction(pasteAct);
connect(pasteAct, SIGNAL(triggered()), workout, SLOT(paste()));
// stretch the labels to the right hand side
QWidget *empty = new QWidget(this);
empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
@@ -163,11 +189,15 @@ void
WorkoutWindow::drawMode()
{
draw = true;
drawAct->setEnabled(false);
selectAct->setEnabled(true);
}
void
WorkoutWindow::selectMode()
{
draw = false;
drawAct->setEnabled(true);
selectAct->setEnabled(false);
}

View File

@@ -42,6 +42,7 @@ class WWLine;
class WWWBLine;
class WWRect;
class WWBlockCursor;
class WWBlockSelection;
class WorkoutWindow : public GcWindow
{
@@ -56,7 +57,8 @@ class WorkoutWindow : public GcWindow
QLabel *TSSlabel, *IFlabel;
QAction *saveAct, *undoAct, *redoAct,
*drawAct, *selectAct;
*drawAct, *selectAct,
*cutAct, *copyAct, *pasteAct;
bool draw; // draw or select mode?
@@ -82,6 +84,7 @@ class WorkoutWindow : public GcWindow
WWWBLine *wbline;
WWRect *rect;
WWBlockCursor *bcursor;
WWBlockSelection *brect;
bool active;
};