deleted Models Folder and code related + redesign of Documents UI

preferencesAboutTextFull
Clément Fauconnier 6 years ago
parent 8ecf99f838
commit 319671eeab
  1. 79
      resources/forms/documents.ui
  2. 17
      src/adaptors/UBExportAdaptor.cpp
  3. 11
      src/adaptors/UBExportDocument.cpp
  4. 4
      src/adaptors/UBExportDocument.h
  5. 2
      src/adaptors/UBExportDocumentSetAdaptor.cpp
  6. 83
      src/document/UBDocumentController.cpp
  7. 4
      src/document/UBDocumentController.h
  8. 9
      src/gui/UBDocumentTreeWidget.cpp

@ -54,49 +54,23 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="collapseAll">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Collapse All</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/collapse-all.png</normaloff>:/images/collapse-all.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expandAll">
<widget class="QComboBox" name="sortOrder">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Expand All</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/expand-all.png</normaloff>:/images/expand-all.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>Ascending order</string>
</property>
</item>
<item>
<property name="text">
<string>Descending order</string>
</property>
</item>
</widget>
</item>
<item>
@ -107,11 +81,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Select a sort</string>
</property>
</item>
<item>
<property name="text">
<string>Creation date</string>
@ -129,26 +98,6 @@
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="sortOrder">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Ascending order</string>
</property>
</item>
<item>
<property name="text">
<string>Descending order</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
@ -344,8 +293,6 @@
<header>document/UBDocumentController.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../OpenBoard.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

@ -55,22 +55,25 @@ UBExportAdaptor::~UBExportAdaptor()
// NOOP
}
QString UBExportAdaptor::askForFileName(UBDocumentProxy* pDocument, const QString& pDialogTitle)
{
QString defaultName;
if (pDocument->metaData(UBSettings::documentGroupName).toString().length() > 0)
{
defaultName += pDocument->metaData(UBSettings::documentGroupName).toString() + QString(" ");
}
defaultName += pDocument->metaData(UBSettings::documentName).toString() + exportExtention();
defaultName = UBFileSystemUtils::cleanName(defaultName);
QString defaultPath = UBSettings::settings()->lastExportFilePath->get().toString() + "/" + defaultName;
QString filename = QFileDialog::getSaveFileName(UBApplication::mainWindow, pDialogTitle, defaultPath);
bool useNativeDialog = true;
#ifdef Q_OS_MAC
int versionMac = qMacVersion();
if (versionMac == QSysInfo::MV_Unknown || versionMac >= 11){ // version 11 is MacOSX 10.9 Mavericks
useNativeDialog = false;
}
#endif
QString filename = QFileDialog::getSaveFileName(UBApplication::mainWindow, pDialogTitle, defaultPath, QString(), 0, useNativeDialog?(QFileDialog::Option)0:QFileDialog::DontUseNativeDialog);
if (filename.size() == 0)
{

@ -35,6 +35,7 @@
#include "core/UBApplication.h"
#include "document/UBDocumentProxy.h"
#include "document/UBDocumentController.h"
#include "globals/UBGlobals.h"
@ -111,3 +112,13 @@ QString UBExportDocument::exportName()
{
return tr("Export to OpenBoard Format");
}
bool UBExportDocument::associatedActionactionAvailableFor(const QModelIndex &selectedIndex)
{
const UBDocumentTreeModel *docModel = qobject_cast<const UBDocumentTreeModel*>(selectedIndex.model());
if (!selectedIndex.isValid() || docModel->isCatalog(selectedIndex)) {
return false;
}
return true;
}

@ -41,7 +41,7 @@ class UBDocumentProxy;
class UBExportDocument : public UBExportAdaptor, public UBProcessingProgressListener
{
Q_OBJECT;
Q_OBJECT
public:
UBExportDocument(QObject *parent = 0);
@ -54,6 +54,8 @@ class UBExportDocument : public UBExportAdaptor, public UBProcessingProgressList
virtual bool persistsDocument(UBDocumentProxy* pDocument, const QString& filename);
virtual void processing(const QString& pObjectName, int pCurrent, int pTotal);
virtual bool associatedActionactionAvailableFor(const QModelIndex &selectedIndex);
};
#endif /* UBEXPORTDOCUMENT_H_ */

@ -142,7 +142,7 @@ QString UBExportDocumentSetAdaptor::exportExtention()
QString UBExportDocumentSetAdaptor::exportName()
{
return tr("Export to Sankore UBX Format");
return tr("Export to OpenBoard UBX Format");
}
bool UBExportDocumentSetAdaptor::addDocumentToZip(const QModelIndex &pIndex, UBDocumentTreeModel *model, QuaZip &zip)

@ -347,8 +347,8 @@ UBDocumentTreeModel::UBDocumentTreeModel(QObject *parent) :
UBDocumentTreeNode *myDocsNode = new UBDocumentTreeNode(UBDocumentTreeNode::Catalog, UBPersistenceManager::myDocumentsName, tr("My documents"));
rootNode->addChild(myDocsNode);
UBDocumentTreeNode *modelsNode = new UBDocumentTreeNode(UBDocumentTreeNode::Catalog, UBPersistenceManager::modelsName, tr("Models"));
rootNode->addChild(modelsNode);
//UBDocumentTreeNode *modelsNode = new UBDocumentTreeNode(UBDocumentTreeNode::Catalog, UBPersistenceManager::modelsName, tr("Models"));
//rootNode->addChild(modelsNode);
UBDocumentTreeNode *trashNode = new UBDocumentTreeNode(UBDocumentTreeNode::Catalog, trashName, tr("Trash"));
rootNode->addChild(trashNode);
UBDocumentTreeNode *untitledDocumentsNode = new UBDocumentTreeNode(UBDocumentTreeNode::Catalog, UBPersistenceManager::untitledDocumentsName, tr("Untitled documents"));
@ -358,8 +358,7 @@ UBDocumentTreeModel::UBDocumentTreeModel(QObject *parent) :
mRoot = index(0, 0, QModelIndex());
mMyDocuments = index(0, 0, QModelIndex());
mModels = index(1, 0, QModelIndex());
mTrash = index(2, 0, QModelIndex());
mTrash = index(1, 0, QModelIndex());
mUntitledDocuments = index(0, 0, mMyDocuments);
mAscendingOrder = true;
}
@ -711,13 +710,8 @@ bool UBDocumentTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction act
QList<QModelIndex> incomingIndexes = mimeData->indexes();
foreach (QModelIndex curIndex, incomingIndexes) {
#ifdef Q_WS_MAC
if (inModel(curIndex)) {
return true;
}
#endif
foreach (QModelIndex curIndex, incomingIndexes)
{
//Issue N/C - NNE - 20140528 : use just the index on the first column
if(curIndex.column() == 0){
QModelIndex clonedTopLevel = copyIndexToNewParent(curIndex, parent, action == Qt::MoveAction ? aReference : aContentCopy);
@ -1070,11 +1064,6 @@ bool UBDocumentTreeModel::inTrash(const QModelIndex &index) const
return isDescendantOf(index, trashIndex());
}
bool UBDocumentTreeModel::inModel(const QModelIndex &index) const
{
return isDescendantOf(index, modelsIndex());
}
bool UBDocumentTreeModel::inUntitledDocuments(const QModelIndex &index) const
{
return isDescendantOf(index, untitledDocumentsIndex());
@ -1409,11 +1398,11 @@ void UBDocumentTreeView::dropEvent(QDropEvent *event)
bool isUBPage = event->mimeData()->hasFormat(UBApplication::mimeTypeUniboardPage);
bool inModel = docModel->inModel(targetIndex) || targetIndex == docModel->modelsIndex();
bool inModel = false;
//just check the first index, because the selection is exclusive between
//myDocuments, Model and Tash
bool isSourceAModel = docModel->inModel(dropIndex.first());
bool isSourceAModel = false;
//issue 1629 - NNE - 20131212
bool targetIsInTrash = docModel->inTrash(targetIndex) || docModel->trashIndex() == targetIndex;
@ -1502,27 +1491,12 @@ bool UBDocumentTreeView::isAcceptable(const QModelIndex &dragIndex, const QModel
return false;
}
if (fullModel() && fullModel()->inModel(dragIndexSource)) {
if (atIndexSource == fullModel()->modelsIndex() || fullModel()->inModel(atIndexSource)) {
return false; //do not accept drop from model to itself
}
}
return true;
}
Qt::DropAction UBDocumentTreeView::acceptableAction(const QModelIndex &dragIndex, const QModelIndex &atIndex)
{
if (fullModel()->inModel(dragIndex)) {
if (atIndex == fullModel()->trashIndex() || fullModel()->inTrash(atIndex)) {
return Qt::MoveAction; //do not accept drop from model to trash, only "delete" command accepted
}
return Qt::CopyAction;
} else {
return Qt::MoveAction;
}
return Qt::IgnoreAction;
return Qt::MoveAction;
}
void UBDocumentTreeView::updateIndexEnvirons(const QModelIndex &index)
@ -1844,9 +1818,7 @@ void UBDocumentController::TreeViewSelectionChanged(const QItemSelection &select
UBDocumentTreeModel *model = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel;
bool sameFolder = (model->inModel(sourceIndex1) && model->inModel(sourceIndex2));
sameFolder |= (model->inTrash(sourceIndex1) && model->inTrash(sourceIndex2));
bool sameFolder = (model->inTrash(sourceIndex1) && model->inTrash(sourceIndex2));
sameFolder |= (model->inMyDocuments(sourceIndex1) && model->inMyDocuments(sourceIndex2));
@ -2022,15 +1994,9 @@ void UBDocumentController::setupViews()
mDocumentUI->documentTreeView->hideColumn(1);
mDocumentUI->documentTreeView->hideColumn(2);
mDocumentUI->sortOrder->hide();
connect(mDocumentUI->sortKind, SIGNAL(activated(int)), this, SLOT(onSortKindChanged(int)));
connect(mDocumentUI->sortOrder, SIGNAL(activated(int)), this, SLOT(onSortOrderChanged(int)));
connect(mDocumentUI->collapseAll, SIGNAL(clicked()), this, SLOT(collapseAll()));
connect(mDocumentUI->expandAll, SIGNAL(clicked()), this, SLOT(expandAll()));
connect(mDocumentUI->documentTreeView->itemDelegate(), SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint) ), mDocumentUI->documentTreeView, SLOT(adjustSize()));
connect(mDocumentUI->documentTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(TreeViewSelectionChanged(QItemSelection,QItemSelection)));
connect(UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel, SIGNAL(indexChanged(QModelIndex,QModelIndex))
@ -2083,22 +2049,12 @@ void UBDocumentController::sortDocuments(int kind, int order)
if(kind == UBDocumentController::CreationDate){
mSortFilterProxyModel->setSortRole(UBDocumentTreeModel::CreationDate);
mSortFilterProxyModel->sort(1, sortOrder);
mDocumentUI->documentTreeView->showColumn(1);
mDocumentUI->documentTreeView->hideColumn(2);
}else if(kind == UBDocumentController::UpdateDate){
mSortFilterProxyModel->setSortRole(UBDocumentTreeModel::UpdateDate);
mSortFilterProxyModel->sort(2, sortOrder);
mDocumentUI->documentTreeView->hideColumn(1);
mDocumentUI->documentTreeView->showColumn(2);
}else{
mSortFilterProxyModel->setSortRole(Qt::DisplayRole);
mSortFilterProxyModel->sort(0, sortOrder);
//alphabetical order or nothing
mDocumentUI->documentTreeView->hideColumn(1);
mDocumentUI->documentTreeView->hideColumn(2);
}
}
@ -2115,11 +2071,6 @@ void UBDocumentController::onSortKindChanged(int index)
{
int orderIndex = mDocumentUI->sortOrder->currentIndex();
if(index == -1 || index == 0)
mDocumentUI->sortOrder->hide();
else
mDocumentUI->sortOrder->show();
sortDocuments(index, orderIndex);
}
//N/C - NNE - 20140403 : END
@ -2762,10 +2713,7 @@ void UBDocumentController::thumbnailPageDoubleClicked(QGraphicsItem* item, int i
QModelIndex selectedIndex = firstSelectedTreeIndex();
if (selectedIndex.isValid()) {
if (docModel->inModel(selectedIndex)) {
UBApplication::showMessage(tr("The model documents are not editable. Copy it to \"My documents\" to be able to work with"));
return;
} else if (docModel->inTrash(selectedIndex)) {
if (docModel->inTrash(selectedIndex)) {
return;
}
}
@ -3070,9 +3018,8 @@ void UBDocumentController::updateActions()
}
bool trashSelected = docModel->inTrash(selectedIndex) || selectedIndex == docModel->trashIndex() ? true : false;
bool modelSelected = docModel->inModel(selectedIndex) || selectedIndex == docModel->modelsIndex() ? true : false;
mMainWindow->actionNewDocument->setEnabled(docModel->newNodeAllowed(selectedIndex) && !modelSelected);
mMainWindow->actionNewDocument->setEnabled(docModel->newNodeAllowed(selectedIndex));
mMainWindow->actionNewFolder->setEnabled(docModel->newNodeAllowed(selectedIndex));
mMainWindow->actionExport->setEnabled((docSelected || pageSelected || groupSelected) && !trashSelected);
updateExportSubActions(selectedIndex);
@ -3080,7 +3027,7 @@ void UBDocumentController::updateActions()
bool firstSceneSelected = false;
if (docSelected) {
mMainWindow->actionDuplicate->setEnabled(!trashSelected && !modelSelected);
mMainWindow->actionDuplicate->setEnabled(!trashSelected);
} else if (pageSelected) {
QList<QGraphicsItem*> selection = mDocumentUI->thumbnailWidget->selectedItems();
@ -3104,7 +3051,7 @@ void UBDocumentController::updateActions()
mMainWindow->actionDuplicate->setEnabled(false);
}
mMainWindow->actionOpen->setEnabled((docSelected || pageSelected) && !trashSelected && !modelSelected);
mMainWindow->actionOpen->setEnabled((docSelected || pageSelected) && !trashSelected);
mMainWindow->actionRename->setEnabled(docModel->isOkToRename(selectedIndex));
mMainWindow->actionAddToWorkingDocument->setEnabled(pageSelected
@ -3133,7 +3080,7 @@ void UBDocumentController::updateActions()
break;
}
mMainWindow->actionDocumentAdd->setEnabled((docSelected || pageSelected) && !trashSelected && !modelSelected);
mMainWindow->actionDocumentAdd->setEnabled((docSelected || pageSelected) && !trashSelected);
mMainWindow->actionImport->setEnabled(!trashSelected);
}
@ -3344,7 +3291,7 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*)
mDocumentUI->thumbnailWidget->setGraphicsItems(items, itemsPath, labels, UBApplication::mimeTypeUniboardPage);
if (docModel->inTrash(current) || docModel->inModel(current)) {
if (docModel->inTrash(current)) {
mDocumentUI->thumbnailWidget->setDragEnabled(false);
} else {
mDocumentUI->thumbnailWidget->setDragEnabled(true);

@ -199,7 +199,6 @@ public:
bool newNodeAllowed(const QModelIndex &pSelectedIndex) const;
QModelIndex goTo(const QString &dir);
bool inTrash(const QModelIndex &index) const;
bool inModel(const QModelIndex &index) const;
bool inUntitledDocuments(const QModelIndex &index) const;
bool isCatalog(const QModelIndex &index) const {return nodeFromIndex(index)->nodeType() == UBDocumentTreeNode::Catalog;}
bool isDocument(const QModelIndex &index) const {return nodeFromIndex(index)->nodeType() == UBDocumentTreeNode::Document;}
@ -216,7 +215,6 @@ public:
QString adjustNameForParentIndex(const QString &pName, const QModelIndex &pIndex);
QPersistentModelIndex myDocumentsIndex() const {return mMyDocuments;}
QPersistentModelIndex modelsIndex() const {return mModels;}
QPersistentModelIndex trashIndex() const {return mTrash;}
QPersistentModelIndex untitledDocumentsIndex() const {return mUntitledDocuments;}
UBDocumentTreeNode *nodeFromIndex(const QModelIndex &pIndex) const;
@ -251,7 +249,6 @@ private:
void updateIndexNameBindings(UBDocumentTreeNode *nd);
QPersistentModelIndex mRoot;
QPersistentModelIndex mMyDocuments;
QPersistentModelIndex mModels;
QPersistentModelIndex mTrash;
QPersistentModelIndex mUntitledDocuments;
QList<UBDocumentProxy*> mNewDocuments;
@ -360,7 +357,6 @@ class UBDocumentController : public UBDocumentContainer
enum SortKind
{
Reset = 0,
CreationDate,
UpdateDate,
Alphabetical

@ -72,12 +72,9 @@ void UBDocumentTreeWidget::itemChangedValidation(QTreeWidgetItem * item, int col
if (column == 0)
{
UBDocumentGroupTreeItem* group = dynamic_cast<UBDocumentGroupTreeItem *>(item);
if(group)
{
UBDocumentGroupTreeItem* group = dynamic_cast<UBDocumentGroupTreeItem *>(item);
if(group)
{
QString name = group->text(0);
for(int i = 0; i < topLevelItemCount (); i++)

Loading…
Cancel
Save