Merge pull request #14 from defnax/store-column-tree

Added default column width for file name & store the column state & width
This commit is contained in:
csoler 2020-06-17 20:29:00 +02:00 committed by GitHub
commit 68c3f51f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 102 additions and 74 deletions

View File

@ -266,7 +266,12 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
connect(ui->postsTree,SIGNAL(sizeChanged(QSize)),this,SLOT(handlePostsTreeSizeChange(QSize)));
//ui->nameLabel->setMinimumWidth(20);
/* Set initial section sizes */
QHeaderView * channelpostfilesheader = ui->channelPostFiles_TV->header () ;
QHeaderView * channelfilesheader = ui->channelFiles_TV->header () ;
channelpostfilesheader->resizeSection (RsGxsChannelPostFilesModel::COLUMN_FILES_NAME, fm.width("RetroShare-v0.6.5-1487-g6714648e5-Windows-x64-portable-20200518-Qt-5.14.2.7z")*1.5);
channelfilesheader->resizeSection (RsGxsChannelPostFilesModel::COLUMN_FILES_NAME, fm.width("RetroShare-v0.6.5-1487-g6714648e5-Windows-x64-portable-20200518-Qt-5.14.2.7z")*1.5);
/* Initialize feed widget */
//ui->feedWidget->setSortRole(ROLE_PUBLISH, Qt::DescendingOrder);
@ -421,8 +426,8 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
ui->postTime_LB->setText(QDateTime::fromMSecsSinceEpoch(post.mMeta.mPublishTs*1000).toString("MM/dd/yyyy, hh:mm"));
ui->postTime_LB->setFixedWidth(W);
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE);
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE);
//ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE);
//ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE);
ui->channelPostFiles_TV->setAutoSelect(true);
// Now also set the post as read
@ -484,8 +489,8 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
mChannelPostsModel->getFilesList(files);
mChannelFilesModel->setFiles(files);
ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE);
ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE);
//ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE);
//ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE);
ui->channelFiles_TV->setAutoSelect(true);
@ -536,6 +541,9 @@ GxsChannelPostsWidgetWithModel::~GxsChannelPostsWidgetWithModel()
void GxsChannelPostsWidgetWithModel::processSettings(bool load)
{
QHeaderView *channelpostfilesheader = ui->channelPostFiles_TV->header () ;
QHeaderView *channelfilesheader = ui->channelFiles_TV->header () ;
Settings->beginGroup(QString("ChannelPostsWidget"));
if (load) {
@ -548,6 +556,10 @@ void GxsChannelPostsWidgetWithModel::processSettings(bool load)
/* View mode */
//setViewMode(Settings->value("viewMode", VIEW_MODE_FEEDS).toInt());
#endif
// state of files tree
channelpostfilesheader->restoreState(Settings->value("PostFilesTree").toByteArray());
channelfilesheader->restoreState(Settings->value("FilesTree").toByteArray());
// state of splitter
ui->splitter->restoreState(Settings->value("SplitterChannelPosts").toByteArray());
} else {
@ -560,6 +572,10 @@ void GxsChannelPostsWidgetWithModel::processSettings(bool load)
/* View mode */
//Settings->setValue("viewMode", viewMode());
#endif
// state of files tree
Settings->setValue("PostFilesTree", channelpostfilesheader->saveState());
Settings->setValue("FilesTree", channelfilesheader->saveState());
// state of splitter
Settings->setValue("SplitterChannelPosts", ui->splitter->saveState());
}
@ -939,10 +955,18 @@ void GxsChannelPostsWidgetWithModel::blank()
ui->postButton->setEnabled(false);
ui->subscribeToolButton->setEnabled(false);
mChannelPostsModel->clear();
groupNameChanged(QString());
ui->channelName_LB->setText(tr("No Channel Selected"));
ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channels.png"));
ui->infoPosts->setText("");
ui->infoLastPost->setText("");
ui->infoAdministrator->setText("");
ui->infoDistribution->setText("");
ui->infoCreated->setText("");
ui->infoDescription->setText("");
mChannelPostsModel->clear();
groupNameChanged(QString());
//ui->infoWidget->hide();
}
bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId &msgId)

View File

@ -161,7 +161,7 @@
<item>
<widget class="QTabWidget" name="channel_TW">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
@ -199,25 +199,8 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="3">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="infoDistribution">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="label_2">
<item row="3" column="1" colspan="2">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
@ -225,33 +208,14 @@
</font>
</property>
<property name="text">
<string>Created:</string>
<string>Distribution:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="infoCreated">
<item row="1" column="3">
<widget class="QLabel" name="infoLastPost">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="infoPostsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Posts:</string>
<string notr="true">unknown</string>
</property>
</widget>
</item>
@ -268,21 +232,8 @@
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QLabel" name="infoPosts">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="infoLastPostLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
@ -290,14 +241,31 @@
</font>
</property>
<property name="text">
<string>Last Post:</string>
<string>Created:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="infoLastPost">
<item row="3" column="3">
<widget class="QLabel" name="infoDistribution">
<property name="text">
<string notr="true">unknown</string>
<string>unknown</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="infoPosts">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
@ -314,8 +282,21 @@
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLabel" name="label_3">
<item row="4" column="3">
<widget class="QLabel" name="infoCreated">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLabel" name="infoPostsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
@ -323,7 +304,26 @@
</font>
</property>
<property name="text">
<string>Distribution:</string>
<string>Posts:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="infoLastPostLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Last Post:</string>
</property>
</widget>
</item>
@ -466,7 +466,11 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item>
<widget class="QTextEdit" name="postDetails_TE"/>
<widget class="QTextBrowser" name="postDetails_TE">
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>