Skip to content

Commit

Permalink
Merge cb18fd1 into 376ee1c
Browse files Browse the repository at this point in the history
  • Loading branch information
KraTuX31 committed Apr 13, 2015
2 parents 376ee1c + cb18fd1 commit b2f959f
Show file tree
Hide file tree
Showing 16 changed files with 564 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ install:
- sudo apt-get install libmysqld-dev libmysqlclient-dev libqt5sql5-mysql libqt4-sql-mysql
- sudo apt-get install mlocate
- sudo apt-get install xvfb
- wget -O Qt5.2.0.tar.xz https://www.dropbox.com/s/mkqtb8teeydsmrk/Qt5.2.0.tar.xz?dl=0
- wget -O Qt5.2.0.tar.xz https://www.dropbox.com/s/vkqlecsep2mqp22/Qt5.2.0.tar.xz?dl=0
- mkdir ~/Qt5.2.0
- tar -xJf Qt5.2.0.tar.xz -C ~/Qt5.2.0
- sudo chmod -R 777 ~/Qt5.2.0/
Expand Down
3 changes: 0 additions & 3 deletions src/database/customerdatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ QPixmap CustomerDatabase::getCustomerImage(const int pId)

void CustomerDatabase::setCustomerImage(Models::Customer &pCustomer) {
QSqlQuery q;
qDebug() << pCustomer.getLastname() << " - " << pCustomer.getImage()->size();
QByteArray byteArray = Gui::Utils::Image::pixmapToBytes(
*pCustomer.getImage(),
pCustomer.getExtensionImage());
Expand All @@ -256,8 +255,6 @@ void CustomerDatabase::setCustomerImage(Models::Customer &pCustomer) {
lastError(q),
1.3);
}
qDebug() << pCustomer.getLastname() << " - " << "Image inserted";

}

QSharedPointer<Models::Customer> CustomerDatabase::getCustomer(const int pId) {
Expand Down
10 changes: 8 additions & 2 deletions src/gui/docks/searchdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

namespace Gui {
namespace Docks {
SearchDock::SearchDock(QWidget* parent, Qt::WindowFlags flags) : QDockWidget(parent, flags), ui(new Ui::SearchDock)
SearchDock::SearchDock(QWidget* parent, Qt::WindowFlags flags)
: QDockWidget(parent, flags), ui(new Ui::SearchDock)

{
ui->setupUi(this);
Expand All @@ -18,6 +19,7 @@ SearchDock::~SearchDock()
void SearchDock::search(QString text)
{
Models::Search s;
_text = text;
QString styleSearchBackground =
"background: url(:/icons/searchMini);"
"background-position: right;"
Expand All @@ -30,7 +32,7 @@ void SearchDock::search(QString text)
"height: 25px;"
"border: 1px solid #bbb;";
if(ui->leSearch->text() != "") {
ui->leSearch->setStyleSheet(styleSearchNoBackground);
ui->leSearch->setStyleSheet(styleSearchNoBackground);
} else {
ui->leSearch->setStyleSheet(styleSearchBackground);
}
Expand All @@ -44,6 +46,10 @@ void SearchDock::search(QString text)

emit textChanged(s.getFilter());
}
QString SearchDock::getText() const
{
return _text;
}


}
Expand Down
7 changes: 7 additions & 0 deletions src/gui/docks/searchdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class SearchDock : public QDockWidget
explicit SearchDock(QWidget *parent=0, Qt::WindowFlags flags = 0);
~SearchDock();

/**
* @brief SearchDock::getText Get the current text searched
* @return Text searched
*/
QString getText() const;

public slots:
/**
* @brief SearchDock::search Search elements in database which correspond
Expand All @@ -43,6 +49,7 @@ public slots:

private:
Ui::SearchDock *ui; //!< User interface
QString _text; //!< Search text

};

Expand Down
42 changes: 30 additions & 12 deletions src/gui/mainwindow/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ void MainWindow::responsiveBillingTable()
}
}

bool MainWindow::isEasterEgg(const QString filter) {
return _searchDock->getText() == "FleuryMigeon42";
}



void MainWindow::billingIsPaid()
Expand Down Expand Up @@ -576,6 +580,11 @@ void MainWindow::changeDocsTable()
updateButtons();
}

void MainWindow::changeEasterEgg()
{
ui->stackedWidget->setCurrentIndex(3);
}

void MainWindow::customersTableToProjectsTable()
{
updateTableProjects(getCurrentCustomerId());
Expand Down Expand Up @@ -685,15 +694,20 @@ void MainWindow::openContextualMenuTree(const QPoint point)


void MainWindow::updateTableCustomers(QString filter, const int row) {
ui->tblCustomers->setModel(
Databases::CustomerDatabase::instance()->getCustomersTable(filter));
if (!isEasterEgg(filter)) {
ui->tblCustomers->setModel(
Databases::CustomerDatabase::instance()->getCustomersTable(filter));

if (row > -1) {
ui->tblCustomers->selectRow(row);
if (row > -1) {
ui->tblCustomers->selectRow(row);
} else {
ui->tblCustomers->clearSelection();
}
responsiveCustomerTable();
} else {
ui->tblCustomers->clearSelection();
changeEasterEgg();
}
responsiveCustomerTable();

}

void MainWindow::updateTableProjects(const int pId, const int row)
Expand Down Expand Up @@ -744,13 +758,17 @@ void MainWindow::updateCostAndTurnover()
ui->tblCustomers->currentIndex().row());
}

void MainWindow::updateTree(QString filter)
{
if (ui->trCustomers->model() != NULL) {
delete ui->trCustomers->model();
void MainWindow::updateTree(QString filter) {
if (!isEasterEgg(filter)) {
if (ui->trCustomers->model() != NULL) {
delete ui->trCustomers->model();
}
ui->trCustomers->setModel(
Databases::CustomerDatabase::instance()->getTree(filter));
} else {
changeEasterEgg();
}
ui->trCustomers->setModel(
Databases::CustomerDatabase::instance()->getTree(filter));

}

void MainWindow::updateButtons()
Expand Down
12 changes: 12 additions & 0 deletions src/gui/mainwindow/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ class MainWindow : public QMainWindow
*/
void responsiveBillingTable();

/**
* @brief MainWindow::isEasterEgg Return TRUE if search <i>filter</i> is
* <b>FleuryMigeon42</b> else FALSE
* @param filter Search filter
* @return boolean
*/
bool isEasterEgg(const QString filter);
public slots:
/**
* @brief MainWindow::addCustomer open window to add a new customer
Expand Down Expand Up @@ -286,6 +293,11 @@ private slots:
* when we change the selected doc in tblQuotes
*/
void changeDocsTable();
/**
* @brief MainWindow::changeEasterEgg function to update the view
* when we change the selected dock in easter egg
*/
void changeEasterEgg();
/**
* @brief MainWindow::customersTableToProjectsTable changes projects with
* the <i>index</i>
Expand Down
84 changes: 81 additions & 3 deletions src/gui/mainwindow/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1413</width>
<height>492</height>
<height>548</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -22,7 +22,7 @@
<item row="0" column="0">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_3">
Expand Down Expand Up @@ -387,6 +387,72 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="page_4">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="Gui::Widgets::CoffeeEasterEggWidget" name="wgtCoffeeMaker" native="true">
<property name="minimumSize">
<size>
<width>400</width>
<height>400</height>
</size>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>206</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
Expand All @@ -397,7 +463,7 @@
<x>0</x>
<y>0</y>
<width>1413</width>
<height>27</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuFichier">
Expand Down Expand Up @@ -543,6 +609,12 @@
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
Expand Down Expand Up @@ -796,6 +868,12 @@
<signal>lockProject()</signal>
</slots>
</customwidget>
<customwidget>
<class>Gui::Widgets::CoffeeEasterEggWidget</class>
<extends>QWidget</extends>
<header>gui/widgets/coffeeeastereggwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../icons.qrc"/>
Expand Down
8 changes: 8 additions & 0 deletions src/gui/utils/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ QPixmap Image::bytesToPixmap(const QByteArray bytes)
return QPixmap::fromImage(QImage::fromData(bytes));
}

QPixmap Image::getImage(QString path, int width, int height)
{
QPixmap img(path);
img.scaled(width,height,Qt::KeepAspectRatio);

return img;
}

QByteArray Image::imageToBytes(QImage image, const QString ext) {
QByteArray bytesArray;
QByteArray extArray = ext.toLocal8Bit();
Expand Down
12 changes: 12 additions & 0 deletions src/gui/utils/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ class Image
* @return QPixmap from bytes
*/
static QPixmap bytesToPixmap(const QByteArray bytes);

/**
* @brief Image::getImage Return a scaled image from the
* icon specified by it <i>path</i>. The image returned has a resolution of
* <i>width</i>*<i>height</i> (default 256*256)
* @param path Icon path
* @param width Icon width
* @param height Icon height
* @return Scaled image
*/
static QPixmap getImage(QString path, int width = 256, int height = 256);

};

}
Expand Down
Loading

0 comments on commit b2f959f

Please sign in to comment.