Skip to content

Commit 494b3dc

Browse files
committed
Исправлен баг, из-за которого при добавлении заметки от буфера обмена, текст был без симвоовы перехода на следующую строку.
В редактор заметки менежера добавлена панель прикрепляемых файлов заметки. Рефакторинг. Signed-off-by: gil9red <gil9red@gmail.com>
1 parent b186887 commit 494b3dc

12 files changed

Lines changed: 287 additions & 119 deletions

File tree

Manager/pages/page_notes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ void Page_Notes::addNoteFromClipboard()
361361
richTextNote->setText( mimeData->html() );
362362

363363
else if ( mimeData->hasText() )
364-
richTextNote->setText( mimeData->text() );
364+
richTextNote->textEditor()->setPlainText( mimeData->text() );
365365

366366
richTextNote->save();
367367
qApp->restoreOverrideCursor();

NavigationPanel/noteeditwidget.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ NoteEditWidget::NoteEditWidget( QWidget * parent ) :
4747
ui->editor->addAction( addSeparator() );
4848
ui->editor->addAction( ui->actionFindAndReplace );
4949
}
50+
51+
52+
ui->properties->setVisible( ui->showProperties->arrowType() == Qt::UpArrow );
53+
54+
QVBoxLayout * propertiesLayout = new QVBoxLayout();
55+
ui->properties->setLayout( propertiesLayout );
56+
57+
attachPanel = new AttachPanel( this );
58+
propertiesLayout->addWidget( attachPanel );
5059
}
5160
NoteEditWidget::~NoteEditWidget()
5261
{
@@ -64,6 +73,7 @@ void NoteEditWidget::setNote( Note * note )
6473
d_note = note;
6574
RichTextNote * richTextNote = d_note->getRichTextNote();
6675
formattingToolbar->setNote( richTextNote );
76+
attachPanel->setNote( richTextNote );
6777

6878
ui->title->setText( richTextNote->title() );
6979
ui->editor->setDocument( richTextNote->document() );
@@ -148,3 +158,19 @@ void NoteEditWidget::titleChange()
148158
RichTextNote * richTextNote = d_note->getRichTextNote();
149159
richTextNote->setTitle( ui->title->text() );
150160
}
161+
void NoteEditWidget::on_showProperties_clicked()
162+
{
163+
Qt::ArrowType arrowType = ui->showProperties->arrowType();
164+
if ( arrowType == Qt::UpArrow )
165+
{
166+
ui->showProperties->setArrowType( Qt::DownArrow );
167+
ui->properties->setVisible( false );
168+
169+
} else if ( arrowType == Qt::DownArrow )
170+
{
171+
ui->showProperties->setArrowType( Qt::UpArrow );
172+
ui->properties->setVisible( true );
173+
174+
} else
175+
ui->showProperties->setArrowType( Qt::NoArrow );
176+
}

NavigationPanel/noteeditwidget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Ui
1212
#include <QByteArray>
1313
#include "FormattingToolbar/FormattingToolbar.h"
1414
#include "FindAndReplace/findandreplace.h"
15+
#include "Note/AttachPanel.h"
1516

1617
class NoteEditWidget : public QMainWindow
1718
{
@@ -34,11 +35,13 @@ class NoteEditWidget : public QMainWindow
3435
private slots:
3536
void noteChange( int event );
3637
void titleChange();
38+
void on_showProperties_clicked();
3739

3840
private:
3941
Ui::NoteEditWidget * ui;
4042
Note * d_note;
4143
FormattingToolbar * formattingToolbar;
44+
AttachPanel * attachPanel;
4245
};
4346

4447
#endif // NOTEEDITWIDGET_H

NavigationPanel/noteeditwidget.ui

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>403</width>
10-
<height>373</height>
9+
<width>494</width>
10+
<height>434</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -28,7 +28,69 @@
2828
<widget class="QWidget" name="centralwidget">
2929
<layout class="QVBoxLayout" name="verticalLayout_2">
3030
<item>
31-
<widget class="QLineEdit" name="title"/>
31+
<widget class="QFrame" name="frame">
32+
<property name="frameShape">
33+
<enum>QFrame::NoFrame</enum>
34+
</property>
35+
<property name="frameShadow">
36+
<enum>QFrame::Raised</enum>
37+
</property>
38+
<layout class="QVBoxLayout" name="verticalLayout">
39+
<property name="spacing">
40+
<number>0</number>
41+
</property>
42+
<property name="leftMargin">
43+
<number>0</number>
44+
</property>
45+
<property name="topMargin">
46+
<number>0</number>
47+
</property>
48+
<property name="rightMargin">
49+
<number>0</number>
50+
</property>
51+
<property name="bottomMargin">
52+
<number>0</number>
53+
</property>
54+
<item>
55+
<layout class="QHBoxLayout" name="horizontalLayout">
56+
<property name="spacing">
57+
<number>0</number>
58+
</property>
59+
<item>
60+
<widget class="QLineEdit" name="title"/>
61+
</item>
62+
<item>
63+
<widget class="QToolButton" name="showProperties">
64+
<property name="toolTip">
65+
<string>Show properties</string>
66+
</property>
67+
<property name="statusTip">
68+
<string>Show properties</string>
69+
</property>
70+
<property name="whatsThis">
71+
<string>Show properties</string>
72+
</property>
73+
<property name="styleSheet">
74+
<string notr="true"/>
75+
</property>
76+
<property name="text">
77+
<string notr="true">...</string>
78+
</property>
79+
<property name="autoRaise">
80+
<bool>true</bool>
81+
</property>
82+
<property name="arrowType">
83+
<enum>Qt::DownArrow</enum>
84+
</property>
85+
</widget>
86+
</item>
87+
</layout>
88+
</item>
89+
<item>
90+
<widget class="QWidget" name="properties" native="true"/>
91+
</item>
92+
</layout>
93+
</widget>
3294
</item>
3395
<item>
3496
<layout class="QVBoxLayout" name="editorLayout">
@@ -51,7 +113,7 @@
51113
<rect>
52114
<x>0</x>
53115
<y>0</y>
54-
<width>403</width>
116+
<width>494</width>
55117
<height>20</height>
56118
</rect>
57119
</property>

Note/AttachPanel.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ AttachPanel::~AttachPanel()
2727
delete ui;
2828
}
2929

30-
void AttachPanel::setViewTo( RichTextNote * n )
30+
void AttachPanel::setNote( RichTextNote * note )
3131
{
32-
if ( note )
32+
if ( this->note )
3333
disconnect( ui->listView->selectionModel(), SIGNAL( selectionChanged(QItemSelection,QItemSelection) ), this, SLOT( updateStates() ) );
3434

35-
if ( !n )
35+
if ( !note )
3636
{
37-
note = 0;
37+
this->note = 0;
3838
model = 0;
3939
ui->listView->setModel( 0 );
4040
updateStates();
4141
return;
4242
}
4343

44-
note = n;
45-
model = &note->attachModel;
44+
this->note = note;
45+
model = &this->note->attachModel;
4646

4747
ui->listView->setModel( model );
4848
QObject::connect( ui->listView->selectionModel(), SIGNAL( selectionChanged(QItemSelection,QItemSelection) ), this, SLOT( updateStates() ) );
@@ -68,32 +68,32 @@ void AttachPanel::updateStates()
6868
{
6969
if ( !note || !model )
7070
{
71-
ui->tButtonRefreshList->setEnabled( false );
72-
ui->tButtonAttach->setEnabled( false );
73-
ui->tButtonRemoveAll->setEnabled( false );
74-
ui->tButtonRemove->setEnabled( false );
75-
ui->tButtonCopyToClipboard->setEnabled( false );
76-
ui->tButtonRun->setEnabled( false );
71+
ui->refreshList->setEnabled( false );
72+
ui->attach->setEnabled( false );
73+
ui->removeAll->setEnabled( false );
74+
ui->remove->setEnabled( false );
75+
ui->copyToClipboard->setEnabled( false );
76+
ui->run->setEnabled( false );
7777
return;
7878
}
7979

80-
ui->tButtonRefreshList->setEnabled( true );
81-
ui->tButtonAttach->setEnabled( true );
80+
ui->refreshList->setEnabled( true );
81+
ui->attach->setEnabled( true );
8282

8383
bool isEmpty = model->rowCount() == 0;
8484
bool hasSelection = ui->listView->selectionModel()->hasSelection();
8585

86-
ui->tButtonRemoveAll->setEnabled( !isEmpty );
87-
ui->tButtonRemove->setEnabled( hasSelection );
88-
ui->tButtonCopyToClipboard->setEnabled( hasSelection );
89-
ui->tButtonRun->setEnabled( hasSelection );
86+
ui->removeAll->setEnabled( !isEmpty );
87+
ui->remove->setEnabled( hasSelection );
88+
ui->copyToClipboard->setEnabled( hasSelection );
89+
ui->run->setEnabled( hasSelection );
9090
}
9191

92-
void AttachPanel::on_tButtonAttach_clicked()
92+
void AttachPanel::on_attach_clicked()
9393
{
9494
note->selectAttach();
9595
}
96-
void AttachPanel::on_tButtonRemove_clicked()
96+
void AttachPanel::on_remove_clicked()
9797
{
9898
QDir dir( note->attachDirPath() );
9999

@@ -112,7 +112,7 @@ void AttachPanel::on_tButtonRemove_clicked()
112112

113113
emit note->changed( EventsNote::ChangeAttach );
114114
}
115-
void AttachPanel::on_tButtonRemoveAll_clicked()
115+
void AttachPanel::on_removeAll_clicked()
116116
{
117117
QDir dir( note->attachDirPath() );
118118

@@ -131,11 +131,11 @@ void AttachPanel::on_tButtonRemoveAll_clicked()
131131
refresh();
132132
emit note->changed( EventsNote::ChangeAttach );
133133
}
134-
void AttachPanel::on_tButtonRefreshList_clicked()
134+
void AttachPanel::on_refreshList_clicked()
135135
{
136136
refresh();
137137
}
138-
void AttachPanel::on_tButtonCopyToClipboard_clicked()
138+
void AttachPanel::on_copyToClipboard_clicked()
139139
{
140140
int row = ui->listView->currentIndex().row();
141141
int col = ui->listView->currentIndex().column();
@@ -148,7 +148,7 @@ void AttachPanel::on_tButtonCopyToClipboard_clicked()
148148
mime->setUrls( urls );
149149
QApplication::clipboard()->setMimeData( mime );
150150
}
151-
void AttachPanel::on_tButtonRun_clicked()
151+
void AttachPanel::on_run_clicked()
152152
{
153153
int row = ui->listView->currentIndex().row();
154154
int col = ui->listView->currentIndex().column();

Note/AttachPanel.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AttachPanel: public QWidget
2323

2424
//! Отображение и управление прикрепленными файлами заметки n.
2525
/*! После добавления указателя к заметке, панель будет связана с заметкой. */
26-
void setViewTo( RichTextNote * n );
26+
void setNote(RichTextNote * note );
2727

2828
public slots:
2929
//! Обновление списка панели.
@@ -33,12 +33,12 @@ private slots:
3333
//! Обновление состояния панели.
3434
void updateStates();
3535

36-
void on_tButtonAttach_clicked(); //!< Прикрепить файл.
37-
void on_tButtonRemove_clicked(); //!< Удалить файл.
38-
void on_tButtonRemoveAll_clicked(); //!< Очистить список.
39-
void on_tButtonRefreshList_clicked(); //!< Обновить список.
40-
void on_tButtonCopyToClipboard_clicked(); //!< Копировать файл в буфер обмена.
41-
void on_tButtonRun_clicked(); //!< Запустить файл.
36+
void on_attach_clicked(); //!< Прикрепить файл.
37+
void on_remove_clicked(); //!< Удалить файл.
38+
void on_removeAll_clicked(); //!< Очистить список.
39+
void on_refreshList_clicked(); //!< Обновить список.
40+
void on_copyToClipboard_clicked(); //!< Копировать файл в буфер обмена.
41+
void on_run_clicked(); //!< Запустить файл.
4242

4343
private:
4444
Ui::AttachPanel * ui; //!< Форма UI.

0 commit comments

Comments
 (0)