Skip to content

Commit

Permalink
Qt5 Upgrade: Code changes for compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketman768 committed Nov 2, 2014
1 parent 272378c commit 6f6315d
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 59 deletions.
1 change: 1 addition & 0 deletions src/BtTreeModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <Qt>
#include <QObject>
#include <QStringBuilder>
#include <QMimeData>

#include "brewtarget.h"
#include "BtTreeItem.h"
Expand Down
1 change: 1 addition & 0 deletions src/BtTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QDebug>
#include <QHeaderView>
#include <QMessageBox>
#include <QMimeData>
#include "BtTreeView.h"
#include "BtTreeModel.h"
#include "BtTreeFilterProxyModel.h"
Expand Down
5 changes: 3 additions & 2 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <QLinearGradient>
#include <QBrush>
#include <QPen>
#include <QDesktopWidget>

#include "Algorithms.h"
#include "MashStepEditor.h"
Expand Down Expand Up @@ -2156,12 +2157,12 @@ QFile* MainWindow::openForWrite( QString filterStr, QString defaultSuff)
const char* filename;
QFile* outFile = new QFile();

fileSaver->setFilter( filterStr );
fileSaver->setNameFilter( filterStr );
fileSaver->setDefaultSuffix( defaultSuff );

if( fileSaver->exec() )
{
filename = fileSaver->selectedFiles()[0].toAscii();
filename = fileSaver->selectedFiles()[0].toLatin1();
outFile->setFileName(filename);

if( ! outFile->open(QIODevice::WriteOnly | QIODevice::Truncate) )
Expand Down
1 change: 1 addition & 0 deletions src/MashListModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "style.h"
#include "database.h"
#include "recipe.h"
#include "mash.h"

MashListModel::MashListModel(QWidget* parent)
: QAbstractListModel(parent), recipe(0)
Expand Down
2 changes: 0 additions & 2 deletions src/MashStepTableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ void MashStepTableModel::mashStepChanged(QMetaProperty prop, QVariant val)
emit dataChanged( QAbstractItemModel::createIndex(i, 0),
QAbstractItemModel::createIndex(i, MASHSTEPNUMCOLS-1));
}
else
reset();

if( parentTableWidget )
{
Expand Down
22 changes: 11 additions & 11 deletions src/OptionDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void OptionDialog::saveAndClose()
newUserDataDir = lineEdit_dbDir->text();

// Make sure the dir ends with a "/" or "\"
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
if( !newUserDataDir.endsWith("/") )
newUserDataDir += "/";
#else
Expand Down Expand Up @@ -366,45 +366,45 @@ void OptionDialog::showChanges()
switch( Brewtarget::weightUnitSystem )
{
case Imperial:
weight_imperial->setChecked(TRUE);
weight_imperial->setChecked(true);
break;
case USCustomary:
weight_us->setChecked(TRUE);
weight_us->setChecked(true);
break;
case SI:
default:
weight_si->setChecked(TRUE);
weight_si->setChecked(true);
}

// Check the right volume unit system box.
switch( Brewtarget::volumeUnitSystem )
{
case Imperial:
volume_imperial->setChecked(TRUE);
volume_imperial->setChecked(true);
break;
case USCustomary:
volume_us->setChecked(TRUE);
volume_us->setChecked(true);
break;
case SI:
default:
volume_si->setChecked(TRUE);
volume_si->setChecked(true);
}

// Check gravity.
if( Brewtarget::usePlato )
radioButton_plato->setChecked(TRUE);
radioButton_plato->setChecked(true);
else
radioButton_sg->setChecked(TRUE);
radioButton_sg->setChecked(true);

// Temp.
switch( Brewtarget::tempScale )
{
case Fahrenheit:
fahrenheit->setChecked(TRUE);
fahrenheit->setChecked(true);
break;
case Celsius:
default:
celsius->setChecked(TRUE);
celsius->setChecked(true);
break;
}

Expand Down
6 changes: 4 additions & 2 deletions src/WaterTableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ void WaterTableModel::addWater(Water* water)
)
return;

beginInsertRows( QModelIndex(), waterObs.size(), waterObs.size() );
waterObs.append(water);
connect( water, SIGNAL(changed(QMetaProperty,QVariant)), this, SLOT(changed(QMetaProperty,QVariant)) );
reset(); // Tell everybody that the table has changed.
endInsertRows();

if(parentTableWidget)
{
Expand Down Expand Up @@ -140,9 +141,10 @@ void WaterTableModel::removeWater(Water* water)
i = waterObs.indexOf(water);
if( i >= 0 )
{
beginRemoveRows( QModelIndex(), i, i );
disconnect( water, 0, this, 0 );
waterObs.removeAt(i);
reset(); // Tell everybody the table has changed.
endRemoveRows();

if(parentTableWidget)
{
Expand Down
3 changes: 3 additions & 0 deletions src/brewnote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include "Algorithms.h"
#include "mashstep.h"
#include "recipe.h"
#include "equipment.h"
#include "mash.h"
#include "yeast.h"

QHash<QString,QString> BrewNote::tagToProp = BrewNote::tagToPropHash();

Expand Down
7 changes: 2 additions & 5 deletions src/brewnote.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
#include <QStringList>
#include <QDate>

#include "equipment.h"
#include "mash.h"
#include "mashstep.h"
#include "yeast.h"

#include "BeerXMLElement.h"

// Forward declarations;
Expand Down Expand Up @@ -204,6 +199,8 @@ class BrewNote : public BeerXMLElement
static QHash<QString,QString> tagToProp;
};

Q_DECLARE_METATYPE( QList<BrewNote*> )

inline bool BrewNotePtrLt( BrewNote* lhs, BrewNote* rhs)
{
return *lhs < *rhs;
Expand Down
32 changes: 21 additions & 11 deletions src/brewtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
#include "ImperialVolumeUnitSystem.h"
#include "BtSplashScreen.h"
#include "MainWindow.h"
#include "mash.h"
#include "instruction.h"
#include "water.h"

MainWindow* Brewtarget::_mainWindow = 0;
QDomDocument* Brewtarget::optionsDoc;
Expand Down Expand Up @@ -274,19 +277,21 @@ TempScale Brewtarget::getTemperatureScale()
QString Brewtarget::getDataDir()
{
QString dir = qApp->applicationDirPath();
#if defined(Q_WS_X11) // Linux OS.
#if defined(Q_OS_LINUX) // Linux OS.

dir = QString(CONFIGDATADIR);

#elif defined(Q_WS_MAC) // MAC OS.
#elif defined(Q_OS_MAC) // MAC OS.

// We should be inside an app bundle.
dir += "/../Resources/";

#else // Windows OS.
#elif defined(Q_OS_WIN) // Windows OS.

dir += "/../data/";

#else
# error "Unsupported OS"
#endif

if( ! dir.endsWith('/') )
Expand All @@ -298,19 +303,21 @@ QString Brewtarget::getDataDir()
QString Brewtarget::getDocDir()
{
QString dir = qApp->applicationDirPath();
#if defined(Q_WS_X11) // Linux OS.
#if defined(Q_OS_LINUX) // Linux OS.

dir = QString(CONFIGDOCDIR);

#elif defined(Q_WS_MAC) // MAC OS.
#elif defined(Q_OS_MAC) // MAC OS.

// We should be inside an app bundle.
dir += "/../Resources/en.lproj/";

#else // Windows OS.
#elif defined(Q_OS_WIN) // Windows OS.

dir += "/../doc/";

#else
# error "Unsupported OS"
#endif

if( ! dir.endsWith('/') )
Expand All @@ -321,7 +328,7 @@ QString Brewtarget::getDocDir()

QString Brewtarget::getConfigDir(bool *success)
{
#if defined(Q_WS_X11) || defined(Q_WS_MAC) // Linux OS or Mac OS.
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) // Linux OS or Mac OS.

QDir dir;
QFileInfo fileInfo;
Expand Down Expand Up @@ -397,7 +404,7 @@ QString Brewtarget::getConfigDir(bool *success)
*success = true;
return dir.absolutePath() + "/";

#else // Windows OS.
#elif defined(Q_OS_WIN) // Windows OS.

QDir dir;
// This is the bin/ directory.
Expand All @@ -410,7 +417,10 @@ QString Brewtarget::getConfigDir(bool *success)
*success = true;
return dir.absolutePath() + "/";

#else
# error "Unsupported OS"
#endif

}

QString Brewtarget::getUserDataDir()
Expand Down Expand Up @@ -438,7 +448,7 @@ bool Brewtarget::initialize()
qRegisterMetaType< QList<Water*> >();

// In Unix, make sure the user isn't running 2 copies.
#if defined(Q_WS_X11)
#if defined(Q_OS_LINUX)
pidFile.setFileName(QString("%1.pid").arg(getUserDataDir()));
if( pidFile.exists() )
{
Expand Down Expand Up @@ -488,7 +498,7 @@ bool Brewtarget::initialize()

loadTranslations(); // Do internationalization.

#if defined(Q_WS_MAC)
#if defined(Q_OS_MAC)
qt_set_sequence_auto_mnemonic(TRUE); // turns on Mac Keyboard shortcuts
#endif

Expand Down Expand Up @@ -527,7 +537,7 @@ void Brewtarget::cleanup()
delete _mainWindow;

Database::dropInstance();
#if defined(Q_WS_X11)
#if defined(Q_OS_LINUX)
pidFile.remove();
#endif

Expand Down
19 changes: 0 additions & 19 deletions src/brewtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,11 @@ extern void qt_set_sequence_auto_mnemonic(bool b);
#include <QList>
#include "UnitSystem.h"

// Forward declarations.
class BeerXMLElement;
class BrewNote;
class Equipment;
class Fermentable;
class Hop;
class Instruction;
class MainWindow;
class Mash;
class Misc;
class Style;
class Unit;
class Water;
class Yeast;

// Need these for changed(QMetaProperty,QVariant) to be emitted across threads.
Q_DECLARE_METATYPE( QMetaProperty )
Q_DECLARE_METATYPE( QList<BrewNote*> )
Q_DECLARE_METATYPE( QList<Hop*> )
Q_DECLARE_METATYPE( QList<Instruction*> )
Q_DECLARE_METATYPE( QList<Fermentable*> )
Q_DECLARE_METATYPE( QList<Misc*> )
Q_DECLARE_METATYPE( QList<Yeast*> )
Q_DECLARE_METATYPE( QList<Water*> )

/*!
* \class Brewtarget
Expand Down
9 changes: 3 additions & 6 deletions src/equipment.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
#include <QDomNode>
#include "BeerXMLElement.h"

// Forward declarations.
class Equipment;
class EquipmentException;
bool operator<(Equipment &e1, Equipment &e2);
bool operator==(Equipment &e1, Equipment &e2);

/*!
* \class Equipment
* \author Philip G. Lee
Expand Down Expand Up @@ -160,6 +154,9 @@ class Equipment : public BeerXMLElement

Q_DECLARE_METATYPE( Equipment* )

bool operator<(Equipment &e1, Equipment &e2);
bool operator==(Equipment &e1, Equipment &e2);

inline bool EquipmentPtrLt( Equipment* lhs, Equipment* rhs)
{
return *lhs < *rhs;
Expand Down
2 changes: 2 additions & 0 deletions src/fermentable.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class Fermentable : public BeerXMLElement
static QHash<QString,QString> tagToPropHash();
};

Q_DECLARE_METATYPE( QList<Fermentable*> )

inline bool FermentablePtrLt( Fermentable* lhs, Fermentable* rhs)
{
return *lhs < *rhs;
Expand Down
2 changes: 2 additions & 0 deletions src/hop.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ class Hop : public BeerXMLElement
static QHash<QString,QString> tagToPropHash();
};

Q_DECLARE_METATYPE( QList<Hop*> )

inline bool HopPtrLt( Hop* lhs, Hop* rhs)
{
return *lhs < *rhs;
Expand Down
3 changes: 2 additions & 1 deletion src/instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#define _INSTRUCTION_H

// This class is completely outside the BeerXML spec.
class Instruction;

#include <QString>
#include <QVector>
Expand Down Expand Up @@ -101,6 +100,8 @@ class Instruction : public BeerXMLElement
static QHash<QString,QString> tagToPropHash();
};

Q_DECLARE_METATYPE( QList<Instruction*> )

//! \brief Compares Instruction pointers by Instruction::instructionNumber().
inline bool insPtrLtByNumber( Instruction* lhs, Instruction* rhs)
{
Expand Down
2 changes: 2 additions & 0 deletions src/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class Misc : public BeerXMLElement
static QHash<QString,QString> tagToPropHash();
};

Q_DECLARE_METATYPE( QList<Misc*> )

inline bool MiscPtrLt( Misc* lhs, Misc* rhs)
{
return lhs->name() < rhs->name();
Expand Down
1 change: 1 addition & 0 deletions src/recipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Water;
class Instruction;
class PreInstruction;
class BrewNote;
class MashStep;

//! \brief Compares recipes based on name.
bool operator<(Recipe &r1, Recipe &r2 );
Expand Down
Loading

0 comments on commit 6f6315d

Please sign in to comment.