forked from mirror/openmw-tes3mp
		
	fixed missing adjuster widget in file dialog open view
This commit is contained in:
		
							parent
							
								
									ea7a8eb2a4
								
							
						
					
					
						commit
						b51bef0d98
					
				
					 6 changed files with 53 additions and 23 deletions
				
			
		|  | @ -11,7 +11,7 @@ | |||
| #include <QStyle> | ||||
| 
 | ||||
| CSVDoc::AdjusterWidget::AdjusterWidget (QWidget *parent) | ||||
| : QWidget (parent), mValid (false) | ||||
|     : QWidget (parent), mValid (false), mAction (ContentAction_Undefined) | ||||
| { | ||||
|     QHBoxLayout *layout = new QHBoxLayout (this); | ||||
| 
 | ||||
|  | @ -30,6 +30,11 @@ CSVDoc::AdjusterWidget::AdjusterWidget (QWidget *parent) | |||
|     setLayout (layout); | ||||
| } | ||||
| 
 | ||||
| void CSVDoc::AdjusterWidget::setAction (ContentAction action) | ||||
| { | ||||
|     mAction = action; | ||||
| } | ||||
| 
 | ||||
| void CSVDoc::AdjusterWidget::setLocalData (const boost::filesystem::path& localData) | ||||
| { | ||||
|     mLocalData = localData; | ||||
|  | @ -51,6 +56,12 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon) | |||
| { | ||||
|     QString message; | ||||
| 
 | ||||
|     if (mAction == ContentAction_Undefined) | ||||
|     { | ||||
|         throw std::runtime_error("ContentAction_Undefined when AdjusterWidget::setName() called."); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     if (name.isEmpty()) | ||||
|     { | ||||
|         mValid = false; | ||||
|  |  | |||
|  | @ -9,21 +9,32 @@ class QLabel; | |||
| 
 | ||||
| namespace CSVDoc | ||||
| { | ||||
|     enum ContentAction | ||||
|     { | ||||
|         ContentAction_New, | ||||
|         ContentAction_Edit, | ||||
|         ContentAction_Undefined | ||||
|     }; | ||||
| 
 | ||||
|     class AdjusterWidget : public QWidget | ||||
|     { | ||||
|             Q_OBJECT | ||||
| 
 | ||||
|         public: | ||||
| 
 | ||||
|             boost::filesystem::path mLocalData; | ||||
|             QLabel *mMessage; | ||||
|             QLabel *mIcon; | ||||
|             bool mValid; | ||||
|             boost::filesystem::path mResultPath; | ||||
|             ContentAction mAction; | ||||
| 
 | ||||
|         public: | ||||
| 
 | ||||
|             AdjusterWidget (QWidget *parent = 0); | ||||
| 
 | ||||
|             void setLocalData (const boost::filesystem::path& localData); | ||||
|             void setAction (ContentAction action); | ||||
| 
 | ||||
|             bool isValid() const; | ||||
| 
 | ||||
|  |  | |||
|  | @ -53,17 +53,19 @@ void CSVDoc::FileDialog::setLocalData (const boost::filesystem::path& localData) | |||
|     mAdjusterWidget->setLocalData (localData); | ||||
| } | ||||
| 
 | ||||
| void CSVDoc::FileDialog::showDialog(DialogType dialogType) | ||||
| void CSVDoc::FileDialog::showDialog (ContentAction action) | ||||
| { | ||||
|     mDialogType = dialogType; | ||||
|     mAction = action; | ||||
| 
 | ||||
|     switch (mDialogType) | ||||
|     ui.projectGroupBoxLayout->insertWidget (0, mAdjusterWidget); | ||||
| 
 | ||||
|     switch (mAction) | ||||
|     { | ||||
|     case DialogType_New: | ||||
|     case ContentAction_New: | ||||
|         buildNewFileView(); | ||||
|         break; | ||||
| 
 | ||||
|     case DialogType_Open: | ||||
|     case ContentAction_Edit: | ||||
|         buildOpenFileView(); | ||||
|         break; | ||||
|     default: | ||||
|  | @ -95,7 +97,6 @@ void CSVDoc::FileDialog::buildNewFileView() | |||
|     mFileWidget->extensionLabelIsVisible(true); | ||||
| 
 | ||||
|     ui.projectGroupBoxLayout->insertWidget (0, mFileWidget); | ||||
|     ui.projectGroupBoxLayout->insertWidget (1, mAdjusterWidget); | ||||
| 
 | ||||
|     connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)), | ||||
|         mAdjusterWidget, SLOT (setName (const QString&, bool))); | ||||
|  | @ -110,12 +111,12 @@ void CSVDoc::FileDialog::buildOpenFileView() | |||
| { | ||||
|     setWindowTitle(tr("Open")); | ||||
|     ui.projectGroupBox->setTitle (QString("")); | ||||
|     ui.projectGroupBox->layout()->addWidget (mAdjusterWidget); | ||||
| 
 | ||||
|     mAdjusterWidget->setVisible (false); | ||||
| 
 | ||||
|     ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false); | ||||
| 
 | ||||
|     connect (mSelector, SIGNAL (signalAddonFileSelected (int)), this, SLOT (slotUpdateAcceptButton (int))); | ||||
|     connect (mSelector, SIGNAL (signalAddonFileUnselected (int)), this, SLOT (slotUpdateAcceptButton (int))); | ||||
| 
 | ||||
|     connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile())); | ||||
| } | ||||
| 
 | ||||
|  | @ -135,6 +136,11 @@ void CSVDoc::FileDialog::slotUpdateAcceptButton(const QString &name, bool) | |||
| 
 | ||||
|     if (mDialogType == DialogType_New) | ||||
|         success = success && !(name.isEmpty()); | ||||
|     else | ||||
|     { | ||||
|         ContentSelectorModel::EsmFile *file = mSelector->selectedFiles().back(); | ||||
|         mAdjusterWidget->setName (file->fileName(), !file->isGameFile()); | ||||
|     } | ||||
| 
 | ||||
|     ui.projectButtonBox->button (QDialogButtonBox::Ok)->setEnabled (success); | ||||
| } | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ | |||
| #include <QModelIndex> | ||||
| 
 | ||||
| #include <boost/filesystem/path.hpp> | ||||
| #include "adjusterwidget.hpp" | ||||
| 
 | ||||
| #ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED | ||||
| #define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED | ||||
|  | @ -24,32 +25,23 @@ namespace ContentSelectorView | |||
| namespace CSVDoc | ||||
| { | ||||
|     class FileWidget; | ||||
|     class AdjusterWidget; | ||||
| 
 | ||||
|     class FileDialog : public QDialog | ||||
|     { | ||||
|         Q_OBJECT | ||||
| 
 | ||||
|     public: | ||||
| 
 | ||||
|         enum DialogType | ||||
|         { | ||||
|             DialogType_New, | ||||
|             DialogType_Open | ||||
|         }; | ||||
| 
 | ||||
|     private: | ||||
| 
 | ||||
|         ContentSelectorView::ContentSelector *mSelector; | ||||
|         Ui::FileDialog ui; | ||||
|         DialogType mDialogType; | ||||
|         ContentAction mAction; | ||||
|         FileWidget *mFileWidget; | ||||
|         AdjusterWidget *mAdjusterWidget; | ||||
| 
 | ||||
|     public: | ||||
| 
 | ||||
|         explicit FileDialog(QWidget *parent = 0); | ||||
|         void showDialog (DialogType dialogType); | ||||
|         void showDialog (ContentAction action); | ||||
| 
 | ||||
|         void addFiles (const QString &path); | ||||
| 
 | ||||
|  |  | |||
|  | @ -151,8 +151,16 @@ void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QMode | |||
| { | ||||
|     QAbstractItemModel *const model = ui.addonView->model(); | ||||
| 
 | ||||
|     Qt::CheckState checkState = Qt::Unchecked; | ||||
| 
 | ||||
|     if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked) | ||||
|         model->setData(index, Qt::Checked, Qt::CheckStateRole); | ||||
|         checkState = Qt::Checked; | ||||
| 
 | ||||
|     model->setData(index, checkState, Qt::CheckStateRole); | ||||
| 
 | ||||
|     if (checkState == Qt::Checked) | ||||
|         emit signalAddonFileSelected (index.row()); | ||||
|     else | ||||
|         model->setData(index, Qt::Unchecked, Qt::CheckStateRole); | ||||
|         emit signalAddonFileUnselected (index.row()); | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -54,6 +54,8 @@ namespace ContentSelectorView | |||
| 
 | ||||
|     signals: | ||||
|         void signalCurrentGamefileIndexChanged (int); | ||||
|         void signalAddonFileSelected (int); | ||||
|         void signalAddonFileUnselected (int); | ||||
| 
 | ||||
|     private slots: | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue