teacher bar behaves correctly

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent 20a787f157
commit 5a6de660d2
  1. 18
      src/board/UBBoardView.cpp
  2. 18
      src/gui/UBTeacherGuideWidget.cpp
  3. 3
      src/gui/UBTeacherGuideWidgetsTools.cpp

@ -35,8 +35,8 @@
#include "gui/UBToolWidget.h"
#include "gui/UBResources.h"
#include "gui/UBMainWindow.h"
#include "gui/UBMediaPlayer.h"
#include "gui/UBThumbnailWidget.h"
#include "gui/UBTeacherGuideWidgetsTools.h"
#include "board/UBBoardController.h"
@ -764,11 +764,6 @@ UBBoardView::drawItems (QPainter *painter, int numItems,
}
}
//void UBBoardView::dragEnterEvent (QDragEnterEvent *event)
//{
// // TODO UB 4.x be smarter with drag accept code .... we cannot handle everything ...
// event->acceptProposedAction ();
//}
void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
{
@ -805,14 +800,17 @@ void UBBoardView::dropEvent (QDropEvent *event)
QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y());
UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos);
if (graphicsWidget && graphicsWidget->acceptDrops()) {
qDebug() << event->source();
if (graphicsWidget && graphicsWidget->acceptDrops()) {
graphicsWidget->processDropEvent(event);
event->acceptProposedAction();
} else if (!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source())
|| dynamic_cast<QWebView*>(event->source())) {
}
else if (!event->source()
|| dynamic_cast<UBThumbnailWidget *>(event->source())
|| dynamic_cast<QWebView*>(event->source())
|| dynamic_cast<UBTGMediaWidget*>(event->source())) {
mController->processMimeData (event->mimeData (), mapToScene (event->pos ()));
event->acceptProposedAction();
}

@ -84,6 +84,11 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
mpTreeWidget->setDropIndicatorShown(false);
mpTreeWidget->header()->close();
mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mpTreeWidget->setColumnCount(2);
mpTreeWidget->header()->setStretchLastSection(false);
mpTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch);
mpTreeWidget->header()->setResizeMode(1, QHeaderView::Custom);
connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int)));
mpAddAnActionItem = new UBAddItem(tr("Add an action"),eUBTGAddSubItemWidgetType_Action,mpTreeWidget);
@ -97,7 +102,6 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget()
{
DELETEPTR(mpDocumentTitle);
DELETEPTR(mpPageTitle);
DELETEPTR(mpComment);
@ -165,6 +169,8 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int
if(column == 0 && addSubItemWidgetType != eUBTGAddSubItemWidgetType_None){
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(widget);
newWidgetItem->setData(column,Qt::UserRole,eUBTGAddSubItemWidgetType_None);
newWidgetItem->setData(1,Qt::UserRole,eUBTGAddSubItemWidgetType_None);
newWidgetItem->setIcon(1,QIcon(":images/close.svg"));
switch(addSubItemWidgetType)
{
case eUBTGAddSubItemWidgetType_Action:
@ -177,7 +183,9 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int
mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGUrlWidget());
break;
default:
qDebug() << "onAddItemClicked no action set";
delete newWidgetItem;
qCritical() << "onAddItemClicked no action set";
return;
}
if(addSubItemWidgetType != eUBTGAddSubItemWidgetType_None && !widget->isExpanded() )
@ -188,6 +196,11 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int
widget->setExpanded(true);
}
}
else if(column == 1 && addSubItemWidgetType == eUBTGAddSubItemWidgetType_None){
int index = mpTreeWidget->currentIndex().row();
QTreeWidgetItem* toBeDeletedWidgetItem = widget->parent()->takeChild(index);
delete toBeDeletedWidgetItem;
}
}
/***************************************************************************
@ -252,6 +265,7 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare
mpTreeWidget->setDropIndicatorShown(false);
mpTreeWidget->header()->close();
mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// mpTreeWidget->setColumnCount(1);
connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int)));
}

@ -39,6 +39,7 @@ UBAddItem::UBAddItem(const QString &string, int addSubItemWidgetType, QTreeWidge
setIcon(0,QIcon(":images/increase.svg"));
setText(0,string);
setData(0,Qt::UserRole,QVariant(addSubItemWidgetType));
setData(1,Qt::UserRole,QVariant(addSubItemWidgetType));
}
UBAddItem::~UBAddItem()
@ -305,7 +306,7 @@ void UBTGMediaWidget::mousePressEvent(QMouseEvent *event)
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
QList<QUrl> urlList;
urlList << QUrl::fromLocalFile(mRelativePath);
urlList << QUrl(mRelativePath);
mimeData->setUrls(urlList);
drag->setMimeData(mimeData);

Loading…
Cancel
Save