add modifed QLabel as UiModLabel, ProfileInterface widgets are now in

QMap
This commit is contained in:
Rafael 2016-04-01 19:32:16 +02:00
parent 2d7707488a
commit ea2b9046e7
6 changed files with 135 additions and 10 deletions

View file

@ -27,7 +27,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="labPicture"> <widget class="UiModLabel" name="labPicture">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -110,6 +110,19 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>UiModLabel</class>
<extends>QLabel</extends>
<header>uimod/UiModLabel.h</header>
<slots>
<signal>mouseMoved()</signal>
<signal>mouseReleased()</signal>
<signal>mousePressed()</signal>
<signal>mouseDoubleClicked()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View file

@ -66,9 +66,9 @@ ProfileInterface::~ProfileInterface()
picture->deleteLater(); picture->deleteLater();
delete picture; delete picture;
} }
foreach(QWidget *widget, widgets) foreach(QWidget *widget, widgets.keys())
{ {
widgets.removeAll(widget); widgets.remove(widget);
widget->deleteLater(); widget->deleteLater();
delete widget; delete widget;
} }
@ -99,7 +99,7 @@ void ProfileInterface::on_savegameLoaded(SavegameData *savegame, QString savegam
SavegameWidget *sgdWidget = new SavegameWidget(); SavegameWidget *sgdWidget = new SavegameWidget();
sgdWidget->setSavegameData(savegame, savegamePath); sgdWidget->setSavegameData(savegame, savegamePath);
ui->vlSavegame->addWidget(sgdWidget); ui->vlSavegame->addWidget(sgdWidget);
widgets.append(sgdWidget); widgets[sgdWidget] = "SavegameWidget";
savegames.append(savegame); savegames.append(savegame);
QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(on_savegameDeleted())); QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(on_savegameDeleted()));
} }
@ -109,7 +109,7 @@ void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString pictu
SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, threadDB); SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, threadDB);
picWidget->setSnapmaticPicture(picture, picturePath); picWidget->setSnapmaticPicture(picture, picturePath);
ui->vlSnapmatic->addWidget(picWidget); ui->vlSnapmatic->addWidget(picWidget);
widgets.append(picWidget); widgets[picWidget] = "SnapmaticWidget";
pictures.append(picture); pictures.append(picture);
QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(on_pictureDeleted())); QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(on_pictureDeleted()));
} }
@ -133,7 +133,7 @@ void ProfileInterface::on_profileLoaded()
void ProfileInterface::on_savegameDeleted() void ProfileInterface::on_savegameDeleted()
{ {
SavegameWidget *sgdWidget = (SavegameWidget*)sender(); SavegameWidget *sgdWidget = (SavegameWidget*)sender();
widgets.removeAll(sgdWidget); widgets.remove(sgdWidget);
sgdWidget->deleteLater(); sgdWidget->deleteLater();
delete sgdWidget; delete sgdWidget;
} }
@ -141,7 +141,7 @@ void ProfileInterface::on_savegameDeleted()
void ProfileInterface::on_pictureDeleted() void ProfileInterface::on_pictureDeleted()
{ {
SnapmaticWidget *picWidget = (SnapmaticWidget*)sender(); SnapmaticWidget *picWidget = (SnapmaticWidget*)sender();
widgets.removeAll(picWidget); widgets.remove(picWidget);
picWidget->deleteLater(); picWidget->deleteLater();
delete picWidget; delete picWidget;
} }

View file

@ -29,6 +29,7 @@
#include <QSpacerItem> #include <QSpacerItem>
#include <QWidget> #include <QWidget>
#include <QList> #include <QList>
#include <QMap>
namespace Ui { namespace Ui {
class ProfileInterface; class ProfileInterface;
@ -62,7 +63,7 @@ private:
ProfileLoader *profileLoader; ProfileLoader *profileLoader;
QList<SavegameData*> savegames; QList<SavegameData*> savegames;
QList<SnapmaticPicture*> pictures; QList<SnapmaticPicture*> pictures;
QList<QWidget*> widgets; QMap<QWidget*,QString> widgets;
QSpacerItem *saSpacerItem; QSpacerItem *saSpacerItem;
QString profileFolder; QString profileFolder;
QString profileName; QString profileName;

View file

@ -40,7 +40,8 @@ SOURCES += main.cpp \
SnapmaticWidget.cpp \ SnapmaticWidget.cpp \
StandardPaths.cpp \ StandardPaths.cpp \
StringParser.cpp \ StringParser.cpp \
UserInterface.cpp UserInterface.cpp \
uimod/UiModLabel.cpp
HEADERS += \ HEADERS += \
AboutDialog.h \ AboutDialog.h \
@ -59,7 +60,8 @@ HEADERS += \
SnapmaticWidget.h \ SnapmaticWidget.h \
StandardPaths.h \ StandardPaths.h \
StringParser.h \ StringParser.h \
UserInterface.h UserInterface.h \
uimod/UiModLabel.h
FORMS += \ FORMS += \
AboutDialog.ui \ AboutDialog.ui \

61
uimod/UiModLabel.cpp Executable file
View file

@ -0,0 +1,61 @@
/*****************************************************************************
* 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 "UiModLabel.h"
UiModLabel::UiModLabel(const QString &text, QWidget *parent) : QLabel(parent)
{
setText(text);
}
UiModLabel::UiModLabel(QWidget *parent, const QString &text) : QLabel(parent)
{
setText(text);
}
UiModLabel::UiModLabel(QWidget *parent) : QLabel(parent)
{
}
UiModLabel::~UiModLabel()
{
}
void UiModLabel::mouseMoveEvent(QMouseEvent *ev)
{
QLabel::mouseMoveEvent(ev);
emit mouseMoved();
}
void UiModLabel::mousePressEvent(QMouseEvent *ev)
{
QLabel::mousePressEvent(ev);
emit mousePressed();
}
void UiModLabel::mouseReleaseEvent(QMouseEvent *ev)
{
QLabel::mouseReleaseEvent(ev);
emit mouseReleased();
}
void UiModLabel::mouseDoubleClickEvent(QMouseEvent *ev)
{
QLabel::mouseDoubleClickEvent(ev);
emit mouseDoubleClicked();
}

48
uimod/UiModLabel.h Executable file
View file

@ -0,0 +1,48 @@
/*****************************************************************************
* 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 UIMODLABEL_H
#define UIMODLABEL_H
#include <QWidget>
#include <QLabel>
#include <QString>
class UiModLabel : public QLabel
{
Q_OBJECT
public:
UiModLabel(const QString &text, QWidget *parent = 0);
UiModLabel(QWidget *parent, const QString &text);
UiModLabel(QWidget *parent = 0);
~UiModLabel();
protected:
void mouseMoveEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
void mouseDoubleClickEvent(QMouseEvent *ev);
signals:
void mouseMoved();
void mousePressed();
void mouseReleased();
void mouseDoubleClicked();
};
#endif // UIMODLABEL_H