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))); 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 */ /* Initialize feed widget */
//ui->feedWidget->setSortRole(ROLE_PUBLISH, Qt::DescendingOrder); //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->setText(QDateTime::fromMSecsSinceEpoch(post.mMeta.mPublishTs*1000).toString("MM/dd/yyyy, hh:mm"));
ui->postTime_LB->setFixedWidth(W); ui->postTime_LB->setFixedWidth(W);
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE); //ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE);
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE); //ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE);
ui->channelPostFiles_TV->setAutoSelect(true); ui->channelPostFiles_TV->setAutoSelect(true);
// Now also set the post as read // Now also set the post as read
@ -484,8 +489,8 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
mChannelPostsModel->getFilesList(files); mChannelPostsModel->getFilesList(files);
mChannelFilesModel->setFiles(files); mChannelFilesModel->setFiles(files);
ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE); //ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE);
ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE); //ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE);
ui->channelFiles_TV->setAutoSelect(true); ui->channelFiles_TV->setAutoSelect(true);
@ -536,6 +541,9 @@ GxsChannelPostsWidgetWithModel::~GxsChannelPostsWidgetWithModel()
void GxsChannelPostsWidgetWithModel::processSettings(bool load) void GxsChannelPostsWidgetWithModel::processSettings(bool load)
{ {
QHeaderView *channelpostfilesheader = ui->channelPostFiles_TV->header () ;
QHeaderView *channelfilesheader = ui->channelFiles_TV->header () ;
Settings->beginGroup(QString("ChannelPostsWidget")); Settings->beginGroup(QString("ChannelPostsWidget"));
if (load) { if (load) {
@ -548,6 +556,10 @@ void GxsChannelPostsWidgetWithModel::processSettings(bool load)
/* View mode */ /* View mode */
//setViewMode(Settings->value("viewMode", VIEW_MODE_FEEDS).toInt()); //setViewMode(Settings->value("viewMode", VIEW_MODE_FEEDS).toInt());
#endif #endif
// state of files tree
channelpostfilesheader->restoreState(Settings->value("PostFilesTree").toByteArray());
channelfilesheader->restoreState(Settings->value("FilesTree").toByteArray());
// state of splitter // state of splitter
ui->splitter->restoreState(Settings->value("SplitterChannelPosts").toByteArray()); ui->splitter->restoreState(Settings->value("SplitterChannelPosts").toByteArray());
} else { } else {
@ -560,6 +572,10 @@ void GxsChannelPostsWidgetWithModel::processSettings(bool load)
/* View mode */ /* View mode */
//Settings->setValue("viewMode", viewMode()); //Settings->setValue("viewMode", viewMode());
#endif #endif
// state of files tree
Settings->setValue("PostFilesTree", channelpostfilesheader->saveState());
Settings->setValue("FilesTree", channelfilesheader->saveState());
// state of splitter // state of splitter
Settings->setValue("SplitterChannelPosts", ui->splitter->saveState()); Settings->setValue("SplitterChannelPosts", ui->splitter->saveState());
} }
@ -939,10 +955,18 @@ void GxsChannelPostsWidgetWithModel::blank()
ui->postButton->setEnabled(false); ui->postButton->setEnabled(false);
ui->subscribeToolButton->setEnabled(false); ui->subscribeToolButton->setEnabled(false);
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(); mChannelPostsModel->clear();
groupNameChanged(QString()); groupNameChanged(QString());
//ui->infoWidget->hide();
} }
bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId &msgId) bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId &msgId)

View File

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