Skip to content

Commit

Permalink
Исправлен баг, из-за которого при добавлении заметки от буфера обмена…
Browse files Browse the repository at this point in the history
…, текст был без симвоовы перехода на следующую строку.

В редактор заметки менежера добавлена панель прикрепляемых файлов заметки.
Рефакторинг.

Signed-off-by: gil9red <[email protected]>
  • Loading branch information
gil9red committed Jun 6, 2014
1 parent b186887 commit 494b3dc
Show file tree
Hide file tree
Showing 12 changed files with 287 additions and 119 deletions.
2 changes: 1 addition & 1 deletion Manager/pages/page_notes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void Page_Notes::addNoteFromClipboard()
richTextNote->setText( mimeData->html() );

else if ( mimeData->hasText() )
richTextNote->setText( mimeData->text() );
richTextNote->textEditor()->setPlainText( mimeData->text() );

richTextNote->save();
qApp->restoreOverrideCursor();
Expand Down
26 changes: 26 additions & 0 deletions NavigationPanel/noteeditwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ NoteEditWidget::NoteEditWidget( QWidget * parent ) :
ui->editor->addAction( addSeparator() );
ui->editor->addAction( ui->actionFindAndReplace );
}


ui->properties->setVisible( ui->showProperties->arrowType() == Qt::UpArrow );

QVBoxLayout * propertiesLayout = new QVBoxLayout();
ui->properties->setLayout( propertiesLayout );

attachPanel = new AttachPanel( this );
propertiesLayout->addWidget( attachPanel );
}
NoteEditWidget::~NoteEditWidget()
{
Expand All @@ -64,6 +73,7 @@ void NoteEditWidget::setNote( Note * note )
d_note = note;
RichTextNote * richTextNote = d_note->getRichTextNote();
formattingToolbar->setNote( richTextNote );
attachPanel->setNote( richTextNote );

ui->title->setText( richTextNote->title() );
ui->editor->setDocument( richTextNote->document() );
Expand Down Expand Up @@ -148,3 +158,19 @@ void NoteEditWidget::titleChange()
RichTextNote * richTextNote = d_note->getRichTextNote();
richTextNote->setTitle( ui->title->text() );
}
void NoteEditWidget::on_showProperties_clicked()
{
Qt::ArrowType arrowType = ui->showProperties->arrowType();
if ( arrowType == Qt::UpArrow )
{
ui->showProperties->setArrowType( Qt::DownArrow );
ui->properties->setVisible( false );

} else if ( arrowType == Qt::DownArrow )
{
ui->showProperties->setArrowType( Qt::UpArrow );
ui->properties->setVisible( true );

} else
ui->showProperties->setArrowType( Qt::NoArrow );
}
3 changes: 3 additions & 0 deletions NavigationPanel/noteeditwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Ui
#include <QByteArray>
#include "FormattingToolbar/FormattingToolbar.h"
#include "FindAndReplace/findandreplace.h"
#include "Note/AttachPanel.h"

class NoteEditWidget : public QMainWindow
{
Expand All @@ -34,11 +35,13 @@ class NoteEditWidget : public QMainWindow
private slots:
void noteChange( int event );
void titleChange();
void on_showProperties_clicked();

private:
Ui::NoteEditWidget * ui;
Note * d_note;
FormattingToolbar * formattingToolbar;
AttachPanel * attachPanel;
};

#endif // NOTEEDITWIDGET_H
70 changes: 66 additions & 4 deletions NavigationPanel/noteeditwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>403</width>
<height>373</height>
<width>494</width>
<height>434</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -28,7 +28,69 @@
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="title"/>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="title"/>
</item>
<item>
<widget class="QToolButton" name="showProperties">
<property name="toolTip">
<string>Show properties</string>
</property>
<property name="statusTip">
<string>Show properties</string>
</property>
<property name="whatsThis">
<string>Show properties</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<property name="arrowType">
<enum>Qt::DownArrow</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="properties" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="editorLayout">
Expand All @@ -51,7 +113,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>403</width>
<width>494</width>
<height>20</height>
</rect>
</property>
Expand Down
48 changes: 24 additions & 24 deletions Note/AttachPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ AttachPanel::~AttachPanel()
delete ui;
}

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

if ( !n )
if ( !note )
{
note = 0;
this->note = 0;
model = 0;
ui->listView->setModel( 0 );
updateStates();
return;
}

note = n;
model = &note->attachModel;
this->note = note;
model = &this->note->attachModel;

ui->listView->setModel( model );
QObject::connect( ui->listView->selectionModel(), SIGNAL( selectionChanged(QItemSelection,QItemSelection) ), this, SLOT( updateStates() ) );
Expand All @@ -68,32 +68,32 @@ void AttachPanel::updateStates()
{
if ( !note || !model )
{
ui->tButtonRefreshList->setEnabled( false );
ui->tButtonAttach->setEnabled( false );
ui->tButtonRemoveAll->setEnabled( false );
ui->tButtonRemove->setEnabled( false );
ui->tButtonCopyToClipboard->setEnabled( false );
ui->tButtonRun->setEnabled( false );
ui->refreshList->setEnabled( false );
ui->attach->setEnabled( false );
ui->removeAll->setEnabled( false );
ui->remove->setEnabled( false );
ui->copyToClipboard->setEnabled( false );
ui->run->setEnabled( false );
return;
}

ui->tButtonRefreshList->setEnabled( true );
ui->tButtonAttach->setEnabled( true );
ui->refreshList->setEnabled( true );
ui->attach->setEnabled( true );

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

ui->tButtonRemoveAll->setEnabled( !isEmpty );
ui->tButtonRemove->setEnabled( hasSelection );
ui->tButtonCopyToClipboard->setEnabled( hasSelection );
ui->tButtonRun->setEnabled( hasSelection );
ui->removeAll->setEnabled( !isEmpty );
ui->remove->setEnabled( hasSelection );
ui->copyToClipboard->setEnabled( hasSelection );
ui->run->setEnabled( hasSelection );
}

void AttachPanel::on_tButtonAttach_clicked()
void AttachPanel::on_attach_clicked()
{
note->selectAttach();
}
void AttachPanel::on_tButtonRemove_clicked()
void AttachPanel::on_remove_clicked()
{
QDir dir( note->attachDirPath() );

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

emit note->changed( EventsNote::ChangeAttach );
}
void AttachPanel::on_tButtonRemoveAll_clicked()
void AttachPanel::on_removeAll_clicked()
{
QDir dir( note->attachDirPath() );

Expand All @@ -131,11 +131,11 @@ void AttachPanel::on_tButtonRemoveAll_clicked()
refresh();
emit note->changed( EventsNote::ChangeAttach );
}
void AttachPanel::on_tButtonRefreshList_clicked()
void AttachPanel::on_refreshList_clicked()
{
refresh();
}
void AttachPanel::on_tButtonCopyToClipboard_clicked()
void AttachPanel::on_copyToClipboard_clicked()
{
int row = ui->listView->currentIndex().row();
int col = ui->listView->currentIndex().column();
Expand All @@ -148,7 +148,7 @@ void AttachPanel::on_tButtonCopyToClipboard_clicked()
mime->setUrls( urls );
QApplication::clipboard()->setMimeData( mime );
}
void AttachPanel::on_tButtonRun_clicked()
void AttachPanel::on_run_clicked()
{
int row = ui->listView->currentIndex().row();
int col = ui->listView->currentIndex().column();
Expand Down
14 changes: 7 additions & 7 deletions Note/AttachPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AttachPanel: public QWidget

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

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

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

private:
Ui::AttachPanel * ui; //!< Форма UI.
Expand Down
Loading

0 comments on commit 494b3dc

Please sign in to comment.