|
@@ -18,81 +18,10 @@
|
|
|
*/
|
|
|
|
|
|
#include <QSettings>
|
|
|
+#include <QMenu>
|
|
|
|
|
|
#include "mainwindow-common.h"
|
|
|
|
|
|
-bool issueCmpFunct_statusIsClosed_lt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- int issue_statusIsClosed_a = redmine->get_issue_status ( issue_a["status"].toObject() ["id"].toInt() ) ["is_closed"].toBool();
|
|
|
- int issue_statusIsClosed_b = redmine->get_issue_status ( issue_b["status"].toObject() ["id"].toInt() ) ["is_closed"].toBool();
|
|
|
- return issue_statusIsClosed_a < issue_statusIsClosed_b;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-bool issueCmpFunct_statusPosition_lt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- int issue_statusPosition_a = redmine->get_issue_status ( issue_a["status"].toObject() ["id"].toInt() ) ["position"].toInt();
|
|
|
- int issue_statusPosition_b = redmine->get_issue_status ( issue_b["status"].toObject() ["id"].toInt() ) ["position"].toInt();
|
|
|
- return issue_statusPosition_a < issue_statusPosition_b;
|
|
|
-}
|
|
|
-bool issueCmpFunct_statusPosition_gt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- int issue_statusPosition_a = redmine->get_issue_status ( issue_a["status"].toObject() ["id"].toInt() ) ["position"].toInt();
|
|
|
- int issue_statusPosition_b = redmine->get_issue_status ( issue_b["status"].toObject() ["id"].toInt() ) ["position"].toInt();
|
|
|
- return issue_statusPosition_a > issue_statusPosition_b;
|
|
|
-}
|
|
|
-
|
|
|
-bool issueCmpFunct_updatedOn_lt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- QString issue_updatedOn_a = issue_a["updated_on"].toString();
|
|
|
- QString issue_updatedOn_b = issue_b["updated_on"].toString();
|
|
|
- return issue_updatedOn_a < issue_updatedOn_b;
|
|
|
-}
|
|
|
-bool issueCmpFunct_updatedOn_gt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- QString issue_updatedOn_a = issue_a["updated_on"].toString();
|
|
|
- QString issue_updatedOn_b = issue_b["updated_on"].toString();
|
|
|
- return issue_updatedOn_a > issue_updatedOn_b;
|
|
|
-}
|
|
|
-
|
|
|
-bool issueCmpFunct_name_lt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- QString issue_name_a = issue_a["name"].toString();
|
|
|
- QString issue_name_b = issue_b["name"].toString();
|
|
|
- return issue_name_a < issue_name_b;
|
|
|
-}
|
|
|
-bool issueCmpFunct_name_gt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- QString issue_name_a = issue_a["name"].toString();
|
|
|
- QString issue_name_b = issue_b["name"].toString();
|
|
|
- return issue_name_a > issue_name_b;
|
|
|
-}
|
|
|
-
|
|
|
-bool issueCmpFunct_assignee_lt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- QString issue_assignee_a = issue_a["assigned_to"].toObject() ["name"].toString();
|
|
|
- QString issue_assignee_b = issue_b["assigned_to"].toObject() ["name"].toString();
|
|
|
- return issue_assignee_a < issue_assignee_b;
|
|
|
-}
|
|
|
-bool issueCmpFunct_assignee_gt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- QString issue_assignee_a = issue_a["assigned_to"].toObject() ["name"].toString();
|
|
|
- QString issue_assignee_b = issue_b["assigned_to"].toObject() ["name"].toString();
|
|
|
- return issue_assignee_a > issue_assignee_b;
|
|
|
-}
|
|
|
-
|
|
|
-bool issueCmpFunct_dueTo_lt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- QString issue_dueTo_a = issue_a["due_date"].toString();
|
|
|
- QString issue_dueTo_b = issue_b["due_date"].toString();
|
|
|
- return issue_dueTo_a < issue_dueTo_b;
|
|
|
-}
|
|
|
-bool issueCmpFunct_dueTo_gt ( const QJsonObject &issue_a, const QJsonObject &issue_b )
|
|
|
-{
|
|
|
- QString issue_dueTo_a = issue_a["due_date"].toString();
|
|
|
- QString issue_dueTo_b = issue_b["due_date"].toString();
|
|
|
- return issue_dueTo_a > issue_dueTo_b;
|
|
|
-}
|
|
|
|
|
|
MainWindowCommon::MainWindowCommon ( QWidget *parent ) :
|
|
|
QMainWindow ( parent )
|
|
@@ -110,10 +39,22 @@ MainWindowCommon::MainWindowCommon ( QWidget *parent ) :
|
|
|
this->sortFunctMap.insert ( SORT_UPDATED_ON_ASC, issueCmpFunct_updatedOn_lt );
|
|
|
this->sortFunctMap.insert ( SORT_UPDATED_ON_DESC, issueCmpFunct_updatedOn_gt );
|
|
|
this->sortFunctMap.insert ( SORT_STATUS_ISCLOSED_ASC, issueCmpFunct_statusIsClosed_lt );
|
|
|
+
|
|
|
+ this->sortFunctMap.insert ( SORT_TIMEENTRY_FROM_ASC, timeEntryCmpFunct_from_lt );
|
|
|
+
|
|
|
memset ( this->sortColumn, 0, sizeof ( this->sortColumn ) );
|
|
|
- this->sortColumn[0] = ( MainWindowCommon::ESortColumn ) qsettings.value ( "sortcode" ).toInt();
|
|
|
- this->sortLogicalIndex = qsettings.value ( "sortcolumn" ).toInt();
|
|
|
- this->sortOrder = ( Qt::SortOrder ) qsettings.value ( "sortorder" ).toInt();
|
|
|
+ this->sortColumn[0] = ( MainWindowCommon::ESortColumn ) qsettings.value ( "sortcode" ).toInt();
|
|
|
+ this->sortLogicalIndex = qsettings.value ( "sortcolumn" ).toInt();
|
|
|
+ this->sortOrder = ( Qt::SortOrder ) qsettings.value ( "sortorder" ).toInt();
|
|
|
+
|
|
|
+ this->createIconComboBox();
|
|
|
+ this->createTrayIcon();
|
|
|
+ this->status ( GOOD );
|
|
|
+ this->setIcon ( GOOD );
|
|
|
+ this->trayIcon->show();
|
|
|
+
|
|
|
+ this->logTimeWindow = NULL;
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -140,7 +81,7 @@ void MainWindowCommon::get_roles_callback ( QNetworkReply *reply, QJsonDocument
|
|
|
|
|
|
int MainWindowCommon::updateRoles()
|
|
|
{
|
|
|
- redmine->get_roles ( ( Redmine::callback_t ) &MainWindowCommon::get_roles_callback, this );
|
|
|
+ redmine->get_roles ( ( Redmine::callback_t ) &MainWindowCommon::get_roles_callback, this );
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -157,7 +98,7 @@ void MainWindowCommon::get_memberships_callback ( QNetworkReply *reply, QJsonDoc
|
|
|
|
|
|
int MainWindowCommon::updateMemberships()
|
|
|
{
|
|
|
- redmine->get_memberships ( ( Redmine::callback_t ) &MainWindowCommon::get_memberships_callback, this );
|
|
|
+ redmine->get_memberships ( ( Redmine::callback_t ) &MainWindowCommon::get_memberships_callback, this );
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -177,7 +118,7 @@ void MainWindowCommon::get_enumerations_callback ( QNetworkReply *reply, QJsonDo
|
|
|
|
|
|
int MainWindowCommon::updateEnumerations()
|
|
|
{
|
|
|
- redmine->get_enumerations ( ( Redmine::callback_t ) &MainWindowCommon::get_enumerations_callback, this );
|
|
|
+ redmine->get_enumerations ( ( Redmine::callback_t ) &MainWindowCommon::get_enumerations_callback, this );
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -210,7 +151,7 @@ QList<QJsonObject> MainWindowCommon::issues_get_byProjectId ( int project_id )
|
|
|
|
|
|
int MainWindowCommon::updateProjects()
|
|
|
{
|
|
|
- redmine->get_projects ( ( Redmine::callback_t ) &MainWindowCommon::get_projects_callback, this );
|
|
|
+ redmine->get_projects ( ( Redmine::callback_t ) &MainWindowCommon::get_projects_callback, this );
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -239,8 +180,110 @@ void MainWindowCommon::get_issues_callback ( QNetworkReply *reply, QJsonDocument
|
|
|
|
|
|
int MainWindowCommon::updateIssues()
|
|
|
{
|
|
|
- redmine->get_issues ( ( Redmine::callback_t ) &MainWindowCommon::get_issues_callback, this, false, "status=*&limit=10000" );
|
|
|
+ redmine->get_issues ( ( Redmine::callback_t ) &MainWindowCommon::get_issues_callback, this, false, "status=*&limit=10000" );
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**** /updateIssues ****/
|
|
|
+
|
|
|
+/**** tray-related stuff ****/
|
|
|
+
|
|
|
+void MainWindowCommon::createTrayIcon()
|
|
|
+{
|
|
|
+ this->trayIconMenu = new QMenu ( this );
|
|
|
+ this->trayIcon = new QSystemTrayIcon ( this );
|
|
|
+ this->trayIcon->setContextMenu ( trayIconMenu );
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindowCommon::setIcon ( EIcon index )
|
|
|
+{
|
|
|
+ //qDebug("icon: %i", index);
|
|
|
+ QIcon icon = this->iconComboBox.itemIcon ( index );
|
|
|
+ this->trayIcon->setIcon ( icon );
|
|
|
+ this->setWindowIcon ( icon );
|
|
|
+ this->trayIcon->setToolTip ( this->iconComboBox.itemText ( index ) );
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindowCommon::createIconComboBox()
|
|
|
+{
|
|
|
+ this->iconComboBox.addItem ( QIcon ( ":/images/good.png" ), tr ( "Просроченных задач нет" ) );
|
|
|
+ this->iconComboBox.addItem ( QIcon ( ":/images/bad.png" ), tr ( "Есть просроченные задачи" ) );
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindowCommon::on_closeLogTimeWindow()
|
|
|
+{
|
|
|
+ this->logTimeWindow = NULL;
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindowCommon::openLogTimeWindow()
|
|
|
+{
|
|
|
+ if (this->logTimeWindow != NULL)
|
|
|
+ delete this->logTimeWindow;
|
|
|
+ this->logTimeWindow = new LogTimeWindow;
|
|
|
+
|
|
|
+ connect ( this->logTimeWindow, SIGNAL ( on_destructor() ), this, SLOT ( on_closeLogTimeWindow() ) );
|
|
|
+
|
|
|
+ this->logTimeWindow->show();
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void MainWindowCommon::on_closeShowTimeWindow()
|
|
|
+{
|
|
|
+ this->showTimeWindow = NULL;
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindowCommon::openShowTimeWindow()
|
|
|
+{
|
|
|
+ if (this->showTimeWindow != NULL)
|
|
|
+ delete this->showTimeWindow;
|
|
|
+ this->showTimeWindow = new ShowTimeWindow;
|
|
|
+
|
|
|
+ connect ( this->showTimeWindow, SIGNAL ( on_destructor() ), this, SLOT ( on_closeShowTimeWindow() ) );
|
|
|
+
|
|
|
+ this->showTimeWindow->show();
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void MainWindowCommon::showOnTop()
|
|
|
+{
|
|
|
+#ifdef Q_OS_WIN32
|
|
|
+ // raise() doesn't work :(
|
|
|
+ Qt::WindowFlags flags_old = this->windowFlags();
|
|
|
+ Qt::WindowFlags flags_ontop = flags_old | Qt::WindowStaysOnTopHint;
|
|
|
+ this->setWindowFlags ( flags_ontop );
|
|
|
+ this->show();
|
|
|
+ this->setWindowFlags ( flags_old );
|
|
|
+ this->show();
|
|
|
+#else
|
|
|
+ this->show();
|
|
|
+ this->raise();
|
|
|
+#endif
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindowCommon::toggleShowHide()
|
|
|
+{
|
|
|
+ if ( this->isVisible() ) {
|
|
|
+ settings.hideOnStart = true;
|
|
|
+ this->hide();
|
|
|
+ } else {
|
|
|
+ settings.hideOnStart = false;
|
|
|
+ this->showOnTop();
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**** /tray-related stuff ****/
|