Просмотр исходного кода

More improvements to the logtime window

Dmitry Yu Okunev лет назад: 7
Родитель
Сommit
e815785bdd
4 измененных файлов с 48 добавлено и 2 удалено
  1. 31 0
      logtimewindow.cpp
  2. 5 0
      logtimewindow.h
  3. 9 2
      myqlineedit.cpp
  4. 3 0
      myqlineedit.h

+ 31 - 0
logtimewindow.cpp

@@ -36,11 +36,16 @@ LogTimeWindow::LogTimeWindow ( QWidget *parent ) :
 	this->updateProjects();
 	this->ui->issue->setSortingEnabled ( true );
 	this->ui->issue->sortByColumn ( 0, Qt::AscendingOrder );
+
+	this->continousLoggingTimer = new QTimer(this);
+
+	connect ( this->continousLoggingTimer, SIGNAL(timeout()), this, SLOT(updateUntilTime()) );
 }
 
 LogTimeWindow::~LogTimeWindow()
 {
 	this->on_destructor();
+	delete this->continousLoggingTimer;
 	delete ui;
 }
 
@@ -386,9 +391,13 @@ void LogTimeWindow::on_continousLoggingStartButton_clicked()
 {
 	this->ui->continousLoggingStartButton->setEnabled(false);
 
+	this->continousLoggingTimer->start(1000);
+
 	QDateTime now = QDateTime::currentDateTime();
 	this->ui->sinceInput->setDateTime(now);
 
+
+
 	this->ui->continousLoggingStopButton->setEnabled(true);
 }
 
@@ -398,6 +407,8 @@ void LogTimeWindow::on_continousLoggingStopButton_clicked()
 
 	this->ui->continousLoggingStopButton->setEnabled(false);
 	this->saveCurrentEntry();
+
+	this->continousLoggingTimer->stop();
 	this->ui->continousLoggingStartButton->setEnabled(true);
 }
 
@@ -413,7 +424,27 @@ void LogTimeWindow::on_issue_currentItemChanged(QTreeWidgetItem *current, QTreeW
 
 void LogTimeWindow::on_comment_textEdited(const QString &arg1)
 {
+	Q_UNUSED(arg1)
+}
+
+void LogTimeWindow::on_comment_textChanged(const QString &arg1)
+{
+	Q_UNUSED(arg1)
+	if (!this->ui->comment->isEnabled()) {
+		return;
+	}
+
 	if (this->ui->continousLoggingStopButton->isEnabled()) {
+		this->ui->comment->setEnabled(false);
+		this->ui->comment->undo();
 		this->saveCurrentEntry();
+		this->ui->comment->redo();
+		this->ui->comment->setEnabled(true);
 	}
 }
+
+void LogTimeWindow::updateUntilTime()
+{
+	QDateTime now = QDateTime::currentDateTime();
+	this->ui->untilInput->setDateTime(now);
+}

+ 5 - 0
logtimewindow.h

@@ -61,6 +61,10 @@ private slots:
 	void on_comment_textEdited(const QString &arg1);
 
 
+	void on_comment_textChanged(const QString &arg1);
+
+	void updateUntilTime();
+
 private:
 	int updateLastLogTime();
 	void get_time_entries_callback ( QNetworkReply *reply, QJsonDocument *json, void *arg );
@@ -83,6 +87,7 @@ private:
 	QMutex projectsDisplayExceptionMutex;
 
 	QTimer projectsDisplayRetryTimer;
+	QTimer *continousLoggingTimer;
 
 	QHash<int, int> selected_issues_id;
 	RedmineClass_TimeEntry timeEntry;

+ 9 - 2
myqlineedit.cpp

@@ -3,14 +3,16 @@
 
 MyQLineEdit::MyQLineEdit(QWidget *parent) : QLineEdit(parent)
 {
-	_selectOnMousePress = false;
+	this->_selectOnMousePress = false;
+	//this->_textBeforeEdit = "";
 }
 
 void MyQLineEdit::focusInEvent(QFocusEvent *e)
 {
 	QLineEdit::focusInEvent(e);
 	selectAll();
-	_selectOnMousePress = true;
+	this->_selectOnMousePress = true;
+	//this->_textBeforeEdit = this->text();
 }
 
 void MyQLineEdit::mousePressEvent(QMouseEvent *me)
@@ -21,3 +23,8 @@ void MyQLineEdit::mousePressEvent(QMouseEvent *me)
 		_selectOnMousePress = false;
 	}
 }
+
+/*QString MyQLineEdit::textBeforeEdit()
+{
+	return this->_textBeforeEdit;
+}*/

+ 3 - 0
myqlineedit.h

@@ -10,11 +10,14 @@ public:
 	MyQLineEdit(QWidget *parent);
 	virtual ~MyQLineEdit() {}
 
+	//QString textBeforeEdit();
+
 protected:
 	void focusInEvent(QFocusEvent *e);
 	void mousePressEvent(QMouseEvent *me);
 
 	bool _selectOnMousePress;
+	//QString _textBeforeEdit;
 };
 
 #endif // MYQLINEEDIT_H