acas
This commit is contained in:
parent
d16dbfa2e2
commit
eb0c734369
@ -188,7 +188,7 @@ bool MessagesModel::setMessageDeleted(int row_index, int deleted) {
|
|||||||
|
|
||||||
bool MessagesModel::switchMessageImportance(int row_index) {
|
bool MessagesModel::switchMessageImportance(int row_index) {
|
||||||
QModelIndex target_index = index(row_index, MSG_DB_IMPORTANT_INDEX);
|
QModelIndex target_index = index(row_index, MSG_DB_IMPORTANT_INDEX);
|
||||||
int current_importance = data(target_index).toInt();
|
int current_importance = data(target_index, Qt::EditRole).toInt();
|
||||||
|
|
||||||
return current_importance == 1 ?
|
return current_importance == 1 ?
|
||||||
setData(target_index, 0) :
|
setData(target_index, 0) :
|
||||||
@ -215,7 +215,7 @@ bool MessagesModel::switchBatchMessageImportance(const QModelIndexList &messages
|
|||||||
|
|
||||||
foreach (const QModelIndex &message, messages) {
|
foreach (const QModelIndex &message, messages) {
|
||||||
message_id = messageId(message.row());
|
message_id = messageId(message.row());
|
||||||
importance = record(message.row()).value(MSG_DB_IMPORTANT_INDEX).toInt();
|
importance = data(message.row(), MSG_DB_IMPORTANT_INDEX, Qt::EditRole).toInt();
|
||||||
|
|
||||||
query_delete_msg.bindValue(":id", message_id);
|
query_delete_msg.bindValue(":id", message_id);
|
||||||
query_delete_msg.bindValue(":important",
|
query_delete_msg.bindValue(":important",
|
||||||
|
@ -30,6 +30,10 @@ FeedMessageViewer::FeedMessageViewer(QWidget *parent)
|
|||||||
m_messagesBrowser, SLOT(clear()));
|
m_messagesBrowser, SLOT(clear()));
|
||||||
connect(m_messagesView, SIGNAL(currentMessageChanged(Message)),
|
connect(m_messagesView, SIGNAL(currentMessageChanged(Message)),
|
||||||
m_messagesBrowser, SLOT(navigateToMessage(Message)));
|
m_messagesBrowser, SLOT(navigateToMessage(Message)));
|
||||||
|
connect(FormMain::getInstance()->m_ui->m_actionSwitchImportanceOfSelectedMessages,
|
||||||
|
SIGNAL(triggered()),
|
||||||
|
m_messagesView,
|
||||||
|
SLOT(switchSelectedMessagesImportance()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedMessageViewer::initialize() {
|
void FeedMessageViewer::initialize() {
|
||||||
|
@ -125,6 +125,10 @@ void FormMain::display() {
|
|||||||
QtSingleApplication::alert(this);
|
QtSingleApplication::alert(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormMain::onCommitData(QSessionManager &manager) {
|
||||||
|
qDebug("OS asked application to commit its data.");
|
||||||
|
}
|
||||||
|
|
||||||
void FormMain::onAboutToQuit() {
|
void FormMain::onAboutToQuit() {
|
||||||
qDebug("Cleaning up resources and saving application state before it exits.");
|
qDebug("Cleaning up resources and saving application state before it exits.");
|
||||||
}
|
}
|
||||||
@ -174,6 +178,10 @@ void FormMain::setupIcons() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormMain::createConnections() {
|
void FormMain::createConnections() {
|
||||||
|
// Core connections.
|
||||||
|
connect(qApp, SIGNAL(commitDataRequest(QSessionManager&)),
|
||||||
|
this, SLOT(onCommitData(QSessionManager&)));
|
||||||
|
|
||||||
// Menu "File" connections.
|
// Menu "File" connections.
|
||||||
connect(m_ui->m_actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
|
connect(m_ui->m_actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
|
||||||
|
|
||||||
|
@ -64,6 +64,8 @@ class FormMain : public QMainWindow {
|
|||||||
void switchFullscreenMode(bool turn_fullscreen_on);
|
void switchFullscreenMode(bool turn_fullscreen_on);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
void onCommitData(QSessionManager &manager);
|
||||||
|
|
||||||
// Used for last-minute actions.
|
// Used for last-minute actions.
|
||||||
void onAboutToQuit();
|
void onAboutToQuit();
|
||||||
|
|
||||||
|
@ -97,6 +97,28 @@ void MessagesView::keyPressEvent(QKeyEvent *event) {
|
|||||||
QTreeView::keyPressEvent(event);
|
QTreeView::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesView::mousePressEvent(QMouseEvent *event) {
|
||||||
|
QTreeView::mousePressEvent(event);
|
||||||
|
|
||||||
|
if (event->button() != Qt::LeftButton) {
|
||||||
|
// No need for extra actions on right/middle click.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex clicked_index = indexAt(event->pos());
|
||||||
|
|
||||||
|
if (!clicked_index.isValid()) {
|
||||||
|
qDebug("Clicked on invalid index in MessagesView.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex mapped_index = m_proxyModel->mapToSource(clicked_index);
|
||||||
|
|
||||||
|
if (mapped_index.column() == MSG_DB_IMPORTANT_INDEX) {
|
||||||
|
m_sourceModel->switchMessageImportance(mapped_index.row());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesView::currentChanged(const QModelIndex ¤t,
|
void MessagesView::currentChanged(const QModelIndex ¤t,
|
||||||
const QModelIndex &previous) {
|
const QModelIndex &previous) {
|
||||||
QModelIndex mapped_current = m_proxyModel->mapToSource(current);
|
QModelIndex mapped_current = m_proxyModel->mapToSource(current);
|
||||||
@ -112,7 +134,24 @@ void MessagesView::currentChanged(const QModelIndex ¤t,
|
|||||||
QTreeView::currentChanged(current, previous);
|
QTreeView::currentChanged(current, previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesView::setSelectedMessagesReadStatus(int read) {
|
void MessagesView::switchSelectedMessagesImportance() {
|
||||||
|
/*
|
||||||
|
// toto muže obsahovat moc indexů -> z jednoho radku to muze
|
||||||
|
// obsahovat indexy ze vsech sloupcu, overit.
|
||||||
|
QItemSelection selected_indexes = selectionModel()->selection();
|
||||||
|
QItemSelection mapped_selection = m_proxyModel->mapSelectionToSource(selected_indexes);
|
||||||
|
|
||||||
|
m_sourceModel->switchBatchMessageImportance(mapped_selection.indexes());
|
||||||
|
*/
|
||||||
|
|
||||||
|
QModelIndexList selected_indexes = selectionModel()->selectedRows();
|
||||||
|
QModelIndexList mapped_indexes;
|
||||||
|
|
||||||
|
foreach (const QModelIndex &index, selected_indexes) {
|
||||||
|
mapped_indexes << m_proxyModel->mapToSource(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sourceModel->switchBatchMessageImportance(mapped_indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesView::setAllMessagesRead() {
|
void MessagesView::setAllMessagesRead() {
|
||||||
|
@ -24,19 +24,15 @@ class MessagesView : public QTreeView {
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Message manipulators.
|
// Message manipulators.
|
||||||
void setSelectedMessagesReadStatus(int read);
|
void switchSelectedMessagesImportance();
|
||||||
|
|
||||||
void setAllMessagesRead();
|
void setAllMessagesRead();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setupAppearance();
|
void setupAppearance();
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
|
|
||||||
void currentChanged(const QModelIndex ¤t,
|
void currentChanged(const QModelIndex ¤t,
|
||||||
const QModelIndex &previous);
|
const QModelIndex &previous);
|
||||||
|
|
||||||
void selectionChanged(const QItemSelection &selected,
|
void selectionChanged(const QItemSelection &selected,
|
||||||
const QItemSelection &deselected);
|
const QItemSelection &deselected);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user