selection mode added
This commit is contained in:
		
							parent
							
								
									d2baaa961e
								
							
						
					
					
						commit
						58b3843e94
					
				
					 11 changed files with 259 additions and 19 deletions
				
			
		|  | @ -44,6 +44,7 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre | |||
|     ui->cmdImport->setEnabled(false); | ||||
|     ui->cmdCloseProfile->setEnabled(false); | ||||
|     loadingStr = ui->labProfileLoading->text(); | ||||
|     selectedWidgts = 0; | ||||
|     profileFolder = ""; | ||||
|     profileLoader = 0; | ||||
|     saSpacerItem = 0; | ||||
|  | @ -66,7 +67,7 @@ ProfileInterface::~ProfileInterface() | |||
|         picture->deleteLater(); | ||||
|         delete picture; | ||||
|     } | ||||
|     foreach(QWidget *widget, widgets.keys()) | ||||
|     foreach(ProfileWidget *widget, widgets.keys()) | ||||
|     { | ||||
|         widgets.remove(widget); | ||||
|         widget->deleteLater(); | ||||
|  | @ -102,6 +103,8 @@ void ProfileInterface::on_savegameLoaded(SavegameData *savegame, QString savegam | |||
|     widgets[sgdWidget] = "SavegameWidget"; | ||||
|     savegames.append(savegame); | ||||
|     QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(on_savegameDeleted())); | ||||
|     QObject::connect(sgdWidget, SIGNAL(widgetSelected()), this, SLOT(on_profileWidgetSelected())); | ||||
|     QObject::connect(sgdWidget, SIGNAL(widgetDeselected()), this, SLOT(on_profileWidgetDeselected())); | ||||
| } | ||||
| 
 | ||||
| void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString picturePath) | ||||
|  | @ -112,6 +115,8 @@ void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString pictu | |||
|     widgets[picWidget] = "SnapmaticWidget"; | ||||
|     pictures.append(picture); | ||||
|     QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(on_pictureDeleted())); | ||||
|     QObject::connect(picWidget, SIGNAL(widgetSelected()), this, SLOT(on_profileWidgetSelected())); | ||||
|     QObject::connect(picWidget, SIGNAL(widgetDeselected()), this, SLOT(on_profileWidgetDeselected())); | ||||
| } | ||||
| 
 | ||||
| void ProfileInterface::on_loadingProgress(int value, int maximum) | ||||
|  | @ -323,3 +328,27 @@ bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPat | |||
|         return false; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void ProfileInterface::on_profileWidgetSelected() | ||||
| { | ||||
|     if (selectedWidgts == 0) | ||||
|     { | ||||
|         foreach(ProfileWidget *widget, widgets.keys()) | ||||
|         { | ||||
|             widget->setSelectionMode(true); | ||||
|         } | ||||
|     } | ||||
|     selectedWidgts++; | ||||
| } | ||||
| 
 | ||||
| void ProfileInterface::on_profileWidgetDeselected() | ||||
| { | ||||
|     if (selectedWidgts == 1) | ||||
|     { | ||||
|         foreach(ProfileWidget *widget, widgets.keys()) | ||||
|         { | ||||
|             widget->setSelectionMode(false); | ||||
|         } | ||||
|     } | ||||
|     selectedWidgts--; | ||||
| } | ||||
|  |  | |||
|  | @ -24,6 +24,7 @@ | |||
| #include "ProfileDatabase.h" | ||||
| #include "DatabaseThread.h" | ||||
| #include "ProfileLoader.h" | ||||
| #include "ProfileWidget.h" | ||||
| #include "SavegameData.h" | ||||
| #include "CrewDatabase.h" | ||||
| #include <QSpacerItem> | ||||
|  | @ -53,6 +54,8 @@ private slots: | |||
|     void on_pictureDeleted(); | ||||
|     void on_profileLoaded(); | ||||
|     void on_cmdImport_clicked(); | ||||
|     void on_profileWidgetSelected(); | ||||
|     void on_profileWidgetDeselected(); | ||||
| 
 | ||||
| private: | ||||
|     ProfileDatabase *profileDB; | ||||
|  | @ -63,11 +66,12 @@ private: | |||
|     ProfileLoader *profileLoader; | ||||
|     QList<SavegameData*> savegames; | ||||
|     QList<SnapmaticPicture*> pictures; | ||||
|     QMap<QWidget*,QString> widgets; | ||||
|     QMap<ProfileWidget*,QString> widgets; | ||||
|     QSpacerItem *saSpacerItem; | ||||
|     QString profileFolder; | ||||
|     QString profileName; | ||||
|     QString loadingStr; | ||||
|     int selectedWidgts; | ||||
| 
 | ||||
|     bool importSnapmaticPicture(SnapmaticPicture *picture, QString picPath); | ||||
|     bool importSavegameData(SavegameData *savegame, QString sgdPath); | ||||
|  |  | |||
							
								
								
									
										30
									
								
								ProfileWidget.cpp
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										30
									
								
								ProfileWidget.cpp
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,30 @@ | |||
| /*****************************************************************************
 | ||||
| * gta5sync GRAND THEFT AUTO V SYNC | ||||
| * Copyright (C) 2016 Syping | ||||
| * | ||||
| * This program is free software: you can redistribute it and/or modify | ||||
| * it under the terms of the GNU General Public License as published by | ||||
| * the Free Software Foundation, either version 3 of the License, or | ||||
| * (at your option) any later version. | ||||
| * | ||||
| * This program is distributed in the hope that it will be useful, | ||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| * GNU General Public License for more details. | ||||
| * | ||||
| * You should have received a copy of the GNU General Public License | ||||
| * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||
| *****************************************************************************/ | ||||
| 
 | ||||
| #include "ProfileWidget.h" | ||||
| #include <QDebug> | ||||
| 
 | ||||
| ProfileWidget::ProfileWidget(QWidget *parent) : QWidget(parent) | ||||
| { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void ProfileWidget::setSelectionMode(bool selectionMode) | ||||
| { | ||||
|     qDebug() << "ProfileWidget got used without overwrite, result:" << selectionMode; | ||||
| } | ||||
							
								
								
									
										36
									
								
								ProfileWidget.h
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										36
									
								
								ProfileWidget.h
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,36 @@ | |||
| /*****************************************************************************
 | ||||
| * gta5sync GRAND THEFT AUTO V SYNC | ||||
| * Copyright (C) 2016 Syping | ||||
| * | ||||
| * This program is free software: you can redistribute it and/or modify | ||||
| * it under the terms of the GNU General Public License as published by | ||||
| * the Free Software Foundation, either version 3 of the License, or | ||||
| * (at your option) any later version. | ||||
| * | ||||
| * This program is distributed in the hope that it will be useful, | ||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| * GNU General Public License for more details. | ||||
| * | ||||
| * You should have received a copy of the GNU General Public License | ||||
| * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||
| *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef PROFILEWIDGET_H | ||||
| #define PROFILEWIDGET_H | ||||
| 
 | ||||
| #include <QWidget> | ||||
| 
 | ||||
| class ProfileWidget : public QWidget | ||||
| { | ||||
|     Q_OBJECT | ||||
| public: | ||||
|     explicit ProfileWidget(QWidget *parent = 0); | ||||
|     virtual void setSelectionMode(bool selectionMode); | ||||
| 
 | ||||
| signals: | ||||
| 
 | ||||
| public slots: | ||||
| }; | ||||
| 
 | ||||
| #endif // PROFILEWIDGET_H
 | ||||
|  | @ -28,13 +28,18 @@ | |||
| #include <QSettings> | ||||
| #include <QFileInfo> | ||||
| #include <QFile> | ||||
| #include <QMenu> | ||||
| #include <QUrl> | ||||
| 
 | ||||
| SavegameWidget::SavegameWidget(QWidget *parent) : | ||||
|     QWidget(parent), | ||||
|     ProfileWidget(parent), | ||||
|     ui(new Ui::SavegameWidget) | ||||
| { | ||||
|     ui->setupUi(this); | ||||
|     ui->cmdCopy->setVisible(false); | ||||
|     ui->cmdView->setVisible(false); | ||||
|     ui->cmdDelete->setVisible(false); | ||||
|     ui->cbSelected->setVisible(false); | ||||
|     sgdPath = ""; | ||||
|     sgdStr = ""; | ||||
|     sgdata = 0; | ||||
|  | @ -78,19 +83,60 @@ void SavegameWidget::on_cmdDelete_clicked() | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void SavegameWidget::on_cmdView_clicked() | ||||
| { | ||||
|     SavegameDialog *savegameDialog = new SavegameDialog(this); | ||||
|     savegameDialog->setWindowFlags(savegameDialog->windowFlags()^Qt::WindowContextHelpButtonHint); | ||||
|     savegameDialog->setSavegameData(sgdata, sgdPath, true); | ||||
|     savegameDialog->setModal(true); | ||||
|     savegameDialog->show(); | ||||
|     savegameDialog->exec(); | ||||
|     savegameDialog->deleteLater(); | ||||
|     delete savegameDialog; | ||||
| } | ||||
| 
 | ||||
| void SavegameWidget::mouseDoubleClickEvent(QMouseEvent *ev) | ||||
| { | ||||
|     QWidget::mouseDoubleClickEvent(ev); | ||||
| 
 | ||||
|     if (ev->button() == Qt::LeftButton) | ||||
|     { | ||||
|         SavegameDialog *savegameDialog = new SavegameDialog(this); | ||||
|         savegameDialog->setWindowFlags(savegameDialog->windowFlags()^Qt::WindowContextHelpButtonHint); | ||||
|         savegameDialog->setSavegameData(sgdata, sgdPath, true); | ||||
|         savegameDialog->setModal(true); | ||||
|         savegameDialog->show(); | ||||
|         savegameDialog->exec(); | ||||
|         savegameDialog->deleteLater(); | ||||
|         delete savegameDialog; | ||||
|         on_cmdView_clicked(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SavegameWidget::on_savegameSelected() | ||||
| { | ||||
|     ui->cbSelected->setChecked(true); | ||||
| } | ||||
| 
 | ||||
| void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev) | ||||
| { | ||||
|     QMenu contextMenu(this); | ||||
|     if (!ui->cbSelected->isChecked()) | ||||
|     { | ||||
|         contextMenu.addAction(tr("Select"), this, SLOT(on_savegameSelected())); | ||||
|         contextMenu.addSeparator(); | ||||
|     } | ||||
|     contextMenu.addAction(tr("View savegame"), this, SLOT(on_cmdView_clicked())); | ||||
|     contextMenu.addAction(tr("Copy savegame"), this, SLOT(on_cmdCopy_clicked())); | ||||
|     contextMenu.addAction(tr("Delete savegame"), this, SLOT(on_cmdDelete_clicked())); | ||||
|     contextMenu.exec(ev->globalPos()); | ||||
| } | ||||
| 
 | ||||
| void SavegameWidget::on_cbSelected_stateChanged(int arg1) | ||||
| { | ||||
|     if (arg1 == Qt::Checked) | ||||
|     { | ||||
|         emit widgetSelected(); | ||||
|     } | ||||
|     else if (arg1 == Qt::Unchecked) | ||||
|     { | ||||
|         emit widgetDeselected(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SavegameWidget::setSelectionMode(bool selectionMode) | ||||
| { | ||||
|     ui->cbSelected->setVisible(selectionMode); | ||||
| } | ||||
|  |  | |||
|  | @ -19,29 +19,36 @@ | |||
| #ifndef SAVEGAMEWIDGET_H | ||||
| #define SAVEGAMEWIDGET_H | ||||
| 
 | ||||
| #include "ProfileWidget.h" | ||||
| #include "SavegameData.h" | ||||
| #include <QContextMenuEvent> | ||||
| #include <QMouseEvent> | ||||
| #include <QWidget> | ||||
| #include "SavegameData.h" | ||||
| 
 | ||||
| namespace Ui { | ||||
| class SavegameWidget; | ||||
| } | ||||
| 
 | ||||
| class SavegameWidget : public QWidget | ||||
| class SavegameWidget : public ProfileWidget | ||||
| { | ||||
|     Q_OBJECT | ||||
| 
 | ||||
| public: | ||||
|     explicit SavegameWidget(QWidget *parent = 0); | ||||
|     SavegameWidget(QWidget *parent = 0); | ||||
|     void setSavegameData(SavegameData *savegame, QString savegamePath); | ||||
|     void setSelectionMode(bool selectionMode); | ||||
|     ~SavegameWidget(); | ||||
| 
 | ||||
| private slots: | ||||
|     void on_cmdDelete_clicked(); | ||||
|     void on_cmdView_clicked(); | ||||
|     void on_cmdCopy_clicked(); | ||||
|     void on_cmdDelete_clicked(); | ||||
|     void on_savegameSelected(); | ||||
|     void on_cbSelected_stateChanged(int arg1); | ||||
| 
 | ||||
| protected: | ||||
|     void mouseDoubleClickEvent(QMouseEvent *ev); | ||||
|     void contextMenuEvent(QContextMenuEvent *ev); | ||||
| 
 | ||||
| private: | ||||
|     Ui::SavegameWidget *ui; | ||||
|  | @ -51,6 +58,8 @@ private: | |||
| 
 | ||||
| signals: | ||||
|     void savegameDeleted(); | ||||
|     void widgetSelected(); | ||||
|     void widgetDeselected(); | ||||
| }; | ||||
| 
 | ||||
| #endif // SAVEGAMEWIDGET_H
 | ||||
|  |  | |||
|  | @ -14,6 +14,13 @@ | |||
|    <string>Savegame Widget</string> | ||||
|   </property> | ||||
|   <layout class="QHBoxLayout" name="hlSavegameContent"> | ||||
|    <item> | ||||
|     <widget class="QCheckBox" name="cbSelected"> | ||||
|      <property name="text"> | ||||
|       <string/> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QLabel" name="labSavegamePic"> | ||||
|      <property name="text"> | ||||
|  | @ -40,6 +47,13 @@ | |||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QPushButton" name="cmdView"> | ||||
|      <property name="text"> | ||||
|       <string>View</string> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QPushButton" name="cmdCopy"> | ||||
|      <property name="text"> | ||||
|  |  | |||
|  | @ -24,13 +24,18 @@ | |||
| #include <QMessageBox> | ||||
| #include <QPixmap> | ||||
| #include <QDebug> | ||||
| #include <QMenu> | ||||
| #include <QFile> | ||||
| 
 | ||||
| SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *threadDB, QWidget *parent) : | ||||
|     QWidget(parent), profileDB(profileDB), threadDB(threadDB), | ||||
|     ProfileWidget(parent), profileDB(profileDB), threadDB(threadDB), | ||||
|     ui(new Ui::SnapmaticWidget) | ||||
| { | ||||
|     ui->setupUi(this); | ||||
|     ui->cmdView->setVisible(false); | ||||
|     ui->cmdCopy->setVisible(false); | ||||
|     ui->cmdDelete->setVisible(false); | ||||
|     ui->cbSelected->setVisible(false); | ||||
|     picPath = ""; | ||||
|     picStr = ""; | ||||
|     smpic = 0; | ||||
|  | @ -70,6 +75,11 @@ void SnapmaticWidget::on_cmdView_clicked() | |||
|     delete picDialog; | ||||
| } | ||||
| 
 | ||||
| void SnapmaticWidget::on_cmdCopy_clicked() | ||||
| { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void SnapmaticWidget::on_cmdDelete_clicked() | ||||
| { | ||||
|     int uchoice = QMessageBox::question(this, tr("Delete picture"), tr("Are you sure to delete %1 from your Snapmatic pictures?").arg("\""+picStr+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); | ||||
|  | @ -99,3 +109,39 @@ void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev) | |||
|         on_cmdView_clicked(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SnapmaticWidget::on_pictureSelected() | ||||
| { | ||||
|     ui->cbSelected->setChecked(true); | ||||
| } | ||||
| 
 | ||||
| void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev) | ||||
| { | ||||
|     QMenu contextMenu(this); | ||||
|     if (!ui->cbSelected->isChecked()) | ||||
|     { | ||||
|         contextMenu.addAction(tr("Select"), this, SLOT(on_pictureSelected())); | ||||
|         contextMenu.addSeparator(); | ||||
|     } | ||||
|     contextMenu.addAction(tr("View picture"), this, SLOT(on_cmdView_clicked())); | ||||
|     contextMenu.addAction(tr("Copy picture"), this, SLOT(on_cmdView_clicked())); | ||||
|     contextMenu.addAction(tr("Delete picture"), this, SLOT(on_cmdDelete_clicked())); | ||||
|     contextMenu.exec(ev->globalPos()); | ||||
| } | ||||
| 
 | ||||
| void SnapmaticWidget::on_cbSelected_stateChanged(int arg1) | ||||
| { | ||||
|     if (arg1 == Qt::Checked) | ||||
|     { | ||||
|         emit widgetSelected(); | ||||
|     } | ||||
|     else if (arg1 == Qt::Unchecked) | ||||
|     { | ||||
|         emit widgetDeselected(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SnapmaticWidget::setSelectionMode(bool selectionMode) | ||||
| { | ||||
|     ui->cbSelected->setVisible(selectionMode); | ||||
| } | ||||
|  |  | |||
|  | @ -22,6 +22,8 @@ | |||
| #include "SnapmaticPicture.h" | ||||
| #include "ProfileDatabase.h" | ||||
| #include "DatabaseThread.h" | ||||
| #include "ProfileWidget.h" | ||||
| #include <QContextMenuEvent> | ||||
| #include <QMouseEvent> | ||||
| #include <QWidget> | ||||
| 
 | ||||
|  | @ -29,32 +31,40 @@ namespace Ui { | |||
| class SnapmaticWidget; | ||||
| } | ||||
| 
 | ||||
| class SnapmaticWidget : public QWidget | ||||
| class SnapmaticWidget : public ProfileWidget | ||||
| { | ||||
|     Q_OBJECT | ||||
| 
 | ||||
| public: | ||||
|     explicit SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *threadDB, QWidget *parent = 0); | ||||
|     SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *threadDB, QWidget *parent = 0); | ||||
|     void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath); | ||||
|     void setSelectionMode(bool selectionMode); | ||||
|     ~SnapmaticWidget(); | ||||
| 
 | ||||
| private slots: | ||||
|     void on_cmdView_clicked(); | ||||
|     void on_cmdCopy_clicked(); | ||||
|     void on_cmdDelete_clicked(); | ||||
|     void on_pictureSelected(); | ||||
|     void on_cbSelected_stateChanged(int arg1); | ||||
| 
 | ||||
| protected: | ||||
|     void mouseDoubleClickEvent(QMouseEvent *ev); | ||||
|     void contextMenuEvent(QContextMenuEvent *ev); | ||||
| 
 | ||||
| private: | ||||
|     ProfileDatabase *profileDB; | ||||
|     DatabaseThread *threadDB; | ||||
|     Ui::SnapmaticWidget *ui; | ||||
|     SnapmaticPicture *smpic; | ||||
|     QAction *actSelectPic; | ||||
|     QString picPath; | ||||
|     QString picStr; | ||||
| 
 | ||||
| signals: | ||||
|     void pictureDeleted(); | ||||
|     void widgetSelected(); | ||||
|     void widgetDeselected(); | ||||
| }; | ||||
| 
 | ||||
| #endif // SNAPMATICWIDGET_H
 | ||||
|  |  | |||
|  | @ -13,7 +13,14 @@ | |||
|   <property name="windowTitle"> | ||||
|    <string>Snapmatic Widget</string> | ||||
|   </property> | ||||
|   <layout class="QHBoxLayout" name="horizontalLayout"> | ||||
|   <layout class="QHBoxLayout" name="hlSnapmaticWidget"> | ||||
|    <item> | ||||
|     <widget class="QCheckBox" name="cbSelected"> | ||||
|      <property name="text"> | ||||
|       <string/> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QLabel" name="labPicture"> | ||||
|      <property name="minimumSize"> | ||||
|  | @ -65,6 +72,13 @@ | |||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QPushButton" name="cmdCopy"> | ||||
|      <property name="text"> | ||||
|       <string>Copy</string> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QPushButton" name="cmdDelete"> | ||||
|      <property name="text"> | ||||
|  |  | |||
|  | @ -32,6 +32,7 @@ SOURCES += main.cpp \ | |||
|     ProfileDatabase.cpp \ | ||||
|     ProfileInterface.cpp \ | ||||
|     ProfileLoader.cpp \ | ||||
|     ProfileWidget.cpp \ | ||||
|     SavegameCopy.cpp \ | ||||
|     SavegameData.cpp \ | ||||
|     SavegameDialog.cpp \ | ||||
|  | @ -53,6 +54,7 @@ HEADERS  += \ | |||
|     ProfileDatabase.h \ | ||||
|     ProfileInterface.h \ | ||||
|     ProfileLoader.h \ | ||||
|     ProfileWidget.h \ | ||||
|     SavegameCopy.h \ | ||||
|     SavegameData.h \ | ||||
|     SavegameDialog.h \ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue