mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-25 11:26:37 +00:00 
			
		
		
		
	buttons are functional
This commit is contained in:
		
							parent
							
								
									299b7a6ce6
								
							
						
					
					
						commit
						cb9bcc3cc1
					
				
					 3 changed files with 81 additions and 24 deletions
				
			
		|  | @ -255,21 +255,19 @@ CSVWorld::DialogueDelegateDispatcher::~DialogueDelegateDispatcher() | ||||||
| =============================================================EditWidget===================================================== | =============================================================EditWidget===================================================== | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| CSVWorld::EditWidget::EditWidget(QWidget *parent, const CSMWorld::UniversalId& id, CSMDoc::Document& document, bool createAndDelete) : | CSVWorld::EditWidget::EditWidget(QWidget *parent, int row, CSMWorld::IdTable* table, QUndoStack& undoStack, bool createAndDelete) : | ||||||
| mDispatcher(this, dynamic_cast<CSMWorld::IdTable*>(document.getData().getTableModel (id)), document.getUndoStack()), | mDispatcher(this, table, undoStack), | ||||||
| QScrollArea(parent), | QScrollArea(parent), | ||||||
| mWidgetMapper(NULL), | mWidgetMapper(NULL), | ||||||
| mMainWidget(NULL), | mMainWidget(NULL), | ||||||
| mUndoStack(document.getUndoStack()), | mUndoStack(undoStack), | ||||||
| mTable(dynamic_cast<CSMWorld::IdTable*>(document.getData().getTableModel(id))) | mTable(table) | ||||||
| { | { | ||||||
|     remake (id); |     remake (row); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CSVWorld::EditWidget::remake(const CSMWorld::UniversalId& id) | void CSVWorld::EditWidget::remake(int row) | ||||||
| { | { | ||||||
|     const QModelIndex indexToFocus(mTable->getModelIndex (id.getId(), 0)); |  | ||||||
| 
 |  | ||||||
|     if (mMainWidget) |     if (mMainWidget) | ||||||
|     { |     { | ||||||
|         delete mMainWidget; |         delete mMainWidget; | ||||||
|  | @ -300,7 +298,6 @@ void CSVWorld::EditWidget::remake(const CSMWorld::UniversalId& id) | ||||||
| 
 | 
 | ||||||
|     int unlocked = 0; |     int unlocked = 0; | ||||||
|     int locked = 0; |     int locked = 0; | ||||||
|     const int focusedRow = indexToFocus.row(); |  | ||||||
|     const int columns = mTable->columnCount(); |     const int columns = mTable->columnCount(); | ||||||
|     for (int i=0; i<columns; ++i) |     for (int i=0; i<columns; ++i) | ||||||
|     { |     { | ||||||
|  | @ -312,7 +309,7 @@ void CSVWorld::EditWidget::remake(const CSMWorld::UniversalId& id) | ||||||
|                 (mTable->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); |                 (mTable->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); | ||||||
| 
 | 
 | ||||||
|             mDispatcher.makeDelegate(display); |             mDispatcher.makeDelegate(display); | ||||||
|             QWidget *editor = mDispatcher.makeEditor(display, (mTable->index (focusedRow, i))); |             QWidget *editor = mDispatcher.makeEditor(display, (mTable->index (row, i))); | ||||||
| 
 | 
 | ||||||
|             if (editor) |             if (editor) | ||||||
|             { |             { | ||||||
|  | @ -335,7 +332,7 @@ void CSVWorld::EditWidget::remake(const CSMWorld::UniversalId& id) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     mWidgetMapper->setCurrentModelIndex (indexToFocus); |     mWidgetMapper->setCurrentModelIndex(mTable->index(row, 0)); | ||||||
| 
 | 
 | ||||||
|     this->setMinimumWidth(300); |     this->setMinimumWidth(300); | ||||||
|     this->setWidget(mMainWidget); |     this->setWidget(mMainWidget); | ||||||
|  | @ -349,25 +346,71 @@ void CSVWorld::EditWidget::remake(const CSMWorld::UniversalId& id) | ||||||
| CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, | CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, | ||||||
|     bool createAndDelete) : |     bool createAndDelete) : | ||||||
| 
 | 
 | ||||||
|     SubView (id) |     SubView (id), | ||||||
|  |     mEditWidget(0), | ||||||
|  |     mMainLayout(NULL), | ||||||
|  |     mUndoStack(document.getUndoStack()), | ||||||
|  |     mTable(dynamic_cast<CSMWorld::IdTable*>(document.getData().getTableModel(id))), | ||||||
|  |     mRow (-1) | ||||||
| 
 | 
 | ||||||
| { | { | ||||||
|  |     mRow = mTable->getModelIndex (id.getId(), 0).row(); | ||||||
|     QWidget *mainWidget = new QWidget(this); |     QWidget *mainWidget = new QWidget(this); | ||||||
| 
 | 
 | ||||||
|     QHBoxLayout *buttonsLayout = new QHBoxLayout; |     QHBoxLayout *buttonsLayout = new QHBoxLayout; | ||||||
|     QPushButton* mPrevButton = new QPushButton(tr("Previous")); |     QPushButton* prevButton = new QPushButton(tr("Previous"), mainWidget); | ||||||
|     QPushButton* mNextButton = new QPushButton(tr("Next")); |     QPushButton* nextButton = new QPushButton(tr("Next"), mainWidget); | ||||||
|     buttonsLayout->addWidget(mPrevButton); |     buttonsLayout->addWidget(prevButton); | ||||||
|     buttonsLayout->addWidget(mNextButton); |     buttonsLayout->addWidget(nextButton); | ||||||
|  |     connect(nextButton, SIGNAL(clicked()), this, SLOT(nextId())); | ||||||
|  |     connect(prevButton, SIGNAL(clicked()), this, SLOT(prevId())); | ||||||
| 
 | 
 | ||||||
|     QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget); |     mMainLayout = new QVBoxLayout(mainWidget); | ||||||
|  | 
 | ||||||
|  |     mEditWidget = new EditWidget(mainWidget, mRow, mTable, mUndoStack, false); | ||||||
|  |     mMainLayout->addLayout(buttonsLayout); | ||||||
|  |     mMainLayout->addWidget(mEditWidget); | ||||||
|  |     mEditWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); | ||||||
| 
 | 
 | ||||||
|     EditWidget* editWidget = new EditWidget(mainWidget, id, document, false); |  | ||||||
|     mainLayout->addLayout(buttonsLayout); |  | ||||||
|     mainLayout->addWidget(editWidget); |  | ||||||
|     editWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); |  | ||||||
|     setWidget(mainWidget); |     setWidget(mainWidget); | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
|  | void CSVWorld::DialogueSubView::prevId() | ||||||
|  | { | ||||||
|  |     if (mRow < 1) | ||||||
|  |     { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     int newRow = mRow - 1; | ||||||
|  |     QModelIndex newIndex(mTable->index(newRow, 0)); | ||||||
|  | 
 | ||||||
|  |     if (!newIndex.isValid()) | ||||||
|  |     { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     mEditWidget->remake(newRow); | ||||||
|  |     mRow = newRow; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void CSVWorld::DialogueSubView::nextId() | ||||||
|  | { | ||||||
|  |     if (mRow == -1) | ||||||
|  |     { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     int newRow = mRow + 1; | ||||||
|  |     QModelIndex newIndex(mTable->index(newRow, 0)); | ||||||
|  | 
 | ||||||
|  |     if (!newIndex.isValid()) | ||||||
|  |     { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     mEditWidget->remake(newRow); | ||||||
|  |     mRow = newRow; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CSVWorld::DialogueSubView::setEditLock (bool locked) | void CSVWorld::DialogueSubView::setEditLock (bool locked) | ||||||
|  |  | ||||||
|  | @ -14,6 +14,7 @@ class QDataWidgetMapper; | ||||||
| class QSize; | class QSize; | ||||||
| class QEvent; | class QEvent; | ||||||
| class QLabel; | class QLabel; | ||||||
|  | class QVBoxLayout; | ||||||
| 
 | 
 | ||||||
| namespace CSMWorld | namespace CSMWorld | ||||||
| { | { | ||||||
|  | @ -130,18 +131,32 @@ namespace CSVWorld | ||||||
| 
 | 
 | ||||||
|         public: |         public: | ||||||
| 
 | 
 | ||||||
|             EditWidget (QWidget *parent, const CSMWorld::UniversalId& id, CSMDoc::Document& document, bool createAndDelete = false); |             EditWidget (QWidget *parent, int row, CSMWorld::IdTable* table, QUndoStack& undoStack, bool createAndDelete = false); | ||||||
| 
 | 
 | ||||||
|             void remake(const CSMWorld::UniversalId& id); |             void remake(int row); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     class DialogueSubView : public CSVDoc::SubView |     class DialogueSubView : public CSVDoc::SubView | ||||||
|     { |     { | ||||||
|  |         Q_OBJECT | ||||||
|  | 
 | ||||||
|  |         EditWidget* mEditWidget; | ||||||
|  |         QVBoxLayout* mMainLayout; | ||||||
|  |         CSMWorld::IdTable* mTable; | ||||||
|  |         QUndoStack& mUndoStack; | ||||||
|  |         int mRow; | ||||||
|  | 
 | ||||||
|         public: |         public: | ||||||
| 
 | 
 | ||||||
|             DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, bool createAndDelete = false); |             DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, bool createAndDelete = false); | ||||||
| 
 | 
 | ||||||
|             virtual void setEditLock (bool locked); |             virtual void setEditLock (bool locked); | ||||||
|  | 
 | ||||||
|  |         private slots: | ||||||
|  | 
 | ||||||
|  |             void nextId(); | ||||||
|  | 
 | ||||||
|  |             void prevId(); | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -9,7 +9,6 @@ | ||||||
| #include <QUndoStack> | #include <QUndoStack> | ||||||
| 
 | 
 | ||||||
| #include "../../model/world/commands.hpp" | #include "../../model/world/commands.hpp" | ||||||
| #include <iostream> |  | ||||||
| 
 | 
 | ||||||
| void CSVWorld::EnumDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model, | void CSVWorld::EnumDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model, | ||||||
|     const QModelIndex& index) const |     const QModelIndex& index) const | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue