Skip to content

Добавил отображение id записи и имени каталога в диалоге свойств записи #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: experimental
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions app/bin/resource/translations/mytetra_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1683,22 +1683,32 @@ Try to search for entire database.</source>
<context>
<name>InfoFieldEnter</name>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="28"/>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="32"/>
<source>Id</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="40"/>
<source>Directory name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="48"/>
<source>Title</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="34"/>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="54"/>
<source>Author(s)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="39"/>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="59"/>
<source>Url</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="44"/>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="64"/>
<source>Tags</source>
<translation type="unfinished"></translation>
</message>
Expand Down
18 changes: 14 additions & 4 deletions app/bin/resource/translations/mytetra_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2365,22 +2365,32 @@ Try to search for entire database.</source>
<context>
<name>InfoFieldEnter</name>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="28"/>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="32"/>
<source>Id</source>
<translation>ID</translation>
</message>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="40"/>
<source>Directory name</source>
<translation>Имя директории</translation>
</message>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="48"/>
<source>Title</source>
<translation>Название</translation>
</message>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="34"/>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="54"/>
<source>Author(s)</source>
<translation>Автор</translation>
</message>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="39"/>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="59"/>
<source>Url</source>
<translation></translation>
</message>
<message>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="44"/>
<location filename="../../../src/views/record/InfoFieldEnter.cpp" line="64"/>
<source>Tags</source>
<translation>Метки</translation>
</message>
Expand Down
10 changes: 6 additions & 4 deletions app/src/controllers/recordTable/RecordTableController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,12 @@ void RecordTableController::editFieldContext(QModelIndex proxyIndex)
RecordTableData *table=recordSourceModel->getTableData();

// Поля окна заполняются начальными значениями
editRecordWin.setField("name", table->getField("name", pos) );
editRecordWin.setField("author",table->getField("author", pos) );
editRecordWin.setField("url", table->getField("url", pos) );
editRecordWin.setField("tags", table->getField("tags", pos) );
editRecordWin.setField("id", table->getField("id", pos) );
editRecordWin.setField("dir", table->getField("dir", pos) );
editRecordWin.setField("name", table->getField("name", pos) );
editRecordWin.setField("author", table->getField("author", pos) );
editRecordWin.setField("url", table->getField("url", pos) );
editRecordWin.setField("tags", table->getField("tags", pos) );

// Если запись заблокирована
if(table->getField("block", pos)=="1")
Expand Down
3 changes: 3 additions & 0 deletions app/src/views/record/AddNewRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ void AddNewRecord::setupUI(void)
{
this->setWindowTitle(tr("Enter a new note"));

// Виджет ввода инфополей
infoField.setDisplayOnlyEditableFields(true);

// Редактор текста записи
recordTextEditor.initEnableAssembly(true);
recordTextEditor.initConfigFileName(globalParameters.getWorkDirectory()+"/editorconf.ini");
Expand Down
59 changes: 58 additions & 1 deletion app/src/views/record/InfoFieldEnter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ InfoFieldEnter::~InfoFieldEnter()

void InfoFieldEnter::setup_ui(void)
{
QPalette bgPalette = this->palette();
bgPalette.setColor(QPalette::Base, bgPalette.color(QPalette::Background));

// Элементы для отображения id записи
recordIdLabel=new QLabel(this);
recordIdLabel->setText(tr("Id"));
recordId=new QLineEdit(this);
recordId->setMinimumWidth(500);
recordId->setReadOnly(true);
recordId->setPalette(bgPalette);

// Элементы для отображения названия каталога
dirNameLabel=new QLabel(this);
dirNameLabel->setText(tr("Directory name"));
dirName=new QLineEdit(this);
dirName->setMinimumWidth(500);
dirName->setReadOnly(true);
dirName->setPalette(bgPalette);

// Элементы для запроса названия записи
recordNameLabel=new QLabel(this);
recordNameLabel->setText(tr("Title"));
Expand Down Expand Up @@ -67,6 +86,8 @@ void InfoFieldEnter::setup_ui(void)
expandInfo->setIcon(QIcon(":/resource/pic/triangl_up.svg"));
// expandInfo->setIcon(this->style()->standardIcon(QStyle::SP_ArrowUp));
}

updateReadOnlyFieldsVisibility();
}


Expand Down Expand Up @@ -100,6 +121,12 @@ void InfoFieldEnter::assembly(void)
infoFieldLayout->addWidget(recordTagsLabel,++y,0);
infoFieldLayout->addWidget(recordTags,y,1);

infoFieldLayout->addWidget(recordIdLabel,++y,0);
infoFieldLayout->addWidget(recordId,y,1);

infoFieldLayout->addWidget(dirNameLabel,++y,0);
infoFieldLayout->addWidget(dirName,y,1);

// Устанавливается видимость или невидимость полей author, url, tags...
expandInfoOnDisplay( mytetraConfig.get_addnewrecord_expand_info() );

Expand Down Expand Up @@ -133,6 +160,13 @@ void InfoFieldEnter::expandInfoOnDisplay(QString expand)

recordTagsLabel->setVisible(i);
recordTags->setVisible(i);

bool isDisplayReadOnlyFields = i && !isDisplayOnlyEditableFields;
recordIdLabel->setVisible(isDisplayReadOnlyFields);
recordId->setVisible(isDisplayReadOnlyFields);

dirNameLabel->setVisible(isDisplayReadOnlyFields);
dirName->setVisible(isDisplayReadOnlyFields);
}


Expand Down Expand Up @@ -171,7 +205,9 @@ bool InfoFieldEnter::checkFieldName(QString name)
if(name=="name" ||
name=="author" ||
name=="url" ||
name=="tags")
name=="tags" ||
name=="id" ||
name=="dir")
return true;
else
return false;
Expand All @@ -198,6 +234,8 @@ void InfoFieldEnter::setField(QString name,QString value)
{
if(checkFieldName(name))
{
if(name=="id") recordId->setText(value);
if(name=="dir") dirName->setText(value);
if(name=="name") recordName->setText(value);
if(name=="author")recordAuthor->setText(value);
if(name=="url") recordUrl->setText(value);
Expand All @@ -221,3 +259,22 @@ bool InfoFieldEnter::isReadOnly()
{
return recordName->isReadOnly();
}


void InfoFieldEnter::setDisplayOnlyEditableFields(bool value)
{
isDisplayOnlyEditableFields = value;

updateReadOnlyFieldsVisibility();
}

void InfoFieldEnter::updateReadOnlyFieldsVisibility()
{
bool isVisible = !isDisplayOnlyEditableFields;

recordIdLabel->setVisible(isVisible);
recordId->setVisible(isVisible);

dirNameLabel->setVisible(isVisible);
dirName->setVisible(isVisible);
}
13 changes: 13 additions & 0 deletions app/src/views/record/InfoFieldEnter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,24 @@ class InfoFieldEnter : public QWidget
void setReadOnly(bool state);
bool isReadOnly();

void setDisplayOnlyEditableFields(bool value);

public slots:

void expandInfoClick(void);

private:

bool isDisplayOnlyEditableFields;

// Id записи
QLabel *recordIdLabel;
QLineEdit *recordId;

// Название каталога
QLabel *dirNameLabel;
QLineEdit *dirName;

// Ввод названия записи
QLabel *recordNameLabel;
QLineEdit *recordName;
Expand Down Expand Up @@ -63,6 +75,7 @@ public slots:
void assembly(void);

void expandInfoOnDisplay(QString expand);
void updateReadOnlyFieldsVisibility();

};

Expand Down