Changed default section size.

This commit is contained in:
Martin Rotter 2013-12-24 13:35:58 +01:00
parent 1473a7453b
commit 55dcca35be
7 changed files with 48 additions and 14 deletions

View File

@ -30,6 +30,7 @@
#define TRAY_ICON_BUBBLE_TIMEOUT 15000 #define TRAY_ICON_BUBBLE_TIMEOUT 15000
#define KEY_MESSAGES_VIEW "messages_view_column_" #define KEY_MESSAGES_VIEW "messages_view_column_"
#define CLOSE_LOCK_TIMEOUT 3000 #define CLOSE_LOCK_TIMEOUT 3000
#define MESSAGES_VIEW_DEFAULT_COL 170
#define APP_DB_INIT_FILE "db_init.sql" #define APP_DB_INIT_FILE "db_init.sql"
#define APP_DB_INIT_SPLIT "-- !\n" #define APP_DB_INIT_SPLIT "-- !\n"

View File

@ -105,6 +105,19 @@ void FeedMessageViewer::updateSelectedFeeds() {
} }
} }
void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed,
int current,
int total) {
// Some feed got updated.
// Now we should change some widgets (reload counts
// of messages for the feed, update status bar and so on).
// TODO: Don't update counts of all feeds here,
// it is enough to update counts of update feed.
m_feedsView->updateCountsOfAllFeeds(true);
}
void FeedMessageViewer::onFeedUpdatesFinished() { void FeedMessageViewer::onFeedUpdatesFinished() {
// Updates of some feeds finished, unlock the lock. // Updates of some feeds finished, unlock the lock.
SystemFactory::getInstance()->applicationCloseLock()->unlock(); SystemFactory::getInstance()->applicationCloseLock()->unlock();
@ -127,6 +140,16 @@ void FeedMessageViewer::createConnections() {
connect(m_messagesView, SIGNAL(feedCountsChanged()), connect(m_messagesView, SIGNAL(feedCountsChanged()),
m_feedsView, SLOT(updateCountsOfSelectedFeeds())); m_feedsView, SLOT(updateCountsOfSelectedFeeds()));
// Downloader connections.
connect(m_feedDownloaderThread, SIGNAL(finished()),
m_feedDownloaderThread, SLOT(deleteLater()));
connect(this, SIGNAL(feedsUpdateRequested(QList<FeedsModelFeed*>)),
m_feedDownloader, SLOT(updateFeeds(QList<FeedsModelFeed*>)));
connect(m_feedDownloader, SIGNAL(finished()),
this, SLOT(onFeedUpdatesFinished()));
connect(m_feedDownloader, SIGNAL(progress(FeedsModelFeed*,int,int)),
this, SLOT(onFeedUpdatesProgress(FeedsModelFeed*,int,int)));
// Toolbar forwardings. // Toolbar forwardings.
connect(FormMain::getInstance()->m_ui->m_actionSwitchImportanceOfSelectedMessages, connect(FormMain::getInstance()->m_ui->m_actionSwitchImportanceOfSelectedMessages,
SIGNAL(triggered()), m_messagesView, SLOT(switchSelectedMessagesImportance())); SIGNAL(triggered()), m_messagesView, SLOT(switchSelectedMessagesImportance()));
@ -150,15 +173,6 @@ void FeedMessageViewer::createConnections() {
SIGNAL(triggered()), m_messagesView, SLOT(setAllMessagesDeleted())); SIGNAL(triggered()), m_messagesView, SLOT(setAllMessagesDeleted()));
connect(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeeds, connect(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeeds,
SIGNAL(triggered()), this, SLOT(updateSelectedFeeds())); SIGNAL(triggered()), this, SLOT(updateSelectedFeeds()));
// Downloader connections.
// TODO: Připravit spojení pro progress a finished.
connect(m_feedDownloaderThread, SIGNAL(finished()),
m_feedDownloaderThread, SLOT(deleteLater()));
connect(this, SIGNAL(feedsUpdateRequested(QList<FeedsModelFeed*>)),
m_feedDownloader, SLOT(updateFeeds(QList<FeedsModelFeed*>)));
connect(m_feedDownloader, SIGNAL(finished()),
this, SLOT(onFeedUpdatesFinished()));
} }
void FeedMessageViewer::initialize() { void FeedMessageViewer::initialize() {

View File

@ -34,6 +34,9 @@ class FeedMessageViewer : public TabContent {
public slots: public slots:
void updateSelectedFeeds(); void updateSelectedFeeds();
protected slots:
void onFeedUpdatesProgress(FeedsModelFeed *feed, int current, int total);
void onFeedUpdatesFinished(); void onFeedUpdatesFinished();
protected: protected:

View File

@ -38,17 +38,28 @@ QList<FeedsModelFeed *> FeedsView::allFeeds() const {
return m_sourceModel->getAllFeeds(); return m_sourceModel->getAllFeeds();
} }
void FeedsView::updateCountsOfSelectedFeeds() { void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
QList<FeedsModelFeed*> feeds = selectedFeeds(); QList<FeedsModelFeed*> feeds = selectedFeeds();
foreach (FeedsModelFeed *feed, feeds) { foreach (FeedsModelFeed *feed, feeds) {
feed->updateCounts(); feed->updateCounts(update_total_too);
} }
// Make sure that selected view reloads changed indexes. // Make sure that selected view reloads changed indexes.
m_sourceModel->reloadChangedLayout(m_proxyModel->mapListToSource(selectionModel()->selectedRows())); m_sourceModel->reloadChangedLayout(m_proxyModel->mapListToSource(selectionModel()->selectedRows()));
} }
void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
QList<FeedsModelFeed*> feeds = allFeeds();
foreach (FeedsModelFeed *feed, feeds) {
feed->updateCounts(update_total_too);
}
// Make sure that all views reloads its data.
m_sourceModel->reloadWholeLayout();
}
void FeedsView::setupAppearance() { void FeedsView::setupAppearance() {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
// Setup column resize strategies. // Setup column resize strategies.

View File

@ -24,8 +24,11 @@ class FeedsView : public QTreeView {
QList<FeedsModelFeed*> allFeeds() const; QList<FeedsModelFeed*> allFeeds() const;
public slots: public slots:
// Reloads count for selected feeds. // Reloads counts for selected feeds.
void updateCountsOfSelectedFeeds(); void updateCountsOfSelectedFeeds(bool update_total_too = true);
// Reloads counts for all feeds.
void updateCountsOfAllFeeds(bool update_total_too = true);
protected: protected:
// Sets up appearance of this widget. // Sets up appearance of this widget.

View File

@ -100,6 +100,7 @@ void MessagesView::setupAppearance() {
hideColumn(MSG_DB_CONTENTS_INDEX); hideColumn(MSG_DB_CONTENTS_INDEX);
} }
header()->setDefaultSectionSize(MESSAGES_VIEW_DEFAULT_COL);
header()->setStretchLastSection(false); header()->setStretchLastSection(false);
setUniformRowHeights(true); setUniformRowHeights(true);
setAcceptDrops(false); setAcceptDrops(false);
@ -115,7 +116,7 @@ void MessagesView::setupAppearance() {
// Make sure that initial sorting is that unread messages are visible // Make sure that initial sorting is that unread messages are visible
// first. // first.
// NOTE: This can be rewritten so that it's changeable. // NOTE: This can be rewritten so that it's changeable.
sortByColumn(MSG_DB_READ_INDEX, Qt::AscendingOrder); sortByColumn(MSG_DB_DUPDATED_INDEX, Qt::AscendingOrder);
} }
void MessagesView::keyPressEvent(QKeyEvent *event) { void MessagesView::keyPressEvent(QKeyEvent *event) {

View File

@ -23,6 +23,7 @@ class MessagesView : public QTreeView {
MessagesModel *sourceModel(); MessagesModel *sourceModel();
void createConnections(); void createConnections();
public slots: public slots:
// Loads un-deleted messages from selected feeds. // Loads un-deleted messages from selected feeds.
void loadFeeds(const QList<int> &feed_ids); void loadFeeds(const QList<int> &feed_ids);