mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #1253 from PhenomRetroShare/Add_LastPostColInGroupTreeWidget
Add Last Post Column in GroupTreeWidget.
This commit is contained in:
commit
6d67936026
@ -43,7 +43,8 @@
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_UNREAD 1
|
||||
#define COLUMN_POPULARITY 2
|
||||
#define COLUMN_COUNT 3
|
||||
#define COLUMN_LAST_POST 3
|
||||
#define COLUMN_COUNT 4
|
||||
#define COLUMN_DATA COLUMN_NAME
|
||||
|
||||
#define ROLE_ID Qt::UserRole
|
||||
@ -100,9 +101,12 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
|
||||
|
||||
/* Initialize tree widget */
|
||||
ui->treeWidget->setColumnCount(COLUMN_COUNT);
|
||||
ui->treeWidget->enableColumnCustomize(true);
|
||||
ui->treeWidget->setColumnCustomizable(COLUMN_NAME, false);
|
||||
|
||||
int S = QFontMetricsF(font()).height() ;
|
||||
int W = QFontMetricsF(font()).width("999") ;
|
||||
int D = QFontMetricsF(font()).width("9999-99-99[]") ;
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView *header = ui->treeWidget->header ();
|
||||
@ -113,6 +117,15 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
|
||||
header->resizeSection(COLUMN_UNREAD, W+4) ;
|
||||
QHeaderView_setSectionResizeModeColumn(header, COLUMN_POPULARITY, QHeaderView::Fixed);
|
||||
header->resizeSection(COLUMN_POPULARITY, 2*S) ;
|
||||
QHeaderView_setSectionResizeModeColumn(header, COLUMN_LAST_POST, QHeaderView::Fixed);
|
||||
header->resizeSection(COLUMN_LAST_POST, D+4) ;
|
||||
header->setSectionHidden(COLUMN_LAST_POST, true);
|
||||
|
||||
QTreeWidgetItem *headerItem = ui->treeWidget->headerItem();
|
||||
headerItem->setText(COLUMN_NAME, tr("Name"));
|
||||
headerItem->setText(COLUMN_UNREAD, tr("Unread"));
|
||||
headerItem->setText(COLUMN_POPULARITY, tr("Popularity"));
|
||||
headerItem->setText(COLUMN_LAST_POST, tr("Last Post"));
|
||||
|
||||
/* add filter actions */
|
||||
ui->filterLineEdit->addFilter(QIcon(), tr("Title"), FILTER_NAME_INDEX , tr("Search Title"));
|
||||
@ -192,9 +205,10 @@ void GroupTreeWidget::addToolButton(QToolButton *toolButton)
|
||||
ui->titleBarFrame->layout()->addWidget(toolButton);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::processSettings(RshareSettings *settings, bool load)
|
||||
// Load and save settings (group must be started from the caller)
|
||||
void GroupTreeWidget::processSettings(bool load)
|
||||
{
|
||||
if (settings == NULL) {
|
||||
if (Settings == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -204,16 +218,18 @@ void GroupTreeWidget::processSettings(RshareSettings *settings, bool load)
|
||||
const int SORTBY_POSTS = 4;
|
||||
const int SORTBY_UNREAD = 5;
|
||||
|
||||
ui->treeWidget->processSettings(load);
|
||||
|
||||
if (load) {
|
||||
// load settings
|
||||
// load Settings
|
||||
|
||||
// state of order
|
||||
bool ascSort = settings->value("GroupAscSort", true).toBool();
|
||||
bool ascSort = Settings->value("GroupAscSort", true).toBool();
|
||||
actionSortAscending->setChecked(ascSort);
|
||||
actionSortDescending->setChecked(!ascSort);
|
||||
|
||||
// state of sort
|
||||
int sortby = settings->value("GroupSortBy").toInt();
|
||||
int sortby = Settings->value("GroupSortBy").toInt();
|
||||
switch (sortby) {
|
||||
case SORTBY_NAME:
|
||||
if (actionSortByName) {
|
||||
@ -242,10 +258,10 @@ void GroupTreeWidget::processSettings(RshareSettings *settings, bool load)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// save settings
|
||||
// save Settings
|
||||
|
||||
// state of order
|
||||
settings->setValue("GroupAscSort", !(actionSortDescending && actionSortDescending->isChecked())); //True by default
|
||||
Settings->setValue("GroupAscSort", !(actionSortDescending && actionSortDescending->isChecked())); //True by default
|
||||
|
||||
// state of sort
|
||||
int sortby = SORTBY_NAME;
|
||||
@ -260,7 +276,7 @@ void GroupTreeWidget::processSettings(RshareSettings *settings, bool load)
|
||||
} else if (actionSortByUnread && actionSortByUnread->isChecked()) {
|
||||
sortby = SORTBY_UNREAD;
|
||||
}
|
||||
settings->setValue("GroupSortBy", sortby);
|
||||
Settings->setValue("GroupSortBy", sortby);
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,6 +469,11 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
||||
/* Set last post */
|
||||
qlonglong lastPost = itemInfo.lastpost.toTime_t();
|
||||
item->setData(COLUMN_DATA, ROLE_LASTPOST, -lastPost); // negative for correct sorting
|
||||
if(itemInfo.lastpost == QDateTime::fromTime_t(0))
|
||||
item->setText(COLUMN_LAST_POST, tr("Never"));
|
||||
else
|
||||
item->setText(COLUMN_LAST_POST, itemInfo.lastpost.toString(Qt::ISODate).replace("T"," "));
|
||||
|
||||
|
||||
/* Set visible posts */
|
||||
item->setData(COLUMN_DATA, ROLE_POSTS, -itemInfo.max_visible_posts);// negative for correct sorting
|
||||
|
@ -77,8 +77,8 @@ public:
|
||||
// Add a tool button to the tool area
|
||||
void addToolButton(QToolButton *toolButton);
|
||||
|
||||
// Load and save settings (group must be startet from the caller)
|
||||
void processSettings(RshareSettings *settings, bool load);
|
||||
// Load and save settings (group must be started from the caller)
|
||||
void processSettings(bool load);
|
||||
|
||||
// Add a new category item
|
||||
QTreeWidgetItem *addCategoryItem(const QString &name, const QIcon &icon, bool expand);
|
||||
|
@ -194,7 +194,7 @@ void GxsGroupFrameDialog::processSettings(bool load)
|
||||
Settings->setValue("Splitter", ui->splitter->saveState());
|
||||
}
|
||||
|
||||
ui->groupTreeWidget->processSettings(Settings, load);
|
||||
ui->groupTreeWidget->processSettings(load);
|
||||
|
||||
Settings->endGroup();
|
||||
}
|
||||
@ -253,8 +253,11 @@ void GxsGroupFrameDialog::todo()
|
||||
|
||||
void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
|
||||
{
|
||||
QMenu contextMnu(this);
|
||||
|
||||
QString id = ui->groupTreeWidget->itemIdAt(point);
|
||||
if (id.isEmpty()) return;
|
||||
if (!id.isEmpty())
|
||||
{
|
||||
|
||||
mGroupId = RsGxsGroupId(id.toStdString());
|
||||
int subscribeFlags = ui->groupTreeWidget->subscribeFlags(QString::fromStdString(mGroupId.toStdString()));
|
||||
@ -263,7 +266,6 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
|
||||
bool isPublisher = IS_GROUP_PUBLISHER(subscribeFlags);
|
||||
bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags);
|
||||
|
||||
QMenu contextMnu(this);
|
||||
|
||||
QAction *action;
|
||||
|
||||
@ -341,6 +343,10 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addActions(actions);
|
||||
}
|
||||
}
|
||||
|
||||
//Add Standard Menu
|
||||
ui->groupTreeWidget->treeWidget()->createStandardContextMenu(&contextMnu);
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user