Dirk, Those are all the bugfixes that you send me as "must fix" today morning. :) I hope everything is ok with them.
I did the calendar widget fixes even tougth I changed the calendar widget because I will use that in the future. Tomaz
From 6e1487a0c93f94029c62dd21933619dbf7b5a79b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tomaz.canabr...@intel.com> Date: Mon, 30 Jun 2014 15:34:55 -0300 Subject: [PATCH 1/8] Align the texts on the Left inside of Right for the DiveList The Qt Framework adds a visual 'tab' on the children of a node, but if we forced a right alignment on them, it will lose that. Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com> --- qt-ui/models.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 823619f..1b7f028 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -1053,16 +1053,7 @@ QVariant DiveItem::data(int column, int role) const switch (role) { case Qt::TextAlignmentRole: - switch (column) { - case DATE: /* fall through */ - case SUIT: /* fall through */ - case LOCATION: - retVal = int(Qt::AlignLeft | Qt::AlignVCenter); - break; - default: - retVal = int(Qt::AlignRight | Qt::AlignVCenter); - break; - } + retVal = int(Qt::AlignLeft | Qt::AlignVCenter); break; case DiveTripModel::SORT_ROLE: Q_ASSERT(dive != NULL); -- 2.0.1
From ce278cd8d7541e15530ab5d06b0bebc0cebb4f80 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tomaz.canabr...@intel.com> Date: Mon, 30 Jun 2014 17:45:52 -0300 Subject: [PATCH 2/8] Fixed SearchBar layout and icons This is almost a rewrite of the Search function on the WebView the old code had a few uneeded things, mostly being a subclass of QMainWindow instead of the QWebView - this makes the code use a tiny bit less ram. The SearchBox was also moved to an own class ( we can use it later to filter the contents of the DiveList for instance ) and a forced use of the pixmaps for the Mac and Windows platform was added. Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com> --- qt-ui/mainwindow.cpp | 2 +- qt-ui/mainwindow.h | 3 +- qt-ui/searchbar.ui | 121 ++++++++++++++++++++++++++++++++++++++ qt-ui/usermanual.cpp | 90 +++++++++++++++------------- qt-ui/usermanual.h | 33 +++++++---- qt-ui/usermanual.ui | 163 --------------------------------------------------- subsurface.pro | 6 +- 7 files changed, 197 insertions(+), 221 deletions(-) create mode 100644 qt-ui/searchbar.ui delete mode 100644 qt-ui/usermanual.ui diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index ab01794..79c10bf 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -706,7 +706,7 @@ void MainWindow::on_actionUserManual_triggered() { #ifndef NO_USERMANUAL if (!helpView) { - helpView = new UserManual(this); + helpView = new UserManual(); } helpView->show(); #endif diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index cfac072..8bdb47e 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -29,6 +29,7 @@ class ProfileGraphicsView; class QWebView; class QSettings; class UpdateManager; +class UserManual; enum MainWindowTitleFormat { MWTF_DEFAULT, @@ -163,7 +164,7 @@ private: Ui::MainWindow ui; QAction *actionNextDive; QAction *actionPreviousDive; - QMainWindow *helpView; + UserManual *helpView; QTreeView *yearlyStats; QAbstractItemModel *yearlyStatsModel; CurrentState state; diff --git a/qt-ui/searchbar.ui b/qt-ui/searchbar.ui new file mode 100644 index 0000000..df956b2 --- /dev/null +++ b/qt-ui/searchbar.ui @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SearchBar</class> + <widget class="QWidget" name="SearchBar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>34</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>2</number> + </property> + <property name="leftMargin"> + <number>2</number> + </property> + <property name="topMargin"> + <number>2</number> + </property> + <property name="rightMargin"> + <number>2</number> + </property> + <property name="bottomMargin"> + <number>2</number> + </property> + <item> + <widget class="QLineEdit" name="searchEdit"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="findPrev"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset theme="go-up"> + <normaloff/> + </iconset> + </property> + <property name="flat"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="findNext"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset theme="go-down"> + <normaloff/> + </iconset> + </property> + <property name="flat"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="findClose"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset theme="window-close"> + <normaloff/> + </iconset> + </property> + <property name="flat"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/qt-ui/usermanual.cpp b/qt-ui/usermanual.cpp index a57717a..6d9c564 100644 --- a/qt-ui/usermanual.cpp +++ b/qt-ui/usermanual.cpp @@ -4,19 +4,43 @@ #include <QDebug> #include "usermanual.h" -#include "ui_usermanual.h" #include "helpers.h" -UserManual::UserManual(QWidget *parent) : QMainWindow(parent), - ui(new Ui::UserManual) +SearchBar::SearchBar(QWidget *parent): QWidget(parent) { - ui->setupUi(this); + ui.setupUi(this); + #if defined(Q_OS_MAC) || defined(Q_OS_WIN) + ui.findNext->setIcon(QIcon(":icons/subsurface/32x32/actions/go-down.png")); + ui.findPrev->setIcon(QIcon(":icons/subsurface/32x32/actions/go-up.png")); + ui.findClose->setIcon(QIcon(":icons/subsurface/32x32/actions/window-close.png")); + #endif + + connect(ui.findNext, SIGNAL(pressed()), this, SIGNAL(searchNext())); + connect(ui.findPrev, SIGNAL(pressed()), this, SIGNAL(searchPrev())); + connect(ui.searchEdit, SIGNAL(textChanged(QString)), this, SIGNAL(searchTextChanged(QString))); + connect(ui.searchEdit, SIGNAL(textChanged(QString)), this, SLOT(enableButtons(QString))); + connect(ui.findClose, SIGNAL(pressed()), this, SLOT(hide())); +} + +void SearchBar::setVisible(bool visible) +{ + QWidget::setVisible(visible); + ui.searchEdit->setFocus(); +} +void SearchBar::enableButtons(const QString &s) +{ + ui.findPrev->setEnabled(s.length()); + ui.findNext->setEnabled(s.length()); +} + +UserManual::UserManual(QWidget *parent) : QWebView(parent) +{ QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); connect(closeKey, SIGNAL(activated()), this, SLOT(close())); QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); - connect(quitKey, SIGNAL(activated()), parent, SLOT(close())); + connect(quitKey, SIGNAL(activated()), qApp, SLOT(quit())); QAction *actionShowSearch = new QAction(this); actionShowSearch->setShortcut(Qt::CTRL + Qt::Key_F); @@ -30,7 +54,7 @@ UserManual::UserManual(QWidget *parent) : QMainWindow(parent), setWindowTitle(tr("User Manual")); - ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); + page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); QString searchPath = getSubsurfaceDataPath("Documentation"); if (searchPath.size()) { // look for localized versions of the manual first @@ -42,65 +66,48 @@ UserManual::UserManual(QWidget *parent) : QMainWindow(parent), if (!manual.exists()) manual.setFileName(prefix + ".html"); if (!manual.exists()) { - ui->webView->setHtml(tr("Cannot find the Subsurface manual")); + setHtml(tr("Cannot find the Subsurface manual")); } else { QString urlString = QString("file:///") + manual.fileName(); - QUrl url(urlString, QUrl::TolerantMode); - ui->webView->setUrl(url); + setUrl(QUrl(urlString, QUrl::TolerantMode)); } } else { - ui->webView->setHtml(tr("Cannot find the Subsurface manual")); + setHtml(tr("Cannot find the Subsurface manual")); } - ui->searchPanel->setParent(this); - ui->searchPanel->hide(); - - connect(actionShowSearch, SIGNAL(triggered(bool)), this, SLOT(showSearchPanel())); - connect(actionHideSearch, SIGNAL(triggered(bool)), this, SLOT(hideSearchPanel())); - connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl))); - connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString))); - connect(ui->findNext, SIGNAL(clicked()), this, SLOT(searchNext())); - connect(ui->findPrev, SIGNAL(clicked()), this, SLOT(searchPrev())); -} -void UserManual::showSearchPanel() -{ - ui->searchPanel->show(); - ui->searchEdit->setFocus(); - ui->searchEdit->selectAll(); -} - -void UserManual::hideSearchPanel() -{ - ui->searchPanel->hide(); + searchBar = new SearchBar(this); + searchBar->hide(); + connect(actionShowSearch, SIGNAL(triggered(bool)), searchBar, SLOT(show())); + connect(actionHideSearch, SIGNAL(triggered(bool)), searchBar, SLOT(hide())); + connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl))); + connect(searchBar, SIGNAL(searchTextChanged(QString)), this, SLOT(searchTextChanged(QString))); + connect(searchBar, SIGNAL(searchNext()), this, SLOT(searchNext())); + connect(searchBar, SIGNAL(searchPrev()), this, SLOT(searchPrev())); } void UserManual::search(QString text, QWebPage::FindFlags flags = 0) { - if (ui->webView->findText(text, QWebPage::FindWrapsAroundDocument | flags) || text.length() == 0) { - ui->searchEdit->setStyleSheet(""); + if (findText(text, QWebPage::FindWrapsAroundDocument | flags) || text.length() == 0) { + searchBar->setStyleSheet(""); } else { - ui->searchEdit->setStyleSheet("QLineEdit{background: red;}"); + searchBar->setStyleSheet("QLineEdit{background: red;}"); } } -void UserManual::searchTextChanged(QString text) +void UserManual::searchTextChanged(const QString& text) { - bool hasText = text.length() > 0; - - ui->findPrev->setEnabled(hasText); - ui->findNext->setEnabled(hasText); - + mLastText = text; search(text); } void UserManual::searchNext() { - search(ui->searchEdit->text()); + search(mLastText); } void UserManual::searchPrev() { - search(ui->searchEdit->text(), QWebPage::FindBackward); + search(mLastText, QWebPage::FindBackward); } void UserManual::linkClickedSlot(QUrl url) @@ -110,5 +117,4 @@ void UserManual::linkClickedSlot(QUrl url) UserManual::~UserManual() { - delete ui; } diff --git a/qt-ui/usermanual.h b/qt-ui/usermanual.h index de8770e..7cd10c1 100644 --- a/qt-ui/usermanual.h +++ b/qt-ui/usermanual.h @@ -1,31 +1,42 @@ #ifndef USERMANUAL_H #define USERMANUAL_H -#include <QMainWindow> -#include <QWebPage> +#include <QWebView> -namespace Ui { - class UserManual; -} +#include "ui_searchbar.h" -class UserManual : public QMainWindow { +class SearchBar : public QWidget{ + Q_OBJECT +public: + SearchBar(QWidget *parent = 0); +signals: + void searchTextChanged(const QString& s); + void searchNext(); + void searchPrev(); +protected: + void setVisible(bool visible); +private slots: + void enableButtons(const QString& s); +private: + Ui::SearchBar ui; +}; + +class UserManual : public QWebView { Q_OBJECT public: explicit UserManual(QWidget *parent = 0); ~UserManual(); - private slots: - void showSearchPanel(); - void hideSearchPanel(); - void searchTextChanged(QString); + void searchTextChanged(const QString& s); void searchNext(); void searchPrev(); void linkClickedSlot(QUrl url); private: - Ui::UserManual *ui; + SearchBar *searchBar; + QString mLastText; void search(QString, QWebPage::FindFlags); }; #endif // USERMANUAL_H diff --git a/qt-ui/usermanual.ui b/qt-ui/usermanual.ui deleted file mode 100644 index e8f0095..0000000 --- a/qt-ui/usermanual.ui +++ /dev/null @@ -1,163 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UserManual</class> - <widget class="QMainWindow" name="UserManual"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>834</width> - <height>599</height> - </rect> - </property> - <property name="windowIcon"> - <iconset resource="../subsurface.qrc"> - <normaloff>:/subsurface-icon</normaloff>:/subsurface-icon</iconset> - </property> - <widget class="QWidget" name="centralWidget"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QWidget" name="searchPanel" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>230</width> - <height>40</height> - </size> - </property> - <property name="autoFillBackground"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>9</number> - </property> - <property name="topMargin"> - <number>9</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLineEdit" name="searchEdit"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="findPrev"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset theme="go-up"> - <normaloff/> - </iconset> - </property> - <property name="flat"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="findNext"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset theme="go-down"> - <normaloff/> - </iconset> - </property> - <property name="flat"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="findClose"> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset theme="window-close"> - <normaloff/> - </iconset> - </property> - <property name="flat"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWebView" name="webView" native="true"/> - </item> - </layout> - </widget> - </widget> - <layoutdefault spacing="6" margin="11"/> - <customwidgets> - <customwidget> - <class>QWebView</class> - <extends>QWidget</extends> - <header>qwebview.h</header> - </customwidget> - </customwidgets> - <resources> - <include location="../subsurface.qrc"/> - </resources> - <connections> - <connection> - <sender>findClose</sender> - <signal>clicked()</signal> - <receiver>searchPanel</receiver> - <slot>hide()</slot> - <hints> - <hint type="sourcelabel"> - <x>261</x> - <y>37</y> - </hint> - <hint type="destinationlabel"> - <x>220</x> - <y>11</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/subsurface.pro b/subsurface.pro index 3dec531..b9ff68a 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -4,7 +4,7 @@ QT = core gui network svg concurrent lessThan(QT_MAJOR_VERSION, 5) { QT += webkit } else { - !android: QT += webkitwidgets + !android: QT += webkitwidgets webkit android: QT += androidextras } INCLUDEPATH += qt-ui $$PWD @@ -191,13 +191,13 @@ FORMS = \ qt-ui/webservices.ui \ qt-ui/tableview.ui \ qt-ui/divelogimportdialog.ui \ - qt-ui/usermanual.ui \ + qt-ui/searchbar.ui \ qt-ui/divelogexportdialog.ui \ qt-ui/plannerSettings.ui \ qt-ui/usersurvey.ui # Nether usermanual or printing is supported on android right now -android: FORMS -= qt-ui/usermanual.ui qt-ui/printoptions.ui +android: FORMS -= qt-ui/printoptions.ui RESOURCES = subsurface.qrc -- 2.0.1
From 946115970ad25213b9c3939c2a9f63bf987c3d86 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tomaz.canabr...@intel.com> Date: Mon, 30 Jun 2014 18:20:17 -0300 Subject: [PATCH 3/8] Calendar widget should hide when clicking somewhere else This patch adds a event filter to hide the calendar widget when it loses focus Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com> --- qt-ui/simplewidgets.cpp | 16 ++++++++++++++-- qt-ui/simplewidgets.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 94670b0..7da691d 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -297,8 +297,7 @@ DateWidget::DateWidget(QWidget *parent) : QWidget(parent), setDate(QDate::currentDate()); setMinimumSize(QSize(80,64)); setFocusPolicy(Qt::StrongFocus); - calendarWidget->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); - calendarWidget->setWindowModality(Qt::ApplicationModal); + calendarWidget->setWindowFlags(Qt::FramelessWindowHint); calendarWidget->setFirstDayOfWeek(getLocale().firstDayOfWeek()); calendarWidget->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader); @@ -306,8 +305,19 @@ DateWidget::DateWidget(QWidget *parent) : QWidget(parent), connect(calendarWidget, SIGNAL(clicked(QDate)), calendarWidget, SLOT(hide())); connect(calendarWidget, SIGNAL(activated(QDate)), this, SLOT(setDate(QDate))); connect(calendarWidget, SIGNAL(clicked(QDate)), this, SLOT(setDate(QDate))); + calendarWidget->installEventFilter(this); } +bool DateWidget::eventFilter(QObject *object, QEvent *event) +{ + if(event->type() == QEvent::FocusOut){ + calendarWidget->hide(); + return true; + } + return QObject::eventFilter(object, event); +} + + void DateWidget::setDate(const QDate& date) { mDate = date; @@ -367,6 +377,8 @@ void DateWidget::mousePressEvent(QMouseEvent *event) { calendarWidget->move(event->globalPos()); calendarWidget->show(); + calendarWidget->raise(); + calendarWidget->setFocus(); } void DateWidget::focusInEvent(QFocusEvent *event) diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index f57046e..58c9199 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -104,6 +104,7 @@ protected: void focusOutEvent(QFocusEvent *); void keyPressEvent(QKeyEvent *); void changeEvent(QEvent *); + bool eventFilter(QObject *, QEvent *); signals: void dateChanged(const QDate& date); private: -- 2.0.1
From 5769c7c29c1f3a2339ab10f7c5aa2c909afd3e3e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tomaz.canabr...@intel.com> Date: Mon, 30 Jun 2014 18:28:13 -0300 Subject: [PATCH 4/8] Added a shortcut 'ESC' to close the calendar widget This hides the calendar widget when the user press esc when it's running. Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com> --- qt-ui/simplewidgets.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 7da691d..b11d752 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -314,6 +314,12 @@ bool DateWidget::eventFilter(QObject *object, QEvent *event) calendarWidget->hide(); return true; } + if(event->type() == QEvent::KeyPress){ + QKeyEvent *ev = static_cast<QKeyEvent*>(event); + if(ev->key() == Qt::Key_Escape){ + calendarWidget->hide(); + } + } return QObject::eventFilter(object, event); } -- 2.0.1
From bba4a21a7e1a49ac240e8a11fb7916db7cfc6d2b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tomaz.canabr...@intel.com> Date: Mon, 30 Jun 2014 18:31:29 -0300 Subject: [PATCH 5/8] Selects the dive date before showing it up. Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com> --- qt-ui/simplewidgets.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index b11d752..5908c2b 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -381,6 +381,7 @@ void DateWidget::paintEvent(QPaintEvent *event) void DateWidget::mousePressEvent(QMouseEvent *event) { + calendarWidget->setSelectedDate(mDate); calendarWidget->move(event->globalPos()); calendarWidget->show(); calendarWidget->raise(); -- 2.0.1
From 2a027176df3d4d45e1a615bfbc96d2c908ab6b2d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tomaz.canabr...@intel.com> Date: Mon, 30 Jun 2014 18:46:02 -0300 Subject: [PATCH 6/8] Revert Date widget to default in Qt The new one, while it's prettier, doesn't fit into the current layout in a good way, we need a better layout for it. So it's code will continue as dead code for a while. Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com> --- qt-ui/maintab.ui | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 3105d17..44ead68 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -37,8 +37,8 @@ <rect> <x>0</x> <y>0</y> - <width>668</width> - <height>658</height> + <width>662</width> + <height>642</height> </rect> </property> <layout class="QGridLayout" name="gridLayout_2"> @@ -177,13 +177,6 @@ </property> </widget> </item> - <item row="1" column="0" rowspan="2"> - <widget class="DateWidget" name="dateEdit" native="true"> - <property name="focusPolicy"> - <enum>Qt::StrongFocus</enum> - </property> - </widget> - </item> <item row="12" column="0" colspan="3"> <widget class="TagWidget" name="tagWidget"> <property name="sizePolicy"> @@ -293,6 +286,20 @@ </property> </widget> </item> + <item row="2" column="0"> + <widget class="QDateEdit" name="dateEdit"> + <property name="calendarPopup"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Date</string> + </property> + </widget> + </item> </layout> </widget> </widget> @@ -323,8 +330,8 @@ <rect> <x>0</x> <y>0</y> - <width>100</width> - <height>30</height> + <width>662</width> + <height>642</height> </rect> </property> <layout class="QGridLayout" name="gridLayout_5"> @@ -403,8 +410,8 @@ <rect> <x>0</x> <y>0</y> - <width>387</width> - <height>285</height> + <width>662</width> + <height>642</height> </rect> </property> <layout class="QGridLayout" name="gridLayout_6"> @@ -713,8 +720,8 @@ <rect> <x>0</x> <y>0</y> - <width>341</width> - <height>167</height> + <width>662</width> + <height>642</height> </rect> </property> <layout class="QGridLayout" name="gridLayout_7"> @@ -957,16 +964,9 @@ <extends>QListView</extends> <header>divepicturewidget.h</header> </customwidget> - <customwidget> - <class>DateWidget</class> - <extends>QWidget</extends> - <header>simplewidgets.h</header> - <container>1</container> - </customwidget> </customwidgets> <tabstops> <tabstop>scrollArea</tabstop> - <tabstop>dateEdit</tabstop> <tabstop>airtemp</tabstop> <tabstop>watertemp</tabstop> <tabstop>location</tabstop> -- 2.0.1
From 1e0b87d21cd5457274fb8ab9b302afbe6f1e2575 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tomaz.canabr...@intel.com> Date: Mon, 30 Jun 2014 18:46:51 -0300 Subject: [PATCH 7/8] Better colors for Add and Plan modes. Those are ligther colors and it should be a better choice a way better choice is to ask for a designer wich color to use but most of my minions are busy. Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com> --- qt-ui/profile/profilewidget2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 7fd182f..0aa2a4a 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -805,7 +805,7 @@ void ProfileWidget2::setAddState() /* show the same stuff that the profile shows. */ currentState = ADD; /* enable the add state. */ diveCeiling->setVisible(true); - setBackgroundBrush(QColor(Qt::blue).light()); + setBackgroundBrush(QColor("#A7DCFF")); } void ProfileWidget2::setPlanState() @@ -834,7 +834,7 @@ void ProfileWidget2::setPlanState() /* show the same stuff that the profile shows. */ currentState = PLAN; /* enable the add state. */ diveCeiling->setVisible(true); - setBackgroundBrush(QColor(Qt::green).light()); + setBackgroundBrush(QColor("#D7E3EF")); } extern struct ev_select *ev_namelist; -- 2.0.1
From ac5caafb8a8273c11ae1dfe5cbb409b726177dd1 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tomaz.canabr...@intel.com> Date: Mon, 30 Jun 2014 19:08:16 -0300 Subject: [PATCH 8/8] Only replot the dive if maxDepth > oldMaxDepth on plan / add mode. This fixes the "impossible to work with" planner with the mouse now the dive will only grow and not shrink untill you release the mouse. Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com> --- qt-ui/diveplanner.cpp | 12 ++++++++++++ qt-ui/diveplanner.h | 4 ++++ qt-ui/profile/profilewidget2.cpp | 32 +++++++++++++++++++++++++++++--- qt-ui/profile/profilewidget2.h | 5 +++++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index e6c1889..44449a5 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -258,6 +258,18 @@ void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event) emit moved(); } +void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + QGraphicsItem::mousePressEvent(event); + emit clicked(); +} + +void DiveHandler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + QGraphicsItem::mouseReleaseEvent(event); + emit released(); +} + DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { ui.setupUi(this); diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 4911a56..02c4018 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -118,8 +118,12 @@ public: protected: void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); signals: void moved(); + void clicked(); + void released(); private: int parentIndex(); public diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 0aa2a4a..f9186da 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -90,7 +90,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), rulerItem(new RulerItem2()), isGrayscale(false), printMode(false), - shouldCalculateMaxTime(true) + shouldCalculateMaxTime(true), + shouldCalculateMaxDepth(true) { memset(&plotInfo, 0, sizeof(plotInfo)); @@ -430,7 +431,19 @@ void ProfileWidget2::plotDives(QList<dive *> dives) create_plot_info_new(d, currentdc, &pInfo); if(shouldCalculateMaxTime) maxtime = get_maxtime(&pInfo); - int maxdepth = get_maxdepth(&pInfo); + + /* Only update the max depth if it's bigger than the current ones + * when we are dragging the handler to plan / add dive. + * otherwhise, update normally. + */ + int newMaxDepth = get_maxdepth(&pInfo); + if(!shouldCalculateMaxDepth) { + if (maxdepth < newMaxDepth) { + maxdepth = newMaxDepth; + } + } else { + maxdepth = newMaxDepth; + } dataModel->setDive(d, pInfo); toolTipItem->setPlotInfo(pInfo); @@ -506,7 +519,6 @@ void ProfileWidget2::plotDives(QList<dive *> dives) // Only set visible the events that should be visible Q_FOREACH (DiveEventItem *event, eventItems) { event->setVisible(!event->shouldBeHidden()); - // qDebug() << event->getEvent()->name << "@" << event->getEvent()->time.seconds << "is hidden:" << event->isHidden(); } QString dcText = get_dc_nickname(currentdc->model, currentdc->deviceid); int nr; @@ -567,6 +579,18 @@ void ProfileWidget2::mousePressEvent(QMouseEvent *event) shouldCalculateMaxTime = false; } +void ProfileWidget2::divePlannerHandlerClicked() +{ + shouldCalculateMaxDepth = false; + replot(); +} + +void ProfileWidget2::divePlannerHandlerReleased() +{ + shouldCalculateMaxDepth = true; + replot(); +} + void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event) { QGraphicsView::mouseReleaseEvent(event); @@ -1090,6 +1114,8 @@ void ProfileWidget2::pointInserted(const QModelIndex &parent, int start, int end handles << item; connect(item, SIGNAL(moved()), this, SLOT(recreatePlannedDive())); + connect(item, SIGNAL(clicked()), this, SLOT(divePlannerHandlerClicked())); + connect(item, SIGNAL(released()), this, SLOT(divePlannerHandlerReleased())); QGraphicsSimpleTextItem *gasChooseBtn = new QGraphicsSimpleTextItem(); scene()->addItem(gasChooseBtn); gasChooseBtn->setZValue(10); diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 47e9a51..42d5abb 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -107,6 +107,8 @@ slots: // Necessary to call from QAction's signals. void keyLeftAction(); void keyRightAction(); + void divePlannerHandlerClicked(); + void divePlannerHandlerReleased(); protected: virtual void resizeEvent(QResizeEvent *event); virtual void wheelEvent(QWheelEvent *event); @@ -115,6 +117,7 @@ protected: virtual void mouseDoubleClickEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event); + private: /*methods*/ void fixBackgroundPos(); void scrollViewTo(const QPoint &pos); @@ -169,7 +172,9 @@ private: friend class DiveHandler; QHash<Qt::Key, QAction *> actionsForKeys; bool shouldCalculateMaxTime; + bool shouldCalculateMaxDepth; int maxtime; + int maxdepth; }; #endif // PROFILEWIDGET2_H -- 2.0.1
_______________________________________________ subsurface mailing list subsurface@hohndel.org http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface