acas
This commit is contained in:
parent
d16dbfa2e2
commit
eb0c734369
@ -130,11 +130,11 @@ QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
||||
}
|
||||
}
|
||||
|
||||
// Return RAW data for EditRole.
|
||||
// Return RAW data for EditRole.
|
||||
case Qt::EditRole:
|
||||
return QSqlTableModel::data(idx, role);
|
||||
|
||||
// Return "red" color for just deleted messages.
|
||||
// Return "red" color for just deleted messages.
|
||||
case Qt::BackgroundRole:
|
||||
return record(idx.row()).value(MSG_DB_DELETED_INDEX).toInt() == 1 ?
|
||||
QColor(255, 0, 0, 100) :
|
||||
@ -188,7 +188,7 @@ bool MessagesModel::setMessageDeleted(int row_index, int deleted) {
|
||||
|
||||
bool MessagesModel::switchMessageImportance(int row_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 ?
|
||||
setData(target_index, 0) :
|
||||
@ -215,7 +215,7 @@ bool MessagesModel::switchBatchMessageImportance(const QModelIndexList &messages
|
||||
|
||||
foreach (const QModelIndex &message, messages) {
|
||||
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(":important",
|
||||
|
@ -30,6 +30,10 @@ FeedMessageViewer::FeedMessageViewer(QWidget *parent)
|
||||
m_messagesBrowser, SLOT(clear()));
|
||||
connect(m_messagesView, SIGNAL(currentMessageChanged(Message)),
|
||||
m_messagesBrowser, SLOT(navigateToMessage(Message)));
|
||||
connect(FormMain::getInstance()->m_ui->m_actionSwitchImportanceOfSelectedMessages,
|
||||
SIGNAL(triggered()),
|
||||
m_messagesView,
|
||||
SLOT(switchSelectedMessagesImportance()));
|
||||
}
|
||||
|
||||
void FeedMessageViewer::initialize() {
|
||||
|
@ -125,6 +125,10 @@ void FormMain::display() {
|
||||
QtSingleApplication::alert(this);
|
||||
}
|
||||
|
||||
void FormMain::onCommitData(QSessionManager &manager) {
|
||||
qDebug("OS asked application to commit its data.");
|
||||
}
|
||||
|
||||
void FormMain::onAboutToQuit() {
|
||||
qDebug("Cleaning up resources and saving application state before it exits.");
|
||||
}
|
||||
@ -174,6 +178,10 @@ void FormMain::setupIcons() {
|
||||
}
|
||||
|
||||
void FormMain::createConnections() {
|
||||
// Core connections.
|
||||
connect(qApp, SIGNAL(commitDataRequest(QSessionManager&)),
|
||||
this, SLOT(onCommitData(QSessionManager&)));
|
||||
|
||||
// Menu "File" connections.
|
||||
connect(m_ui->m_actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
|
||||
|
||||
|
@ -64,6 +64,8 @@ class FormMain : public QMainWindow {
|
||||
void switchFullscreenMode(bool turn_fullscreen_on);
|
||||
|
||||
protected slots:
|
||||
void onCommitData(QSessionManager &manager);
|
||||
|
||||
// Used for last-minute actions.
|
||||
void onAboutToQuit();
|
||||
|
||||
|
@ -97,6 +97,28 @@ void MessagesView::keyPressEvent(QKeyEvent *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,
|
||||
const QModelIndex &previous) {
|
||||
QModelIndex mapped_current = m_proxyModel->mapToSource(current);
|
||||
@ -112,7 +134,24 @@ void MessagesView::currentChanged(const QModelIndex ¤t,
|
||||
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() {
|
||||
|
@ -24,19 +24,15 @@ class MessagesView : public QTreeView {
|
||||
|
||||
public slots:
|
||||
// Message manipulators.
|
||||
void setSelectedMessagesReadStatus(int read);
|
||||
|
||||
void switchSelectedMessagesImportance();
|
||||
void setAllMessagesRead();
|
||||
|
||||
|
||||
protected:
|
||||
void setupAppearance();
|
||||
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
void currentChanged(const QModelIndex ¤t,
|
||||
const QModelIndex &previous);
|
||||
|
||||
void selectionChanged(const QItemSelection &selected,
|
||||
const QItemSelection &deselected);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user