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>
</property>
<item>
<widget class="QLabel" name="labPicture">
<widget class="UiModLabel" name="labPicture">
<property name="text">
<string/>
</property>
@ -110,6 +110,19 @@
</item>
</layout>
</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/>
<connections/>
</ui>

View File

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

View File

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

View File

@ -40,7 +40,8 @@ SOURCES += main.cpp \
SnapmaticWidget.cpp \
StandardPaths.cpp \
StringParser.cpp \
UserInterface.cpp
UserInterface.cpp \
uimod/UiModLabel.cpp
HEADERS += \
AboutDialog.h \
@ -59,7 +60,8 @@ HEADERS += \
SnapmaticWidget.h \
StandardPaths.h \
StringParser.h \
UserInterface.h
UserInterface.h \
uimod/UiModLabel.h
FORMS += \
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