-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edit service settings via tableView #4
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,4 +64,3 @@ repos: | |
ci: | ||
autofix_prs: true | ||
autoupdate_schedule: quarterly | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import os.path | ||
|
||
|
||
DEFAULT_PG_SERVICE_PATH = os.path.expanduser("~/.pg_service.conf") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from qgis.PyQt.QtCore import QAbstractTableModel, Qt | ||
from qgis.PyQt.QtGui import QFont | ||
|
||
|
||
class ServiceConfigModel(QAbstractTableModel): | ||
KEY_COL = 0 | ||
VALUE_COL = 1 | ||
|
||
def __init__(self, service_name, service_config): | ||
super().__init__() | ||
self.__service_name = service_name | ||
self.__model_data = service_config | ||
self.__dirty = False | ||
|
||
def rowCount(self, parent): | ||
return len(self.__model_data) | ||
|
||
def columnCount(self, parent): | ||
return 2 | ||
|
||
def data(self, index, role=Qt.DisplayRole): | ||
if not index.isValid(): | ||
return None | ||
|
||
key = list(self.__model_data.keys())[index.row()] | ||
if role == Qt.DisplayRole: | ||
if index.column() == self.KEY_COL: | ||
return key | ||
elif index.column() == self.VALUE_COL: | ||
return self.__model_data[key] | ||
elif role == Qt.EditRole and index.column() == self.VALUE_COL: | ||
return self.__model_data[key] | ||
elif role == Qt.FontRole and index.column() == self.KEY_COL: | ||
font = QFont() | ||
font.setBold(True) | ||
return font | ||
|
||
return None | ||
|
||
def setData(self, index, value, role=Qt.EditRole) -> bool: | ||
if not index.isValid(): | ||
return False | ||
|
||
key = list(self.__model_data.keys())[index.row()] | ||
if value != self.__model_data[key]: | ||
self.__model_data[key] = value | ||
self.__dirty = True | ||
return True | ||
|
||
return False | ||
|
||
def flags(self, idx): | ||
if not idx.isValid(): | ||
return ~Qt.ItemIsSelectable & ~Qt.ItemIsEnabled | ||
|
||
_flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled | ||
if idx.column() == self.KEY_COL: | ||
return _flags | ||
elif idx.column() == self.VALUE_COL: | ||
return _flags | Qt.ItemIsEditable | ||
|
||
def is_dirty(self): | ||
return self.__dirty | ||
|
||
def service_config(self): | ||
return self.__model_data.copy() | ||
|
||
def service_name(self): | ||
return self.__service_name | ||
|
||
def set_not_dirty(self): | ||
self.__dirty = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
from pg_service_parser.gui.dlg_pg_service import PgServiceDialog | ||
|
||
|
||
class PgServiceParserPlugin(): | ||
class PgServiceParserPlugin: | ||
def __init__(self, iface): | ||
self.iface = iface | ||
self.action = None | ||
|
||
def initGui(self): | ||
self.action = QAction('Go!', self.iface.mainWindow()) | ||
self.action = QAction("Go!", self.iface.mainWindow()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's create an icon for the plugin (in another PR it's fine) |
||
self.action.triggered.connect(self.run) | ||
self.iface.addToolBarIcon(self.action) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are/were just quick tests. There I was changing parameters so that the overwrite result was even more evident.
BTW, those quick tests could eventually become unit tests in this repo.